Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
add new pane switch events for MRU UI
Browse files Browse the repository at this point in the history
  • Loading branch information
iolsen committed Oct 17, 2016
1 parent b84a300 commit 8e431a3
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/pane.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,39 @@ class Pane extends Model
onDidChangeActiveItem: (callback) ->
@emitter.on 'did-change-active-item', callback

# Public: Invoke the given callback when {::activateNextRecentlyUsedItem}
# has been called, either initiating or continuing a forward MRU traversal of
# pane items.
#
# * `callback` {Function} to be called with when the active item changes.
# * `nextRecentlyUsedItem` The next MRU item, now being set active
#
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
onChooseNextMRUItem: (callback) ->
@emitter.on 'choose-next-mru-item', callback

# Public: Invoke the given callback when {::activatePreviousRecentlyUsedItem}
# has been called, either initiating or continuing a reverse MRU traversal of
# pane items.
#
# * `callback` {Function} to be called with when the active item changes.
# * `previousRecentlyUsedItem` The previous MRU item, now being set active
#
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
onChooseLastMRUItem: (callback) ->
@emitter.on 'choose-last-mru-item', callback

# Public: Invoke the given callback when {::moveActiveItemToTopOfStack}
# has been called, terminating an MRU traversal of pane items and moving the
# current active item to the top of the stack. Typically bound to a modifier
# (e.g. CTRL) key up event.
#
# * `callback` {Function} to be called with when the MRU traversal is done.
#
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
onDoneChoosingMRUItem: (callback) ->
@emitter.on 'done-choosing-mru-item', callback

# Public: Invoke the given callback with the current and future values of
# {::getActiveItem}.
#
Expand Down Expand Up @@ -334,6 +367,7 @@ class Pane extends Model
@itemStackIndex = @itemStack.length if @itemStackIndex is 0
@itemStackIndex = @itemStackIndex - 1
nextRecentlyUsedItem = @itemStack[@itemStackIndex]
@emitter.emit 'choose-next-mru-item', nextRecentlyUsedItem
@setActiveItem(nextRecentlyUsedItem, modifyStack: false)

# Makes the previous item in the itemStack active.
Expand All @@ -343,12 +377,15 @@ class Pane extends Model
@itemStackIndex = -1
@itemStackIndex = @itemStackIndex + 1
previousRecentlyUsedItem = @itemStack[@itemStackIndex]
@emitter.emit 'choose-last-mru-item', previousRecentlyUsedItem
@setActiveItem(previousRecentlyUsedItem, modifyStack: false)

# Moves the active item to the end of the itemStack once the ctrl key is lifted
moveActiveItemToTopOfStack: ->
delete @itemStackIndex
@addItemToStack(@activeItem)
@emitter.emit 'done-choosing-mru-item'


# Public: Makes the next item active.
activateNextItem: ->
Expand Down

0 comments on commit 8e431a3

Please sign in to comment.