From c07d9d38510c2f13ecfd2b2300a65ae11fd23cb0 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Fri, 7 Nov 2008 18:13:33 +0000 Subject: [PATCH] a fix to the way tabs switch around, plus a few additions (that are disabled for now) in preparation for making drscheme automatically compile files that it runs svn: r12344 original commit: a4b631050741fee37a321781ac93b6c079921eb4 --- collects/framework/gui-utils.ss | 25 ++++++++---- collects/framework/private/editor.ss | 32 ++++++++------- collects/scribblings/framework/canvas.scrbl | 2 +- collects/scribblings/framework/color.scrbl | 10 ++--- collects/scribblings/framework/editor.scrbl | 43 +++++++++++++-------- collects/scribblings/framework/group.scrbl | 2 +- collects/scribblings/framework/keymap.scrbl | 2 +- collects/scribblings/framework/panel.scrbl | 10 ++--- collects/scribblings/framework/scheme.scrbl | 2 +- collects/scribblings/framework/text.scrbl | 30 +++++++------- 10 files changed, 89 insertions(+), 69 deletions(-) diff --git a/collects/framework/gui-utils.ss b/collects/framework/gui-utils.ss index b11bd38e..9bcf60de 100644 --- a/collects/framework/gui-utils.ss +++ b/collects/framework/gui-utils.ss @@ -1,8 +1,8 @@ #reader scribble/reader -#lang scheme/gui - -(require string-constants) +#lang scheme/base +(require string-constants scheme/gui/base + scheme/contract scheme/class) (require scribble/srcdoc) (require/doc scheme/base scribble/manual) @@ -232,12 +232,12 @@ (λ () (cursor-off))))]))) (define unsaved-warning - (lambda (filename action-anyway (can-save-now? #f) (parent #f)) + (lambda (filename action-anyway (can-save-now? #f) (parent #f) [cancel? #t]) (let ([mb-res (message-box/custom (string-constant warning) (format (string-constant file-is-not-saved) filename) (string-constant save) - (string-constant cancel) + (and cancel? (string-constant cancel)) action-anyway parent (if can-save-now? @@ -454,11 +454,13 @@ (boolean? (or/c false/c (is-a?/c frame%) - (is-a?/c dialog%))) + (is-a?/c dialog%)) + boolean?) (symbols 'continue 'save 'cancel)) ((filename action) ((can-save-now? #f) - (parent #f))) + (parent #f) + (cancel? #t))) @{This displays a dialog that warns the user of a unsaved file. @@ -468,7 +470,14 @@ The result symbol indicates the user's choice. If @scheme[can-save-now?] is @scheme[#f], this function does not give the user the ``Save'' option and thus will not return - @scheme['save].}) + @scheme['save]. + + If @scheme[cancel?] is @scheme[#t] there is a cancel button + in the dialog and the result may be @scheme['cancel]. If it + is @scheme[#f], then there is no cancel button, and @scheme['cancel] + will not be the result of the function. + + }) (proc-doc/names gui-utils:get-choice diff --git a/collects/framework/private/editor.ss b/collects/framework/private/editor.ss index 70a0a0c4..fa3f4869 100644 --- a/collects/framework/private/editor.ss +++ b/collects/framework/private/editor.ss @@ -495,21 +495,23 @@ (inherit save-file) (define/public (allow-close-with-no-filename?) #f) (define/augment (can-close?) - (let* ([user-allowed-or-not-modified - (or (not (is-modified?)) - (and (not (get-filename)) - (allow-close-with-no-filename?)) - (case (gui-utils:unsaved-warning - (get-filename/untitled-name) - (string-constant dont-save) - #t - (or (get-top-level-window) - (get-can-close-parent))) - [(continue) #t] - [(save) (save-file)] - [else #f]))]) - (and user-allowed-or-not-modified - (inner #t can-close?)))) + (and (user-saves-or-not-modified?) + (inner #t can-close?))) + + (define/public (user-saves-or-not-modified? [allow-cancel? #t]) + (or (not (is-modified?)) + (and (not (get-filename)) + (allow-close-with-no-filename?)) + (case (gui-utils:unsaved-warning + (get-filename/untitled-name) + (string-constant dont-save) + #t + (or (get-top-level-window) + (get-can-close-parent)) + allow-cancel?) + [(continue) #t] + [(save) (save-file)] + [else #f]))) (define/public (get-can-close-parent) #f) diff --git a/collects/scribblings/framework/canvas.scrbl b/collects/scribblings/framework/canvas.scrbl index 5735b866..ec1cc5c3 100644 --- a/collects/scribblings/framework/canvas.scrbl +++ b/collects/scribblings/framework/canvas.scrbl @@ -27,7 +27,7 @@ @defmixin[canvas:delegate-mixin (canvas:basic<%>) (canvas:delegate<%>)]{ Provides an implementation of @scheme[canvas:delegate<%>]. - @defmethod*[#:mode override (((on-superwindow-show (shown? boolean)) void))]{ + @defmethod*[#:mode override (((on-superwindow-show (shown? boolean?)) void))]{ Notifies the delegate window when the original window is visible. When invisible, the blue highlighting is erased. diff --git a/collects/scribblings/framework/color.scrbl b/collects/scribblings/framework/color.scrbl index 2c61f6b7..48cb6018 100644 --- a/collects/scribblings/framework/color.scrbl +++ b/collects/scribblings/framework/color.scrbl @@ -78,7 +78,7 @@ If clear-colors is true all the text in the buffer will have it's style set to Standard. } - @defmethod*[(((force-stop-colorer (stop? boolean)) void))]{ + @defmethod*[(((force-stop-colorer (stop? boolean?)) void))]{ Causes the entire tokenizing/coloring system to become inactive. Intended for debugging purposes only. @@ -86,11 +86,11 @@ stop? determines whether the system is being forced to stop or allowed to wake back up. } - @defmethod*[(((is-stopped?) boolean))]{ + @defmethod*[(((is-stopped?) boolean?))]{ Indicates if the colorer for this editor has been stopped, or not. } - @defmethod*[(((is-frozen?) boolean))]{ + @defmethod*[(((is-frozen?) boolean?))]{ Indicates if this editor's colorer is frozen. See also @method[color:text<%> freeze-colorer] and @@ -131,7 +131,7 @@ This returns the list of regions that are currently being colored in the editor. } - @defmethod*[(((skip-whitespace (position natural-number?) (direction (symbols (quote forward) (quote backward))) (comments? boolean)) natural-number?))]{ + @defmethod*[(((skip-whitespace (position natural-number?) (direction (symbols (quote forward) (quote backward))) (comments? boolean?)) natural-number?))]{ Returns the next non-whitespace character. @@ -172,7 +172,7 @@ Must only be called while the tokenizer is started. } - @defmethod*[(((insert-close-paren (position natural-number?) (char char?) (flash? boolean) (fixup? boolean)) void))]{ + @defmethod*[(((insert-close-paren (position natural-number?) (char char?) (flash? boolean?) (fixup? boolean?)) void))]{ Position is the place to put the parenthesis and char is the diff --git a/collects/scribblings/framework/editor.scrbl b/collects/scribblings/framework/editor.scrbl index 7a29a05a..d5d19533 100644 --- a/collects/scribblings/framework/editor.scrbl +++ b/collects/scribblings/framework/editor.scrbl @@ -8,13 +8,13 @@ Classes matching this interface support the basic @scheme[editor<%>] functionality required by the framework. - @defmethod*[(((has-focus?) boolean))]{ + @defmethod*[(((has-focus?) boolean?))]{ This function returns @scheme[#t] when the editor has the keyboard focus. It is implemented using: @method[editor<%> on-focus] } - @defmethod*[(((local-edit-sequence?) boolean))]{ + @defmethod*[(((local-edit-sequence?) boolean?))]{ Indicates if this editor is in an edit sequence. Enclosing buffer's edit-sequence status is not considered by this method. @@ -49,11 +49,11 @@ } - @defmethod*[(((save-file-out-of-date?) boolean))]{ + @defmethod*[(((save-file-out-of-date?) boolean?))]{ Returns @scheme[#t] if the file on disk has been modified, by some other program. } - @defmethod*[(((save-file/gui-error (filename (union path |#f|) |#f|) (format (union (quote guess) (quote standard) (quote text) (quote text-force-cr) same copy) (quote same)) (show-errors? boolean |#t|)) boolean))]{ + @defmethod*[(((save-file/gui-error (filename (union path |#f|) |#f|) (format (union (quote guess) (quote standard) (quote text) (quote text-force-cr) same copy) (quote same)) (show-errors? boolean |#t|)) boolean?))]{ This method is an alternative to @method[editor<%> save-file]. Rather than showing errors via the original stdout, it opens a dialog with an error message showing the error. @@ -63,7 +63,7 @@ no error occurred and @scheme[#f] if an error occurred. } - @defmethod*[(((load-file/gui-error (filename (union string |#f|) |#f|) (format (union (quote guess) (quote standard) (quote text) (quote text-force-cr) (quote same) (quote copy)) (quote guess)) (show-errors? boolean |#t|)) boolean))]{ + @defmethod*[(((load-file/gui-error (filename (union string |#f|) |#f|) (format (union (quote guess) (quote standard) (quote text) (quote text-force-cr) (quote same) (quote copy)) (quote guess)) (show-errors? boolean |#t|)) boolean?))]{ This method is an alternative to @method[editor<%> load-file]. Rather than showing errors via the original stdout, it opens a dialog with an error message showing the error. @@ -91,7 +91,7 @@ Does nothing. } - @defmethod*[(((can-close?) boolean))]{ + @defmethod*[(((can-close?) boolean?))]{ This method is called to query the editor if is okay to close the editor. Although there is no visible effect associated with closing an editor, there may be some cleanup @@ -105,7 +105,7 @@ Returns @scheme[#t]. } - @defmethod*[(((close) boolean))]{ + @defmethod*[(((close) boolean?))]{ This method is merely @schemeblock[ (if (can-close?) @@ -155,7 +155,7 @@ This installs the global keymap @scheme[keymap:get-global] to handle keyboard and mouse mappings not handled by @scheme[keymap]. The global keymap is created when the framework is invoked. - @defmethod*[#:mode augment (((can-save-file? (filename string) (format symbol?)) boolean))]{ + @defmethod*[#:mode augment (((can-save-file? (filename string) (format symbol?)) boolean?))]{ Checks to see if the file on the disk has been modified out side of this editor, using @@ -163,7 +163,7 @@ If it has, this method prompts the user to be sure they want to save. } - @defmethod*[#:mode augment (((after-save-file (success? boolean)) void))]{ + @defmethod*[#:mode augment (((after-save-file (success? boolean?)) void))]{ If the current filename is not a temporary filename, this method calls @scheme[handler:add-to-recent]with the current filename. @@ -175,19 +175,19 @@ @method[editor:basic<%> save-file-out-of-date?]. } - @defmethod*[#:mode augment (((after-load-file (success? boolean)) void))]{ + @defmethod*[#:mode augment (((after-load-file (success? boolean?)) void))]{ Updates a private instance variable with the modification time of the file, for using in implementing @method[editor:basic<%> save-file-out-of-date?] } - @defmethod*[#:mode override (((on-focus (on? boolean)) void))]{ + @defmethod*[#:mode override (((on-focus (on? boolean?)) void))]{ Manages the state to implement @method[editor:basic<%> has-focus?] } - @defmethod*[#:mode augment (((on-edit-sequence) boolean))]{ + @defmethod*[#:mode augment (((on-edit-sequence) boolean?))]{ Always returns @scheme[#t]. Updates a flag for @method[editor:basic<%> local-edit-sequence?] @@ -323,7 +323,7 @@ in the editor. } - @defmethod*[(((allow-close-with-no-filename?) boolean))]{ + @defmethod*[(((allow-close-with-no-filename?) boolean?))]{ This method indicates if closing the file when it hasn't been saved is a reason to alert the user. See also @method[editor:file-mixin can-close?]. @@ -331,6 +331,15 @@ Defaultly returns @scheme[#f]. } + + @defmethod[(user-saves-or-not-modified? [allow-cancel? #t]) boolean?]{ + If the file has not been saved, this prompts the user about saving and, + if the user says to save, then it saves the file. + + The result is @scheme[#t] if the save file is up to date, or if + the user says it is okay to continue without saving. Generally used + when closing the file or quiting the app. + } } @defmixin[editor:file-mixin (editor:keymap<%>) (editor:file<%>)]{ This editor locks itself when the file that is opened is read-only in @@ -344,7 +353,7 @@ frame that matches @scheme[frame:editor<%>]. } - @defmethod*[#:mode augment (((can-close?) boolean))]{ + @defmethod*[#:mode augment (((can-close?) boolean?))]{ If the @method[editor:file<%> allow-close-with-no-filename?] @@ -369,7 +378,7 @@ } @definterface[editor:backup-autosave<%> (editor:basic<%>)]{ Classes matching this interface support backup files and autosaving. - @defmethod*[(((backup?) boolean))]{ + @defmethod*[(((backup?) boolean?))]{ Indicates weather this @scheme[editor<%>] should be backed up. @@ -382,7 +391,7 @@ @index{'framework:backup-files?} } - @defmethod*[(((autosave?) boolean))]{ + @defmethod*[(((autosave?) boolean?))]{ Indicates weather this @scheme[editor<%>] should be autosaved. @@ -455,7 +464,7 @@ See also @scheme[frame:text-info<%>]. - @defmethod*[#:mode override (((lock (lock? boolean)) void))]{ + @defmethod*[#:mode override (((lock (lock? boolean?)) void))]{ Uses @method[editor:basic<%> run-after-edit-sequence] diff --git a/collects/scribblings/framework/group.scrbl b/collects/scribblings/framework/group.scrbl index a43a1a8a..92819703 100644 --- a/collects/scribblings/framework/group.scrbl +++ b/collects/scribblings/framework/group.scrbl @@ -83,7 +83,7 @@ } - @defmethod*[(((clear) boolean))]{ + @defmethod*[(((clear) boolean?))]{ This removes all of the frames in the group. It does not close the frames. See also @method[group:% on-close-all]and @method[group:% can-close-all?]. diff --git a/collects/scribblings/framework/keymap.scrbl b/collects/scribblings/framework/keymap.scrbl index 09ec0b93..09cb6736 100644 --- a/collects/scribblings/framework/keymap.scrbl +++ b/collects/scribblings/framework/keymap.scrbl @@ -26,7 +26,7 @@ } } @defmixin[keymap:aug-keymap-mixin (keymap%) (keymap:aug-keymap<%>)]{ - @defmethod*[#:mode override (((chain-to-keymap (next (instance keymap%)) (prefix? boolean)) void))]{ + @defmethod*[#:mode override (((chain-to-keymap (next (instance keymap%)) (prefix? boolean?)) void))]{ Keeps a list of the keymaps chained to this one. } diff --git a/collects/scribblings/framework/panel.scrbl b/collects/scribblings/framework/panel.scrbl index 2e8c5c3c..19541b84 100644 --- a/collects/scribblings/framework/panel.scrbl +++ b/collects/scribblings/framework/panel.scrbl @@ -47,7 +47,7 @@ } @defmixin[panel:single-window-mixin (panel:single<%> window<%>) (panel:single-window<%>)]{ - @defmethod*[#:mode override (((container-size (info (list-of (list exact-integer exact-integer boolean boolean)))) (values exact-integer exact-integer)))]{ + @defmethod*[#:mode override (((container-size (info (list-of (list exact-integer exact-integer boolean boolean?)))) (values exact-integer exact-integer)))]{ Factors the border width into the size calculation. } @@ -89,7 +89,7 @@ Return the current percentages of the children. } - @defmethod*[(((get-vertical?) boolean))]{ + @defmethod*[(((get-vertical?) boolean?))]{ This method controls the behavior of the other overridden methods in mixins that implement this interface. @@ -124,7 +124,7 @@ matches the number of children and calls @method[panel:dragable<%> after-percentage-change]. } - @defmethod*[#:mode override (((on-subwindow-event (receiver (instanceof window<%>)) (event (instanceof mouse-event%))) boolean))]{ + @defmethod*[#:mode override (((on-subwindow-event (receiver (instanceof window<%>)) (event (instanceof mouse-event%))) boolean?))]{ When the cursor is dragging the middle bar around, this method handles the resizing of the two panes. @@ -149,7 +149,7 @@ method of the @scheme[panel:dragable-mixin] to return @scheme[#t]. - @defmethod*[#:mode override (((get-vertical?) boolean))]{ + @defmethod*[#:mode override (((get-vertical?) boolean?))]{ Returns @scheme[#t]. } @@ -160,7 +160,7 @@ method of the @scheme[panel:dragable-mixin] to return @scheme[#f]. - @defmethod*[#:mode override (((get-vertical?) boolean))]{ + @defmethod*[#:mode override (((get-vertical?) boolean?))]{ Returns @scheme[#f]. } diff --git a/collects/scribblings/framework/scheme.scrbl b/collects/scribblings/framework/scheme.scrbl index 07ec4b51..e7f1c5bd 100644 --- a/collects/scribblings/framework/scheme.scrbl +++ b/collects/scribblings/framework/scheme.scrbl @@ -53,7 +53,7 @@ @scheme[preferences:get]) the matching open parenthesis is flashed. } - @defmethod*[(((tabify-on-return?) boolean))]{ + @defmethod*[(((tabify-on-return?) boolean?))]{ The result of this method is used to determine if the return key automatically tabs over to the correct position. diff --git a/collects/scribblings/framework/text.scrbl b/collects/scribblings/framework/text.scrbl index b8599a71..b60f88e1 100644 --- a/collects/scribblings/framework/text.scrbl +++ b/collects/scribblings/framework/text.scrbl @@ -70,7 +70,7 @@ Returns a list of (opaque) values representing the active ranges in the editor. } - @defmethod*[(((get-styles-fixed) boolean))]{ + @defmethod*[(((get-styles-fixed) boolean?))]{ If the result of this function is @scheme[#t], the styles in this @scheme[text:basic<%>] will be fixed. This means @@ -87,7 +87,7 @@ @method[text:basic<%> set-styles-fixed]when setting the styles. } - @defmethod*[(((set-styles-fixed (fixed? boolean)) void))]{ + @defmethod*[(((set-styles-fixed (fixed? boolean?)) void))]{ Sets the styles fixed parameter of this @scheme[text%]. See also @method[text:basic<%> get-styles-fixed] @@ -125,7 +125,7 @@ See also @method[text:basic<%> port-name-matches?]. } - @defmethod*[(((port-name-matches? (id (or/c path? symbol?))) boolean))]{ + @defmethod*[(((port-name-matches? (id (or/c path? symbol?))) boolean?))]{ Indicates if @scheme[id] matches the port name of this file. If the file is saved, the port name matches when the save file @@ -428,7 +428,7 @@ @defmixin[text:return-mixin (text%) (text:return<%>)]{ Use this buffer to perform some special action when return is typed. - @defconstructor[((return (-> boolean)))]{ + @defconstructor[((return (-> boolean?)))]{ } @defmethod*[#:mode override (((on-local-char (event (is-a?/c key-event%))) void))]{ @@ -612,7 +612,7 @@ ends an edit sequence in the delegate. } - @defmethod*[#:mode override (((resized (snip (is-a?/c snip%)) (redraw-now? boolean)) void))]{ + @defmethod*[#:mode override (((resized (snip (is-a?/c snip%)) (redraw-now? boolean?)) void))]{ Sends a message to the delegate to update the size of the copied snip, if there is one. @@ -634,7 +634,7 @@ remembers the filename, for use in @method[text:delegate-mixin after-load-file]. } - @defmethod*[#:mode augment (((after-load-file (success? boolean)) void))]{ + @defmethod*[#:mode augment (((after-load-file (success? boolean?)) void))]{ updates the delegate with the new contents of the text. } @@ -737,7 +737,7 @@ @definterface[text:file<%> (editor:file<%> text:basic<%>)]{ Mixins that implement this interface lock themselves when the file they are editing is read only. - @defmethod*[(((get-read-write?) boolean))]{ + @defmethod*[(((get-read-write?) boolean?))]{ Indicates whether or not this editor is in read-write mode. } @@ -748,14 +748,14 @@ } } @defmixin[text:file-mixin (editor:file<%> text:basic<%>) (text:file<%>)]{ - @defmethod*[#:mode augment (((can-insert? (start number) (len number)) boolean))]{ + @defmethod*[#:mode augment (((can-insert? (start number) (len number)) boolean?))]{ Returns false if the result of @method[text:file<%> get-read-write?] is true, otherwise returns the result of calling @scheme[inner]. } - @defmethod*[#:mode augment (((can-delete? (start number) (len number)) boolean))]{ + @defmethod*[#:mode augment (((can-delete? (start number) (len number)) boolean?))]{ Returns false if the result of @method[text:file<%> get-read-write?] @@ -850,14 +850,14 @@ @method[text:ports<%> get-unread-start-point]. } - @defmethod*[(((set-allow-edits (allow-edits? boolean)) void))]{ + @defmethod*[(((set-allow-edits (allow-edits? boolean?)) void))]{ Enables or disables editing in the buffer. Be sure to update the unread start point (via @method[text:ports<%> set-unread-start-point]) and the insertion point (via @method[text:ports<%> set-insertion-point]) after making changes to the buffer. } - @defmethod*[(((get-allow-edits) boolean))]{ + @defmethod*[(((get-allow-edits) boolean?))]{ Indicates if editing is allowed in the buffer at this point. } @@ -885,7 +885,7 @@ @method[text:ports<%> set-insertion-point]. } - @defmethod*[(((submit-to-port? (key char)) boolean))]{ + @defmethod*[(((submit-to-port? (key char)) boolean?))]{ Augment this method to help control when characters should be submitted to the input port. @@ -1028,13 +1028,13 @@ } @defmixin[text:ports-mixin (text:wide-snip<%>) (text:ports<%>)]{ - @defmethod*[#:mode augment (((can-insert? (start exact-integer) (len exact-integer)) boolean))]{ + @defmethod*[#:mode augment (((can-insert? (start exact-integer) (len exact-integer)) boolean?))]{ Returns the results of the @scheme[inner] call, unless @method[text:ports<%> get-allow-edits] returns @scheme[#f]. } - @defmethod*[#:mode augment (((can-delete? (start exact-integer) (len exact-integer)) boolean))]{ + @defmethod*[#:mode augment (((can-delete? (start exact-integer) (len exact-integer)) boolean?))]{ Returns the results of the @scheme[inner] call, unless @method[text:ports<%> get-allow-edits] @@ -1099,7 +1099,7 @@ @scheme[(make-object color% 204 153 255)]. } - @defmethod*[(((completion-mode-key-event? (key-event key-event%)) boolean))]{ + @defmethod*[(((completion-mode-key-event? (key-event key-event%)) boolean?))]{ Returns true when the key event passed to it should initiate the completions menu.