Merge branch 'haasn-hintmodes'
This commit is contained in:
commit
513a02b545
@ -51,6 +51,8 @@ Changed
|
|||||||
`:bind`) now don't immediately evaluate variables.
|
`:bind`) now don't immediately evaluate variables.
|
||||||
- Tab titles in the `:buffer` completion now update correctly when a page's
|
- Tab titles in the `:buffer` completion now update correctly when a page's
|
||||||
title is changed via javascript.
|
title is changed via javascript.
|
||||||
|
- `:hint` now has a `--mode <mode>` flag to override the hint mode configured
|
||||||
|
using the `hints -> mode` setting.
|
||||||
|
|
||||||
Removed
|
Removed
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
|
@ -202,6 +202,7 @@ Contributors, sorted by the number of commits in descending order:
|
|||||||
* Samuel Loury
|
* Samuel Loury
|
||||||
* Peter Michely
|
* Peter Michely
|
||||||
* Panashe M. Fundira
|
* Panashe M. Fundira
|
||||||
|
* Niklas Haas
|
||||||
* Link
|
* Link
|
||||||
* Larry Hynes
|
* Larry Hynes
|
||||||
* Johannes Altmanninger
|
* Johannes Altmanninger
|
||||||
@ -212,7 +213,6 @@ Contributors, sorted by the number of commits in descending order:
|
|||||||
* adam
|
* adam
|
||||||
* Samir Benmendil
|
* Samir Benmendil
|
||||||
* Regina Hug
|
* Regina Hug
|
||||||
* Niklas Haas
|
|
||||||
* Mathias Fussenegger
|
* Mathias Fussenegger
|
||||||
* Marcelo Santos
|
* Marcelo Santos
|
||||||
* Jean-Louis Fuchs
|
* Jean-Louis Fuchs
|
||||||
|
@ -324,12 +324,12 @@ Show help about a command or setting.
|
|||||||
|
|
||||||
[[hint]]
|
[[hint]]
|
||||||
=== hint
|
=== hint
|
||||||
Syntax: +:hint [*--rapid*] ['group'] ['target'] ['args' ['args' ...]]+
|
Syntax: +:hint [*--rapid*] [*--mode* 'mode'] ['group'] ['target'] ['args' ['args' ...]]+
|
||||||
|
|
||||||
Start hinting.
|
Start hinting.
|
||||||
|
|
||||||
==== positional arguments
|
==== positional arguments
|
||||||
* +'group'+: The hinting mode to use.
|
* +'group'+: The element types to hint.
|
||||||
|
|
||||||
- `all`: All clickable elements.
|
- `all`: All clickable elements.
|
||||||
- `links`: Only links.
|
- `links`: Only links.
|
||||||
@ -380,6 +380,15 @@ Start hinting.
|
|||||||
* +*-r*+, +*--rapid*+: Whether to do rapid hinting. This is only possible with targets `tab` (with background-tabs=true), `tab-bg`,
|
* +*-r*+, +*--rapid*+: Whether to do rapid hinting. This is only possible with targets `tab` (with background-tabs=true), `tab-bg`,
|
||||||
`window`, `run`, `hover`, `userscript` and `spawn`.
|
`window`, `run`, `hover`, `userscript` and `spawn`.
|
||||||
|
|
||||||
|
* +*-m*+, +*--mode*+: The hinting mode to use.
|
||||||
|
|
||||||
|
- `number`: Use numeric hints.
|
||||||
|
- `letter`: Use the chars in the hints->chars settings.
|
||||||
|
- `word`: Use hint words based on the html elements and the
|
||||||
|
extra words.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
==== note
|
==== note
|
||||||
* This command does not split arguments after the last argument and handles quotes literally.
|
* This command does not split arguments after the last argument and handles quotes literally.
|
||||||
|
@ -94,6 +94,7 @@ class HintContext:
|
|||||||
self.args = []
|
self.args = []
|
||||||
self.tab = None
|
self.tab = None
|
||||||
self.group = None
|
self.group = None
|
||||||
|
self.hint_mode = None
|
||||||
|
|
||||||
def get_args(self, urlstr):
|
def get_args(self, urlstr):
|
||||||
"""Get the arguments, with {hint-url} replaced by the given URL."""
|
"""Get the arguments, with {hint-url} replaced by the given URL."""
|
||||||
@ -393,7 +394,7 @@ class HintManager(QObject):
|
|||||||
Return:
|
Return:
|
||||||
A list of hint strings, in the same order as the elements.
|
A list of hint strings, in the same order as the elements.
|
||||||
"""
|
"""
|
||||||
hint_mode = config.get('hints', 'mode')
|
hint_mode = self._context.hint_mode
|
||||||
if hint_mode == 'word':
|
if hint_mode == 'word':
|
||||||
try:
|
try:
|
||||||
return self._word_hinter.hint(elems)
|
return self._word_hinter.hint(elems)
|
||||||
@ -547,7 +548,7 @@ class HintManager(QObject):
|
|||||||
|
|
||||||
# Make text uppercase if set in config
|
# Make text uppercase if set in config
|
||||||
if (config.get('hints', 'uppercase') and
|
if (config.get('hints', 'uppercase') and
|
||||||
config.get('hints', 'mode') == 'letter'):
|
self._context.hint_mode == 'letter'):
|
||||||
attrs.append(('text-transform', 'uppercase !important'))
|
attrs.append(('text-transform', 'uppercase !important'))
|
||||||
else:
|
else:
|
||||||
attrs.append(('text-transform', 'none !important'))
|
attrs.append(('text-transform', 'none !important'))
|
||||||
@ -660,14 +661,14 @@ class HintManager(QObject):
|
|||||||
backend=usertypes.Backend.QtWebKit)
|
backend=usertypes.Backend.QtWebKit)
|
||||||
@cmdutils.argument('win_id', win_id=True)
|
@cmdutils.argument('win_id', win_id=True)
|
||||||
def start(self, rapid=False, group=webelem.Group.all, target=Target.normal,
|
def start(self, rapid=False, group=webelem.Group.all, target=Target.normal,
|
||||||
*args, win_id):
|
*args, win_id, mode=None):
|
||||||
"""Start hinting.
|
"""Start hinting.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
rapid: Whether to do rapid hinting. This is only possible with
|
rapid: Whether to do rapid hinting. This is only possible with
|
||||||
targets `tab` (with background-tabs=true), `tab-bg`,
|
targets `tab` (with background-tabs=true), `tab-bg`,
|
||||||
`window`, `run`, `hover`, `userscript` and `spawn`.
|
`window`, `run`, `hover`, `userscript` and `spawn`.
|
||||||
group: The hinting mode to use.
|
group: The element types to hint.
|
||||||
|
|
||||||
- `all`: All clickable elements.
|
- `all`: All clickable elements.
|
||||||
- `links`: Only links.
|
- `links`: Only links.
|
||||||
@ -694,6 +695,13 @@ class HintManager(QObject):
|
|||||||
link.
|
link.
|
||||||
- `spawn`: Spawn a command.
|
- `spawn`: Spawn a command.
|
||||||
|
|
||||||
|
mode: The hinting mode to use.
|
||||||
|
|
||||||
|
- `number`: Use numeric hints.
|
||||||
|
- `letter`: Use the chars in the hints->chars settings.
|
||||||
|
- `word`: Use hint words based on the html elements and the
|
||||||
|
extra words.
|
||||||
|
|
||||||
*args: Arguments for spawn/userscript/run/fill.
|
*args: Arguments for spawn/userscript/run/fill.
|
||||||
|
|
||||||
- With `spawn`: The executable and arguments to spawn.
|
- With `spawn`: The executable and arguments to spawn.
|
||||||
@ -732,11 +740,15 @@ class HintManager(QObject):
|
|||||||
raise cmdexc.CommandError("Rapid hinting makes no sense with "
|
raise cmdexc.CommandError("Rapid hinting makes no sense with "
|
||||||
"target {}!".format(name))
|
"target {}!".format(name))
|
||||||
|
|
||||||
|
if mode is None:
|
||||||
|
mode = config.get('hints', 'mode')
|
||||||
|
|
||||||
self._check_args(target, *args)
|
self._check_args(target, *args)
|
||||||
self._context = HintContext()
|
self._context = HintContext()
|
||||||
self._context.tab = tab
|
self._context.tab = tab
|
||||||
self._context.target = target
|
self._context.target = target
|
||||||
self._context.rapid = rapid
|
self._context.rapid = rapid
|
||||||
|
self._context.hint_mode = mode
|
||||||
try:
|
try:
|
||||||
self._context.baseurl = tabbed_browser.current_url()
|
self._context.baseurl = tabbed_browser.current_url()
|
||||||
except qtutils.QtValueError:
|
except qtutils.QtValueError:
|
||||||
@ -748,6 +760,13 @@ class HintManager(QObject):
|
|||||||
self._context.tab.find_all_elements(selector, self._start_cb,
|
self._context.tab.find_all_elements(selector, self._start_cb,
|
||||||
only_visible=True)
|
only_visible=True)
|
||||||
|
|
||||||
|
def current_mode(self):
|
||||||
|
"""Returns the currently active hinting mode (or None otherwise)."""
|
||||||
|
if self._context is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return self._context.hint_mode
|
||||||
|
|
||||||
def handle_partial_key(self, keystr):
|
def handle_partial_key(self, keystr):
|
||||||
"""Handle a new partial keypress."""
|
"""Handle a new partial keypress."""
|
||||||
log.hints.debug("Handling new keystring: '{}'".format(keystr))
|
log.hints.debug("Handling new keystring: '{}'".format(keystr))
|
||||||
@ -846,7 +865,7 @@ class HintManager(QObject):
|
|||||||
except webelem.Error:
|
except webelem.Error:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if config.get('hints', 'mode') == 'number':
|
if self._context.hint_mode == 'number':
|
||||||
visible = self._filter_number_hints()
|
visible = self._filter_number_hints()
|
||||||
else:
|
else:
|
||||||
visible = self._filter_non_number_hints()
|
visible = self._filter_non_number_hints()
|
||||||
|
@ -189,7 +189,7 @@ class HintKeyParser(keyparser.CommandKeyParser):
|
|||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return super()._handle_special_key(e)
|
return super()._handle_special_key(e)
|
||||||
elif config.get('hints', 'mode') != 'number':
|
elif hintmanager.current_mode() != 'number':
|
||||||
return super()._handle_special_key(e)
|
return super()._handle_special_key(e)
|
||||||
elif not e.text():
|
elif not e.text():
|
||||||
return super()._handle_special_key(e)
|
return super()._handle_special_key(e)
|
||||||
|
@ -257,3 +257,11 @@ Feature: Using hints
|
|||||||
And I run :hint --rapid
|
And I run :hint --rapid
|
||||||
And I run :follow-hint 00
|
And I run :follow-hint 00
|
||||||
Then data/numbers/1.txt should be loaded
|
Then data/numbers/1.txt should be loaded
|
||||||
|
|
||||||
|
Scenario: Using a specific hints mode
|
||||||
|
When I open data/hints/number.html
|
||||||
|
And I set hints -> mode to letter
|
||||||
|
And I run :hint --mode number all
|
||||||
|
And I press the key "s"
|
||||||
|
And I run :follow-hint 1
|
||||||
|
Then data/numbers/7.txt should be loaded
|
||||||
|
Loading…
Reference in New Issue
Block a user