cleanup code. attempt to add preference for line numbers in the general tab. closes pr11367
This commit is contained in:
parent
4f3e87d42a
commit
18504774f0
|
@ -670,6 +670,7 @@
|
|||
(send (send frame get-interactions-canvas) focus))
|
||||
(send frame show #t)))
|
||||
|
||||
;; FIXME: get this from racket/list ?
|
||||
(define (remove-duplicates files)
|
||||
(let loop ([files files])
|
||||
(cond
|
||||
|
|
|
@ -447,98 +447,6 @@ module browser threading seems wrong.
|
|||
(set! definitions-text% (make-definitions-text%)))
|
||||
definitions-text%)))
|
||||
|
||||
;; links two editor's together so they scroll in tandem
|
||||
#;
|
||||
(define (linked-scroller %)
|
||||
(class %
|
||||
(super-new)
|
||||
(field [linked #f])
|
||||
(init-field [line-numbers? #f])
|
||||
|
||||
(inherit insert line-start-position line-end-position)
|
||||
|
||||
(define/public (link-to! who)
|
||||
(set! linked who))
|
||||
|
||||
#;
|
||||
(define/override (scroll-editor-to . args)
|
||||
(printf "Scroll editor to ~a\n" args))
|
||||
|
||||
#;
|
||||
(define/override (scroll-to-position . args)
|
||||
(printf "Scroll-to-position ~a\n" args))
|
||||
|
||||
(define self (gensym))
|
||||
(define (visible? want-start want-end)
|
||||
(define start (box 0))
|
||||
(define end (box 0))
|
||||
(send this get-visible-line-range start end)
|
||||
#;
|
||||
(printf "Visible line range ~a ~a ~a\n" (unbox start) (unbox end) self)
|
||||
(and (>= want-start (unbox start))
|
||||
(<= want-end (unbox end))))
|
||||
|
||||
(define/public (scroll-to-line start end)
|
||||
#;
|
||||
(printf "Need to scroll to ~a ~a ~a\n" start end self)
|
||||
;; dont need to scroll unless the range of lines is out of view
|
||||
(when (not (visible? start end))
|
||||
(send this scroll-to-position
|
||||
(send this line-end-position start)
|
||||
#f
|
||||
(send this line-end-position end))))
|
||||
|
||||
(define/augment (after-delete start length)
|
||||
(update-numbers)
|
||||
(inner (void) after-delete start length))
|
||||
|
||||
(define/augment (after-insert start length)
|
||||
(update-numbers)
|
||||
(inner (void) after-insert start length))
|
||||
|
||||
(define/public (update-numbers)
|
||||
(when (and (not line-numbers?) linked)
|
||||
(send linked ensure-length (send this last-line))))
|
||||
|
||||
;; make sure the set of line numbers is complete
|
||||
(define/public (ensure-length length)
|
||||
(define lines (send this last-line))
|
||||
(when line-numbers?
|
||||
(when (> lines (add1 length))
|
||||
(send this delete
|
||||
(line-start-position (add1 length))
|
||||
(line-end-position lines)
|
||||
#f))
|
||||
(send this begin-edit-sequence)
|
||||
(for ([line (in-range (add1 lines) (add1 (add1 length)))])
|
||||
#;
|
||||
(printf "Insert line ~a\n" line)
|
||||
(insert (format "~a\n" line)))
|
||||
(send this end-edit-sequence)))
|
||||
|
||||
(define/override (on-paint . args)
|
||||
(define start (box 0))
|
||||
(define end (box 0))
|
||||
(define (current-time) (current-inexact-milliseconds))
|
||||
;; pass #f to avoid getting visible line ranges from multiple sources
|
||||
(send this get-visible-line-range start end #f)
|
||||
#;
|
||||
(printf "text: Repaint at ~a to ~a at ~a!\n" (unbox start) (unbox end) (current-time))
|
||||
;; update the linked editor when the main widget is redrawn
|
||||
(when (and (not line-numbers?) linked)
|
||||
#;
|
||||
(printf "Send linked scroll to ~a ~a ~a\n" (unbox start) (unbox end) self)
|
||||
(send linked scroll-to-line (unbox start) (unbox end)))
|
||||
(super on-paint . args))
|
||||
))
|
||||
|
||||
;; an editor that does not respond to key presses
|
||||
#;
|
||||
(define (uneditable %)
|
||||
(class %
|
||||
(super-new)
|
||||
(define/override (on-char . stuff) (void))))
|
||||
|
||||
(define (show-line-numbers?)
|
||||
(preferences:get 'drracket:show-line-numbers?))
|
||||
|
||||
|
@ -2780,42 +2688,7 @@ module browser threading seems wrong.
|
|||
(define (create-definitions-canvas)
|
||||
(new (drracket:get/extend:get-definitions-canvas)
|
||||
[parent resizable-panel]
|
||||
[editor definitions-text])
|
||||
#;
|
||||
(define (with-line-numbers)
|
||||
(define line-numbers-text (new (linked-scroller (uneditable scheme:text%))
|
||||
[line-numbers? #t]))
|
||||
(define shared-pane (new horizontal-panel% [parent resizable-panel]))
|
||||
(define line-canvas (new editor-canvas%
|
||||
[parent shared-pane]
|
||||
[style '(hide-vscroll hide-hscroll)]
|
||||
[editor line-numbers-text]
|
||||
[stretchable-width #f]
|
||||
[min-width 60]))
|
||||
(send definitions-text link-to! line-numbers-text)
|
||||
(send line-numbers-text link-to! definitions-text)
|
||||
(new (drracket:get/extend:get-definitions-canvas)
|
||||
[parent shared-pane]
|
||||
[editor definitions-text]))
|
||||
#;
|
||||
(define (without-line-numbers)
|
||||
(send definitions-text link-to! #f)
|
||||
(new (drracket:get/extend:get-definitions-canvas)
|
||||
[parent resizable-panel]
|
||||
[editor definitions-text]))
|
||||
#;
|
||||
(if line-numbers?
|
||||
(with-line-numbers)
|
||||
(without-line-numbers)))
|
||||
|
||||
#;
|
||||
(define/private (re-initialize-definitions-canvas show)
|
||||
(begin-container-sequence)
|
||||
(set! definitions-canvas (create-definitions-canvas show))
|
||||
(set! definitions-canvases (list definitions-canvas))
|
||||
(update-shown)
|
||||
(send (send definitions-canvas get-editor) update-numbers)
|
||||
(end-container-sequence))
|
||||
|
||||
(define/private (initialize-definitions-canvas)
|
||||
(unless definitions-canvas
|
||||
|
|
|
@ -454,8 +454,10 @@ the state transitions / contracts are:
|
|||
'framework:autosaving-on?
|
||||
(string-constant auto-save-files)
|
||||
values values)
|
||||
(make-check editor-panel 'framework:backup-files? (string-constant backup-files) values values)
|
||||
(make-check editor-panel 'framework:backup-files? (string-constant backup-files) values values)
|
||||
(make-check editor-panel 'framework:show-status-line (string-constant show-status-line) values values)
|
||||
;; does this not belong here?
|
||||
;; (make-check editor-panel 'drracket:show-line-numbers (string-constant show-line-numbers)
|
||||
(make-check editor-panel 'framework:col-offsets (string-constant count-columns-from-one) values values)
|
||||
(make-check editor-panel
|
||||
'framework:display-line-numbers
|
||||
|
|
Loading…
Reference in New Issue
Block a user