Merge pull request #23 from ueokande/winopen-command

winopen command
jh-changes
Shin'ya Ueoka 7 years ago committed by GitHub
commit bbf90e77e9
  1. 6
      src/background/actions/operation.js
  2. 10
      src/shared/commands.js
  3. 2
      src/shared/default-settings.js
  4. 1
      src/shared/operations.js

@ -42,6 +42,12 @@ const exec = (operation, tab) => {
return sendConsoleShowCommand(tab, 'tabopen ' + tab.url); return sendConsoleShowCommand(tab, 'tabopen ' + tab.url);
} }
return sendConsoleShowCommand(tab, 'tabopen '); return sendConsoleShowCommand(tab, 'tabopen ');
case operations.COMMAND_SHOW_WINOPEN:
if (operation.alter) {
// alter url
return sendConsoleShowCommand(tab, 'winopen ' + tab.url);
}
return sendConsoleShowCommand(tab, 'winopen ');
case operations.COMMAND_SHOW_BUFFER: case operations.COMMAND_SHOW_BUFFER:
return sendConsoleShowCommand(tab, 'buffer '); return sendConsoleShowCommand(tab, 'buffer ');
default: default:

@ -36,6 +36,10 @@ const tabopenCommand = (url) => {
return browser.tabs.create({ url: url }); return browser.tabs.create({ url: url });
}; };
const winopenCommand = (url) => {
return browser.windows.create({ url });
};
const bufferCommand = (keywords) => { const bufferCommand = (keywords) => {
return browser.tabs.query({ return browser.tabs.query({
active: true, currentWindow: true active: true, currentWindow: true
@ -87,11 +91,13 @@ const doCommand = (name, remaining, settings) => {
switch (name) { switch (name) {
case 'o': case 'o':
case 'open': case 'open':
// TODO use search engined and pass keywords to them
return openCommand(normalizeUrl(remaining, settings.search)); return openCommand(normalizeUrl(remaining, settings.search));
case 't': case 't':
case 'tabopen': case 'tabopen':
return tabopenCommand(normalizeUrl(remaining, settings.search)); return tabopenCommand(normalizeUrl(remaining, settings.search));
case 'w':
case 'winopen':
return winopenCommand(normalizeUrl(remaining, settings.search));
case 'b': case 'b':
case 'buffer': case 'buffer':
return bufferCommand(remaining); return bufferCommand(remaining);
@ -105,6 +111,8 @@ const getCompletions = (command, keywords, settings) => {
case 'open': case 'open':
case 't': case 't':
case 'tabopen': case 'tabopen':
case 'w':
case 'winopen':
return getOpenCompletions(command, keywords, settings.search); return getOpenCompletions(command, keywords, settings.search);
case 'b': case 'b':
case 'buffer': case 'buffer':

@ -7,6 +7,8 @@ export default {
"O": { "type": "command.show.open", "alter": true }, "O": { "type": "command.show.open", "alter": true },
"t": { "type": "command.show.tabopen", "alter": false }, "t": { "type": "command.show.tabopen", "alter": false },
"T": { "type": "command.show.tabopen", "alter": true }, "T": { "type": "command.show.tabopen", "alter": true },
"w": { "type": "command.show.winopen", "alter": false },
"W": { "type": "command.show.winopen", "alter": true },
"b": { "type": "command.show.buffer" }, "b": { "type": "command.show.buffer" },
"k": { "type": "scroll.lines", "count": -1 }, "k": { "type": "scroll.lines", "count": -1 },
"j": { "type": "scroll.lines", "count": 1 }, "j": { "type": "scroll.lines", "count": 1 },

@ -3,6 +3,7 @@ export default {
COMMAND_SHOW: 'command.show', COMMAND_SHOW: 'command.show',
COMMAND_SHOW_OPEN: 'command.show.open', COMMAND_SHOW_OPEN: 'command.show.open',
COMMAND_SHOW_TABOPEN: 'command.show.tabopen', COMMAND_SHOW_TABOPEN: 'command.show.tabopen',
COMMAND_SHOW_WINOPEN: 'command.show.winopen',
COMMAND_SHOW_BUFFER: 'command.show.buffer', COMMAND_SHOW_BUFFER: 'command.show.buffer',
// Scrolls // Scrolls