Merge branch 'blyxxyz-master'

This commit is contained in:
Florian Bruhin 2016-07-13 21:26:35 +02:00
commit 7f8d4fa97a
10 changed files with 103 additions and 29 deletions

View File

@ -28,6 +28,9 @@ Added
status bar (top/bottom).
- New `--pdf <filename>` argument for `:print` which can be used to generate a
PDF without a dialog.
- New `:repeat-command` command (mapped to `.`) to repeat the last command.
Note that two former default bundings conflict with that binding, unbinding
them via `:unbind .i` and `:unbind .o` is recommended.
Changed
~~~~~~~

View File

@ -151,6 +151,7 @@ Contributors, sorted by the number of commits in descending order:
* Jakub Klinkovský
* Raphael Pierzina
* Joel Torstensson
* Jan Verbeek
* Tarcisio Fedrizzi
* Patric Schmitz
* Claude
@ -164,7 +165,6 @@ Contributors, sorted by the number of commits in descending order:
* Kevin Velghe
* Austin Anderson
* Jimmy
* Jan Verbeek
* Alexey "Averrin" Nabrodov
* avk
* ZDarian

View File

@ -932,6 +932,7 @@ How many steps to zoom out.
|<<prompt-accept,prompt-accept>>|Accept the current prompt.
|<<prompt-no,prompt-no>>|Answer no to a yes/no prompt.
|<<prompt-yes,prompt-yes>>|Answer yes to a yes/no prompt.
|<<repeat-command,repeat-command>>|Repeat the last executed command.
|<<rl-backward-char,rl-backward-char>>|Move back a character.
|<<rl-backward-delete-char,rl-backward-delete-char>>|Delete the character before the cursor.
|<<rl-backward-word,rl-backward-word>>|Move back to the start of the current or previous word.
@ -1158,6 +1159,13 @@ Answer no to a yes/no prompt.
=== prompt-yes
Answer yes to a yes/no prompt.
[[repeat-command]]
=== repeat-command
Repeat the last executed command.
==== count
Which count to pass the command.
[[rl-backward-char]]
=== rl-backward-char
Move back a character.

View File

