line number fixes

- restore some method augments that I shouldn't have deleted
 - handle font change through a style-list callback
This commit is contained in:
Matthew Flatt 2011-01-07 13:02:33 -07:00
parent a5660f38eb
commit 9d7a7a1520

View File

@ -3766,10 +3766,23 @@ designates the character that triggers autocompletion
(define/public (set-line-numbers-color color) (define/public (set-line-numbers-color color)
(set! line-numbers-color color)) (set! line-numbers-color color))
(define notify-registered-in-list #f)
(define style-change-notify
(lambda (style) (unless style (setup-padding))))
(define/private (get-style-font) (define/private (get-style-font)
(let* ([style-list (send this get-style-list)] (let* ([style-list (send this get-style-list)]
[std (or (send style-list find-named-style "Standard") [std (or (send style-list find-named-style "Standard")
(send style-list basic-style))]) (send style-list basic-style))])
;; If the style changes, we should re-check the width of
;; drawn line numbers:
(unless (eq? notify-registered-in-list style-list)
;; `notify-on-change' holds the given function weakly:
(send style-list notify-on-change style-change-notify)
;; Avoid registering multiple notifications:
(set! notify-registered-in-list style-list))
;; Extract the font from the style:
(send std get-font))) (send std get-font)))
(define-struct saved-dc-state (pen font foreground-color)) (define-struct saved-dc-state (pen font foreground-color))
@ -3863,6 +3876,16 @@ designates the character that triggers autocompletion
(send (send this get-admin) get-view left top width height) (send (send this get-admin) get-view left top width height)
(+ (unbox left) dx)) (+ (unbox left) dx))
(define/augment (after-insert start length)
(inner (void) after-insert start length)
; in case the max line number changed:
(setup-padding))
(define/augment (after-delete start length)
(inner (void) after-delete start length)
; in case the max line number changed:
(setup-padding))
(define/private (draw-numbers dc top bottom dx dy start-line end-line) (define/private (draw-numbers dc top bottom dx dy start-line end-line)
(define (draw-text . args) (define (draw-text . args)
(send/apply dc draw-text args)) (send/apply dc draw-text args))