Skip to content

Commit

Permalink
experiments
Browse files Browse the repository at this point in the history
  • Loading branch information
lydell committed Aug 29, 2016
1 parent d8c45fe commit 2f1eaa4
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 31 deletions.
11 changes: 5 additions & 6 deletions documentation/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,11 @@ the shorter the hint. To learn more about hint characters and hint length, read
about the [hint chars] option.

Hints are added on top of the corresponding element. If they obscure the display
too much you can hold shift to make them transparent, letting you peek through
them. (See [Styling] and the [hints\_peek\_through] pref if you’d like to change
that.) The hints can also sometimes cover each other. Press `<space>` and
`<s-space>` to switch which one should be on top.

TODO: Document that it is ctrl+shift in text mode.
too much you can hold down ctrl and shift simultaneously to make them
transparent, letting you peek through them. (See [Styling] and the
[hints\_peek\_through] pref if you’d like to change that.) The hints can also
sometimes cover each other. Press `<c-space>` and `<s-space>` to switch which
one should be on top.

When giving a count to a hint command, all markers will be re-shown after you’ve
typed the hint characters of one of them, _count_ minus one times. All but the
Expand Down
2 changes: 0 additions & 2 deletions documentation/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,6 @@ input.
The number of milliseconds a matched hint marker should stay on screen before
disappearing (or resetting).

TODO: Document additional usage in hints text mode.

### `hints_sleep`

In Hints mode, VimFx continually checks if the element for a hint marker has
Expand Down
12 changes: 3 additions & 9 deletions extension/lib/commands.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,9 @@ helper_follow = ({name, callback}, {vim, count, callbackOverride = null}) ->
vim.markPageInteraction()
help.removeHelp(window)

hintChars = vim.options.hint_chars
hintChars = hintChars.toUpperCase() if vim.options.hints_text_mode

markerContainer = new MarkerContainer({
window
hintChars
hintChars: vim.options.hint_chars
getComplementaryWrappers: (callback) ->
vim._run(name, {pass: 'complementary'}, ({wrappers, viewport}) ->
# `markerContainer.container` is `null`ed out when leaving Hints mode.
Expand All @@ -453,10 +450,6 @@ helper_follow = ({name, callback}, {vim, count, callbackOverride = null}) ->
)
})
MarkerContainer.remove(window) # Better safe than sorry.
markerContainer.container.setAttribute(
'data-mode',
if vim.options.hints_text_mode then 'text' else 'normal'
)
window.gBrowser.selectedBrowser.parentNode.appendChild(
markerContainer.container
)
Expand Down Expand Up @@ -675,9 +668,10 @@ commands.click_browser_element = ({vim}) ->
if wrappers.length > 0
viewport = viewportUtils.getWindowViewport(window)