@ -32,6 +32,7 @@ from qutebrowser.misc import split
ParseResult = collections.namedtuple('ParseResult', ['cmd', 'args', 'cmdline',
'count'])
last_command = {}
def _current_url(tabbed_browser):
@ -271,6 +272,10 @@ class CommandRunner(QObject):
count: The count to pass to the command.
"""
for result in self.parse_all(text):
mode_manager = objreg.get('mode-manager', scope='window',
window=self._win_id)
cur_mode = mode_manager.mode
args = replace_variables(self._win_id, result.args)
if count is not None:
if result.count is not None:
@ -282,6 +287,11 @@ class CommandRunner(QObject):
else:
result.cmd.run(self._win_id, args)
if result.cmdline[0] != 'repeat-command':
last_command[cur_mode] = (
self._parse_count(text)[1],
count if count is not None else result.count)
@pyqtSlot(str, int)
@pyqtSlot(str)
def run_safely(self, text, count=None):

View File

@ -1458,10 +1458,8 @@ KEY_DATA = collections.OrderedDict([
('hint all hover', [';h']),
('hint images', [';i']),
('hint images tab', [';I']),
('hint images tab-bg', ['.i']),
('hint links fill ":open {hint-url}"', [';o']),
('hint links fill ":open -t {hint-url}"', [';O']),
('hint links fill ":open -b {hint-url}"', ['.o']),
('hint links yank', [';y']),
('hint links yank-primary', [';Y']),
('hint --rapid links tab-bg', [';r']),
@ -1546,6 +1544,7 @@ KEY_DATA = collections.OrderedDict([
('open qute:settings', ['Ss']),
('follow-selected', RETURN_KEYS),
('follow-selected -t', ['<Ctrl-Return>', '<Ctrl-Enter>']),
('repeat-command', ['.']),
])),
('insert', collections.OrderedDict([

View File

@ -217,3 +217,20 @@ def debug_set_fake_clipboard(s=None):
utils.log_clipboard = True
else:
utils.fake_clipboard = s
@cmdutils.register(hide=True)
@cmdutils.argument('win_id', win_id=True)
@cmdutils.argument('count', count=True)
def repeat_command(win_id, count=None):
"""Repeat the last executed command.
Args:
count: Which count to pass the command.
"""
mode_manager = objreg.get('mode-manager', scope='window', window=win_id)
if mode_manager.mode not in runners.last_command:
raise cmdexc.CommandError("You didn't do anything yet.")
cmd = runners.last_command[mode_manager.mode]
commandrunner = runners.CommandRunner(win_id)
commandrunner.run(cmd[0], count if count is not None else cmd[1])

View File

@ -493,3 +493,28 @@ def clipboard_contains_multiline(quteproc, httpbin, content):
@bdd.then("qutebrowser should quit")
def should_quit(qtbot, quteproc):
quteproc.wait_for_quit()
def _get_scroll_values(quteproc):
data = quteproc.get_session()
pos = data['windows'][0]['tabs'][0]['history'][0]['scroll-pos']
return (pos['x'], pos['y'])
@bdd.then(bdd.parsers.re(r"the page should be scrolled "
r"(?P<direction>horizontally|vertically)"))
def check_scrolled(quteproc, direction):
x, y = _get_scroll_values(quteproc)
if direction == 'horizontally':
assert x != 0
assert y == 0
else:
assert x == 0
assert y != 0
@bdd.then("the page should not be scrolled")
def check_not_scrolled(quteproc):
x, y = _get_scroll_values(quteproc)
assert x == 0
assert y == 0

View File

@ -470,3 +470,41 @@ Feature: Various utility commands.
And I wait until cookies is loaded
And I open cookies in a new tab
Then the cookie qute-test should be set to 42
Scenario: :repeat-command
Given I open data/scroll.html
And I run :tab-only
When I run :scroll down
And I run :repeat-command
And I run :scroll up
Then the page should be scrolled vertically
Scenario: :repeat-command with count
Given I open data/scroll.html
And I run :tab-only
When I run :scroll down with count 3
And I run :scroll up
And I run :repeat-command with count 2
Then the page should not be scrolled
Scenario: :repeat-command with not-normal command inbetween
Given I open data/scroll.html
And I run :tab-only
When I run :scroll down with count 3
And I run :scroll up
And I run :prompt-accept
And I run :repeat-command with count 2
Then the page should not be scrolled
And the error "prompt-accept: This command is only allowed in prompt/yesno mode." should be shown
Scenario: :repeat-command with mode-switching command
Given I open data/hints/link_blank.html
And I run :tab-only
When I run :hint
And I run :leave-mode
And I run :repeat-command
And I run :follow-hint a
And I wait until data/hello.txt is loaded
Then the following tabs should be open:
- data/hints/link_blank.html
- data/hello.txt (active)

View File

@ -29,7 +29,6 @@ import qutebrowser
from qutebrowser.utils import docutils
from qutebrowser.browser import pdfjs
bdd.scenarios('misc.feature')

View File

@ -19,28 +19,3 @@
import pytest_bdd as bdd
bdd.scenarios('scroll.feature')
def _get_scroll_values(quteproc):
data = quteproc.get_session()
pos = data['windows'][0]['tabs'][0]['history'][0]['scroll-pos']
return (pos['x'], pos['y'])
@bdd.then(bdd.parsers.re(r"the page should be scrolled "
r"(?P<direction>horizontally|vertically)"))
def check_scrolled(quteproc, direction):
x, y = _get_scroll_values(quteproc)
if direction == 'horizontally':
assert x != 0
assert y == 0
else:
assert x == 0
assert y != 0
@bdd.then("the page should not be scrolled")
def check_not_scrolled(quteproc):
x, y = _get_scroll_values(quteproc)
assert x == 0
assert y == 0