Edit book: Allow using ctrl+shift+t in addition to ctrl+alt+t for selecting the contents of a tag

This commit is contained in:
Kovid Goyal 2022-11-13 22:17:50 +05:30
parent 1e1c15e3fe
commit 7947010d73
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 7 additions and 2 deletions

View File

@ -814,7 +814,8 @@ The HTML editor has very sophisticated syntax highlighting. Features include:
* As you move your cursor through the HTML, the matching HTML tags are * As you move your cursor through the HTML, the matching HTML tags are
highlighted, and you can jump to the opening or closing tag with the highlighted, and you can jump to the opening or closing tag with the
keyboard shortcuts :kbd:`Ctrl+{` and :kbd:`Ctrl+}`. Similarly, you keyboard shortcuts :kbd:`Ctrl+{` and :kbd:`Ctrl+}`. Similarly, you
can select the contents of a tag with :kbd:`Ctrl+Alt+T`. can select the contents of a tag with :kbd:`Ctrl+Alt+T` or
:kbd:`Ctrl+Shift+T`.
* Invalid HTML is highlighted with a red underline * Invalid HTML is highlighted with a red underline
* Spelling errors in the text inside HTML tags and attributes such as title * Spelling errors in the text inside HTML tags and attributes such as title
are highlighted. The spell checking is language aware, based on the value are highlighted. The spell checking is language aware, based on the value

View File

@ -671,6 +671,9 @@ class Smarts(NullSmarts):
is_xml = editor.syntax == 'xml' is_xml = editor.syntax == 'xml'
mods = ev.modifiers() & ( mods = ev.modifiers() & (
Qt.KeyboardModifier.ControlModifier | Qt.KeyboardModifier.AltModifier | Qt.KeyboardModifier.MetaModifier | Qt.KeyboardModifier.KeypadModifier) Qt.KeyboardModifier.ControlModifier | Qt.KeyboardModifier.AltModifier | Qt.KeyboardModifier.MetaModifier | Qt.KeyboardModifier.KeypadModifier)
shifted_mods = ev.modifiers() & (
Qt.KeyboardModifier.ControlModifier | Qt.KeyboardModifier.AltModifier | Qt.KeyboardModifier.MetaModifier |
Qt.KeyboardModifier.KeypadModifier | Qt.KeyboardModifier.ShiftModifier)
if tprefs['replace_entities_as_typed'] and ( if tprefs['replace_entities_as_typed'] and (
';' in ev_text or ';' in ev_text or
@ -728,7 +731,8 @@ class Smarts(NullSmarts):
if mods == Qt.KeyboardModifier.ControlModifier: if mods == Qt.KeyboardModifier.ControlModifier:
if self.jump_to_enclosing_tag(editor, key == Qt.Key.Key_BraceLeft): if self.jump_to_enclosing_tag(editor, key == Qt.Key.Key_BraceLeft):
return True return True
if key == Qt.Key.Key_T and mods == (Qt.KeyboardModifier.ControlModifier | Qt.KeyboardModifier.AltModifier): if key == Qt.Key.Key_T and shifted_mods in (
Qt.KeyboardModifier.ControlModifier | Qt.KeyboardModifier.AltModifier, Qt.KeyboardModifier.ControlModifier | Qt.KeyboardModifier.ShiftModifier):
return self.select_tag_contents(editor) return self.select_tag_contents(editor)
return False return False