hintChars = utils.removeDuplicateChars(vim.options.hint_chars.toLowerCase())
markerContainer = new MarkerContainer({
window
hintChars: vim.options.hint_chars
hintChars
adjustZoom: false
getComplementaryWrappers: (callback) ->
newWrappers = markableElements.find(
Expand Down
7 changes: 4 additions & 3 deletions extension/lib/defaults.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ shortcuts =
'hints':
'':
'<escape>': 'exit'
'<space>': 'rotate_markers_forward'
'<c-space>': 'rotate_markers_forward'
'<s-space>': 'rotate_markers_backward'
'<backspace>': 'delete_hint_char'
'<enter>': 'increase_count'
Expand Down Expand Up @@ -170,9 +170,10 @@ advanced_options =
'prevent_autofocus_modes': 'normal'
'config_file_directory': ''
'blur_timeout': 50
'hints_timeout2': 400
'hints_timeout': 200
'hints_sleep': 15
'hints_text_mode': false
'hints_text_mode': true
'smoothScroll.lines.spring-constant': '1000'
'smoothScroll.pages.spring-constant': '2500'
'smoothScroll.other.spring-constant': '2500'
Expand All @@ -184,7 +185,7 @@ advanced_options =
a, button, input[type="button"]
):not([role="menu"]):not([role="tab"])'
'pattern_attrs': 'rel role data-tooltip aria-label'
'hints_peek_through': '<s->'
'hints_peek_through': '<c-s->'
'hints_toggle_in_tab': '<c-'
'hints_toggle_in_background': '<a-'
'activatable_element_keys': '<enter>'
Expand Down
2 changes: 2 additions & 0 deletions extension/lib/marker-container.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class MarkerContainer

@container = @window.document.createElement('box')
@container.id = CONTAINER_ID
if @alphabet not in [@alphabet.toLowerCase(), @alphabet.toUpperCase()]
@container.classList.add('has-mixedcase')

# This static method looks for an element with the container ID and removes
# it. This is more fail-safe than `@container?.remove()`, because we might
Expand Down
4 changes: 4 additions & 0 deletions extension/lib/migrations.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,8 @@ migrations[5] = ->
unless oldValue == ''
prefs.set('blacklist', oldValue.replace(/,(?:\s+|(?=\*))/g, ' '))

# TODO: Write rename `hints_*` prefs to `hints.*`, rename `hints_timeout` to
# `hints.marker_timout`, rename `hints_timeout2` to `hints_timeout` and write a
# migration for it.

module.exports = migrations
2 changes: 1 addition & 1 deletion extension/lib/modes.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ mode('hints', {

if matchedByText
vim._parent.ignoreKeyEventsUntilTime =
Date.now() + vim.options.hints_timeout
Date.now() + vim.options.hints_timeout2
)

if matchText
Expand Down
2 changes: 1 addition & 1 deletion extension/lib/parse-prefs.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ parseSpaceDelimitedString = (value) ->
parseHintChars = (value, defaultValue) ->
[leading..., end] = value.trim().split(/\s+/)
parsed = if leading.length > 0 then "#{leading.join('')} #{end}" else end
parsed = utils.removeDuplicateCharacters(parsed)
parsed = utils.removeDuplicateChars(parsed)

# Make sure that hint chars contain at least the required amount of chars.
diff = MIN_NUM_HINT_CHARS - parsed.length
Expand Down
6 changes: 2 additions & 4 deletions extension/lib/utils.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -546,9 +546,7 @@ regexEscape = (s) -> s.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')

removeDuplicates = (array) -> Array.from(new Set(array))

# Remove duplicate characters from string (case insensitive).
removeDuplicateCharacters = (str) ->
return removeDuplicates( str.toLowerCase().split('') ).join('')
removeDuplicateChars = (string) -> removeDuplicates(string.split('')).join('')

# Calls `fn` repeatedly, with at least `interval` ms between each call.
interval = (window, interval, fn) ->
Expand Down Expand Up @@ -683,7 +681,7 @@ module.exports = {
nextTick
regexEscape
removeDuplicates
removeDuplicateCharacters
removeDuplicateChars
interval

expandPath
Expand Down
11 changes: 6 additions & 5 deletions extension/skin/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,16 @@ toolbarpaletteitem[place="palette"] > #VimFxButton {
font-size: 0.8em;
line-height: 1;
font-weight: bold;
text-transform: uppercase;
white-space: nowrap;
/* Some light-weight themes set a `text-shadow` that the hint markers inherit,
* making them almost unreadable. */
text-shadow: none;
}

#VimFxMarkersContainer:not(.has-mixedcase) .marker {
text-transform: uppercase;
}

#VimFxMarkersContainer .marker-char {} /* Keep as documentation. */

#VimFxMarkersContainer .marker--matched,
Expand All @@ -123,11 +126,9 @@ toolbarpaletteitem[place="palette"] > #VimFxButton {
display: none;
}

/* alt, ctrl and meta can also be targeted. */
#main-window[vimfx-held-modifiers~="shift"]
#VimFxMarkersContainer[data-mode="normal"],
/* alt, ctrl, meta and shift can be targeted. */
#main-window[vimfx-held-modifiers~="ctrl"][vimfx-held-modifiers~="shift"]
#VimFxMarkersContainer[data-mode="text"] {
#VimFxMarkersContainer {
opacity: 0.2;
}

Expand Down

0 comments on commit 2f1eaa4

Please sign in to comment.