aboutsummaryrefslogtreecommitdiff
path: root/src/console
diff options
context:
space:
mode:
Diffstat (limited to 'src/console')
-rw-r--r--src/console/actions/console.js8
-rw-r--r--src/console/actions/index.js1
-rw-r--r--src/console/components/console.js45
-rw-r--r--src/console/index.html2
-rw-r--r--src/console/index.js2
-rw-r--r--src/console/reducers/index.js4
-rw-r--r--src/console/site.scss7
7 files changed, 63 insertions, 6 deletions
diff --git a/src/console/actions/console.js b/src/console/actions/console.js
index 2cf8e8d..f80045f 100644
--- a/src/console/actions/console.js
+++ b/src/console/actions/console.js
@@ -1,5 +1,11 @@
import actions from 'console/actions';
+const hide = () => {
+ return {
+ type: actions.CONSOLE_HIDE,
+ };
+};
+
const showCommand = (text) => {
return {
type: actions.CONSOLE_SHOW_COMMAND,
@@ -61,6 +67,6 @@ const completionPrev = () => {
};
export {
- showCommand, showFind, showError, showInfo, hideCommand, setConsoleText,
+ hide, showCommand, showFind, showError, showInfo, hideCommand, setConsoleText,
setCompletions, completionNext, completionPrev
};
diff --git a/src/console/actions/index.js b/src/console/actions/index.js
index a85e329..b394179 100644
--- a/src/console/actions/index.js
+++ b/src/console/actions/index.js
@@ -1,5 +1,6 @@
export default {
// console commands
+ CONSOLE_HIDE: 'console.hide',
CONSOLE_SHOW_COMMAND: 'console.show.command',
CONSOLE_SHOW_ERROR: 'console.show.error',
CONSOLE_SHOW_INFO: 'console.show.info',
diff --git a/src/console/components/console.js b/src/console/components/console.js
index 7bc3364..a9ae4ed 100644
--- a/src/console/components/console.js
+++ b/src/console/components/console.js
@@ -31,14 +31,33 @@ export default class ConsoleComponent {
}
}
+ doEnter(e) {
+ e.stopPropagation();
+ e.preventDefault();
+ return this.onEntered(e.target.value);
+ }
+
+ selectNext(e) {
+ this.store.dispatch(consoleActions.completionNext());
+ e.stopPropagation();
+ e.preventDefault();
+ }
+
+ selectPrev(e) {
+ this.store.dispatch(consoleActions.completionPrev());
+ e.stopPropagation();
+ e.preventDefault();
+ }
+
onKeyDown(e) {
+ if (e.keyCode === KeyboardEvent.DOM_VK_ESCAPE && e.ctrlKey) {
+ return this.hideCommand();
+ }
switch (e.keyCode) {
case KeyboardEvent.DOM_VK_ESCAPE:
return this.hideCommand();
case KeyboardEvent.DOM_VK_RETURN:
- e.stopPropagation();
- e.preventDefault();
- return this.onEntered(e.target.value);
+ return this.doEnter(e);
case KeyboardEvent.DOM_VK_TAB:
if (e.shiftKey) {
this.store.dispatch(consoleActions.completionPrev());
@@ -48,6 +67,26 @@ export default class ConsoleComponent {
e.stopPropagation();
e.preventDefault();
break;
+ case KeyboardEvent.DOM_VK_OPEN_BRACKET:
+ if (e.ctrlKey) {
+ return this.hideCommand();
+ }
+ break;
+ case KeyboardEvent.DOM_VK_M:
+ if (e.ctrlKey) {
+ return this.doEnter(e);
+ }
+ break;
+ case KeyboardEvent.DOM_VK_N:
+ if (e.ctrlKey) {
+ this.selectNext(e);
+ }
+ break;
+ case KeyboardEvent.DOM_VK_P:
+ if (e.ctrlKey) {
+ this.selectPrev(e);
+ }
+ break;
}
}
diff --git a/src/console/index.html b/src/console/index.html
index 52ecb76..e049b5e 100644
--- a/src/console/index.html
+++ b/src/console/index.html
@@ -7,7 +7,7 @@
</head>
<body class='vimvixen-console'>
<p class='vimvixen-console-message'></p>
- <div id='vimvixen-console-command'>
+ <div id='vimvixen-console-command' class='vimvixen-console-command-wrapper'>
<ul id='vimvixen-console-completion' class='vimvixen-console-completion'></ul>
<div class='vimvixen-console-command'>
<i class='vimvixen-console-command-prompt'></i><input
diff --git a/src/console/index.js b/src/console/index.js
index 86edd9a..156456c 100644
--- a/src/console/index.js
+++ b/src/console/index.js
@@ -24,6 +24,8 @@ const onMessage = (message) => {
return store.dispatch(consoleActions.showError(message.text));
case messages.CONSOLE_SHOW_INFO:
return store.dispatch(consoleActions.showInfo(message.text));
+ case messages.CONSOLE_HIDE:
+ return store.dispatch(consoleActions.hide());
}
};
diff --git a/src/console/reducers/index.js b/src/console/reducers/index.js
index 60c0007..2aec55c 100644
--- a/src/console/reducers/index.js
+++ b/src/console/reducers/index.js
@@ -53,6 +53,10 @@ const nextConsoleText = (completions, group, item, defaults) => {
export default function reducer(state = defaultState, action = {}) {
switch (action.type) {
+ case actions.CONSOLE_HIDE:
+ return Object.assign({}, state, {
+ mode: '',
+ });
case actions.CONSOLE_SHOW_COMMAND:
return Object.assign({}, state, {
mode: 'command',
diff --git a/src/console/site.scss b/src/console/site.scss
index cd40db5..cb89e50 100644
--- a/src/console/site.scss
+++ b/src/console/site.scss
@@ -12,7 +12,6 @@ body {
}
.vimvixen-console {
- border-top: 1px solid gray;
bottom: 0;
margin: 0;
padding: 0;
@@ -24,6 +23,10 @@ body {
line-height: 16px;
}
+ &-command-wrapper {
+ border-top: 1px solid gray;
+ }
+
&-completion {
background-color: white;
@@ -66,6 +69,8 @@ body {
&-message {
@include consoole-font;
+
+ border-top: 1px solid gray;
}
&-error {