adjust drracket to track an lru order on tabs and use it
when closing one to pick the next one to show added the touched and get-last-touched methods to tab<%>
This commit is contained in:
parent
4fc71951ee
commit
e19243329c
|
@ -1215,6 +1215,10 @@ module browser threading seems wrong.
|
||||||
(send frame enable-evaluation-in-tab this))
|
(send frame enable-evaluation-in-tab this))
|
||||||
(define/public (get-enabled) enabled?)
|
(define/public (get-enabled) enabled?)
|
||||||
|
|
||||||
|
(define last-touched (current-inexact-milliseconds))
|
||||||
|
(define/public-final (touched) (set! last-touched (current-inexact-milliseconds)))
|
||||||
|
(define/public-final (get-last-touched) last-touched)
|
||||||
|
|
||||||
;; current-execute-warning is a snapshot of the needs-execution-message
|
;; current-execute-warning is a snapshot of the needs-execution-message
|
||||||
;; that is taken each time repl submission happens, and it gets reset
|
;; that is taken each time repl submission happens, and it gets reset
|
||||||
;; when "Run" is clicked.
|
;; when "Run" is clicked.
|
||||||
|
@ -2946,6 +2950,8 @@ module browser threading seems wrong.
|
||||||
|
|
||||||
(send definitions-text update-frame-filename)
|
(send definitions-text update-frame-filename)
|
||||||
(update-running (send current-tab is-running?))
|
(update-running (send current-tab is-running?))
|
||||||
|
(when (eq? this (get-top-level-focus-window))
|
||||||
|
(send current-tab touched))
|
||||||
(on-tab-change old-tab current-tab)
|
(on-tab-change old-tab current-tab)
|
||||||
(send tab update-log)
|
(send tab update-log)
|
||||||
(send tab update-planet-status)
|
(send tab update-planet-status)
|
||||||
|
@ -2991,10 +2997,9 @@ module browser threading seems wrong.
|
||||||
(set! tabs (remq tab tabs))
|
(set! tabs (remq tab tabs))
|
||||||
(send tabs-panel delete (send tab get-i))
|
(send tabs-panel delete (send tab get-i))
|
||||||
(update-menu-bindings)
|
(update-menu-bindings)
|
||||||
(change-to-tab (cond
|
(change-to-tab
|
||||||
[(< (send tab get-i) (length tabs))
|
(argmax (λ (tab) (send tab get-last-touched))
|
||||||
(list-ref tabs (send tab get-i))]
|
tabs)))
|
||||||
[else (last tabs)])))
|
|
||||||
(loop (cdr l-tabs))))]))]))
|
(loop (cdr l-tabs))))]))]))
|
||||||
|
|
||||||
;; a helper private method for close-current-tab -- doesn't close an arbitrary tab.
|
;; a helper private method for close-current-tab -- doesn't close an arbitrary tab.
|
||||||
|
@ -3134,6 +3139,11 @@ module browser threading seems wrong.
|
||||||
[else (super restore-keybinding)]))
|
[else (super restore-keybinding)]))
|
||||||
(super-new)))
|
(super-new)))
|
||||||
|
|
||||||
|
(define/override (on-activate active?)
|
||||||
|
(when active?
|
||||||
|
(send (get-current-tab) touched))
|
||||||
|
(super on-activate active?))
|
||||||
|
|
||||||
(define/private (update-menu-bindings)
|
(define/private (update-menu-bindings)
|
||||||
(when close-tab-menu-item
|
(when close-tab-menu-item
|
||||||
(update-close-tab-menu-item-shortcut close-tab-menu-item))
|
(update-close-tab-menu-item-shortcut close-tab-menu-item))
|
||||||
|
|
|
@ -155,7 +155,22 @@ Calls the definitions text's
|
||||||
|
|
||||||
See also @method[drracket:unit:tab<%> add-bkg-running-color].
|
See also @method[drracket:unit:tab<%> add-bkg-running-color].
|
||||||
}
|
}
|
||||||
|
@defmethod[#:mode public-final (touched) void?]{
|
||||||
|
Called by the system to indicate that the tab has
|
||||||
|
just been switched to from another tab in the
|
||||||
|
same frame (when the frame has the focus)
|
||||||
|
or the frame itself has come to the
|
||||||
|
front (via @method[top-level-window<%> on-activate])
|
||||||
|
and the tab is the current tab in that frame.
|
||||||
|
|
||||||
|
This method updates the private state that
|
||||||
|
@method[drracket:unit:tab<%> get-last-touched]
|
||||||
|
returns.
|
||||||
|
}
|
||||||
|
@defmethod[#:mode public-final (get-last-touched) flonum?]{
|
||||||
|
Returns the time that this tab was last focused, as counted
|
||||||
|
by @racket[current-inexact-milliseconds].
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user