use the info-frame's idea of which editor is important for the

goto-line shortcut
This commit is contained in:
Robby Findler 2015-05-12 11:24:54 -05:00
parent d1e3a991cd
commit 6dcdb9744f

View File

@ -352,29 +352,39 @@
(define (setup-global kmap #:alt-as-meta-keymap [alt-as-meta-keymap #f]) (define (setup-global kmap #:alt-as-meta-keymap [alt-as-meta-keymap #f])
(keymap:setup-global kmap #:alt-as-meta-keymap alt-as-meta-keymap) (keymap:setup-global kmap #:alt-as-meta-keymap alt-as-meta-keymap)
(define (goto-line edit event) (define (goto-line keystroke-edit event)
(define num-str (define keystroke-frame
(call/text-keymap-initializer (and (is-a? keystroke-edit editor:basic<%>)
(λ () (send keystroke-edit get-top-level-window)))
(get-text-from-user (define edit
(string-constant goto-line)
(string-constant goto-line)))))
(when (string? num-str)
(define possible-num (string->number num-str))
(define line-num (and possible-num (inexact->exact possible-num)))
(cond (cond
[(and (number? line-num) [(is-a? keystroke-frame frame:info<%>)
(integer? line-num) (send keystroke-frame get-info-editor)]
(<= 1 line-num (+ (send edit last-paragraph) 1))) [(is-a? keystroke-edit text%) keystroke-edit]
(define pos (send edit paragraph-start-position (sub1 line-num))) [else #f]))
(send edit set-position pos)] (when edit
[else (define num-str
(message-box (call/text-keymap-initializer
(string-constant goto-line) (λ ()
(format (get-text-from-user
(string-constant goto-line-invalid-number) (string-constant goto-line)
num-str (string-constant goto-line)))))
(+ (send edit last-line) 1)))])) (when (string? num-str)
(define possible-num (string->number num-str))
(define line-num (and possible-num (inexact->exact possible-num)))
(cond
[(and (number? line-num)
(integer? line-num)
(<= 1 line-num (+ (send edit last-paragraph) 1)))
(define pos (send edit paragraph-start-position (sub1 line-num)))
(send edit set-position pos)]
[else
(message-box
(string-constant goto-line)
(format
(string-constant goto-line-invalid-number)
num-str
(+ (send edit last-line) 1)))])))
#t) #t)
(let ([add-m (λ (name func) (let ([add-m (λ (name func)