add a preference to control whether or not there is an extra

pixel of space in between lines in DrRacket.

This change is based on Matthew's experience having a look
at the font setup on the three platforms.

He writes:
>  * Mac OS X: the convention seems to be to add space between lines.
>   TextEdit, for example, looks like DrRacket: the maze has spaces.
>
>   (I can't find a font that makes the maze look right, actually, even
>   if I adjust the line spacing.)
>
>  * Windows: the convention seems to be that space is built into the
>   font. DrRacket (and SirMail) draw lines more sparsely than Notepad.
>
>   Perhaps consistent with the differing conventions, the height of
>   "Courier New" at 11-pixel size is 14 on Windows, 13 on Mac OS X.
>
>  * Unix: the convention seems to be to add space. DrRacket looks like
>   the default Terminal and Text Editor programs on Ubuntu.
>
>   The maze nevertheless looks right everywhere, because the glyphs
>   extend an extra pixel above the declared bounding box!
This commit is contained in:
Robby Findler 2012-03-24 18:36:47 -05:00
parent c5e30d8af5
commit 0d6b825377
12 changed files with 72 additions and 26 deletions

View File

@ -1765,7 +1765,7 @@ profile todo:
;; GUI. They only manage the profiling information reported
;; in the bottom window
(define profile-text%
(class text:basic%
(class text:line-spacing%
(init-field tab)
;; clear-profile-display : -> void

View File

@ -172,7 +172,7 @@
[text (make-object (text:foreground-color-mixin
(editor:standard-style-list-mixin
text:basic%)))]
text:line-spacing%)))]
[ex-panel (make-object horizontal-panel% main)]
[msg (make-object message% (string-constant example-text) ex-panel)]
[canvas (make-object canvas:color% main text)]

View File

