]>
Commit | Line | Data |
---|---|---|
1 | {ViewModel, Input} = require './view-model' | |
2 | ||
3 | module.exports = | |
4 | class ExViewModel extends ViewModel | |
5 | constructor: (@exCommand) -> | |
6 | super(@exCommand, class: 'command') | |
7 | @historyIndex = -1 | |
8 | ||
9 | atom.commands.add(@view.editorElement, 'core:move-up', @increaseHistoryEx) | |
10 | atom.commands.add(@view.editorElement, 'core:move-down', @decreaseHistoryEx) | |
11 | ||
12 | restoreHistory: (index) -> | |
13 | @view.editorElement.getModel().setText(@history(index).value) | |
14 | ||
15 | history: (index) -> | |
16 | @exState.getExHistoryItem(index) | |
17 | ||
18 | increaseHistoryEx: => | |
19 | if @history(@historyIndex + 1)? | |
20 | @historyIndex += 1 | |
21 | @restoreHistory(@historyIndex) | |
22 | ||
23 | decreaseHistoryEx: => | |
24 | if @historyIndex <= 0 | |
25 | # get us back to a clean slate | |
26 | @historyIndex = -1 | |
27 | @view.editorElement.getModel().setText('') | |
28 | else | |
29 | @historyIndex -= 1 | |
30 | @restoreHistory(@historyIndex) | |
31 | ||
32 | confirm: (view) => | |
33 | @value = @view.value | |
34 | @exState.pushExHistory(@) | |
35 | super(view) |