1 {View, TextEditorView} = require 'atom-space-pen-views'
5 class CommandView extends View
15 @div class: 'pipe-command', =>
16 @subview 'commandLine', new TextEditorView(
18 placeholderText: @samplePlaceholder()
21 @samplePlaceholder: ->
22 @placeholders[Math.floor(Math.random()*@placeholders.length)]
24 initialize: (history, callback) ->
25 historyPos = history.length
28 @on 'core:cancel core:close', =>
31 @on 'core:confirm', =>
32 callback(@commandLine.getText())
34 @commandLine.on 'keydown', (e) =>
35 if history.length is 0 then return
39 unless historyPos <= 0
41 @commandLine.setText history[historyPos]
44 if historyPos >= history.length-1
45 historyPos = history.length
46 @commandLine.setText cur
49 @commandLine.setText history[historyPos]
52 if historyPos >= history.length
53 cur = @commandLine.getText()
55 atom.workspace.addBottomPanel(item: this)