[plt-scheme] Re: scrolling inside an editor-snip?

From: harsha (harsha.v.r at gmail.com)
Date: Fri Oct 5 18:54:36 EDT 2007

The refresh method seems to be telling the editor to draw a subregion
of the snip which is specified in local coordinates. This is what i
need. But what it does right now, is that it draws the subregion
starting in local coordinates (0, y) at (0, y) whereas i would need
this to be displayed at (0,0) where the snip is starting.
I guess this is the expected behaviour as after all, it is a refresh
function and what i need is more like a set-view function,
corresponding to the get-view function in the snip-admin% class.

I want to write a set-view method, but am not sure if this is possible
just using the mred interface and forming subclasses or if it requires
a small change in the source.
What commands should i be using to get the refresh method to start
drawing a subregion from the begining of the snip?


test program:
(define st% (class text%
              (define scroll 0)
              (define/override (refresh x y width height draw-caret
                (super refresh x (+ y scroll) width height draw-caret
              (define/public (set-scroll s) (set! scroll s))

;set up a canvas, pasteboard, editor-snip
(define f (instantiate frame% ("E" #f 400 400)))
(define c (instantiate editor-canvas% (f)))
(define p (instantiate pasteboard% ()))
(send c set-editor p)
(define ed (instantiate st%()))
(define s (new editor-snip% (editor ed)))
(send p insert s)
(send f show #t)

(send ed insert "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n" 0) ; 11 lines of
(send s resize 200 85) ;; enough height to display 4 lines

(send ed set-scroll 150)

Posted on the users mailing list.