From f179b5d3cd35c2ae45d3b28538023d422fd5221f Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Fri, 22 Oct 1999 15:29:43 +0000 Subject: [PATCH] ... original commit: 1d57a71acc69cce5b2a71445af84c29d1bbb14ca --- collects/framework/frame.ss | 5 ++++- collects/framework/prefs.ss | 2 +- collects/framework/scheme.ss | 25 +++++++++++++++++++------ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/collects/framework/frame.ss b/collects/framework/frame.ss index cfe78928..e44fd9b7 100644 --- a/collects/framework/frame.ss +++ b/collects/framework/frame.ss @@ -1172,7 +1172,8 @@ (private [editor-position-changed-offset/numbers (let ([last-start #f] - [last-end #f]) + [last-end #f] + [last-params #f]) (lambda (offset? line-numbers?) (let* ([edit (get-info-editor)] [make-one @@ -1201,8 +1202,10 @@ (let ([start (send edit get-start-position)] [end (send edit get-end-position)]) (unless (and last-start + (equal? last-params (list offset? line-numbers?)) (= last-start start) (= last-end end)) + (set! last-params (list offset? line-numbers?)) (set! last-start start) (set! last-end end) (when (object? position-edit) diff --git a/collects/framework/prefs.ss b/collects/framework/prefs.ss index 9b0faf68..e9bc90fa 100644 --- a/collects/framework/prefs.ss +++ b/collects/framework/prefs.ss @@ -291,6 +291,7 @@ (make-check 'framework:show-status-line "Show status-line" id id) (make-check 'framework:line-offsets "Count line and column numbers from one" id id) + (make-check 'framework:display-line-numbers "Display line numbers in buffer; not character offsets" id id) (make-check 'framework:menu-bindings "Enable keybindings in menus" id id) (unless (eq? (system-type) 'unix) (make-check 'framework:print-output-mode "Automatically print to postscript file" @@ -299,7 +300,6 @@ (lambda (n) (eq? 'postscript n)))) - (make-check 'framework:display-line-numbers "Display line numbers in buffer; not character offsets" id id) '(when (eq? (system-type) 'windows) (make-check 'framework:windows-mdi "Use MDI Windows" id id)) (make-check 'framework:search-using-dialog? diff --git a/collects/framework/scheme.ss b/collects/framework/scheme.ss index b9d8233d..2b135b24 100644 --- a/collects/framework/scheme.ss +++ b/collects/framework/scheme.ss @@ -142,7 +142,7 @@ [super-after-delete after-delete] [super-after-set-size-constraint after-set-size-constraint] [super-after-set-position after-set-position]) - (inherit has-focus?) + (inherit has-focus? find-snip split-snip) (override [on-focus (lambda (on?) @@ -558,7 +558,20 @@ new-pos))) (end-edit-sequence)) (insert #\newline)))] - [comment-out-selection + + + [calc-last-para + (lambda (last-pos) + (let ([last-para (position-paragraph last-pos #t)]) + (if (and (> last-pos 0) + (> last-para 0)) + (begin (split-snip last-pos) + (let ([snip (find-snip last-pos 'before)]) + (if (member 'hard-newline (send snip get-flags)) + (- last-para 1) + last-para))) + last-para)))] + [comment-out-selection (opt-lambda ([start-pos (get-start-position)] [end-pos (get-end-position)]) (begin-edit-sequence) @@ -566,7 +579,7 @@ (= (paragraph-start-position (position-paragraph start-pos)) start-pos)]) (let* ([first-para (position-paragraph start-pos)] - [last-para (position-paragraph end-pos #t)]) + [last-para (calc-last-para end-pos)]) (let para-loop ([curr-para first-para]) (if (<= curr-para last-para) (let ([first-on-para (paragraph-start-position curr-para)]) @@ -582,9 +595,9 @@ (opt-lambda ([start-pos (get-start-position)] [end-pos (get-end-position)]) (begin-edit-sequence) - (let ([last-pos (last-position)] - [first-para (position-paragraph start-pos)] - [last-para (position-paragraph end-pos #t)]) + (let* ([last-pos (last-position)] + [first-para (position-paragraph start-pos)] + [last-para (calc-last-para end-pos)]) (let para-loop ([curr-para first-para]) (if (<= curr-para last-para) (let ([first-on-para