Add separate function in js to set current platform
This commit is contained in:
parent
81a9ea58d6
commit
4fde8ff204
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
import math
|
import math
|
||||||
import functools
|
import functools
|
||||||
import platform
|
import sys
|
||||||
import html as html_utils
|
import html as html_utils
|
||||||
|
|
||||||
import sip
|
import sip
|
||||||
@ -206,8 +206,8 @@ class WebEngineCaret(browsertab.AbstractCaret):
|
|||||||
return
|
return
|
||||||
|
|
||||||
self._tab.run_js_async(
|
self._tab.run_js_async(
|
||||||
javascript.assemble('caret', 'setInitialCursor',
|
javascript.assemble('caret', 'setPlatform', sys.platform))
|
||||||
platform.platform()))
|
self._js_call('setInitialCursor')
|
||||||
|
|
||||||
@pyqtSlot(usertypes.KeyMode)
|
@pyqtSlot(usertypes.KeyMode)
|
||||||
def _on_mode_left(self):
|
def _on_mode_left(self):
|
||||||
|
@ -707,6 +707,12 @@ window._qutebrowser.caret = (function() {
|
|||||||
*/
|
*/
|
||||||
CaretBrowsing.blinkFlag = true;
|
CaretBrowsing.blinkFlag = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The os that user is using.
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
CaretBrowsing.platform = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a node is a control that normally allows the user to interact
|
* Check if a node is a control that normally allows the user to interact
|
||||||
* with it using arrow keys. We won't override the arrow keys when such a
|
* with it using arrow keys. We won't override the arrow keys when such a
|
||||||
@ -814,9 +820,9 @@ window._qutebrowser.caret = (function() {
|
|||||||
* If there's no initial selection, set the cursor just before the
|
* If there's no initial selection, set the cursor just before the
|
||||||
* first text character in the document.
|
* first text character in the document.
|
||||||
*/
|
*/
|
||||||
CaretBrowsing.setInitialCursor = function(platform) {
|
CaretBrowsing.setInitialCursor = function() {
|
||||||
if (platform) {
|
if (CaretBrowsing.platform) {
|
||||||
CaretBrowsing.isWindows = platform.indexOf("Windows") !== -1;
|
CaretBrowsing.isWindows = CaretBrowsing.platform.startsWith("win");
|
||||||
}
|
}
|
||||||
const selectionRange = window.getSelection().toString().length;
|
const selectionRange = window.getSelection().toString().length;
|
||||||
if (selectionRange === 0) {
|
if (selectionRange === 0) {
|
||||||
@ -1252,7 +1258,7 @@ window._qutebrowser.caret = (function() {
|
|||||||
CaretBrowsing.isCaretVisible =
|
CaretBrowsing.isCaretVisible =
|
||||||
(CaretBrowsing.isEnabled && CaretBrowsing.isWindowFocused);
|
(CaretBrowsing.isEnabled && CaretBrowsing.isWindowFocused);
|
||||||
if (CaretBrowsing.isCaretVisible && !CaretBrowsing.caretElement) {
|
if (CaretBrowsing.isCaretVisible && !CaretBrowsing.caretElement) {
|
||||||
CaretBrowsing.setInitialCursor(CaretBrowsing.isWindows);
|
CaretBrowsing.setInitialCursor();
|
||||||
CaretBrowsing.updateCaretOrSelection(true);
|
CaretBrowsing.updateCaretOrSelection(true);
|
||||||
if (CaretBrowsing.caretElement) {
|
if (CaretBrowsing.caretElement) {
|
||||||
CaretBrowsing.blinkFunctionId = window.setInterval(
|
CaretBrowsing.blinkFunctionId = window.setInterval(
|
||||||
@ -1304,9 +1310,9 @@ window._qutebrowser.caret = (function() {
|
|||||||
|
|
||||||
const funcs = {};
|
const funcs = {};
|
||||||
|
|
||||||
funcs.setInitialCursor = (platform) => {
|
funcs.setInitialCursor = () => {
|
||||||
if (!CaretBrowsing.initiated) {
|
if (!CaretBrowsing.initiated) {
|
||||||
CaretBrowsing.setInitialCursor(platform);
|
CaretBrowsing.setInitialCursor();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1316,6 +1322,10 @@ window._qutebrowser.caret = (function() {
|
|||||||
CaretBrowsing.toggle();
|
CaretBrowsing.toggle();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
funcs.setPlatform = (platform) => {
|
||||||
|
CaretBrowsing.platform = platform;
|
||||||
|
}
|
||||||
|
|
||||||
funcs.disableCaret = () => {
|
funcs.disableCaret = () => {
|
||||||
CaretBrowsing.toggle(false);
|
CaretBrowsing.toggle(false);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user