caret: Use strings instead of ints for enums

This commit is contained in:
Florian Bruhin 2020-05-22 20:05:38 +02:00
parent 7a0cbf54fc
commit d57fe79f5f
3 changed files with 13 additions and 8 deletions

View File

@ -427,9 +427,12 @@ class AbstractZoom(QObject):
self._set_factor_internal(self._zoom_factor)
class SelectionState(enum.IntEnum):
class SelectionState(enum.Enum):
"""Possible states of selection in Caret mode."""
"""Possible states of selection in caret mode.
NOTE: Names need to line up with SelectionState in caret.js!
"""
none = 1
normal = 2

View File

@ -504,8 +504,8 @@ class WebEngineCaret(browsertab.AbstractCaret):
code = javascript.assemble('caret', command, *args)
self._tab.run_js_async(code, callback)
def _toggle_sel_translate(self, state_int):
state = browsertab.SelectionState(state_int)
def _toggle_sel_translate(self, state_str):
state = browsertab.SelectionState[state_str]
self.selection_toggled.emit(state)

View File

@ -706,13 +706,15 @@ window._qutebrowser.caret = (function() {
CaretBrowsing.isCaretVisible = false;
/**
* selection modes
* Selection modes.
* NOTE: Values need to line up with SelectionState in browsertab.py!
*
* @type {enum}
*/
CaretBrowsing.SelectionState = {
"NONE": 1,
"NORMAL": 2,
"LINE": 3,
"NONE": "none",
"NORMAL": "normal",
"LINE": "line",
};
/**