mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit Book: Allow selecting the contents of a tag with Ctrl+Alt+t
This commit is contained in:
parent
1088d699b7
commit
9e640df255
@ -802,7 +802,8 @@ The HTML editor has very sophisticated syntax highlighting. Features include:
|
||||
* The text inside bold, italic and heading tags is made bold/italic
|
||||
* 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
|
||||
keyboard shortcuts :kbd:`Ctrl+{` and :kbd:`Ctrl+}`
|
||||
keyboard shortcuts :kbd:`Ctrl+{` and :kbd:`Ctrl+}`. Similarly, you
|
||||
can select the contents of a tag with :kbd:`Ctrl+Alt+T`.
|
||||
* Invalid HTML is highlighted with a red underline
|
||||
* 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
|
||||
|
@ -352,6 +352,18 @@ class Smarts(NullSmarts):
|
||||
editor.setTextCursor(c)
|
||||
return True
|
||||
|
||||
def select_tag_contents(self, editor):
|
||||
editor.highlighter.join()
|
||||
start = self.last_matched_tag
|
||||
end = self.last_matched_closing_tag
|
||||
if start is None or end is None:
|
||||
return False
|
||||
c = editor.textCursor()
|
||||
c.setPosition(start.start_block.position() + start.end_offset + 1)
|
||||
c.setPosition(end.start_block.position() + end.start_offset, c.KeepAnchor)
|
||||
editor.setTextCursor(c)
|
||||
return True
|
||||
|
||||
def remove_tag(self, editor):
|
||||
editor.highlighter.join()
|
||||
if not self.last_matched_closing_tag and not self.last_matched_tag:
|
||||
@ -662,6 +674,8 @@ class Smarts(NullSmarts):
|
||||
if int(mods & Qt.ControlModifier):
|
||||
if self.jump_to_enclosing_tag(editor, key == Qt.Key_BraceLeft):
|
||||
return True
|
||||
if key == Qt.Key_T and int(ev.modifiers() & (Qt.ControlModifier | Qt.AltModifier)):
|
||||
return self.select_tag_contents(editor)
|
||||
|
||||
return False
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user