aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts
diff options
context:
space:
mode:
Diffstat (limited to 'background_scripts')
-rw-r--r--background_scripts/commands.coffee3
-rw-r--r--background_scripts/main.coffee21
2 files changed, 24 insertions, 0 deletions
diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee
index 585ef572..485195a9 100644
--- a/background_scripts/commands.coffee
+++ b/background_scripts/commands.coffee
@@ -111,6 +111,7 @@ Commands =
"goUp",
"goToRoot",
"enterInsertMode",
+ "enterVisualMode",
"focusInput",
"LinkHints.activateMode",
"LinkHints.activateModeToOpenInNewTab",
@@ -195,6 +196,7 @@ defaultKeyMappings =
"gs": "toggleViewSource"
"i": "enterInsertMode"
+ "v": "enterVisualMode"
"H": "goBack"
"L": "goForward"
@@ -283,6 +285,7 @@ commandDescriptions =
openCopiedUrlInNewTab: ["Open the clipboard's URL in a new tab", { background: true, repeatLimit: 20 }]
enterInsertMode: ["Enter insert mode", { noRepeat: true }]
+ enterVisualMode: ["Enter visual mode (not yet implemented)", { noRepeat: true }]
focusInput: ["Focus the first text box on the page. Cycle between them using tab",
{ passCountToFunction: true }]
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee
index 4c1b9ae7..c1c8dfc8 100644
--- a/background_scripts/main.coffee
+++ b/background_scripts/main.coffee
@@ -339,6 +339,25 @@ updateOpenTabs = (tab) ->
setBrowserActionIcon = (tabId,path) ->
chrome.browserAction.setIcon({ tabId: tabId, path: path })
+chrome.browserAction.setBadgeBackgroundColor
+ # This is Vimium blue (from the icon).
+ # color: [102, 176, 226, 255]
+ # This is a slightly darker blue. It makes the badge more striking in the corner of the eye, and the symbol
+ # easier to read.
+ color: [82, 156, 206, 255]
+
+setBadge = do ->
+ current = null
+ timer = null
+ updateBadge = (badge) -> -> chrome.browserAction.setBadgeText text: badge
+ (request) ->
+ badge = request.badge
+ if badge? and badge != current
+ current = badge
+ clearTimeout timer if timer
+ # We wait a few moments. This avoids badge flicker when there are rapid changes.
+ timer = setTimeout updateBadge(badge), 50
+
# Updates the browserAction icon to indicate whether Vimium is enabled or disabled on the current page.
# Also propagates new enabled/disabled/passkeys state to active window, if necessary.
# This lets you disable Vimium on a page without needing to reload.
@@ -367,6 +386,7 @@ root.updateActiveState = updateActiveState = (tabId) ->
else
# We didn't get a response from the front end, so Vimium isn't running.
setBrowserActionIcon(tabId,disabledIcon)
+ setBadge {badge: ""}
handleUpdateScrollPosition = (request, sender) ->
updateScrollPosition(sender.tab, request.scrollX, request.scrollY)
@@ -633,6 +653,7 @@ sendRequestHandlers =
refreshCompleter: refreshCompleter
createMark: Marks.create.bind(Marks)
gotoMark: Marks.goto.bind(Marks)
+ setBadge: setBadge
# Convenience function for development use.
window.runTests = -> open(chrome.runtime.getURL('tests/dom_tests/dom_tests.html'))