Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
(define (get-init-dir path/f)
(cond
[path/f
(let-values ([(base name dir?) (split-path path/f)])
base)]
(define-values (base name dir?) (split-path path/f))
base]
[else
(find-system-path 'home-dir)]))

Expand Down Expand Up @@ -159,11 +159,11 @@
(if sd (list sd) null))])
(λ (p)
(define skip-in-paths? (file-stamp-in-paths p no-dirs))
(define pkg (path->pkg p #:cache path->pkg-cache))
(define skip-pkgs?
(let ([pkg (path->pkg p #:cache path->pkg-cache)])
(and pkg
(not (set-member? open-pkgs pkg))
(file-stamp-in-paths p (list (pkg-directory/use-cache pkg))))))
(and pkg
(not (set-member? open-pkgs pkg))
(file-stamp-in-paths p (list (pkg-directory/use-cache pkg)))))
(log-drracket/cm-info "~a; skip? ~a ~a thd ~a"
p
(and skip-in-paths? #t)
Expand Down
6 changes: 2 additions & 4 deletions drracket-core-lib/drracket/private/expanding-place.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,8 @@
[current-error-port out])
(expand transformed-stx)))
(ep-log-info "expanding-place.rkt: 10 finished expansion")
(define no-io-happened?
(begin
(close-output-port out)
(channel-get the-io)))
(close-output-port out)
(define no-io-happened? (channel-get the-io))
(channel-put old-registry-chan
(namespace-module-registry (current-namespace)))
(place-channel-put pc-status-expanding-place 'finished-expansion)
Expand Down
13 changes: 7 additions & 6 deletions drracket-core-lib/drracket/private/language-object-contract.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
(let loop ([s #'arg])
(cond
[(syntax? s)
(let ([loc (vector (syntax-source s)
(syntax-line s)
(syntax-column s)
(syntax-position s)
(syntax-span s))])
(make-sloc (loop (syntax-e s)) loc))]
(define loc
(vector (syntax-source s)
(syntax-line s)
(syntax-column s)
(syntax-position s)
(syntax-span s)))
(make-sloc (loop (syntax-e s)) loc)]
[(pair? s) (cons (loop (car s)) (loop (cdr s)))]
[else s]))])
#'ans)]))])
Expand Down
8 changes: 3 additions & 5 deletions drracket-core-lib/drracket/private/tool-contract-language.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@
(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 ...) ...))))))]
(for ([str (in-list (syntax->list #'(strs ... ...)))]
#:unless (string? (syntax->datum str)))
(raise-syntax-error 'tool-contract-language.rkt "expected docs string" stx str)))]))

Expand All @@ -80,7 +79,7 @@
(andmap (λ (x) (not (string? (syntax->datum x))))
(syntax->list (syntax (type-names ...))))
(andmap (λ (x) (string? (syntax->datum x)))
(apply append (map syntax->list (syntax->list (syntax ((strs ...) ...)))))))
(syntax->list #'(strs ... ...))))
(with-syntax ([wrap-tool-inputs (datum->syntax stx 'wrap-tool-inputs #'here)])
(syntax/loc stx
(#%module-begin
Expand Down Expand Up @@ -121,7 +120,6 @@
(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 ...) ...))))))]
(for ([str (in-list (syntax->list #'(strs ... ...)))]
#:unless (string? (syntax->datum str)))
(raise-syntax-error 'tool-contract-language.rkt "expected docs string" stx str)))]))
243 changes: 115 additions & 128 deletions drracket-core-lib/drracket/private/unit.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -139,62 +139,58 @@
(λ (menu text event)
(old menu text event)
(when (and (is-a? text text%)
(or (is-a? text (get-definitions-text%))
(is-a? text drracket:rep:text%))
(or (is-a? text (get-definitions-text%)) (is-a? text drracket:rep:text%))
(is-a? event mouse-event%))

(let ([add-sep
(let ([added? #f])
(λ ()
(unless added?
(set! added? #t)
(new separator-menu-item% [parent menu]))))])
(add-search-help-desk-menu-item text menu
(let-values ([(x y)
(send text dc-location-to-editor-location
(send event get-x)
(send event get-y))])
(send text find-position x y))
add-sep)

(when (is-a? text editor:basic<%>)
(let-values ([(pos text) (send text get-pos/text event)])
(when (and pos (is-a? text text%))
(send text split-snip pos)
(send text split-snip (+ pos 1))
(let ([snip (send text find-snip pos 'after-or-none)])
(when (or (is-a? snip image-snip%)
(is-a? snip image-core:image%)
(is-a? snip cache-image-snip%)
(is-a? snip pict-snip:pict-snip%))
(add-sep)
(define (save-image-callback _1 _2)
(define fn
(put-file #f
(send text get-top-level-window)
#f "untitled.png" "png"))
(when fn
(define kind (filename->kind fn))
(cond
[kind
(cond
[(or (is-a? snip image-snip%)
(is-a? snip cache-image-snip%)
(is-a? snip pict-snip:pict-snip%))
(send (send snip get-bitmap) save-file fn kind)]
[else
(image-core:save-image-as-bitmap snip fn kind)])]
[else
(message-box
(string-constant drscheme)
"Must choose a filename that ends with either .png, .jpg, .xbm, or .xpm"
#:dialog-mixin frame:focus-table-mixin)])))
(new menu-item%
[parent menu]
[label (string-constant save-image)]
[callback save-image-callback]))))))

(void))))))

(define add-sep
(let ([added? #f])
(λ ()
(unless added?
(set! added? #t)
(new separator-menu-item% [parent menu])))))
(add-search-help-desk-menu-item text
menu
(let-values ([(x y) (send text dc-location-to-editor-location
(send event get-x)
(send event get-y))])
(send text find-position x y))
add-sep)

(when (is-a? text editor:basic<%>)
(let-values ([(pos text) (send text get-pos/text event)])
(when (and pos (is-a? text text%))
(send text split-snip pos)
(send text split-snip (+ pos 1))
(let ([snip (send text find-snip pos 'after-or-none)])
(when (or (is-a? snip image-snip%)
(is-a? snip image-core:image%)
(is-a? snip cache-image-snip%)
(is-a? snip pict-snip:pict-snip%))
(add-sep)
(define (save-image-callback _1 _2)
(define fn
(put-file #f (send text get-top-level-window) #f "untitled.png" "png"))
(when fn
(define kind (filename->kind fn))
(cond
[kind
(cond
[(or (is-a? snip image-snip%)
(is-a? snip cache-image-snip%)
(is-a? snip pict-snip:pict-snip%))
(send (send snip get-bitmap) save-file fn kind)]
[else (image-core:save-image-as-bitmap snip fn kind)])]
[else
(message-box
(string-constant drscheme)
"Must choose a filename that ends with either .png, .jpg, .xbm, or .xpm"
#:dialog-mixin frame:focus-table-mixin)])))
(new menu-item%
[parent menu]
[label (string-constant save-image)]
[callback save-image-callback]))))))

(void)))))

(define (add-search-help-desk-menu-item text menu position [add-sep void])
(define irl (cond
Expand All @@ -203,49 +199,45 @@
[(is-a? text (get-definitions-text%))
(send text get-irl)]
[else (drracket:frame:try-to-find-an-irl)]))
(let* ([end (send text get-end-position)]
[start (send text get-start-position)])
(unless (= 0 (send text last-position))
(let* ([str (if (= end start)
(find-symbol text position)
(send text get-text start end))]
;; almost the same code as "search-help-desk" in "rep.rkt"
[l (send text get-canvas)]
[l (and l (send l get-top-level-window))]
[l (and l (is-a? l drracket:unit:frame<%>) (send l get-definitions-text))]
[l (and l (send l get-next-settings))]
[l (and l (drracket:language-configuration:language-settings-language l))]
[ctxt (and l
(drracket:module-language-tools:call-capability-value
l
(if (is-a? text drracket:rep:text%)
(send text get-definitions-text)
text)
'drscheme:help-context-term))]
[name (and l (send l get-language-name))])
(unless (string=? str "")
(add-sep)
(let ([short-str (shorten-str str 50)])
(make-object menu-item%
(gui-utils:format-literal-label
(string-constant search-help-desk-for)
(if (equal? short-str str)
str
(string-append short-str "...")))
menu
(λ x
(define fam
(drracket:frame:try-to-find-a-language-family irl))
(help-desk:help-desk str (list ctxt name)
#:language-family fam)))
(void)))))))
(define end (send text get-end-position))
(define start (send text get-start-position))
(unless (= 0 (send text last-position))
(let* ([str (if (= end start)
(find-symbol text position)
(send text get-text start end))]
;; almost the same code as "search-help-desk" in "rep.rkt"
[l (send text get-canvas)]
[l (and l (send l get-top-level-window))]
[l (and l (is-a? l drracket:unit:frame<%>) (send l get-definitions-text))]
[l (and l (send l get-next-settings))]
[l (and l (drracket:language-configuration:language-settings-language l))]
[ctxt (and l
(drracket:module-language-tools:call-capability-value
l
(if (is-a? text drracket:rep:text%)
(send text get-definitions-text)
text)
'drscheme:help-context-term))]
[name (and l (send l get-language-name))])
(unless (string=? str "")
(add-sep)
(let ([short-str (shorten-str str 50)])
(make-object menu-item%
(gui-utils:format-literal-label (string-constant search-help-desk-for)
(if (equal? short-str str)
str
(string-append short-str "...")))
menu
(λ x
(define fam (drracket:frame:try-to-find-a-language-family irl))
(help-desk:help-desk str (list ctxt name) #:language-family fam)))
(void))))))

(define (filename->kind fn)
(let ([ext (filename-extension fn)])
(and ext
(let ([sym (string->symbol (bytes->string/utf-8 ext))])
(ormap (λ (pr) (and (equal? sym (car pr)) (cadr pr)))
allowed-extensions)))))
(define ext (filename-extension fn))
(and ext
(let ([sym (string->symbol (bytes->string/utf-8 ext))])
(ormap (λ (pr) (and (equal? sym (car pr)) (cadr pr))) allowed-extensions))))

(define allowed-extensions '((png png)
(jpg jpeg)
Expand Down Expand Up @@ -302,28 +294,25 @@
[else
(send text split-snip pos)
(send text split-snip (+ pos 1))
(let ([snip (send text find-snip pos 'after)])
(if (is-a? snip string-snip%)
(let* ([before
(let loop ([i (- pos 1)]
[chars null])
(if (< i 0)
chars
(let ([char (send text get-character i)])
(if (non-letter? char)
chars
(loop (- i 1)
(cons char chars))))))]
[after
(let loop ([i pos])
(if (< i (send text last-position))
(let ([char (send text get-character i)])
(if (non-letter? char)
null
(cons char (loop (+ i 1)))))
null))])
(apply string (append before after)))
""))]))
(define snip (send text find-snip pos 'after))
(if (is-a? snip string-snip%)
(let* ([before (let loop ([i (- pos 1)]
[chars null])
(if (< i 0)
chars
(let ([char (send text get-character i)])
(if (non-letter? char)
chars
(loop (- i 1) (cons char chars))))))]
[after (let loop ([i pos])
(if (< i (send text last-position))
(let ([char (send text get-character i)])
(if (non-letter? char)
null
(cons char (loop (+ i 1)))))
null))])
(apply string (append before after)))
"")]))

;; non-letter? : char -> boolean
;; returns #t if the character belongs in a symbol (approx) and #f it is
Expand Down Expand Up @@ -385,16 +374,13 @@
0
(string->number (send whole get-value))))
(cond
[(or (not whole-s) (not (integer? whole-s)))
(string-constant insert-number/bad-whole-part)]
[(or (not whole-s) (not (integer? whole-s))) (string-constant insert-number/bad-whole-part)]
[(or (not num-s) (not (integer? num-s)) (< num-s 0))
(string-constant insert-number/bad-numerator)]
[(or (not den-s) (not (integer? den-s)) (<= den-s 0))
(string-constant insert-number/bad-denominator)]
[else
(if (< whole-s 0)
(- whole-s (/ num-s den-s))
(+ whole-s (/ num-s den-s)))]))
[(< whole-s 0) (- whole-s (/ num-s den-s))]
[else (+ whole-s (/ num-s den-s))]))
(define (ok-callback)
(define v (validate-number))
(cond
Expand All @@ -418,10 +404,11 @@
(send num-m min-width mw))
(send bp set-alignment 'right 'center)
(send dlg show #t)
(and ok?
(let ([v (validate-number)])
(and (number? v)
v))))
(cond
[ok?
(define v (validate-number))
(and (number? v) v)]
[else #f]))

;; create-executable : (instanceof drracket:unit:frame<%>) -> void
(define (create-executable frame)
Expand Down
Loading
Loading