diff --git a/src/calibre/gui2/tweak_book/__init__.py b/src/calibre/gui2/tweak_book/__init__.py index 173daeac1b..8540808468 100644 --- a/src/calibre/gui2/tweak_book/__init__.py +++ b/src/calibre/gui2/tweak_book/__init__.py @@ -17,6 +17,7 @@ d['editor_font_family'] = None d['editor_font_size'] = 12 d['editor_line_wrap'] = True d['editor_tab_stop_width'] = 2 +d['editor_show_char_under_cursor'] = True d['replace_entities_as_typed'] = True d['preview_refresh_time'] = 2 d['choose_tweak_fmt'] = True diff --git a/src/calibre/gui2/tweak_book/editor/widget.py b/src/calibre/gui2/tweak_book/editor/widget.py index 423fd86539..e9f0cfa3b1 100644 --- a/src/calibre/gui2/tweak_book/editor/widget.py +++ b/src/calibre/gui2/tweak_book/editor/widget.py @@ -215,7 +215,11 @@ class Editor(QMainWindow): @property def cursor_position(self): c = self.editor.textCursor() - return (c.blockNumber() + 1, c.positionInBlock()) + char = '' + if not c.atEnd(): + c.setPosition(c.position()+1, c.KeepAnchor) + char = unicode(c.selectedText()) + return (c.blockNumber() + 1, c.positionInBlock(), char) def cut(self): self.editor.cut() diff --git a/src/calibre/gui2/tweak_book/preferences.py b/src/calibre/gui2/tweak_book/preferences.py index 3ee33e4b7f..23555f3098 100644 --- a/src/calibre/gui2/tweak_book/preferences.py +++ b/src/calibre/gui2/tweak_book/preferences.py @@ -180,6 +180,10 @@ class EditorSettings(BasicSettings): ' happens only when the trailing semi-colon is typed.')) l.addRow(lw) + lw = self('editor_show_char_under_cursor') + lw.setText(_('Show the name of the current character under the cursor along with the line and column number')) + l.addRow(lw) + class IntegrationSettings(BasicSettings): def __init__(self, parent=None): diff --git a/src/calibre/gui2/tweak_book/ui.py b/src/calibre/gui2/tweak_book/ui.py index efd35c44ad..3a73288fe2 100644 --- a/src/calibre/gui2/tweak_book/ui.py +++ b/src/calibre/gui2/tweak_book/ui.py @@ -6,6 +6,7 @@ from __future__ import (unicode_literals, division, absolute_import, __license__ = 'GPL v3' __copyright__ = '2013, Kovid Goyal ' +import unicodedata from functools import partial from itertools import product from future_builtins import map @@ -180,11 +181,15 @@ class CursorPositionWidget(QWidget): # {{{ f.setBold(False) self.la.setFont(f) - def update_position(self, line=None, col=None): + def update_position(self, line=None, col=None, character=None): if line is None: self.la.setText('') else: - self.la.setText(_('Line: {0} : {1}').format(line, col)) + name = unicodedata.name(character) if character else None + text = _('Line: {0} : {1}').format(line, col) + if name: + text = name + ' : ' + text + self.la.setText(text) # }}} class Main(MainWindow):