Edit book: Show the name of the current character under the cursor in the status bar. Can be turned off via Preferences.

This commit is contained in:
Kovid Goyal
2013-12-22 17:42:10 +05:30
parent cdc1af5b7d
commit b5645f19aa
4 changed files with 17 additions and 3 deletions
+1
View File
@@ -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
+5 -1
View File
@@ -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()
@@ -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):
+7 -2
View File
@@ -6,6 +6,7 @@ from __future__ import (unicode_literals, division, absolute_import,
__license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
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):