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!

original commit: 0d6b82537776ad4bd850e3b7c5cc1bdaa209b865
This commit is contained in:
Robby Findler 2012-03-24 18:36:47 -05:00
parent 4d109759b7
commit 018fd62d43
5 changed files with 58 additions and 15 deletions

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%) ()]{}