[racket-dev] [plt] Push #21413: master branch updated

From: Jon Rafkind (rafkind at cs.utah.edu)
Date: Tue Nov 2 15:16:56 EDT 2010

There is a scrolling issue left: if you sit on a line and hold down a
key, like "f", once the characters hit the right side of the screen the
editor should scroll but it won't scroll immediately. It will wait for 5
or 6 f's to appear before scrolling -- the same number of f's whose
total space equals the size of the line numbers bar.

Any ideas how to make the editor scroll sooner?

On 11/02/2010 01:12 PM, rafkind at racket-lang.org wrote:
> rafkind has updated `master' from 578b2d846b to 87cc623a6f.
>   http://git.racket-lang.org/plt/578b2d846b..87cc623a6f
>
> =====[ 1 Commits ]======================================================
>
> Directory summary:
>  100.0% collects/framework/private/
>
> ~~~~~~~~~~
>
> 87cc623 Jon Rafkind <rafkind at racket-lang.org> 2010-11-02 12:50
> :
> | set clipping for regular text. minor optimization when choosing line numbers to draw
> :
>   M collects/framework/private/text.rkt |   49 ++++++++++++++++++++++++++------
>
> =====[ Overall Diff ]===================================================
>
> collects/framework/private/text.rkt
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> --- OLD/collects/framework/private/text.rkt
> +++ NEW/collects/framework/private/text.rkt
> @@ -3702,7 +3702,10 @@ designates the character that triggers autocompletion
>  ;; line number text%
>  
>  (define line-numbers<%>
> -  (interface () show-line-numbers! showing-line-numbers?))
> +  (interface ()
> +             show-line-numbers!
> +             showing-line-numbers?
> +             set-line-numbers-color))
>  
>  (define line-numbers-mixin
>    (mixin ((class->interface text%)) (line-numbers<%>)
> @@ -3713,10 +3716,8 @@ designates the character that triggers autocompletion
>               line-start-position
>               line-end-position)
>  
> -    (define line-numbers-color "black")
> +    (init-field [line-numbers-color "black"])
>      (init-field [show-line-numbers? #t])
> -    (define old-origin-x 0)
> -    (define old-origin-y 0)
>      (define cached-snips (list))
>      (define need-to-recalculate-snips #f)
>  
> @@ -3727,6 +3728,9 @@ designates the character that triggers autocompletion
>      (define/public (showing-line-numbers?)
>        show-line-numbers?)
>  
> +    (define/public (set-line-numbers-color color)
> +      (set! line-numbers-color color))
> +
>      (define (get-style-font)
>        (let* ([style-list (send this get-style-list)]
>               [std (or (send style-list find-named-style "Standard")
> @@ -3874,8 +3878,8 @@ designates the character that triggers autocompletion
>        (get-visible-line-range start-line end-line #f)
>        (for ([y heights]
>              [line (in-naturals 1)])
> -        (when (and (ok-height y (unbox start-line) (add1 (unbox end-line)))
> -                   (between top y bottom))
> +        (when (and (between top y bottom)
> +                   (ok-height y (unbox start-line) (add1 (unbox end-line))))
>            (draw-text (number->string line) 0 (+ dy y))))
>  
>        ;; draw the line between the line numbers and the actual text
> @@ -3893,23 +3897,50 @@ designates the character that triggers autocompletion
>                       (send dc get-text-extent stuff))
>        height)
>  
> +    (define old-origin-x 0)
> +    (define old-origin-y 0)
> +    (define old-clipping #f)
>      (define/override (on-paint before? dc left top right bottom dx dy draw-caret)
>        (when show-line-numbers?
>          (if before?
>            (let ()
>              ;; save old origin and push it to the right a little bit
>              ;; TODO: maybe allow the line numbers to be drawn on the right hand side?
> +            (define number-space   "10000")
> +            ;; add an extra 0 so it looks nice
> +            (define number-space+1 "100000")
>              (define-values (x y) (send dc get-origin))
>              (set! old-origin-x x)
>              (set! old-origin-y y)
> +            (set! old-clipping (send dc get-clipping-region))
>              (setup-dc dc)
>              (define-values (font-width font-height baseline space)
> -                           (send dc get-text-extent "10000"))
> -            ;; add an extra 0 so it looks nice
> -            (send dc set-origin (+ x (text-width dc "100000")) y))
> +                           (send dc get-text-extent number-space))
> +            (define clipped (make-object region% dc))
> +            (define all (make-object region% dc))
> +            (define copy (make-object region% dc))
> +            (send all set-rectangle
> +                  (+ dx left) (+ dy top)
> +                  (- right left) (- bottom top))
> +            (if old-clipping
> +              (send copy union old-clipping)
> +              (send copy union all))
> +            (send clipped set-rectangle
> +                  0 (+ dy top)
> +                  (text-width dc number-space+1)
> +                  (- bottom top))
> +            #;
> +            (define (print-region name region)
> +              (define-values (a b c d) (send region get-bounding-box))
> +              (printf "~a: ~a, ~a, ~a, ~a\n" name a b c d))
> +            (send copy subtract clipped)
> +            (send dc set-clipping-region copy)
> +            (send dc set-origin (+ x (text-width dc number-space+1)) y)
> +            )
>            (begin
>              ;; rest the origin and draw the line numbers
>              (send dc set-origin old-origin-x old-origin-y)
> +            (send dc set-clipping-region old-clipping)
>              (draw-line-numbers dc left top right bottom dx dy))))
>        (super on-paint before? dc left top right bottom dx dy draw-caret))
>      ))



Posted on the dev mailing list.