[plt-scheme] Advice on adding a line numbers and/or a gutter to the editor

From: Robby Findler (robby at cs.uchicago.edu)
Date: Sat Jun 16 16:54:12 EDT 2007

Depends on how you want it to look, I guess. Probably the easiest way
would be to have two editor-canvas's side by side, each with an
editor. Then, you'd hide the scrollbars on the gutter editor and
override various callbacks to make them scroll in sync.

I'd work on just getting that going without any drscheme integration,
at least to start. Then, later on you can check out the tools manual
and figure out how to add your gutter into the drscheme window.

Here's a start on just line numbering, that doesn't do any of the hard
parts. It doesn't deal with autowrapping; it doesn't keep the two
editors in sync when scrolling. For the latter, you'd need to override
some callback in the main editor-canvas. For the former, I'm not sure
how you'd do that, but poke around in the manual and see if you see

Of course, this might not be the right strategy ... but it is easy to
get started with!

(require (lib "framework.ss" "framework")
         (lib "etc.ss"))
(define f (new frame:basic% [label ""] [width 500] [height 600]))
(define hp (new horizontal-panel% [parent (send f get-area-container)]))
(define gutter-text (new scheme:text%))
(define gutter-ec (new editor-canvas%
                       [parent hp]
                       [style '(hide-vscroll)]
                       [editor gutter-text]
                       [stretchable-width #f]
                       [min-width 60]))
(define text (new scheme:text%))
(define ec (new editor-canvas% [parent hp] [editor text]))
(send text load-file (build-path (collection-path "drscheme")
"private" "rep.ss"))
 (λ (n) (send gutter-text insert (format "~a\n" n)))
 (build-list (send text last-paragraph) add1))
(send gutter-ec scroll-to 0 0 0 0 #t)
(send f show #t)


On 6/16/07, Grant Rettke <grettke at acm.org> wrote:
> I would like to prepare a tool to add a gutter to the editor. A gutter
> is an area that would appear on the left side of the screen in which
> things "interesting" to the user could be placed.
> For example, line number if one desired. Another thing that interests
> me is the ability to click on the gutter to leave bookmarks. I could
> even add comments in the bookmarks themselves, along with links to
> other bookmarks. The idea is that later on I could browse my bookmarks
> to go to places about which I cared for some reason.
> Perhaps those are two separate tools, line numbers and gutters.
> Where should I start looking or about what should I care learning to
> get started on the path towards adding line numbers?
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.