On 6 October 2015 at 01:45, Aman <[email protected]> wrote:
>
> Thanks Laurent and Paolo.  When you say (send a-text insert string), how are 
> you getting a-text ?

> What I wanted was not to design a new editor window, but to modify or 'send' 
> some command to current editor (the default one when we launch DrRacket) to 
> clear some content or scroll down to hide the content, but I am not able to 
> find a way to get handle for editor%, text% or anything else that can be 
> helpful while executing 'send'

Yeah, a very good question, that's why I asked Laurent for his "quick
attempt" :-).

The two ways I can imagine are writing a plugin or modifying DrRacket,
and I expect the latter to be easier; my only experience is modifying
a DrRacket plugin, and I don't think this is quick, but it's possible.

For that, I think you want to look at
drracket:get/extend:extend-interactions-text. To be in the context to
do that, see http://docs.racket-lang.org/tools/implementing-tools.html
and the examples shown there using
drracket:get/extend:extend-definitions-text.

Below's I'll give an outline anyway of what I actually did, in case
it's helpful — though the docs are probably better.
==

I've been hacking a DrRacket plugin (the handin client), where I use
something more complex because I assumed I only had a editor% (so I
used insert-port). My call is in
https://github.com/racket/handin/pull/27/files#diff-cf0f873382d5f6c351cee18d851376c3R734;
the code around it does a number of potentially useful things.

The starting point is the call drracket:get/extend:extend-unit-frame,
in the context of

(define tool@
(unit
(import drracket:tool^)
(export drracket:tool-exports^)
...

drracket:get/extend:extend-unit-frame subclasses the unit-frame
DrRacket component, and inside it you can call get-definitions-text
and get-interactions-text to get access to the two text%.

For that, refer to the docs extensively, starting from
http://docs.racket-lang.org/tools/, its index, and the introduction
into how to do a plugin.
By doing that, I just found out about
drracket:get/extend:get-interactions-text, which allows you to
subclass the interactions-text directly.

While this is a lot, I've found I managed to get something done
without needing to understand every detail, also thanks to Racket
syntax-check. It's sad it doesn't understand units as well as the
rest.
(OTOH, I'm scared that I'm writing code without understanding every
single line around it. I usually never do that, but I'm new at
Racket).

Cheers,
Paolo


> On Monday, 5 October 2015 12:51:05 UTC-5, Paolo Giarrusso  wrote:
> > On Monday, October 5, 2015 at 10:56:50 AM UTC+2, Laurent Orseau wrote:
> > > I don't think there is anything like this right now, but in case anyone 
> > > wants to do that, my first impression is,  that such a command should not 
> > > completely erase the previous content but only hide it (by scrolling down 
> > > for example). I tried very quickly to do that using `set-position` of 
> > > `text%` but I couldn't make it leave a blank space after the cursor 
> > > position when at the end of the editor.
> >
> > I'm guessing you (or who does this) will need to insert whitespace 
> > (newlines) with some insert method, after setting the position, probably 
> > with
> > (send a-text insert string)
> >
> > You'll also need to act on the editor-canvas% to scroll it down (text% 
> > can't do that because it's just a MVC Model, while editor-canvas% is the 
> > corresponding View). (It seems you'll have to call allow-scroll-to-last and 
> > scroll-to).
> >
> > I can't do the rest myself because I haven't learned enough APIs to "try 
> > something quickly" — only hacked slowly a plugin. But if you share your 
> > attempt I might be able to try.
> >
> > Cheers,
> > Paolo
> >
> > > On Sun, Oct 4, 2015 at 6:28 PM, Aman <[email protected]> wrote:
> > > Hi all,
> > >
> > >
> > >
> > > I am new to DrRacket. I am using swindle language and want to know a way 
> > > so that I can clear my evaluation window(interaction window) after I do 
> > > some direct runs there.
> > >
> > >
> > >
> > > For example if i run following
> > >
> > >
> > >
> > > > (define a 3)
> > >
> > > > (define b 2)
> > >
> > >
> > >
> > > Now i want something like
> > >
> > > > clear
> > >
> > > which could clear the window but still keep a and b in environment 
> > > (memory). Is it possible somehow?
> > >
> > >
> > >
> > > After going through a lot of posts all I was able to figure out was to 
> > > hit "Run" and use "Esc:p" to again load the needed commands which seems 
> > > to me a very bad way.
> > >
> > >
> > >
> > > Thanks!
> > >
> > >
> > >
> > > --
> > >
> > > You received this message because you are subscribed to the Google Groups 
> > > "Racket Users" group.
> > >
> > > To unsubscribe from this group and stop receiving emails from it, send an 
> > > email to [email protected].
> > >
> > > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to a topic in the Google 
> Groups "Racket Users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/racket-users/_XWopH-iMNw/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> [email protected].
> For more options, visit https://groups.google.com/d/optout.




--
Paolo G. Giarrusso - Ph.D. Student, Tübingen University
http://ps.informatik.uni-tuebingen.de/team/giarrusso/

-- 
Paolo G. Giarrusso - Ph.D. Student, Tübingen University
http://ps.informatik.uni-tuebingen.de/team/giarrusso/

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to