From aa8f568c6c3be795c17c3b5107a8a8c70fc6e930 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 26 Mar 2016 11:23:51 +0000 Subject: Fix inappropriate variable name. "description" is the first element here, not all elements. So "descriptor" is a better name. --- background_scripts/commands.coffee | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index 6c452242..b58a3b0c 100644 --- a/background_scripts/commands.coffee +++ b/background_scripts/commands.coffee @@ -1,7 +1,7 @@ Commands = init: -> - for own command, description of commandDescriptions - @addCommand(command, description[0], description[1]) + for own command, descriptor of commandDescriptions + @addCommand(command, descriptor[0], descriptor[1]) @loadKeyMappings Settings.get "keyMappings" Settings.postUpdateHooks["keyMappings"] = @loadKeyMappings.bind this @@ -18,12 +18,11 @@ Commands = # - background: whether this command needs to be run against the background page. # - passCountToFunction: true if this command should have any digits which were typed prior to the # command passed to it. This is used to implement e.g. "closing of 3 tabs". - addCommand: (command, description, options) -> + addCommand: (command, description, options = {}) -> if command of @availableCommands BgUtils.log "#{command} is already defined! Check commands.coffee for duplicates." return - options ||= {} @availableCommands[command] = extend options, description: description mapKeyToCommand: ({ key, command, options }) -> -- cgit v1.2.3 From 18b323f96796a02b4ef36b7041a8cac18b0c1fbd Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 26 Mar 2016 11:27:55 +0000 Subject: Pass count to find commands. With this change, now *every* front-end command either accepts a count argument, or or it doesn't accept a count at all. --- background_scripts/commands.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index b58a3b0c..4785ea47 100644 --- a/background_scripts/commands.coffee +++ b/background_scripts/commands.coffee @@ -337,8 +337,8 @@ commandDescriptions = "LinkHints.activateModeToDownloadLink": ["Download link url", { passCountToFunction: true }] enterFindMode: ["Enter find mode", { noRepeat: true }] - performFind: ["Cycle forward to the next find match"] - performBackwardsFind: ["Cycle backward to the previous find match"] + performFind: ["Cycle forward to the next find match", { passCountToFunction: true }] + performBackwardsFind: ["Cycle backward to the previous find match", { passCountToFunction: true }] goPrevious: ["Follow the link labeled previous or <", { noRepeat: true }] goNext: ["Follow the link labeled next or >", { noRepeat: true }] -- cgit v1.2.3 From 5ab004ba38019aea32408af2bff422e6f01a7430 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 26 Mar 2016 11:45:56 +0000 Subject: passCountToCommand isn't needed. We pass the count to *all* front-end commands. All of the commands which don't use a count, just ignore it. --- background_scripts/commands.coffee | 49 ++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 26 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index 4785ea47..4ec8e6d9 100644 --- a/background_scripts/commands.coffee +++ b/background_scripts/commands.coffee @@ -16,8 +16,6 @@ Commands = # Registers a command, making it available to be optionally bound to a key. # options: # - background: whether this command needs to be run against the background page. - # - passCountToFunction: true if this command should have any digits which were typed prior to the - # command passed to it. This is used to implement e.g. "closing of 3 tabs". addCommand: (command, description, options = {}) -> if command of @availableCommands BgUtils.log "#{command} is already defined! Check commands.coffee for duplicates." @@ -298,58 +296,57 @@ defaultKeyMappings = commandDescriptions = # Navigating the current page showHelp: ["Show help", { background: true, noRepeat: true }] - scrollDown: ["Scroll down", { passCountToFunction: true }] - scrollUp: ["Scroll up", { passCountToFunction: true }] - scrollLeft: ["Scroll left", { passCountToFunction: true }] - scrollRight: ["Scroll right", { passCountToFunction: true }] + scrollDown: ["Scroll down"] + scrollUp: ["Scroll up"] + scrollLeft: ["Scroll left"] + scrollRight: ["Scroll right"] - scrollToTop: ["Scroll to the top of the page", { passCountToFunction: true }] + scrollToTop: ["Scroll to the top of the page"] scrollToBottom: ["Scroll to the bottom of the page", { noRepeat: true }] scrollToLeft: ["Scroll all the way to the left", { noRepeat: true }] scrollToRight: ["Scroll all the way to the right", { noRepeat: true }] - scrollPageDown: ["Scroll a page down", { passCountToFunction: true }] - scrollPageUp: ["Scroll a page up", { passCountToFunction: true }] - scrollFullPageDown: ["Scroll a full page down", { passCountToFunction: true }] - scrollFullPageUp: ["Scroll a full page up", { passCountToFunction: true }] + scrollPageDown: ["Scroll a page down"] + scrollPageUp: ["Scroll a page up"] + scrollFullPageDown: ["Scroll a full page down"] + scrollFullPageUp: ["Scroll a full page up"] reload: ["Reload the page", { noRepeat: true }] toggleViewSource: ["View page source", { noRepeat: true }] copyCurrentUrl: ["Copy the current URL to the clipboard", { noRepeat: true }] - "LinkHints.activateModeToCopyLinkUrl": ["Copy a link URL to the clipboard", { passCountToFunction: true }] + "LinkHints.activateModeToCopyLinkUrl": ["Copy a link URL to the clipboard"] openCopiedUrlInCurrentTab: ["Open the clipboard's URL in the current tab", { background: true, noRepeat: true }] openCopiedUrlInNewTab: ["Open the clipboard's URL in a new tab", { background: true, repeatLimit: 20 }] enterInsertMode: ["Enter insert mode", { noRepeat: true }] - passNextKey: ["Pass the next key to Chrome", { passCountToFunction: true }] + passNextKey: ["Pass the next key to Chrome"] enterVisualMode: ["Enter visual mode", { noRepeat: true }] enterVisualLineMode: ["Enter visual line mode", { noRepeat: true }] - focusInput: ["Focus the first text box on the page. Cycle between them using tab", - { passCountToFunction: true }] + focusInput: ["Focus the first text box on the page. Cycle between them using tab"] - "LinkHints.activateMode": ["Open a link in the current tab", { passCountToFunction: true }] - "LinkHints.activateModeToOpenInNewTab": ["Open a link in a new tab", { passCountToFunction: true }] - "LinkHints.activateModeToOpenInNewForegroundTab": ["Open a link in a new tab & switch to it", { passCountToFunction: true }] + "LinkHints.activateMode": ["Open a link in the current tab"] + "LinkHints.activateModeToOpenInNewTab": ["Open a link in a new tab"] + "LinkHints.activateModeToOpenInNewForegroundTab": ["Open a link in a new tab & switch to it"] "LinkHints.activateModeWithQueue": ["Open multiple links in a new tab", { noRepeat: true }] - "LinkHints.activateModeToOpenIncognito": ["Open a link in incognito window", { passCountToFunction: true }] - "LinkHints.activateModeToDownloadLink": ["Download link url", { passCountToFunction: true }] + "LinkHints.activateModeToOpenIncognito": ["Open a link in incognito window"] + "LinkHints.activateModeToDownloadLink": ["Download link url"] enterFindMode: ["Enter find mode", { noRepeat: true }] - performFind: ["Cycle forward to the next find match", { passCountToFunction: true }] - performBackwardsFind: ["Cycle backward to the previous find match", { passCountToFunction: true }] + performFind: ["Cycle forward to the next find match"] + performBackwardsFind: ["Cycle backward to the previous find match"] goPrevious: ["Follow the link labeled previous or <", { noRepeat: true }] goNext: ["Follow the link labeled next or >", { noRepeat: true }] # Navigating your history - goBack: ["Go back in history", { passCountToFunction: true }] - goForward: ["Go forward in history", { passCountToFunction: true }] + goBack: ["Go back in history"] + goForward: ["Go forward in history"] # Navigating the URL hierarchy - goUp: ["Go up the URL hierarchy", { passCountToFunction: true }] - goToRoot: ["Go to root of current URL hierarchy", { passCountToFunction: true }] + goUp: ["Go up the URL hierarchy"] + goToRoot: ["Go to root of current URL hierarchy"] # Manipulating tabs nextTab: ["Go one tab right", { background: true }] -- cgit v1.2.3 From c40f6fa3da204144b6a1a0fca5f7849a9ce5fe3e Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 26 Mar 2016 11:49:22 +0000 Subject: Move command to correct spot. This command (LinkHints.activateModeToCopyLinkUrl) has been in the wrong spot for quite some time. This just moves it to be with the other link-hints commands. --- background_scripts/commands.coffee | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index 4ec8e6d9..209b5ea3 100644 --- a/background_scripts/commands.coffee +++ b/background_scripts/commands.coffee @@ -131,7 +131,6 @@ Commands = "reload", "toggleViewSource", "copyCurrentUrl", - "LinkHints.activateModeToCopyLinkUrl", "openCopiedUrlInCurrentTab", "openCopiedUrlInNewTab", "goUp", @@ -147,6 +146,7 @@ Commands = "LinkHints.activateModeWithQueue", "LinkHints.activateModeToDownloadLink", "LinkHints.activateModeToOpenIncognito", + "LinkHints.activateModeToCopyLinkUrl", "goPrevious", "goNext", "nextFrame", @@ -238,9 +238,10 @@ defaultKeyMappings = "gi": "focusInput" - "f": "LinkHints.activateMode" - "F": "LinkHints.activateModeToOpenInNewTab" + "f": "LinkHints.activateMode" + "F": "LinkHints.activateModeToOpenInNewTab" "": "LinkHints.activateModeWithQueue" + "yf": "LinkHints.activateModeToCopyLinkUrl" "/": "enterFindMode" "n": "performFind" @@ -250,7 +251,6 @@ defaultKeyMappings = "]]": "goNext" "yy": "copyCurrentUrl" - "yf": "LinkHints.activateModeToCopyLinkUrl" "p": "openCopiedUrlInCurrentTab" "P": "openCopiedUrlInNewTab" @@ -315,7 +315,6 @@ commandDescriptions = toggleViewSource: ["View page source", { noRepeat: true }] copyCurrentUrl: ["Copy the current URL to the clipboard", { noRepeat: true }] - "LinkHints.activateModeToCopyLinkUrl": ["Copy a link URL to the clipboard"] openCopiedUrlInCurrentTab: ["Open the clipboard's URL in the current tab", { background: true, noRepeat: true }] openCopiedUrlInNewTab: ["Open the clipboard's URL in a new tab", { background: true, repeatLimit: 20 }] @@ -332,6 +331,7 @@ commandDescriptions = "LinkHints.activateModeWithQueue": ["Open multiple links in a new tab", { noRepeat: true }] "LinkHints.activateModeToOpenIncognito": ["Open a link in incognito window"] "LinkHints.activateModeToDownloadLink": ["Download link url"] + "LinkHints.activateModeToCopyLinkUrl": ["Copy a link URL to the clipboard"] enterFindMode: ["Enter find mode", { noRepeat: true }] performFind: ["Cycle forward to the next find match"] -- cgit v1.2.3 From e133f8d2b3d104568959759e8ec7cf907257eb1b Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 26 Mar 2016 12:02:55 +0000 Subject: Simplify expression. --- background_scripts/commands.coffee | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index 209b5ea3..2d901b15 100644 --- a/background_scripts/commands.coffee +++ b/background_scripts/commands.coffee @@ -357,9 +357,7 @@ commandDescriptions = createTab: ["Create new tab", { background: true, repeatLimit: 20 }] duplicateTab: ["Duplicate current tab", { background: true, repeatLimit: 20 }] - removeTab: ["Close current tab", { background: true, repeatLimit: - # Require confirmation to remove more tabs than we can restore. - (if chrome.session then chrome.session.MAX_SESSION_RESULTS else 25) }] + removeTab: ["Close current tab", { background: true, repeatLimit: chrome.session?.MAX_SESSION_RESULTS ? 25 }] restoreTab: ["Restore closed tab", { background: true, repeatLimit: 20 }] moveTabToNewWindow: ["Move tab to new window", { background: true }] -- cgit v1.2.3