Implement all caret browsing methods
This commit is contained in:
parent
82b1bd10ec
commit
8aca37e5d5
@ -231,22 +231,28 @@ class WebEngineCaret(browsertab.AbstractCaret):
|
|||||||
javascript.assemble('caret', 'moveToEndOfLine'))
|
javascript.assemble('caret', 'moveToEndOfLine'))
|
||||||
|
|
||||||
def move_to_start_of_next_block(self, count=1):
|
def move_to_start_of_next_block(self, count=1):
|
||||||
log.stub()
|
self._tab.run_js_async(
|
||||||
|
javascript.assemble('caret', 'moveToStartOfNextBlock'))
|
||||||
|
|
||||||
def move_to_start_of_prev_block(self, count=1):
|
def move_to_start_of_prev_block(self, count=1):
|
||||||
log.stub()
|
self._tab.run_js_async(
|
||||||
|
javascript.assemble('caret', 'moveToStartOfPrevBlock'))
|
||||||
|
|
||||||
def move_to_end_of_next_block(self, count=1):
|
def move_to_end_of_next_block(self, count=1):
|
||||||
log.stub()
|
self._tab.run_js_async(
|
||||||
|
javascript.assemble('caret', 'moveToEndOfNextBlock'))
|
||||||
|
|
||||||
def move_to_end_of_prev_block(self, count=1):
|
def move_to_end_of_prev_block(self, count=1):
|
||||||
log.stub()
|
self._tab.run_js_async(
|
||||||
|
javascript.assemble('caret', 'moveToEndOfPrevBlock'))
|
||||||
|
|
||||||
def move_to_start_of_document(self):
|
def move_to_start_of_document(self):
|
||||||
log.stub()
|
self._tab.run_js_async(
|
||||||
|
javascript.assemble('caret', 'moveToStartOfDocument'))
|
||||||
|
|
||||||
def move_to_end_of_document(self):
|
def move_to_end_of_document(self):
|
||||||
log.stub()
|
self._tab.run_js_async(
|
||||||
|
javascript.assemble('caret', 'moveToEndOfDocument'))
|
||||||
|
|
||||||
def toggle_selection(self):
|
def toggle_selection(self):
|
||||||
self._tab.run_js_async(
|
self._tab.run_js_async(
|
||||||
|
@ -825,7 +825,6 @@ window._qutebrowser.caret = (function() {
|
|||||||
str = word + str;
|
str = word + str;
|
||||||
nodesCrossed = nodesCrossed.concat(newNodesCrossed);
|
nodesCrossed = nodesCrossed.concat(newNodesCrossed);
|
||||||
startCursor.copyFrom(wordStartCursor);
|
startCursor.copyFrom(wordStartCursor);
|
||||||
v
|
|
||||||
// Get the previous word and go back to the top of the loop.
|
// Get the previous word and go back to the top of the loop.
|
||||||
newNodesCrossed = [];
|
newNodesCrossed = [];
|
||||||
word = TraverseUtil.getPreviousWord(
|
word = TraverseUtil.getPreviousWord(
|
||||||
@ -1595,28 +1594,54 @@ window._qutebrowser.caret = (function() {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CaretBrowsing.move = function(direction, granularity) {
|
||||||
|
window
|
||||||
|
.getSelection()
|
||||||
|
.modify(
|
||||||
|
CaretBrowsing.selectionEnabled ? 'extend' : 'move',
|
||||||
|
direction,
|
||||||
|
granularity);
|
||||||
|
|
||||||
|
window.setTimeout(function() {
|
||||||
|
CaretBrowsing.updateCaretOrSelection(true);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
CaretBrowsing.moveToBlock = function(paragraph, boundary) {
|
||||||
|
window
|
||||||
|
.getSelection()
|
||||||
|
.modify(
|
||||||
|
CaretBrowsing.selectionEnabled ? 'extend' : 'move',
|
||||||
|
paragraph,
|
||||||
|
'paragraph');
|
||||||
|
|
||||||
|
window
|
||||||
|
.getSelection()
|
||||||
|
.modify(
|
||||||
|
CaretBrowsing.selectionEnabled ? 'extend' : 'move',
|
||||||
|
boundary,
|
||||||
|
'paragraphboundary');
|
||||||
|
|
||||||
|
window.setTimeout(function() {
|
||||||
|
CaretBrowsing.updateCaretOrSelection(true);
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
funcs.moveRight = () => {
|
funcs.moveRight = () => {
|
||||||
var evt = Object.assign({}, document.activeElement);
|
CaretBrowsing.move('right', 'character');
|
||||||
evt.keyCode = 39;
|
|
||||||
CaretBrowsing.onKeyDown(evt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
funcs.moveLeft = () => {
|
funcs.moveLeft = () => {
|
||||||
var evt = Object.assign({}, document.activeElement);
|
CaretBrowsing.move('left', 'character');
|
||||||
evt.keyCode = 37;
|
|
||||||
CaretBrowsing.onKeyDown(evt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
funcs.moveDown = () => {
|
funcs.moveDown = () => {
|
||||||
var evt = Object.assign({}, document.activeElement);
|
CaretBrowsing.move('forward', 'line');
|
||||||
evt.keyCode = 40;
|
|
||||||
CaretBrowsing.onKeyDown(evt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
funcs.moveUp = () => {
|
funcs.moveUp = () => {
|
||||||
var evt = Object.assign({}, document.activeElement);
|
CaretBrowsing.move('backward', 'line');
|
||||||
evt.keyCode = 38;
|
|
||||||
CaretBrowsing.onKeyDown(evt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
funcs.moveToEndOfWord = () => {
|
funcs.moveToEndOfWord = () => {
|
||||||
@ -1625,40 +1650,45 @@ window._qutebrowser.caret = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
funcs.moveToNextWord = () => {
|
funcs.moveToNextWord = () => {
|
||||||
var evt = Object.assign({}, document.activeElement);
|
CaretBrowsing.move('forward', 'word');
|
||||||
evt.keyCode = 39;
|
|
||||||
evt.ctrlKey = true;
|
|
||||||
CaretBrowsing.onKeyDown(evt);
|
|
||||||
funcs.moveRight();
|
funcs.moveRight();
|
||||||
}
|
}
|
||||||
|
|
||||||
funcs.moveToPreviousWord = () => {
|
funcs.moveToPreviousWord = () => {
|
||||||
var evt = Object.assign({}, document.activeElement);
|
CaretBrowsing.move('backward', 'word');
|
||||||
evt.keyCode = 37;
|
|
||||||
evt.ctrlKey = true;
|
|
||||||
CaretBrowsing.onKeyDown(evt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
funcs.moveToStartOfLine = () => {
|
funcs.moveToStartOfLine = () => {
|
||||||
CaretBrowsing.moveToLineBoundary('left');
|
CaretBrowsing.move('left', 'lineboundary');
|
||||||
}
|
}
|
||||||
|
|
||||||
funcs.moveToEndOfLine = () => {
|
funcs.moveToEndOfLine = () => {
|
||||||
CaretBrowsing.moveToLineBoundary('right');
|
CaretBrowsing.move('right', 'lineboundary');
|
||||||
}
|
}
|
||||||
|
|
||||||
CaretBrowsing.moveToLineBoundary = function(side) {
|
funcs.moveToStartOfNextBlock = () => {
|
||||||
window
|
CaretBrowsing.moveToBlock('forward', 'backward');
|
||||||
.getSelection()
|
}
|
||||||
.modify(
|
|
||||||
CaretBrowsing.selectionEnabled ? 'extend' : 'move',
|
|
||||||
side,
|
|
||||||
'lineboundary');
|
|
||||||
|
|
||||||
window.setTimeout(function() {
|
funcs.moveToStartOfPrevBlock = () => {
|
||||||
CaretBrowsing.updateCaretOrSelection(true);
|
CaretBrowsing.moveToBlock('backward', 'backward');
|
||||||
}, 0);
|
}
|
||||||
};
|
|
||||||
|
funcs.moveToEndOfNextBlock = () => {
|
||||||
|
CaretBrowsing.moveToBlock('forward', 'forward');
|
||||||
|
}
|
||||||
|
|
||||||
|
funcs.moveToEndOfPrevBlock = () => {
|
||||||
|
CaretBrowsing.moveToBlock('backward', 'forward');
|
||||||
|
}
|
||||||
|
|
||||||
|
funcs.moveToStartOfDocument = () => {
|
||||||
|
CaretBrowsing.move('backward', 'documentboundary');
|
||||||
|
}
|
||||||
|
|
||||||
|
funcs.moveToEndOfDocument = () => {
|
||||||
|
CaretBrowsing.move('forward', 'documentboundary');
|
||||||
|
}
|
||||||
|
|
||||||
funcs.toggleSelection = () => {
|
funcs.toggleSelection = () => {
|
||||||
CaretBrowsing.selectionEnabled = !CaretBrowsing.selectionEnabled;
|
CaretBrowsing.selectionEnabled = !CaretBrowsing.selectionEnabled;
|
||||||
|
Loading…
Reference in New Issue
Block a user