Skip to content
88 changes: 40 additions & 48 deletions drracket-core-lib/drracket/private/frame.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -262,47 +262,42 @@
(when (is-a? item menu-item-container<%>)
(loop item))))
(when (member (system-type) '(unix windows))
(for ([top-level-menu (in-list (send mb get-items))])
(when (is-a? top-level-menu menu%)
(define amp-key
(let loop ([str (send top-level-menu get-label)])
(cond
[(regexp-match #rx"[^&]*[&](.)(.*)" str)
=>
(λ (m)
(define this-amp (list-ref m 1))
(define rest (list-ref m 2))
(cond
[(equal? this-amp "&")
(loop rest)]
[else
(string-downcase this-amp)]))]
[else #f])))
(when amp-key
(hash-set! name-ht
(string->symbol (format "m:~a" amp-key))
(format "~a menu" (send top-level-menu get-plain-label)))
(when (equal? (system-type) 'windows)
(hash-set! name-ht
(string->symbol (format "m:s:~a" amp-key))
(format "~a menu" (send top-level-menu get-plain-label)))))))))
(for ([top-level-menu (in-list (send mb get-items))]
#:when (is-a? top-level-menu menu%))
(define amp-key
(let loop ([str (send top-level-menu get-label)])
(cond
[(regexp-match #rx"[^&]*[&](.)(.*)" str)
=>
(λ (m)
(define this-amp (list-ref m 1))
(define rest (list-ref m 2))
(cond
[(equal? this-amp "&") (loop rest)]
[else (string-downcase this-amp)]))]
[else #f])))
(when amp-key
(hash-set! name-ht
(string->symbol (format "m:~a" amp-key))
(format "~a menu" (send top-level-menu get-plain-label)))
(when (equal? (system-type) 'windows)
(hash-set! name-ht
(string->symbol (format "m:s:~a" amp-key))
(format "~a menu" (send top-level-menu get-plain-label))))))))
name-ht)

(define (menu-item->prefix-string item)
(apply
string-append
(map (λ (prefix)
(case prefix
[(alt) (if (eq? (system-type) 'windows)
"m:"
"a:")]
[(cmd) "d:"]
[(meta) "m:"]
[(ctl) "c:"]
[(shift) "s:"]
[(opt option) "a:"]
[else (error 'menu-item->prefix-string "unknown prefix ~s\n" prefix)]))
(send item get-shortcut-prefix)))))
(for/list ([prefix (in-list (send item get-shortcut-prefix))])
(case prefix
[(alt) (if (eq? (system-type) 'windows) "m:" "a:")]
[(cmd) "d:"]
[(meta) "m:"]
[(ctl) "c:"]
[(shift) "s:"]
[(opt option) "a:"]
[else (error 'menu-item->prefix-string "unknown prefix ~s\n" prefix)])))))

(require string-constants
racket/match
Expand Down Expand Up @@ -337,12 +332,11 @@
(mixin (frame:standard-menus<%>) (drracket:frame:basics<%>)

(define/override (on-subwindow-focus win on?)
(when the-keybindings-frame
(when on?
(send the-keybindings-frame set-bindings
(if (can-show-keybindings?)
(get-keybindings-to-show)
'())))))
(when (and the-keybindings-frame on?)
(send the-keybindings-frame set-bindings
(if (can-show-keybindings?)
(get-keybindings-to-show)
'()))))

(define/override (on-subwindow-char receiver event)
(define user-key? (send (keymap:get-user)
Expand Down Expand Up @@ -416,12 +410,10 @@

(define/override (file-menu:between-print-and-close menu)
(super file-menu:between-print-and-close menu)
(instantiate menu-item% ()
(label (string-constant mfs-multi-file-search-menu-item))
(parent menu)
(callback
(λ (_1 _2)
(drracket:multi-file-search:multi-file-search))))
(new menu-item%
(label (string-constant mfs-multi-file-search-menu-item))
(parent menu)
(callback (λ (_1 _2) (drracket:multi-file-search:multi-file-search))))
(new separator-menu-item% (parent menu)))

(define/override (edit-menu:between-find-and-preferences menu)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,9 @@ Will not work with the definitions text surrogate interposition that
(for ([chars (in-list (syntax->list #'(chars ...)))])
(unless (string? (syntax-e chars))
(raise-syntax-error 'chars "expected a string" stx chars))
(for ([char (in-string (syntax-e chars))])
(unless (< (char->integer char) 128)
(raise-syntax-error 'chars "expected only one-byte chars" stx chars))))
(for ([char (in-string (syntax-e chars))]
#:unless (< (char->integer char) 128))
(raise-syntax-error 'chars "expected only one-byte chars" stx chars)))
#'(cond
[(check-chars port chars)
rhs ...]
Expand Down
20 changes: 9 additions & 11 deletions drracket-core-lib/drracket/private/palaka.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@
(define (draw-palaka dc w h)
(define alpha (send dc get-alpha))
(send dc set-pen palaka-color 1 'transparent)
(let loop ([dx (- (/ quadrant-size 2))])
(when (< dx w)
(let loop ([dy (- (/ quadrant-size 2))])
(when (< dy h)
(send dc set-alpha 1)
(send dc set-brush palaka-color 'solid)
(send dc draw-rectangle dx dy quadrant-size quadrant-size)
(send dc set-brush "white" 'solid)
(draw-one-palaka dc dx dy)
(loop (+ dy quadrant-size))))
(loop (+ dx quadrant-size))))
(for ([dx (in-range (- (/ quadrant-size 2)) w quadrant-size)])
(let loop ([dy (- (/ quadrant-size 2))])
(when (< dy h)
(send dc set-alpha 1)
(send dc set-brush palaka-color 'solid)
(send dc draw-rectangle dx dy quadrant-size quadrant-size)
(send dc set-brush "white" 'solid)
(draw-one-palaka dc dx dy)
(loop (+ dy quadrant-size)))))
(send dc set-alpha alpha))

(define (draw-one-palaka dc dx dy)
Expand Down
35 changes: 16 additions & 19 deletions drracket-core-lib/drracket/private/stick-figures.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,8 @@

(define (normalize points)
(define-values (min-x min-y) (get-max/min-x/y min points))
(map (λ (x) (list (car x)
(- (list-ref x 1) min-x)
(- (list-ref x 2) min-y)))
points))
(for/list ([x (in-list points)])
(list (car x) (- (list-ref x 1) min-x) (- (list-ref x 2) min-y))))

(define (get-max/min-x/y choose points)
(values (apply choose
Expand Down Expand Up @@ -185,14 +183,14 @@
(send dc set-brush "black" 'transparent)
(draw-points points dc factor dx dy)

(let* ([head (assoc 'head points)]
[hx (list-ref head 1)]
[hy (list-ref head 2)])
(send dc draw-ellipse
(+ dx (* factor (- hx (/ head-size 2))))
(+ dy (* factor (- hy (/ head-size 2))))
(* factor head-size)
(* factor head-size)))))
(define head (assoc 'head points))
(define hx (list-ref head 1))
(define hy (list-ref head 2))
(send dc draw-ellipse
(+ dx (* factor (- hx (/ head-size 2))))
(+ dy (* factor (- hy (/ head-size 2))))
(* factor head-size)
(* factor head-size))))

(define (draw-points points dc factor dx dy)
(connect 'neck 'shoulders points dc factor dx dy)
Expand Down Expand Up @@ -250,13 +248,12 @@
(set! orig-y (list-ref orig-point 2)))]
[(and clicked-point (send evt moving?))
(set! points
(map (λ (x)
(if (eq? (car x) clicked-point)
(list (list-ref x 0)
(+ orig-x (- (send evt get-x) clicked-x))
(+ orig-y (- (send evt get-y) clicked-y)))
x))
points))
(for/list ([x (in-list points)])
(if (eq? (car x) clicked-point)
(list (list-ref x 0)
(+ orig-x (- (send evt get-x) clicked-x))
(+ orig-y (- (send evt get-y) clicked-y)))
x)))
(refresh)
(send csmall refresh)]
[(send evt button-up? 'left)
Expand Down
48 changes: 24 additions & 24 deletions drracket-core-lib/drracket/private/tool-contract-language.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,19 @@
body)))))])))))))]
[(_ (name type type-names strs ...) ...)
(begin
(for ([str-stx (in-list (syntax->list (syntax (type-names ...))))])
(when (string? (syntax->datum str-stx))
(raise-syntax-error 'tool-contract-language.rkt
"expected type name specification"
stx
str-stx)))
(for ([name (in-list (syntax->list (syntax (name ...))))])
(unless (identifier? name)
(raise-syntax-error 'tool-contract-language.rkt "expected identifier" stx name)))
(for ([str-stx (in-list (syntax->list (syntax (type-names ...))))]
#:when (string? (syntax->datum str-stx)))
(raise-syntax-error 'tool-contract-language.rkt
"expected type name specification"
stx
str-stx))
(for ([name (in-list (syntax->list (syntax (name ...))))]
#:unless (identifier? name))
(raise-syntax-error 'tool-contract-language.rkt "expected identifier" stx name))
(for ([str (in-list (apply append
(map syntax->list (syntax->list (syntax ((strs ...) ...))))))])
(unless (string? (syntax->datum str))
(raise-syntax-error 'tool-contract-language.rkt "expected docs string" stx str))))]))
(map syntax->list (syntax->list (syntax ((strs ...) ...))))))]
#:unless (string? (syntax->datum str)))
(raise-syntax-error 'tool-contract-language.rkt "expected docs string" stx str)))]))

(define-syntax (-#%module-begin2 stx)
(syntax-case stx ()
Expand Down Expand Up @@ -112,16 +112,16 @@
body)))]))))))]
[(_ (name type type-names strs ...) ...)
(begin
(for ([str-stx (in-list (syntax->list (syntax (type-names ...))))])
(when (string? (syntax->datum str-stx))
(raise-syntax-error 'tool-contract-language.rkt
"expected type name specification"
stx
str-stx)))
(for ([name (in-list (syntax->list (syntax (name ...))))])
(unless (identifier? name)
(raise-syntax-error 'tool-contract-language.rkt "expected identifier" stx name)))
(for ([str-stx (in-list (syntax->list (syntax (type-names ...))))]
#:when (string? (syntax->datum str-stx)))
(raise-syntax-error 'tool-contract-language.rkt
"expected type name specification"
stx
str-stx))
(for ([name (in-list (syntax->list (syntax (name ...))))]
#:unless (identifier? name))
(raise-syntax-error 'tool-contract-language.rkt "expected identifier" stx name))
(for ([str (in-list (apply append
(map syntax->list (syntax->list (syntax ((strs ...) ...))))))])
(unless (string? (syntax->datum str))
(raise-syntax-error 'tool-contract-language.rkt "expected docs string" stx str))))]))
(map syntax->list (syntax->list (syntax ((strs ...) ...))))))]
#:unless (string? (syntax->datum str)))
(raise-syntax-error 'tool-contract-language.rkt "expected docs string" stx str)))]))
45 changes: 16 additions & 29 deletions drracket-test/tests/drracket/private/gui.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,17 @@
(cond
[(= i (string-length string1)) (only-whitespace? string2 j)]
[(= j (string-length string2)) (only-whitespace? string1 i)]
[else (let ([c1 (string-ref string1 i)]
[c2 (string-ref string2 j)])
(cond
[in-whitespace?
(cond
[(whitespace? c1)
(loop (+ i 1)
j
#t)]
[(whitespace? c2)
(loop i
(+ j 1)
#t)]
[else (loop i j #f)])]
[(and (whitespace? c1)
(whitespace? c2))
(loop (+ i 1)
(+ j 1)
#t)]
[(char=? c1 c2)
(loop (+ i 1)
(+ j 1)
#f)]
[else #f]))])))
[else (define c1 (string-ref string1 i))
(define c2 (string-ref string2 j))
(cond
[in-whitespace?
(cond
[(whitespace? c1) (loop (+ i 1) j #t)]
[(whitespace? c2) (loop i (+ j 1) #t)]
[else (loop i j #f)])]
[(and (whitespace? c1) (whitespace? c2)) (loop (+ i 1) (+ j 1) #t)]
[(char=? c1 c2) (loop (+ i 1) (+ j 1) #f)]
[else #f])])))

;; whitespace? : char -> boolean
;; deteremines if `c' is whitespace
Expand Down Expand Up @@ -113,11 +100,11 @@
window label class))
(let loop ([window window])
(cond
[(and (or (not class)
(is-a? window class))
(let ([win-label (and (is-a? window window<%>)
(send window get-label))])
(equal? label win-label)))
[(cond
[(or (not class) (is-a? window class))
(define win-label (and (is-a? window window<%>) (send window get-label)))
(equal? label win-label)]
[else #f])
(list window)]
[(is-a? window area-container<%>) (apply append (map loop (send window get-children)))]
[else '()])))
Expand Down
Loading