|
|
@@ -65,13 +65,13 @@
|
|
|
<command-line>
|
|
|
<form autocomplete='off' onsubmit={ process } show={ visible }>
|
|
|
<raw-html name='lhs' content={ prompt } show={ prompt_visible }>
|
|
|
- </raw-html><input type='text' name='command' />
|
|
|
+ </raw-html><input type='text' ref='command' />
|
|
|
</form>
|
|
|
|
|
|
<style>
|
|
|
- command-line input[name='command'],
|
|
|
- command-line input[name='command']:hover,
|
|
|
- command-line input[name='command']:focus {
|
|
|
+ command-line input[ref='command'],
|
|
|
+ command-line input[ref='command']:hover,
|
|
|
+ command-line input[ref='command']:focus {
|
|
|
padding: 0; margin: 0; line-height: normal; font-size: 100%;
|
|
|
background-color: transparent; border: none; outline: none;
|
|
|
height: auto; width: 70%;
|
|
|
@@ -86,7 +86,7 @@
|
|
|
this.visible = this.prompt_visible = true
|
|
|
this.prompt = opts.prompt || '$ '
|
|
|
|
|
|
- this.on('mount', function() { this.command.focus() })
|
|
|
+ this.on('mount', function() { this.refs.command.focus() })
|
|
|
|
|
|
ev.on('prompt_set', function(text) { self.prompt = text })
|
|
|
|
|
|
@@ -94,15 +94,15 @@
|
|
|
|
|
|
ev.on('prompt_show', function() { self.update({ prompt_visible: true }) })
|
|
|
|
|
|
- ev.on('cmd_add', function(text) { self.command.value += text })
|
|
|
+ ev.on('cmd_add', function(text) { self.refs.command.value += text })
|
|
|
|
|
|
- ev.on('cmd_set', function(text) { self.command.value = text })
|
|
|
+ ev.on('cmd_set', function(text) { self.refs.command.value = text })
|
|
|
|
|
|
ev.on('cli_hide', function() { self.update({ visible: false }) })
|
|
|
|
|
|
ev.on('cli_show', function() {
|
|
|
self.update({ visible: true })
|
|
|
- self.command.focus()
|
|
|
+ self.refs.command.focus()
|
|
|
})
|
|
|
|
|
|
ev.on('context_swap', function(name) {
|
|
|
@@ -119,19 +119,20 @@
|
|
|
// Update the display.
|
|
|
self.current = name
|
|
|
if (self.visible) {
|
|
|
- self.command.focus()
|
|
|
+ self.refs.command.focus()
|
|
|
}
|
|
|
})
|
|
|
|
|
|
- process() {
|
|
|
+ process(event) {
|
|
|
var prompt = this.prompt_visible ? this.prompt : ''
|
|
|
- var command = this.encode(this.command.value)
|
|
|
+ var command = this.encode(this.refs.command.value)
|
|
|
ev.trigger('disp_add', prompt + command + '\n')
|
|
|
ev.trigger('cmd_entered', command)
|
|
|
- this.command.value = ''
|
|
|
+ this.refs.command.value = ''
|
|
|
// Refocus to scroll display and keep input in view.
|
|
|
- this.command.blur()
|
|
|
- this.command.focus()
|
|
|
+ this.refs.command.blur()
|
|
|
+ this.refs.command.focus()
|
|
|
+ event.preventDefault()
|
|
|
}
|
|
|
|
|
|
encode(text) {
|