clean operation definitions

jh-changes
Shin'ya Ueoka 7 years ago
parent c2a5a41cb6
commit 4edb0331a1
  1. 18
      src/actions/operation.js
  2. 28
      src/background/keys.js
  3. 4
      src/content/index.js
  4. 31
      src/operations/index.js

@ -6,15 +6,15 @@ import * as zooms from '../background/zooms';
const exec = (operation, tab) => { const exec = (operation, tab) => {
switch (operation.type) { switch (operation.type) {
case operations.TABS_CLOSE: case operations.TAB_CLOSE:
return tabs.closeTab(tab.id); return tabs.closeTab(tab.id);
case operations.TABS_REOPEN: case operations.TAB_REOPEN:
return tabs.reopenTab(); return tabs.reopenTab();
case operations.TABS_PREV: case operations.TAB_PREV:
return tabs.selectPrevTab(tab.index, operation.count); return tabs.selectPrevTab(tab.index, operation.count);
case operations.TABS_NEXT: case operations.TAB_NEXT:
return tabs.selectNextTab(tab.index, operation.count); return tabs.selectNextTab(tab.index, operation.count);
case operations.TABS_RELOAD: case operations.TAB_RELOAD:
return tabs.reload(tab, operation.cache); return tabs.reload(tab, operation.cache);
case operations.ZOOM_IN: case operations.ZOOM_IN:
return zooms.zoomIn(); return zooms.zoomIn();
@ -22,21 +22,21 @@ const exec = (operation, tab) => {
return zooms.zoomOut(); return zooms.zoomOut();
case operations.ZOOM_NEUTRAL: case operations.ZOOM_NEUTRAL:
return zooms.neutral(); return zooms.neutral();
case operations.COMMAND_OPEN: case operations.COMMAND_SHOW:
return consoleActions.showCommand(''); return consoleActions.showCommand('');
case operations.COMMAND_TABS_OPEN: case operations.COMMAND_SHOW_OPEN:
if (operation.alter) { if (operation.alter) {
// alter url // alter url
return consoleActions.showCommand('open ' + tab.url); return consoleActions.showCommand('open ' + tab.url);
} }
return consoleActions.showCommand('open '); return consoleActions.showCommand('open ');
case operations.COMMAND_TABS_NEW: case operations.COMMAND_SHOW_TABOPEN:
if (operation.alter) { if (operation.alter) {
// alter url // alter url
return consoleActions.showCommand('tabopen ' + tab.url); return consoleActions.showCommand('tabopen ' + tab.url);
} }
return consoleActions.showCommand('tabopen '); return consoleActions.showCommand('tabopen ');
case operations.COMMAND_BUFFER: case operations.COMMAND_SHOW_BUFFER:
return consoleActions.showCommand('buffer '); return consoleActions.showCommand('buffer ');
default: default:
return browser.tabs.sendMessage(tab.id, { return browser.tabs.sendMessage(tab.id, {

@ -1,12 +1,12 @@
import operations from '../operations'; import operations from '../operations';
const defaultKeymap = { const defaultKeymap = {
':': { type: operations.COMMAND_OPEN }, ':': { type: operations.COMMAND_SHOW },
'o': { type: operations.COMMAND_TABS_OPEN, alter: false }, 'o': { type: operations.COMMAND_SHOW_OPEN, alter: false },
'O': { type: operations.COMMAND_TABS_OPEN, alter: true }, 'O': { type: operations.COMMAND_SHOW_OPEN, alter: true },
't': { type: operations.COMMAND_TABS_NEW, alter: false }, 't': { type: operations.COMMAND_SHOW_TABOPEN, alter: false },
'T': { type: operations.COMMAND_TABS_NEW, alter: true }, 'T': { type: operations.COMMAND_SHOW_TABOPEN, alter: true },
'b': { type: operations.COMMAND_BUFFER }, 'b': { type: operations.COMMAND_SHOW_BUFFER },
'k': { type: operations.SCROLL_LINES, count: -1 }, 'k': { type: operations.SCROLL_LINES, count: -1 },
'j': { type: operations.SCROLL_LINES, count: 1 }, 'j': { type: operations.SCROLL_LINES, count: 1 },
'<C-E>': { type: operations.SCROLL_LINES, count: -1 }, '<C-E>': { type: operations.SCROLL_LINES, count: -1 },
@ -17,14 +17,14 @@ const defaultKeymap = {
'<C-F>': { type: operations.SCROLL_PAGES, count: 1 }, '<C-F>': { type: operations.SCROLL_PAGES, count: 1 },
'gg': { type: operations.SCROLL_TOP }, 'gg': { type: operations.SCROLL_TOP },
'G': { type: operations.SCROLL_BOTTOM }, 'G': { type: operations.SCROLL_BOTTOM },
'0': { type: operations.SCROLL_LEFT }, '0': { type: operations.SCROLL_HOME },
'$': { type: operations.SCROLL_RIGHT }, '$': { type: operations.SCROLL_END },
'd': { type: operations.TABS_CLOSE }, 'd': { type: operations.TAB_CLOSE },
'u': { type: operations.TABS_REOPEN }, 'u': { type: operations.TAB_REOPEN },
'h': { type: operations.TABS_PREV, count: 1 }, 'h': { type: operations.TAB_PREV, count: 1 },
'l': { type: operations.TABS_NEXT, count: 1 }, 'l': { type: operations.TAB_NEXT, count: 1 },
'r': { type: operations.TABS_RELOAD, cache: false }, 'r': { type: operations.TAB_RELOAD, cache: false },
'R': { type: operations.TABS_RELOAD, cache: true }, 'R': { type: operations.TAB_RELOAD, cache: true },
'zi': { type: operations.ZOOM_IN }, 'zi': { type: operations.ZOOM_IN },
'zo': { type: operations.ZOOM_OUT }, 'zo': { type: operations.ZOOM_OUT },
'zz': { type: operations.ZOOM_NEUTRAL }, 'zz': { type: operations.ZOOM_NEUTRAL },

@ -85,9 +85,9 @@ const execOperation = (operation) => {
return scrolls.scrollTop(window); return scrolls.scrollTop(window);
case operations.SCROLL_BOTTOM: case operations.SCROLL_BOTTOM:
return scrolls.scrollBottom(window); return scrolls.scrollBottom(window);
case operations.SCROLL_LEFT: case operations.SCROLL_HOME:
return scrolls.scrollLeft(window); return scrolls.scrollLeft(window);
case operations.SCROLL_RIGHT: case operations.SCROLL_END:
return scrolls.scrollRight(window); return scrolls.scrollRight(window);
case operations.FOLLOW_START: case operations.FOLLOW_START:
return startFollows(operation.newTab); return startFollows(operation.newTab);

@ -1,17 +1,22 @@
export default { export default {
// Command // Command
COMMAND_OPEN: 'cmd.open', COMMAND_SHOW: 'command.show',
COMMAND_TABS_OPEN: 'cmd.tabs.open', COMMAND_SHOW_OPEN: 'command.show.open',
COMMAND_TABS_NEW: 'cmd.tabs.new', COMMAND_SHOW_TABOPEN: 'command.show.tabopen',
COMMAND_BUFFER: 'cmd.buffer', COMMAND_SHOW_BUFFER: 'command.show.buffer',
// Scrolls
SCROLL_LINES: 'scroll.lines', SCROLL_LINES: 'scroll.lines',
SCROLL_PAGES: 'scroll.pages', SCROLL_PAGES: 'scroll.pages',
SCROLL_TOP: 'scroll.top', SCROLL_TOP: 'scroll.top',
SCROLL_BOTTOM: 'scroll.bottom', SCROLL_BOTTOM: 'scroll.bottom',
SCROLL_LEFT: 'scroll.left', SCROLL_HOME: 'scroll.home',
SCROLL_RIGHT: 'scroll.right', SCROLL_END: 'scroll.end',
// Follows
FOLLOW_START: 'follow.start', FOLLOW_START: 'follow.start',
// Navigations
NAVIGATE_HISTORY_PREV: 'navigate.history.prev', NAVIGATE_HISTORY_PREV: 'navigate.history.prev',
NAVIGATE_HISTORY_NEXT: 'navigate.history.next', NAVIGATE_HISTORY_NEXT: 'navigate.history.next',
NAVIGATE_LINK_PREV: 'navigate.link.prev', NAVIGATE_LINK_PREV: 'navigate.link.prev',
@ -19,12 +24,14 @@ export default {
NAVIGATE_PARENT: 'navigate.parent', NAVIGATE_PARENT: 'navigate.parent',
NAVIGATE_ROOT: 'navigate.root', NAVIGATE_ROOT: 'navigate.root',
// Background // Tabs
TABS_CLOSE: 'tabs.close', TAB_CLOSE: 'tabs.close',
TABS_REOPEN: 'tabs.reopen', TAB_REOPEN: 'tabs.reopen',
TABS_PREV: 'tabs.prev', TAB_PREV: 'tabs.prev',
TABS_NEXT: 'tabs.next', TAB_NEXT: 'tabs.next',
TABS_RELOAD: 'tabs.reload', TAB_RELOAD: 'tabs.reload',
// Zooms
ZOOM_IN: 'zoom.in', ZOOM_IN: 'zoom.in',
ZOOM_OUT: 'zoom.out', ZOOM_OUT: 'zoom.out',
ZOOM_NEUTRAL: 'zoom.neutral', ZOOM_NEUTRAL: 'zoom.neutral',