Fix some lint warnings. Enable caret tests
This commit is contained in:
parent
c7a5dd6abb
commit
4eda328a61
@ -392,7 +392,7 @@ class AbstractCaret(QObject):
|
||||
def has_selection(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def selection(self, html=False, selection=None):
|
||||
def selection(self, html=False, callback=None):
|
||||
raise NotImplementedError
|
||||
|
||||
def follow_selected(self, *, tab=False):
|
||||
|
@ -839,9 +839,9 @@ class CommandDispatcher:
|
||||
keep: Stay in visual mode after yanking the selection.
|
||||
"""
|
||||
self.yank_object = {
|
||||
'sel': sel,
|
||||
'what': what,
|
||||
'keep': keep
|
||||
'sel': sel,
|
||||
'what': what,
|
||||
'keep': keep
|
||||
}
|
||||
if what == 'title':
|
||||
s = self._tabbed_browser.page_title(self._current_index())
|
||||
@ -877,7 +877,8 @@ class CommandDispatcher:
|
||||
|
||||
utils.set_clipboard(s, selection=self.yank_object['sel'])
|
||||
if self.yank_object['what'] != 'selection':
|
||||
message.info("Yanked {} to {}: {}".format(self.yank_object['what'], target, s))
|
||||
message.info("Yanked {} to {}: {}".format(
|
||||
self.yank_object['what'], target, s))
|
||||
else:
|
||||
message.info("{} {} yanked to {}".format(
|
||||
len(s), "char" if len(s) == 1 else "chars", target))
|
||||
@ -1222,9 +1223,9 @@ class CommandDispatcher:
|
||||
# until it fixed or blocked async call implemented:
|
||||
# https://github.com/qutebrowser/qutebrowser/issues/3327
|
||||
self.userscript_object = {
|
||||
'cmd': cmd,
|
||||
'args': args,
|
||||
'verbose': verbose
|
||||
'cmd': cmd,
|
||||
'args': args,
|
||||
'verbose': verbose
|
||||
}
|
||||
caret = self._current_widget().caret
|
||||
caret.selection(False, self._selection_callback)
|
||||
@ -1279,9 +1280,9 @@ class CommandDispatcher:
|
||||
env['QUTE_URL'] = url.toString(QUrl.FullyEncoded)
|
||||
|
||||
try:
|
||||
userscripts.run_async(tab, self.userscript_object['cmd'],
|
||||
*self.userscript_object['args'], win_id=self._win_id,
|
||||
env=env, verbose=self.userscript_object['verbose'])
|
||||
userscripts.run_async(tab, self.userscript_object['cmd'],
|
||||
*self.userscript_object['args'], win_id=self._win_id,
|
||||
env=env, verbose=self.userscript_object['verbose'])
|
||||
except userscripts.Error as e:
|
||||
raise cmdexc.CommandError(e)
|
||||
finally:
|
||||
|
@ -180,91 +180,91 @@ class WebEngineCaret(browsertab.AbstractCaret):
|
||||
@pyqtSlot(usertypes.KeyMode)
|
||||
def _on_mode_entered(self, mode):
|
||||
self._tab.run_js_async(
|
||||
javascript.assemble('caret', 'setInitialCursor'))
|
||||
javascript.assemble('caret', 'setInitialCursor'))
|
||||
|
||||
@pyqtSlot(usertypes.KeyMode)
|
||||
def _on_mode_left(self):
|
||||
self._tab.run_js_async(
|
||||
javascript.assemble('caret', 'toggle'))
|
||||
javascript.assemble('caret', 'toggle'))
|
||||
|
||||
def move_to_next_line(self, count=1):
|
||||
for _ in range(count):
|
||||
self._tab.run_js_async(
|
||||
javascript.assemble('caret', 'moveDown'))
|
||||
javascript.assemble('caret', 'moveDown'))
|
||||
|
||||
def move_to_prev_line(self, count=1):
|
||||
for _ in range(count):
|
||||
self._tab.run_js_async(
|
||||
javascript.assemble('caret', 'moveUp'))
|
||||
javascript.assemble('caret', 'moveUp'))
|
||||
|
||||
def move_to_next_char(self, count=1):
|
||||
for _ in range(count):
|
||||
self._tab.run_js_async(
|
||||
javascript.assemble('caret', 'moveRight'))
|
||||
javascript.assemble('caret', 'moveRight'))
|
||||
|
||||
def move_to_prev_char(self, count=1):
|
||||
for _ in range(count):
|
||||
self._tab.run_js_async(
|
||||
javascript.assemble('caret', 'moveLeft'))
|
||||
javascript.assemble('caret', 'moveLeft'))
|
||||
|
||||
def move_to_end_of_word(self, count=1):
|
||||
for _ in range(count):
|
||||
self._tab.run_js_async(
|
||||
javascript.assemble('caret', 'moveToEndOfWord'))
|
||||
javascript.assemble('caret', 'moveToEndOfWord'))
|
||||
|
||||
def move_to_next_word(self, count=1):
|
||||
for _ in range(count):
|
||||
self._tab.run_js_async(
|
||||
javascript.assemble('caret', 'moveToNextWord'))
|
||||
javascript.assemble('caret', 'moveToNextWord'))
|
||||
|
||||
def move_to_prev_word(self, count=1):
|
||||
for _ in range(count):
|
||||
self._tab.run_js_async(
|
||||
javascript.assemble('caret', 'moveToPreviousWord'))
|
||||
javascript.assemble('caret', 'moveToPreviousWord'))
|
||||
|
||||
def move_to_start_of_line(self):
|
||||
self._tab.run_js_async(
|
||||
javascript.assemble('caret', 'moveToStartOfLine'))
|
||||
javascript.assemble('caret', 'moveToStartOfLine'))
|
||||
|
||||
def move_to_end_of_line(self):
|
||||
self._tab.run_js_async(
|
||||
javascript.assemble('caret', 'moveToEndOfLine'))
|
||||
javascript.assemble('caret', 'moveToEndOfLine'))
|
||||
|
||||
def move_to_start_of_next_block(self, count=1):
|
||||
for _ in range(count):
|
||||
self._tab.run_js_async(
|
||||
javascript.assemble('caret', 'moveToStartOfNextBlock'))
|
||||
javascript.assemble('caret', 'moveToStartOfNextBlock'))
|
||||
|
||||
def move_to_start_of_prev_block(self, count=1):
|
||||
for _ in range(count):
|
||||
self._tab.run_js_async(
|
||||
javascript.assemble('caret', 'moveToStartOfPrevBlock'))
|
||||
javascript.assemble('caret', 'moveToStartOfPrevBlock'))
|
||||
|
||||
def move_to_end_of_next_block(self, count=1):
|
||||
for _ in range(count):
|
||||
self._tab.run_js_async(
|
||||
javascript.assemble('caret', 'moveToEndOfNextBlock'))
|
||||
javascript.assemble('caret', 'moveToEndOfNextBlock'))
|
||||
|
||||
def move_to_end_of_prev_block(self, count=1):
|
||||
for _ in range(count):
|
||||
self._tab.run_js_async(
|
||||
javascript.assemble('caret', 'moveToEndOfPrevBlock'))
|
||||
javascript.assemble('caret', 'moveToEndOfPrevBlock'))
|
||||
|
||||
def move_to_start_of_document(self):
|
||||
self._tab.run_js_async(
|
||||
javascript.assemble('caret', 'moveToStartOfDocument'))
|
||||
javascript.assemble('caret', 'moveToStartOfDocument'))
|
||||
|
||||
def move_to_end_of_document(self):
|
||||
self._tab.run_js_async(
|
||||
javascript.assemble('caret', 'moveToEndOfDocument'))
|
||||
javascript.assemble('caret', 'moveToEndOfDocument'))
|
||||
|
||||
def toggle_selection(self):
|
||||
self._tab.run_js_async(
|
||||
javascript.assemble('caret', 'toggleSelection'))
|
||||
javascript.assemble('caret', 'toggleSelection'))
|
||||
|
||||
def drop_selection(self):
|
||||
self._tab.run_js_async(
|
||||
javascript.assemble('caret', 'dropSelection'))
|
||||
javascript.assemble('caret', 'dropSelection'))
|
||||
|
||||
def has_selection(self):
|
||||
if qtutils.version_check('5.10'):
|
||||
@ -283,7 +283,7 @@ class WebEngineCaret(browsertab.AbstractCaret):
|
||||
# WORKAROUND for
|
||||
# https://bugreports.qt.io/browse/QTBUG-53134
|
||||
self._tab.run_js_async(
|
||||
'window.getSelection().toString()', callback)
|
||||
'window.getSelection().toString()', callback)
|
||||
self.drop_selection()
|
||||
|
||||
def _follow_selected_cb(self, js_elem, tab=False):
|
||||
@ -328,6 +328,7 @@ class WebEngineCaret(browsertab.AbstractCaret):
|
||||
self._tab.run_js_async(js_code, lambda jsret:
|
||||
self._follow_selected_cb(jsret, tab))
|
||||
|
||||
|
||||
class WebEngineScroller(browsertab.AbstractScroller):
|
||||
|
||||
"""QtWebEngine implementations related to scrolling."""
|
||||
|
@ -1,8 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
window._qutebrowser.caret = (function() {
|
||||
|
||||
var axs = {};
|
||||
const axs = {};
|
||||
|
||||
axs.dom = {};
|
||||
|
||||
|
@ -23,9 +23,4 @@ import pytest_bdd as bdd
|
||||
# pylint: disable=unused-import
|
||||
from end2end.features.test_yankpaste_bdd import init_fake_clipboard
|
||||
|
||||
|
||||
pytestmark = pytest.mark.qtwebengine_todo("Caret mode is not implemented",
|
||||
run=False)
|
||||
|
||||
|
||||
bdd.scenarios('caret.feature')
|
||||
|
Loading…
Reference in New Issue
Block a user