working title
This commit is contained in:
parent
ffbe36efec
commit
1a8657b3d4
13 changed files with 234 additions and 77 deletions
35
lib/ex-view-model.coffee
Normal file
35
lib/ex-view-model.coffee
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
{ViewModel, Input} = require './view-model'
|
||||
|
||||
module.exports =
|
||||
class ExViewModel extends ViewModel
|
||||
constructor: (@exCommand) ->
|
||||
super(@exCommand, class: 'command')
|
||||
@historyIndex = -1
|
||||
|
||||
@view.editor.on('core:move-up', @increaseHistoryEx)
|
||||
@view.editor.on('core:move-down', @decreaseHistoryEx)
|
||||
|
||||
restoreHistory: (index) ->
|
||||
@view.editor.setText(@history(index).value)
|
||||
|
||||
history: (index) ->
|
||||
@exState.getExHistoryItem(index)
|
||||
|
||||
increaseHistoryEx: =>
|
||||
if @history(@historyIndex + 1)?
|
||||
@historyIndex += 1
|
||||
@restoreHistory(@historyIndex)
|
||||
|
||||
decreaseHistoryEx: =>
|
||||
if @historyIndex <= 0
|
||||
# get us back to a clean slate
|
||||
@historyIndex = -1
|
||||
@view.editor.setText('')
|
||||
else
|
||||
@historyIndex -= 1
|
||||
@restoreHistory(@historyIndex)
|
||||
|
||||
confirm: (view) =>
|
||||
@value = @view.value
|
||||
@exState.pushExHistory(@)
|
||||
super(view)
|
||||
Loading…
Add table
Add a link
Reference in a new issue