@ -124,10 +124,11 @@
(define results-super-text%
(text:hide-caret/selection-mixin
(text:basic-mixin
(editor:standard-style-list-mixin
(editor:basic-mixin
text%)))))
(text:line-spacing-mixin
(text:basic-mixin
(editor:standard-style-list-mixin
(editor:basic-mixin
text%))))))
;; results-text% : derived from text%
;; init args: zoom-text
@ -631,7 +632,7 @@
(define (exact-match-searcher params key) ;; thread: main eventspace thread
(let ([case-sensitive? (car params)])
(λ (filename add-entry) ;; thread: searching thread
(let ([text (make-object text:basic%)])
(let ([text (make-object text:line-spacing%)])
(send text load-file filename)
(let loop ([pos 0])
(let ([found (send text find-string key 'forward pos 'eof #t case-sensitive?)])

View File

@ -1978,7 +1978,7 @@ TODO
(insert/delta text " in: ")
(insert/delta text (format "~s" (syntax->datum expr)) error-text-style-delta))
(insert/delta text "\n")
(when (and (is-a? src text:basic%)
(when (and (is-a? src text:basic<%>)
(number? pos)
(number? span))
(highlight-errors (list (list src (- pos 1) (+ pos -1 span)))))))
@ -1997,7 +1997,7 @@ TODO
(insert-file-name/icon src pos span line col))
(insert/delta text (format "~a" (exn-message exn)) error-delta)
(insert/delta text "\n")
(when (and (is-a? src text:basic%)
(when (and (is-a? src text:basic<%>)
(number? pos)
(number? span))
(highlight-errors (list (list src (- pos 1) (+ pos -1 span))))))]

View File

@ -1531,7 +1531,7 @@ module browser threading seems wrong.
(member logger-panel (send logger-parent-panel get-children))))
(define/private (new-logger-text)
(set! logger-gui-text (new (text:hide-caret/selection-mixin text:basic%)))
(set! logger-gui-text (new (text:hide-caret/selection-mixin text:line-spacing%)))
(send logger-gui-text lock #t))
(define/public (update-logger-window command)

View File

@ -86,7 +86,7 @@
[else (format "~a" n)]))
(define cumulative-t%
(class text:basic%
(class text:line-spacing%
(init-field open-button vp ec1 lp info-editor)
(inherit begin-edit-sequence
end-edit-sequence

View File

@ -22,6 +22,10 @@
(application-preferences-handler (λ () (preferences:show-dialog)))
(preferences:set-default 'framework:line-spacing-add-gap?
(not (eq? (system-type) 'windows))
boolean?)
;; used to time how long it takes to set a preference; the value is not actually used.
(preferences:set-default 'drracket:prefs-debug #f (λ (x) #t))

View File

@ -456,7 +456,7 @@ the state transitions / contracts are:
(list (string-constant editor-prefs-panel-label)
(string-constant general-prefs-panel-label))
(λ (editor-panel)
(make-check editor-panel 'framework:delete-forward? (string-constant map-delete-to-backspace)
(make-check editor-panel 'framework:delete-forward? (string-constant map-delete-to-backspace)
not not)
(make-check editor-panel
'framework:auto-set-wrap?
@ -499,6 +499,10 @@ the state transitions / contracts are:
'framework:always-use-platform-specific-linefeed-convention
(string-constant always-use-platform-specific-linefeed-convention)
values values))
(make-check editor-panel
'framework:line-spacing-add-gap?
(string-constant add-spacing-between-lines)
values values)
(editor-panel-procs editor-panel))))])
(add-editor-checkbox-panel)))

View File

@ -168,6 +168,7 @@
(define-signature text-class^
(basic<%>
line-spacing<%>
first-line<%>
line-numbers<%>
foreground-color<%>
@ -187,6 +188,7 @@
autocomplete<%>
basic%
line-spacing%
hide-caret/selection%
nbsp->space%
normalize-paste%
@ -206,6 +208,7 @@
input-box%
basic-mixin
line-spacing-mixin
first-line-mixin
line-numbers-mixin
foreground-color-mixin

View File

@ -56,10 +56,6 @@
(values register-port-name! lookup-port-name)))
;; wx: `default-wrapping?', add as the initial value for auto-wrap bitmap,
;; unless matthew makes it primitive
(define basic<%>
(interface (editor:basic<%> (class->interface text%))
highlight-range
@ -545,6 +541,23 @@
(define (hash-cons! h k v) (hash-set! h k (cons v (hash-ref h k '()))))
(define line-spacing<%> (interface ()))
(define line-spacing-mixin
(mixin (basic<%>) (line-spacing<%>)
(super-new)
(inherit set-line-spacing)
;; this is a field so that the weakly
;; held callback works out properly
(define (pref-cb-func sym val)
(set-line-spacing (if val 1 0)))
(preferences:add-callback 'framework:line-spacing-add-gap?
pref-cb-func
#t)
(set-line-spacing (if (preferences:get 'framework:line-spacing-add-gap?)
1
0))))
(define first-line<%>
(interface ()
highlight-first-line
@ -4119,11 +4132,12 @@ designates the character that triggers autocompletion
(setup-padding)))
(define basic% (basic-mixin (editor:basic-mixin text%)))
(define hide-caret/selection% (hide-caret/selection-mixin basic%))
(define nbsp->space% (nbsp->space-mixin basic%))
(define normalize-paste% (normalize-paste-mixin basic%))
(define delegate% (delegate-mixin basic%))
(define wide-snip% (wide-snip-mixin basic%))
(define line-spacing% (line-spacing-mixin basic%))
(define hide-caret/selection% (hide-caret/selection-mixin line-spacing%))
(define nbsp->space% (nbsp->space-mixin line-spacing%))
(define normalize-paste% (normalize-paste-mixin line-spacing%))
(define delegate% (delegate-mixin line-spacing%))
(define wide-snip% (wide-snip-mixin line-spacing%))
(define standard-style-list% (editor:standard-style-list-mixin wide-snip%))
(define input-box% (input-box-mixin standard-style-list%))
(define -keymap% (editor:keymap-mixin standard-style-list%))

View File

@ -171,6 +171,23 @@
}
}
@definterface[text:line-spacing<%> (text:basic<%>)]{
Objects implementing this interface adjust their
spacing based on the @racket['framework:line-spacing-add-gap?]
preference.
}
@defmixin[text:line-spacing-mixin (text:basic<%>) (text:line-spacing<%>)]{
Calls @method[text% set-line-spacing] to either @racket[0] or @racket[1]
when an object is created, based
on the @racket['framework:line-spacing-add-gap?]
preference.
Also registers a callback (via @racket[preferences:add-callback]) to call
@method[text% set-line-spacing] when the @racket['framework:line-spacing-add-gap?]
preference changes.
}
@definterface[text:first-line<%> (text%)]{
Objects implementing this interface, when @method[text:first-line<%>
@ -1091,11 +1108,12 @@
}
@defclass[text:basic% (text:basic-mixin (editor:basic-mixin text%)) ()]{}
@defclass[text:hide-caret/selection% (text:hide-caret/selection-mixin text:basic%) ()]{}
@defclass[text:nbsp->space% (text:nbsp->space-mixin text:basic%) ()]{}
@defclass[text:normalize-paste% (text:normalize-paste-mixin text:basic%) ()]{}
@defclass[text:delegate% (text:delegate-mixin text:basic%) ()]{}
@defclass[text:wide-snip% (text:wide-snip-mixin text:basic%) ()]{}
@defclass[text:line-spacing% (text:line-spacing-mixin text:basic%) ()]{}
@defclass[text:hide-caret/selection% (text:hide-caret/selection-mixin text:line-spacing%) ()]{}
@defclass[text:nbsp->space% (text:nbsp->space-mixin text:line-spacing%) ()]{}
@defclass[text:normalize-paste% (text:normalize-paste-mixin text:line-spacing%) ()]{}
@defclass[text:delegate% (text:delegate-mixin text:line-spacing%) ()]{}
@defclass[text:wide-snip% (text:wide-snip-mixin text:line-spacing%) ()]{}
@defclass[text:standard-style-list% (editor:standard-style-list-mixin text:wide-snip%) ()]{}
@defclass[text:input-box% (text:input-box-mixin text:standard-style-list%) ()]{}
@defclass[text:keymap% (editor:keymap-mixin text:standard-style-list%) ()]{}

View File

@ -509,6 +509,8 @@ please adhere to these guidelines:
(black-on-white-color-scheme "Black on White") ;; these two appear in the color preferences dialog on butttons
(white-on-black-color-scheme "White on Black") ;; clicking the buttons changes the color schemes to some defaults that've been set up.
(add-spacing-between-lines "Add one pixel of extra space between lines")
; title of the color choosing dialog
; should have entire alphabet