commit
b580ef8170
5 changed files with 30 additions and 17 deletions
|
@ -43,7 +43,7 @@ export default class BackgroundComponent {
|
||||||
type: messages.CONSOLE_HIDE_COMMAND,
|
type: messages.CONSOLE_HIDE_COMMAND,
|
||||||
});
|
});
|
||||||
case messages.CONSOLE_ENTERED:
|
case messages.CONSOLE_ENTERED:
|
||||||
return commands.exec(message.text, this.settings).catch((e) => {
|
return commands.exec(message.text, this.settings.value).catch((e) => {
|
||||||
return browser.tabs.sendMessage(sender.tab.id, {
|
return browser.tabs.sendMessage(sender.tab.id, {
|
||||||
type: messages.CONSOLE_SHOW_ERROR,
|
type: messages.CONSOLE_SHOW_ERROR,
|
||||||
text: e.message,
|
text: e.message,
|
||||||
|
@ -52,7 +52,7 @@ export default class BackgroundComponent {
|
||||||
case messages.SETTINGS_QUERY:
|
case messages.SETTINGS_QUERY:
|
||||||
return Promise.resolve(this.store.getState().value);
|
return Promise.resolve(this.store.getState().value);
|
||||||
case messages.CONSOLE_QUERY_COMPLETIONS:
|
case messages.CONSOLE_QUERY_COMPLETIONS:
|
||||||
return commands.complete(message.text, this.settings);
|
return commands.complete(message.text, this.settings.value);
|
||||||
case messages.SETTINGS_RELOAD:
|
case messages.SETTINGS_RELOAD:
|
||||||
this.store.dispatch(settingsActions.load());
|
this.store.dispatch(settingsActions.load());
|
||||||
return this.broadcastSettingsChanged();
|
return this.broadcastSettingsChanged();
|
||||||
|
|
|
@ -8,8 +8,10 @@ import * as consoleFrames from 'content/console-frames';
|
||||||
|
|
||||||
const exec = (operation) => {
|
const exec = (operation) => {
|
||||||
switch (operation.type) {
|
switch (operation.type) {
|
||||||
case operations.SCROLL_LINES:
|
case operations.SCROLL_VERTICALLY:
|
||||||
return scrolls.scrollLines(window, operation.count);
|
return scrolls.scrollVertically(window, operation.count);
|
||||||
|
case operations.SCROLL_HORIZONALLY:
|
||||||
|
return scrolls.scrollHorizonally(window, operation.count);
|
||||||
case operations.SCROLL_PAGES:
|
case operations.SCROLL_PAGES:
|
||||||
return scrolls.scrollPages(window, operation.count);
|
return scrolls.scrollPages(window, operation.count);
|
||||||
case operations.SCROLL_TOP:
|
case operations.SCROLL_TOP:
|
||||||
|
@ -17,9 +19,9 @@ const exec = (operation) => {
|
||||||
case operations.SCROLL_BOTTOM:
|
case operations.SCROLL_BOTTOM:
|
||||||
return scrolls.scrollBottom(window);
|
return scrolls.scrollBottom(window);
|
||||||
case operations.SCROLL_HOME:
|
case operations.SCROLL_HOME:
|
||||||
return scrolls.scrollLeft(window);
|
return scrolls.scrollHome(window);
|
||||||
case operations.SCROLL_END:
|
case operations.SCROLL_END:
|
||||||
return scrolls.scrollRight(window);
|
return scrolls.scrollEnd(window);
|
||||||
case operations.FOLLOW_START:
|
case operations.FOLLOW_START:
|
||||||
return followActions.enable(false);
|
return followActions.enable(false);
|
||||||
case operations.NAVIGATE_HISTORY_PREV:
|
case operations.NAVIGATE_HISTORY_PREV:
|
||||||
|
|
|
@ -1,8 +1,15 @@
|
||||||
const SCROLL_DELTA = 48;
|
const SCROLL_DELTA_X = 48;
|
||||||
|
const SCROLL_DELTA_Y = 48;
|
||||||
|
|
||||||
const scrollLines = (page, count) => {
|
const scrollVertically = (page, count) => {
|
||||||
let x = page.scrollX;
|
let x = page.scrollX;
|
||||||
let y = page.scrollY + SCROLL_DELTA * count;
|
let y = page.scrollY + SCROLL_DELTA_X * count;
|
||||||
|
page.scrollTo(x, y);
|
||||||
|
};
|
||||||
|
|
||||||
|
const scrollHorizonally = (page, count) => {
|
||||||
|
let x = page.scrollX + SCROLL_DELTA_Y * count;
|
||||||
|
let y = page.scrollY;
|
||||||
page.scrollTo(x, y);
|
page.scrollTo(x, y);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,18 +32,19 @@ const scrollBottom = (page) => {
|
||||||
page.scrollTo(x, y);
|
page.scrollTo(x, y);
|
||||||
};
|
};
|
||||||
|
|
||||||
const scrollLeft = (page) => {
|
const scrollHome = (page) => {
|
||||||
let x = 0;
|
let x = 0;
|
||||||
let y = page.scrollY;
|
let y = page.scrollY;
|
||||||
page.scrollTo(x, y);
|
page.scrollTo(x, y);
|
||||||
};
|
};
|
||||||
|
|
||||||
const scrollRight = (page) => {
|
const scrollEnd = (page) => {
|
||||||
let x = page.scrollMaxX;
|
let x = page.scrollMaxX;
|
||||||
let y = page.scrollY;
|
let y = page.scrollY;
|
||||||
page.scrollTo(x, y);
|
page.scrollTo(x, y);
|
||||||
};
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
scrollLines, scrollPages, scrollTop, scrollBottom, scrollLeft, scrollRight
|
scrollVertically, scrollHorizonally, scrollPages,
|
||||||
|
scrollTop, scrollBottom, scrollHome, scrollEnd
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,8 +11,10 @@ export default {
|
||||||
"w": { "type": "command.show.winopen", "alter": false },
|
"w": { "type": "command.show.winopen", "alter": false },
|
||||||
"W": { "type": "command.show.winopen", "alter": true },
|
"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.vertically", "count": -1 },
|
||||||
"j": { "type": "scroll.lines", "count": 1 },
|
"j": { "type": "scroll.vertically", "count": 1 },
|
||||||
|
"h": { "type": "scroll.horizonally", "count": -1 },
|
||||||
|
"l": { "type": "scroll.horizonally", "count": 1 },
|
||||||
"<C-E>": { "type": "scroll.lines", "count": -1 },
|
"<C-E>": { "type": "scroll.lines", "count": -1 },
|
||||||
"<C-Y>": { "type": "scroll.lines", "count": 1 },
|
"<C-Y>": { "type": "scroll.lines", "count": 1 },
|
||||||
"<C-U>": { "type": "scroll.pages", "count": -0.5 },
|
"<C-U>": { "type": "scroll.pages", "count": -0.5 },
|
||||||
|
@ -24,8 +26,8 @@ export default {
|
||||||
"$": { "type": "scroll.end" },
|
"$": { "type": "scroll.end" },
|
||||||
"d": { "type": "tabs.close" },
|
"d": { "type": "tabs.close" },
|
||||||
"u": { "type": "tabs.reopen" },
|
"u": { "type": "tabs.reopen" },
|
||||||
"h": { "type": "tabs.prev", "count": 1 },
|
"K": { "type": "tabs.prev", "count": 1 },
|
||||||
"l": { "type": "tabs.next", "count": 1 },
|
"J": { "type": "tabs.next", "count": 1 },
|
||||||
"r": { "type": "tabs.reload", "cache": false },
|
"r": { "type": "tabs.reload", "cache": false },
|
||||||
"R": { "type": "tabs.reload", "cache": true },
|
"R": { "type": "tabs.reload", "cache": true },
|
||||||
"zi": { "type": "zoom.in" },
|
"zi": { "type": "zoom.in" },
|
||||||
|
|
|
@ -7,7 +7,8 @@ export default {
|
||||||
COMMAND_SHOW_BUFFER: 'command.show.buffer',
|
COMMAND_SHOW_BUFFER: 'command.show.buffer',
|
||||||
|
|
||||||
// Scrolls
|
// Scrolls
|
||||||
SCROLL_LINES: 'scroll.lines',
|
SCROLL_VERTICALLY: 'scroll.vertically',
|
||||||
|
SCROLL_HORIZONALLY: 'scroll.horizonally',
|
||||||
SCROLL_PAGES: 'scroll.pages',
|
SCROLL_PAGES: 'scroll.pages',
|
||||||
SCROLL_TOP: 'scroll.top',
|
SCROLL_TOP: 'scroll.top',
|
||||||
SCROLL_BOTTOM: 'scroll.bottom',
|
SCROLL_BOTTOM: 'scroll.bottom',
|
||||||
|
|
Reference in a new issue