]> arthur.barton.de Git - atom-ax-pipe.git/blob - lib/command-view.coffee
initial commit
[atom-ax-pipe.git] / lib / command-view.coffee
1 {View, EditorView} = require 'atom'
2
3 module.exports =
4 class CommandView extends View
5   @placeholders: [
6     'sort -n'
7     'tac'
8     'sed \'s/^/\\/\\//g\''
9     'grep foo'
10     'tee ~/temp.txt'
11   ]
12
13   @content: ->
14     @div class: 'pipe-command', =>
15       @subview 'commandLine', new EditorView(
16         mini: true
17         placeholderText: @samplePlaceholder()
18       )
19
20   @samplePlaceholder: ->
21     @placeholders[Math.floor(Math.random()*@placeholders.length)]
22
23   initialize: (callback) ->
24     @on 'core:cancel core:close', =>
25       callback(null)
26       @detach()
27     @on 'core:confirm', =>
28       callback(@commandLine.getText())
29       @detach()
30
31     atom.workspaceView.append(this)
32     @commandLine.focus()