After more playing around, I got to this — which scrolls down a bit but not
enough. Now it's down to actually understanding `(send an-editor-canvas
scroll-to ...)` docs — in particular, what are editor coordinates. I'm fearing
it's in pixels.
#lang racket/base
(require racket/class)
;; string? -> (or/c string? #f)
(provide item-callback)
(define (item-callback str #:interactions interactions #:frame frame)
;(send interactions insert "\n\n\n\n(void)")
(define interaction-canvas (send frame get-interactions-canvas))
(send* interaction-canvas
(allow-scroll-to-last #t)
;(scroll-with-bottom-base #f)
(scroll-to 0 300 1 1 #t 'end))
str)
On Tuesday, October 6, 2015 at 12:31:54 PM UTC+2, Paolo Giarrusso wrote:
> So, a skeleton calling insert, relying on `script-plugin`, is the following.
> It doesn't work yet, but it took like 1 minute, so it's a cool starting
> point. With script-plugin, you can just edit it and rerun it without
> restarting Racket:
>
> ```
> #lang racket/base
> (require racket/class)
>
> ; Sample identity function:
> ;; string? -> (or/c string? #f)
> (provide item-callback)
> (define (item-callback str #:interactions interactions)
> (send interactions insert "\n\n\n\n")
> str)
> ```
>
> On Tuesday, October 6, 2015 at 11:36:55 AM UTC+2, Laurent Orseau wrote:
> > I'm using the script plugin [*] to test things quickly. You get direct
> > access to the current editor, either the interactions or the definitions
> > one. Possibly it would be even more helpful to have an interaction window
> > with access to the same things for quick hacks.
>
> Yes, that would be even cooler (Emacs-style), but this tool is already really
> cool.
>
> > That could be either a standalone plugin or I think that should also be
> > easy with the script plugin.
> >
> >
> >
> > [*] http://pkgs.racket-lang.org/#[script-plugin]
> > Disclaimer: I wrote this. I have no idea if anyone else is using it, but I
> > personally use it all the time.
>
> Don't take this the wrong way, but once you have a solution to such a big
> problem, I think you probably should to advertise it a bit to get it to your
> users — try to get a link in the plugin guide, make this an official plugin,
> ... This takes much less effort than the work, and increases the positive
> impact on the community.
>
> Furthermore, your plugin enables a the birth of *lots* of simple editor
> extensions — you empower your users to do much more work.
> Here's an example of more people who would have needed it:
> http://comments.gmane.org/gmane.comp.lang.racket.user/24630
>
> I think the above would hold as soon as script-plugin was decent for you; in
> fact, I think it's already great.
>
> Cheers,
> Paolo
>
> > On Tue, Oct 6, 2015 at 4:11 AM, Paolo Giarrusso <[email protected]> wrote:
> > 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.
--
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.