diff --git a/collects/framework/main.rkt b/collects/framework/main.rkt index 4352051f..882b5e5f 100644 --- a/collects/framework/main.rkt +++ b/collects/framework/main.rkt @@ -838,14 +838,7 @@ ((filename) ((make-default (λ () ((handler:current-create-new-window) filename))))) - @{This function creates a frame or re-uses an existing frame to edit a file. - - If the preference @racket['framework:open-here] is set to @racket[#t], and - @racket[(send (group:get-the-frame-group) get-open-here-frame)] returns a - frame, the @method[frame:open-here<%> open-here] method of that frame is - used to load the file in the existing frame. - - Otherwise, it invokes the appropriate format handler to open the file (see + @{This function invokes the appropriate format handler to open the file (see @racket[handler:insert-format-handler]). @itemize[ diff --git a/collects/framework/private/frame.rkt b/collects/framework/private/frame.rkt index 9930c009..f889d472 100644 --- a/collects/framework/private/frame.rkt +++ b/collects/framework/private/frame.rkt @@ -1453,128 +1453,6 @@ ;; it might not yet be implemented (send canvas focus))))) -(define open-here<%> - (interface (-editor<%>) - get-open-here-editor - open-here)) - -(define open-here-mixin - (mixin (-editor<%>) (open-here<%>) - - (define/override (file-menu:new-on-demand item) - (super file-menu:new-on-demand item) - (send item set-label (if (preferences:get 'framework:open-here?) - (string-constant new-...-menu-item) - (string-constant new-menu-item)))) - - (define/override (file-menu:new-callback item event) - (cond - [(preferences:get 'framework:open-here?) - (let ([clear-current (ask-about-new-here)]) - (cond - [(eq? clear-current 'cancel) (void)] - [clear-current - (let* ([editor (get-editor)] - [canceled? (cancel-due-to-unsaved-changes editor)]) - (unless canceled? - (send editor begin-edit-sequence) - (send editor lock #f) - (send editor set-filename #f) - (send editor erase) - (send editor set-modified #f) - (send editor clear-undos) - (send editor end-edit-sequence)))] - [else ((handler:current-create-new-window) #f)]))] - [else ((handler:current-create-new-window) #f)])) - - ;; cancel-due-to-unsaved-changes : -> boolean - ;; returns #t if the action should be cancelled - (define/private (cancel-due-to-unsaved-changes editor) - (and (send editor is-modified?) - (let ([save (gui-utils:unsaved-warning - (let ([fn (send editor get-filename)]) - (if fn - (path->string fn) - (get-label))) - (string-constant clear-anyway) - #t - this)]) - (case save - [(continue) #f] - [(save) (not (send editor save-file/gui-error))] - [(cancel) #t])))) - - ;; ask-about-new-here : -> (union 'cancel boolean?) - ;; prompts the user about creating a new window - ;; or "reusing" the current one. - (define/private (ask-about-new-here) - (gui-utils:get-choice - (string-constant create-new-window-or-clear-current) - (string-constant clear-current) - (string-constant new-window) - (string-constant warning) - 'cancel - this)) - - (define/override (file-menu:open-on-demand item) - (super file-menu:open-on-demand item) - (send item set-label (if (preferences:get 'framework:open-here?) - (string-constant open-here-menu-item) - (string-constant open-menu-item)))) - - (define/augment (on-close) - (let ([group (group:get-the-frame-group)]) - (when (eq? this (send group get-open-here-frame)) - (send group set-open-here-frame #f))) - (inner (void) on-close)) - - (define/override (on-activate on?) - (super on-activate on?) - (when on? - (send (group:get-the-frame-group) set-open-here-frame this))) - - (inherit get-editor) - (define/public (get-open-here-editor) (get-editor)) - (define/public (open-here filename) - (let* ([editor (get-open-here-editor)] - [okay-to-switch? (user-okays-switch? editor)]) - (when okay-to-switch? - (when (is-a? editor text%) - (let* ([b (box #f)] - [filename (send editor get-filename b)]) - (unless (unbox b) - (when filename - (handler:set-recent-position - filename - (send editor get-start-position) - (send editor get-end-position)))))) - (send editor begin-edit-sequence) - (send editor lock #f) - (send editor load-file/gui-error filename) - (send editor end-edit-sequence) - (void)))) - - (inherit get-label) - (define/private (user-okays-switch? ed) - (or (not (send ed is-modified?)) - (let ([answer - (gui-utils:unsaved-warning - (let ([fn (send ed get-filename)]) - (if fn - (path->string fn) - (get-label))) - (string-constant switch-anyway) - #t)]) - (case answer - [(continue) - #t] - [(save) - (send ed save-file/gui-error)] - [(cancel) - #f])))) - - (super-new))) - (define text<%> (interface (-editor<%>))) (define text-mixin (mixin (-editor<%>) (text<%>) @@ -2738,10 +2616,9 @@ (define status-line% (status-line-mixin text-info%)) (define standard-menus% (standard-menus-mixin status-line%)) (define editor% (editor-mixin standard-menus%)) -(define open-here% (open-here-mixin editor%)) -(define -text% (text-mixin open-here%)) +(define -text% (text-mixin editor%)) (define searchable% (searchable-text-mixin (searchable-mixin -text%))) (define delegate% (delegate-mixin searchable%)) -(define -pasteboard% (pasteboard-mixin open-here%)) +(define -pasteboard% (pasteboard-mixin editor%)) diff --git a/collects/framework/private/group.rkt b/collects/framework/private/group.rkt index 1f9390a2..1bc409e9 100644 --- a/collects/framework/private/group.rkt +++ b/collects/framework/private/group.rkt @@ -162,19 +162,6 @@ (set-close-menu-item-state! a-frame #t)) frames)))) - (field [open-here-frame #f]) - (define/public (set-open-here-frame fr) (set! open-here-frame fr)) - (define/public (get-open-here-frame) - (cond - [open-here-frame open-here-frame] - [else - (let ([candidates - (filter (λ (x) (is-a? (frame-frame x) frame:open-here<%>)) - frames)]) - (if (null? candidates) - #f - (frame-frame (car candidates))))])) - (define/public (get-mdi-parent) (when (and (eq? (system-type) 'windows) (preferences:get 'framework:windows-mdi) diff --git a/collects/framework/private/handler.rkt b/collects/framework/private/handler.rkt index 8f49494b..5fb720f7 100644 --- a/collects/framework/private/handler.rkt +++ b/collects/framework/private/handler.rkt @@ -101,14 +101,6 @@ (send already-open make-visible filename) (send already-open show #t) already-open] - [(and (preferences:get 'framework:open-here?) - (send (group:get-the-frame-group) get-open-here-frame)) - => - (λ (fr) - (add-to-recent filename) - (send fr open-here filename) - (send fr show #t) - fr)] [else (let ([handler (and (path? filename) (find-format-handler filename))]) @@ -228,11 +220,7 @@ [end (caddr recent-list-item)]) (cond [(file-exists? filename) - (let ([fr (edit-file filename)]) - (when (is-a? fr frame:open-here<%>) - (let ([ed (send fr get-open-here-editor)]) - (when (equal? (send ed get-filename) filename) - (send ed set-position start end)))))] + (edit-file filename)] [else (preferences:set 'framework:recently-opened-files/pos (remove* (list recent-list-item) @@ -355,8 +343,7 @@ (super-instantiate ())))) (define (open-file [directory #f]) - (let* ([parent (and (or (not (eq? 'macosx (system-type))) - (preferences:get 'framework:open-here?)) + (let* ([parent (and (not (eq? 'macosx (system-type))) (get-top-level-focus-window))] [file (parameterize ([finder:dialog-parent-parameter parent]) diff --git a/collects/framework/private/main.rkt b/collects/framework/private/main.rkt index ba59746e..043978d1 100644 --- a/collects/framework/private/main.rkt +++ b/collects/framework/private/main.rkt @@ -196,7 +196,6 @@ (λ (x) (or (eq? x 'age) (eq? x 'name)))) (preferences:set-default 'framework:recent-items-window-w 400 number?) (preferences:set-default 'framework:recent-items-window-h 600 number?) -(preferences:set-default 'framework:open-here? #f boolean?) (preferences:set-default 'framework:show-delegate? #f boolean?) (preferences:set-default 'framework:windows-mdi #f boolean?) (preferences:set-default 'framework:menu-bindings #t boolean?) diff --git a/collects/framework/private/preferences.rkt b/collects/framework/private/preferences.rkt index 02999702..f50bd14e 100644 --- a/collects/framework/private/preferences.rkt +++ b/collects/framework/private/preferences.rkt @@ -464,10 +464,6 @@ the state transitions / contracts are: 'framework:auto-set-wrap? (string-constant wrap-words-in-editor-buffers) values values) - (make-check editor-panel - 'framework:open-here? - (string-constant reuse-existing-frames) - values values) (make-check editor-panel 'framework:menu-bindings diff --git a/collects/framework/private/sig.rkt b/collects/framework/private/sig.rkt index aa76198d..0abac09b 100644 --- a/collects/framework/private/sig.rkt +++ b/collects/framework/private/sig.rkt @@ -262,7 +262,6 @@ status-line<%> standard-menus<%> editor<%> - open-here<%> text<%> pasteboard<%> delegate<%> @@ -280,7 +279,6 @@ pasteboard-info% standard-menus% editor% - open-here% text% searchable% delegate% @@ -293,7 +291,6 @@ status-line-mixin standard-menus-mixin editor-mixin - open-here-mixin text-mixin pasteboard-mixin delegate-mixin diff --git a/collects/scribblings/framework/frame.scrbl b/collects/scribblings/framework/frame.scrbl index 1ffda924..faeb9ace 100644 --- a/collects/scribblings/framework/frame.scrbl +++ b/collects/scribblings/framework/frame.scrbl @@ -683,61 +683,6 @@ } } -@definterface[frame:open-here<%> (frame:editor<%>)]{ - Frames implementing this mixin can change the file they are displaying. - - The frame is only re-used when the @racket['framework:open-here?] preference - is set (see @racket[preferences:get] and @racket[preferences:set] for details - on preferences). - - The @racket[frame:open-here-mixin] implements this interface. - - @defmethod*[(((get-open-here-editor) (is-a?/c editor<%>)))]{ - When the user switches the visible file in this frame, the of this method - is the editor that gets switched. - - By Default, returns the result of @method[frame:editor<%> get-editor]. - } - - @defmethod*[(((open-here (filename string)) void?))]{ - Opens @racket[filename] in the current frame, possibly prompting the user - about saving a file (in which case the frame might not get switched). - } - -} -@defmixin[frame:open-here-mixin (frame:editor<%>) (frame:open-here<%>)]{ - Provides an implementation of @racket[frame:open-here<%>] - - @defmethod*[#:mode override (((file-menu:new-on-demand (item (is-a?/c menu-item%))) void?))]{ - Sets the label of @racket[item] to @racket["New..."] if the preference - @racket['framework:open-here?] is set. - } - - @defmethod*[#:mode override (((file-menu:new-callback (item (is-a?/c menu-item%)) - (evt (is-a?/c control-event%))) - void?))]{ - When the preference @racket['framework:open-here?] preference is set, this - method prompts the user, asking if they would like to create a new frame, - or just clear out this one. If they clear it out and the file hasn't been - saved, they are asked about saving. - } - - @defmethod*[#:mode override (((file-menu:open-on-demand (item (is-a?/c menu-item%))) void?))]{ - Sets the label of @racket[item] to "Open Here..." if the preference - @racket['framework:open-here?] is set. - } - - @defmethod*[#:mode augment (((on-close) void?))]{ - Calls @method[group:% set-open-here-frame] with @racket[#f] if the result - of @method[group:% get-open-here-frame] is @racket[eq?] to @racket[this]. - } - - @defmethod*[#:mode override (((on-activate (on? boolean?)) void?))]{ - When @racket[on?] is @racket[#t], calls @method[group:% - set-open-here-frame] with @racket[this]. - } -} - @definterface[frame:text<%> (frame:editor<%>)]{ Frames matching this interface provide support for @racket[text%]s. } @@ -995,10 +940,9 @@ @defclass[frame:status-line% (frame:status-line-mixin frame:text-info%) ()]{} @defclass[frame:standard-menus% (frame:standard-menus-mixin frame:status-line%) ()]{} @defclass[frame:editor% (frame:editor-mixin frame:standard-menus%) ()]{} -@defclass[frame:open-here% (frame:open-here-mixin frame:editor%) ()]{} -@defclass[frame:text% (frame:text-mixin frame:open-here%) ()]{} +@defclass[frame:text% (frame:text-mixin frame:editor%) ()]{} @defclass[frame:searchable% (frame:searchable-text-mixin (frame:searchable-mixin frame:text%)) ()]{} @defclass[frame:delegate% (frame:delegate-mixin frame:searchable%) ()]{} -@defclass[frame:pasteboard% (frame:pasteboard-mixin frame:open-here%) ()]{} +@defclass[frame:pasteboard% (frame:pasteboard-mixin frame:editor%) ()]{} @(include-previously-extracted "main-extracts.rkt" #rx"^frame:") diff --git a/collects/scribblings/framework/group.scrbl b/collects/scribblings/framework/group.scrbl index 84cd1d65..dc558578 100644 --- a/collects/scribblings/framework/group.scrbl +++ b/collects/scribblings/framework/group.scrbl @@ -11,15 +11,6 @@ constructed with @racket[frame:basic-mixin] adds itself to the result of @racket[group:get-the-frame-group]. - @defmethod*[(((set-open-here-frame (frame (is-a?/c frame:editor%))) void?))]{ - Sets the frame to load new files into. See also - @racket[frame:open-here<%>]. - } - - @defmethod*[(((get-open-here-frame) (or/c false/c (is-a?/c frame:editor<%>))))]{ - Returns the currently saved frame to load new files into. - } - @defmethod*[(((get-mdi-parent) (or/c false/c (is-a?/c frame%))))]{ The result of this method must be used as the parent frame for each frame in the group.