Skip to content

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.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"))
(for-each
 (λ (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 Comments

  1. Luciano Ramalho wrote:

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

    Tuesday, April 21, 2009 at 12:01 | Permalink
  2. Grant wrote:

    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.

    Tuesday, April 21, 2009 at 12:13 | Permalink
  3. paul wrote:

    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.

    Tuesday, October 13, 2009 at 03:58 | Permalink
  4. Grant wrote:

    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.

    Tuesday, October 13, 2009 at 07:26 | Permalink

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*