Adding a gutter to DrScheme

I had asked about how to add a gutter with line numbers to DrScheme, and Robby explained one approach here.

#lang scheme/gui
(require (lib "" "framework")
         (lib ""))
(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" ""))
 (λ (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)

4 thoughts on “Adding a gutter to DrScheme”

  1. That’s a very useful hack, I wish I knew how to intall it in my DrScheme environment. Where should I put it?

  2. Hi Luciano,
    That code Robby provided is a starting point; it is his example of how one might add line numbers to the UI control.
    The next step is to read up on writing “Tools” (aka plugins) for DrScheme and then writing a line number plugin.
    Are you interested? 🙂
    I have written one DrScheme tool, and overall it was a pleasant experience, that, for me scratched an important itch.
    Line numbers are another one, I am just focused on a few other things right now.

  3. Hello ^^
    i just looked for a tool how i can show line numbers in scheme and found your site ^^
    the code above seems interesting, still it isnt the solution.
    Did anyone here already made a Plug-In to see the line numbers? if yes, could you share it? 🙂
    ty ^^
    btw, maybe in my free time (aint gonna happen soon ^^) i will write it as a challenge, if nobody has written it yet.

  4. Hi Paul:
    It has not been made into a plug-in yet; in fact it has been waiting for you to appear and write it! If you do I would be happy to be a tester.
    If you are looking for a Scheme editor that has line numbers you might also try Emacs; it has a line-number plug-in built-in.

Leave a Reply

Your email address will not be published. Required fields are marked *