From cc0fbdd496f02c311492df5cbfa1db6676d3c0b6 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Wed, 15 Nov 2017 21:54:52 +0900 Subject: border on console --- src/console/index.html | 2 +- src/console/site.scss | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/console') 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 @@

-
+
    Date: Wed, 15 Nov 2017 22:42:09 +0900 Subject: Add c-n, c-p, c-m to console Add `c-n`, `c-j` for select next item. Add `c-p`, `c-k` for select previous item. Add `c-m` for select item. Above console keybinds are same as Vim(Vimperator)'s completion selector. --- src/console/components/console.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/console') diff --git a/src/console/components/console.js b/src/console/components/console.js index 7bc3364..cabd229 100644 --- a/src/console/components/console.js +++ b/src/console/components/console.js @@ -48,6 +48,34 @@ 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) { + e.stopPropagation(); + e.preventDefault(); + return this.onEntered(e.target.value); + } + break; + case KeyboardEvent.DOM_VK_N: + case KeyboardEvent.DOM_VK_J: + if (e.ctrlKey) { + this.store.dispatch(consoleActions.completionNext()); + e.stopPropagation(); + e.preventDefault(); + } + break; + case KeyboardEvent.DOM_VK_P: + case KeyboardEvent.DOM_VK_K: + if (e.ctrlKey) { + this.store.dispatch(consoleActions.completionPrev()); + e.stopPropagation(); + e.preventDefault(); + } + break; } } -- cgit v1.2.3 From f32dce829c90f67776c6827a8f7e493615a88aaf Mon Sep 17 00:00:00 2001 From: Shinya Ohyanagi Date: Thu, 16 Nov 2017 21:50:44 +0900 Subject: Add allow up and down to move cursor Also refactor methods. --- src/console/components/console.js | 40 +++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'src/console') diff --git a/src/console/components/console.js b/src/console/components/console.js index cabd229..7c1976e 100644 --- a/src/console/components/console.js +++ b/src/console/components/console.js @@ -31,14 +31,30 @@ 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) { 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()); @@ -55,25 +71,25 @@ export default class ConsoleComponent { break; case KeyboardEvent.DOM_VK_M: if (e.ctrlKey) { - e.stopPropagation(); - e.preventDefault(); - return this.onEntered(e.target.value); + this.doEnter(e); } break; + case KeyboardEvent.DOM_VK_DOWN: + this.selectNext(e); + break; case KeyboardEvent.DOM_VK_N: case KeyboardEvent.DOM_VK_J: if (e.ctrlKey) { - this.store.dispatch(consoleActions.completionNext()); - e.stopPropagation(); - e.preventDefault(); + this.selectNext(e); } break; + case KeyboardEvent.DOM_VK_UP: + this.selectPrev(e); + break; case KeyboardEvent.DOM_VK_P: case KeyboardEvent.DOM_VK_K: if (e.ctrlKey) { - this.store.dispatch(consoleActions.completionPrev()); - e.stopPropagation(); - e.preventDefault(); + this.selectPrev(e); } break; } -- cgit v1.2.3 From 9ce54583314444a7f6c41db731be5d58f669702a Mon Sep 17 00:00:00 2001 From: Shinya Ohyanagi Date: Thu, 16 Nov 2017 23:22:56 +0900 Subject: Fix add return statement --- src/console/components/console.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/console') diff --git a/src/console/components/console.js b/src/console/components/console.js index 7c1976e..682d5dc 100644 --- a/src/console/components/console.js +++ b/src/console/components/console.js @@ -71,7 +71,7 @@ export default class ConsoleComponent { break; case KeyboardEvent.DOM_VK_M: if (e.ctrlKey) { - this.doEnter(e); + return this.doEnter(e); } break; case KeyboardEvent.DOM_VK_DOWN: -- cgit v1.2.3 From b70a671d7e7c8b801f8a05210c71f7c9a8e48828 Mon Sep 17 00:00:00 2001 From: Shinya Ohyanagi Date: Sat, 18 Nov 2017 13:22:43 +0900 Subject: Fix drop , from cursor selector Because these are not Vim's default behavior. --- src/console/components/console.js | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/console') diff --git a/src/console/components/console.js b/src/console/components/console.js index 682d5dc..21439ef 100644 --- a/src/console/components/console.js +++ b/src/console/components/console.js @@ -78,7 +78,6 @@ export default class ConsoleComponent { this.selectNext(e); break; case KeyboardEvent.DOM_VK_N: - case KeyboardEvent.DOM_VK_J: if (e.ctrlKey) { this.selectNext(e); } @@ -87,7 +86,6 @@ export default class ConsoleComponent { this.selectPrev(e); break; case KeyboardEvent.DOM_VK_P: - case KeyboardEvent.DOM_VK_K: if (e.ctrlKey) { this.selectPrev(e); } -- cgit v1.2.3 From 5d0554c7e8be7d2e96a76927b46a37c82e0eb011 Mon Sep 17 00:00:00 2001 From: Shinya Ohyanagi Date: Sat, 18 Nov 2017 13:53:33 +0900 Subject: Fix drop arrow keys from console --- src/console/components/console.js | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/console') diff --git a/src/console/components/console.js b/src/console/components/console.js index 21439ef..7c23dab 100644 --- a/src/console/components/console.js +++ b/src/console/components/console.js @@ -74,17 +74,11 @@ export default class ConsoleComponent { return this.doEnter(e); } break; - case KeyboardEvent.DOM_VK_DOWN: - this.selectNext(e); - break; case KeyboardEvent.DOM_VK_N: if (e.ctrlKey) { this.selectNext(e); } break; - case KeyboardEvent.DOM_VK_UP: - this.selectPrev(e); - break; case KeyboardEvent.DOM_VK_P: if (e.ctrlKey) { this.selectPrev(e); -- cgit v1.2.3 From 27263e906d558e53e04121a79e20b62d03d4c40f Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 19 Nov 2017 12:01:49 +0900 Subject: Fix message CSS --- src/console/site.scss | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/console') diff --git a/src/console/site.scss b/src/console/site.scss index 5aaea12..cb89e50 100644 --- a/src/console/site.scss +++ b/src/console/site.scss @@ -69,6 +69,8 @@ body { &-message { @include consoole-font; + + border-top: 1px solid gray; } &-error { -- cgit v1.2.3 From 57dba2d841e088ee1a0921f36b30a081d02d041c Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Mon, 26 Feb 2018 21:40:51 +0900 Subject: hide console by --- src/console/components/console.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/console') diff --git a/src/console/components/console.js b/src/console/components/console.js index 7c23dab..a9ae4ed 100644 --- a/src/console/components/console.js +++ b/src/console/components/console.js @@ -50,6 +50,9 @@ export default class ConsoleComponent { } 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(); -- cgit v1.2.3 From 37410b874f89de4907ba038244318129835e8157 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 4 Mar 2018 17:57:56 +0900 Subject: add hide action for console --- src/console/actions/console.js | 8 +++++++- src/console/actions/index.js | 1 + src/console/index.js | 2 ++ src/console/reducers/index.js | 4 ++++ test/console/actions/console.test.js | 6 ++++++ test/console/reducers/console.test.js | 6 ++++++ 6 files changed, 26 insertions(+), 1 deletion(-) (limited to 'src/console') 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/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/test/console/actions/console.test.js b/test/console/actions/console.test.js index 9af13d4..1774431 100644 --- a/test/console/actions/console.test.js +++ b/test/console/actions/console.test.js @@ -3,6 +3,12 @@ import actions from 'console/actions'; import * as consoleActions from 'console/actions/console'; describe("console actions", () => { + describe('hide', () => { + it('create CONSOLE_HIDE action', () => { + let action = consoleActions.hide(); + expect(action.type).to.equal(actions.CONSOLE_HIDE); + }); + }); describe("showCommand", () => { it('create CONSOLE_SHOW_COMMAND action', () => { let action = consoleActions.showCommand('hello'); diff --git a/test/console/reducers/console.test.js b/test/console/reducers/console.test.js index 438d513..d196011 100644 --- a/test/console/reducers/console.test.js +++ b/test/console/reducers/console.test.js @@ -13,6 +13,12 @@ describe("console reducer", () => { expect(state).to.have.property('itemSelection', -1); }); + it('return next state for CONSOLE_HIDE', () => { + let action = { type: actions.CONSOLE_HIDE }; + let state = reducer({ mode: 'error' }, action); + expect(state).to.have.property('mode', ''); + }) + it('return next state for CONSOLE_SHOW_COMMAND', () => { let action = { type: actions.CONSOLE_SHOW_COMMAND, text: 'open ' }; let state = reducer({}, action); -- cgit v1.2.3