diff options
| author | Stephen Blott | 2017-10-07 16:41:59 +0100 |
|---|---|---|
| committer | Stephen Blott | 2017-10-07 16:41:59 +0100 |
| commit | 0e1d0d317e5d5f9fcebebbdf4a0a243f122b7471 (patch) | |
| tree | df3740e1e7646ecfe3e19b3344346509b24eadba | |
| parent | 2c9582c83903cb40cd851dc44d57648bd1d1ac68 (diff) | |
| parent | bc8df497670658fdafa26660ee09987cf9d969ae (diff) | |
| download | vimium-0e1d0d317e5d5f9fcebebbdf4a0a243f122b7471.tar.bz2 | |
Merge branch 'ahstro/feature/upper-case-link-hints'
| -rw-r--r-- | content_scripts/link_hints.coffee | 26 | ||||
| -rw-r--r-- | pages/options.html | 6 |
2 files changed, 18 insertions, 14 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index eeadfc0c..d9ce5d06 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -236,13 +236,8 @@ class LinkHintsMode previousTabCount = @tabCount @tabCount = 0 - # NOTE(smblott) As of 1.54, the Ctrl modifier doesn't work for filtered link hints; therefore we only - # offer the control modifier for alphabet hints. It is not clear whether we should fix this. As of - # 16-03-28, nobody has complained. - modifiers = ["Shift"] - modifiers.push "Control" unless Settings.get "filterLinkHints" - - if event.key in modifiers and + # NOTE(smblott) The modifier behaviour here applies only to alphabet hints. + if event.key in ["Control", "Shift"] and not Settings.get("filterLinkHints") and @mode in [ OPEN_IN_CURRENT_TAB, OPEN_WITH_QUEUE, OPEN_IN_NEW_BG_TAB, OPEN_IN_NEW_FG_TAB ] @tabCount = previousTabCount # Toggle whether to open the link in a new or current tab. @@ -289,7 +284,12 @@ class LinkHintsMode else @tabCount = previousTabCount if event.ctrlKey or event.metaKey or event.altKey unless event.repeat - if keyChar = KeyboardUtils.getKeyChar(event).toLowerCase() + keyChar = + if Settings.get "filterLinkHints" + KeyboardUtils.getKeyChar(event) + else + KeyboardUtils.getKeyChar(event).toLowerCase() + if keyChar keyChar = " " if keyChar == "space" if keyChar.length == 1 @markerMatcher.pushKeyChar keyChar @@ -473,10 +473,10 @@ class AlphabetHints # For alphabet hints, <Space> always rotates the hints, regardless of modifiers. shouldRotateHints: -> true -# Use numbers (usually) for hints, and also filter links by their text. +# Use characters for hints, and also filter links by their text. class FilterHints constructor: -> - @linkHintNumbers = Settings.get "linkHintNumbers" + @linkHintNumbers = Settings.get("linkHintNumbers").toUpperCase() @hintKeystrokeQueue = [] @linkTextKeystrokeQueue = [] @activeHintMarker = null @@ -526,11 +526,15 @@ class FilterHints pushKeyChar: (keyChar) -> if 0 <= @linkHintNumbers.indexOf keyChar @hintKeystrokeQueue.push keyChar + else if keyChar.toLowerCase() != keyChar and @linkHintNumbers.toLowerCase() != @linkHintNumbers.toUpperCase() + # The the keyChar is upper case and the link hint "numbers" contain characters (e.g. [a-zA-Z]). We don't want + # some upper-case letters matching hints (above) and some matching text (below), so we ignore such keys. + return # We only accept <Space> and characters which are not used for splitting (e.g. "a", "b", etc., but not "-"). else if keyChar == " " or not @splitRegexp.test keyChar # Since we might renumber the hints, we should reset the current hintKeyStrokeQueue. @hintKeystrokeQueue = [] - @linkTextKeystrokeQueue.push keyChar + @linkTextKeystrokeQueue.push keyChar.toLowerCase() popKeyChar: -> @hintKeystrokeQueue.pop() or @linkTextKeystrokeQueue.pop() diff --git a/pages/options.html b/pages/options.html index 412e17df..46307b6f 100644 --- a/pages/options.html +++ b/pages/options.html @@ -115,11 +115,11 @@ b: http://b.com/?q=%s description </td> </tr> <tr id="linkHintNumbersContainer"> - <td class="caption">Numbers used<br/> for link hints</td> + <td class="caption">Characters used<br/> for link hints</td> <td verticalAlign="top"> <div class="help"> <div class="example"> - The numbers placed next to each link after typing "f" to enter link-hint mode. + The characters placed next to each link after typing "f" to enter link-hint mode. </div> </div> <input id="linkHintNumbers" type="text" /> @@ -145,7 +145,7 @@ b: http://b.com/?q=%s description </div> <label> <input id="filterLinkHints" type="checkbox"/> - Use the link's name and numbers for link-hint filtering + Use the link's name and characters for link-hint filtering </label> </td> </tr> |
