Merge branch 'Carpetsmoker-scroll_page_navigate'
This commit is contained in:
commit
1e5c67f152
@ -141,10 +141,10 @@ Contributors, sorted by the number of commits in descending order:
|
|||||||
* Artur Shaik
|
* Artur Shaik
|
||||||
* ZDarian
|
* ZDarian
|
||||||
* Peter Vilim
|
* Peter Vilim
|
||||||
|
* Martin Tournoij
|
||||||
* John ShaggyTwoDope Jenkins
|
* John ShaggyTwoDope Jenkins
|
||||||
* Jimmy
|
* Jimmy
|
||||||
* Zach-Button
|
* Zach-Button
|
||||||
* Martin Tournoij
|
|
||||||
* rikn00
|
* rikn00
|
||||||
* Patric Schmitz
|
* Patric Schmitz
|
||||||
* Martin Zimmermann
|
* Martin Zimmermann
|
||||||
|
@ -1009,7 +1009,7 @@ multiplier
|
|||||||
|
|
||||||
[[scroll-page]]
|
[[scroll-page]]
|
||||||
=== scroll-page
|
=== scroll-page
|
||||||
Syntax: +:scroll-page 'x' 'y'+
|
Syntax: +:scroll-page [*--top-navigate* 'ACTION'] [*--bottom-navigate* 'ACTION'] 'x' 'y'+
|
||||||
|
|
||||||
Scroll the frame page-wise.
|
Scroll the frame page-wise.
|
||||||
|
|
||||||
@ -1017,6 +1017,12 @@ Scroll the frame page-wise.
|
|||||||
* +'x'+: How many pages to scroll to the right.
|
* +'x'+: How many pages to scroll to the right.
|
||||||
* +'y'+: How many pages to scroll down.
|
* +'y'+: How many pages to scroll down.
|
||||||
|
|
||||||
|
==== optional arguments
|
||||||
|
* +*-t*+, +*--top-navigate*+: :navigate action (prev, decrement) to run when scrolling up at the top of the page.
|
||||||
|
|
||||||
|
* +*-b*+, +*--bottom-navigate*+: :navigate action (next, increment) to run when scrolling down at the bottom of the page.
|
||||||
|
|
||||||
|
|
||||||
==== count
|
==== count
|
||||||
multiplier
|
multiplier
|
||||||
|
|
||||||
|
@ -643,14 +643,37 @@ class CommandDispatcher:
|
|||||||
|
|
||||||
@cmdutils.register(instance='command-dispatcher', hide=True,
|
@cmdutils.register(instance='command-dispatcher', hide=True,
|
||||||
scope='window', count='count')
|
scope='window', count='count')
|
||||||
def scroll_page(self, x: {'type': float}, y: {'type': float}, count=1):
|
def scroll_page(self, x: {'type': float}, y: {'type': float}, *,
|
||||||
|
top_navigate: {'type': ('prev', 'decrement'),
|
||||||
|
'metavar': 'ACTION'}=None,
|
||||||
|
bottom_navigate: {'type': ('next', 'increment'),
|
||||||
|
'metavar': 'ACTION'}=None,
|
||||||
|
count=1):
|
||||||
"""Scroll the frame page-wise.
|
"""Scroll the frame page-wise.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
x: How many pages to scroll to the right.
|
x: How many pages to scroll to the right.
|
||||||
y: How many pages to scroll down.
|
y: How many pages to scroll down.
|
||||||
|
bottom_navigate: :navigate action (next, increment) to run when
|
||||||
|
scrolling down at the bottom of the page.
|
||||||
|
top_navigate: :navigate action (prev, decrement) to run when
|
||||||
|
scrolling up at the top of the page.
|
||||||
count: multiplier
|
count: multiplier
|
||||||
"""
|
"""
|
||||||
|
frame = self._current_widget().page().currentFrame()
|
||||||
|
if not frame.url().isValid():
|
||||||
|
# See https://github.com/The-Compiler/qutebrowser/issues/701
|
||||||
|
return
|
||||||
|
|
||||||
|
if (bottom_navigate is not None and
|
||||||
|
frame.scrollPosition().y() >=
|
||||||
|
frame.scrollBarMaximum(Qt.Vertical)):
|
||||||
|
self.navigate(bottom_navigate)
|
||||||
|
return
|
||||||
|
elif top_navigate is not None and frame.scrollPosition().y() == 0:
|
||||||
|
self.navigate(top_navigate)
|
||||||
|
return
|
||||||
|
|
||||||
mult_x = count * x
|
mult_x = count * x
|
||||||
mult_y = count * y
|
mult_y = count * y
|
||||||
if mult_y.is_integer():
|
if mult_y.is_integer():
|
||||||
@ -663,7 +686,6 @@ class CommandDispatcher:
|
|||||||
mult_y = 0
|
mult_y = 0
|
||||||
if mult_x == 0 and mult_y == 0:
|
if mult_x == 0 and mult_y == 0:
|
||||||
return
|
return
|
||||||
frame = self._current_widget().page().currentFrame()
|
|
||||||
size = frame.geometry()
|
size = frame.geometry()
|
||||||
dx = mult_x * size.width()
|
dx = mult_x * size.width()
|
||||||
dy = mult_y * size.height()
|
dy = mult_y * size.height()
|
||||||
|
@ -61,7 +61,8 @@ class Command:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
AnnotationInfo = collections.namedtuple('AnnotationInfo',
|
AnnotationInfo = collections.namedtuple('AnnotationInfo',
|
||||||
['kwargs', 'type', 'flag', 'hide'])
|
['kwargs', 'type', 'flag', 'hide',
|
||||||
|
'metavar'])
|
||||||
|
|
||||||
def __init__(self, *, handler, name, instance=None, maxsplit=None,
|
def __init__(self, *, handler, name, instance=None, maxsplit=None,
|
||||||
hide=False, completion=None, modes=None, not_modes=None,
|
hide=False, completion=None, modes=None, not_modes=None,
|
||||||
@ -257,10 +258,10 @@ class Command:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
if isinstance(typ, tuple):
|
if isinstance(typ, tuple):
|
||||||
pass
|
kwargs['metavar'] = annotation_info.metavar or param.name
|
||||||
elif utils.is_enum(typ):
|
elif utils.is_enum(typ):
|
||||||
kwargs['choices'] = [e.name.replace('_', '-') for e in typ]
|
kwargs['choices'] = [e.name.replace('_', '-') for e in typ]
|
||||||
kwargs['metavar'] = param.name
|
kwargs['metavar'] = annotation_info.metavar or param.name
|
||||||
elif typ is bool:
|
elif typ is bool:
|
||||||
kwargs['action'] = 'store_true'
|
kwargs['action'] = 'store_true'
|
||||||
elif typ is not None:
|
elif typ is not None:
|
||||||
@ -322,11 +323,12 @@ class Command:
|
|||||||
flag: The short name/flag if overridden.
|
flag: The short name/flag if overridden.
|
||||||
name: The long name if overridden.
|
name: The long name if overridden.
|
||||||
"""
|
"""
|
||||||
info = {'kwargs': {}, 'type': None, 'flag': None, 'hide': False}
|
info = {'kwargs': {}, 'type': None, 'flag': None, 'hide': False,
|
||||||
|
'metavar': None}
|
||||||
if param.annotation is not inspect.Parameter.empty:
|
if param.annotation is not inspect.Parameter.empty:
|
||||||
log.commands.vdebug("Parsing annotation {}".format(
|
log.commands.vdebug("Parsing annotation {}".format(
|
||||||
param.annotation))
|
param.annotation))
|
||||||
for field in ('type', 'flag', 'name', 'hide'):
|
for field in ('type', 'flag', 'name', 'hide', 'metavar'):
|
||||||
if field in param.annotation:
|
if field in param.annotation:
|
||||||
info[field] = param.annotation[field]
|
info[field] = param.annotation[field]
|
||||||
if 'nargs' in param.annotation:
|
if 'nargs' in param.annotation:
|
||||||
|
Loading…
Reference in New Issue
Block a user