Edit book: Fix column number of cursor one less than it should be.

Also fix non-BMP characters before cursor not being reported correctly.
This commit is contained in:
Kovid Goyal 2014-03-06 17:30:35 +05:30
parent 4c9e1733ec
commit a8d8f92e9f

View File

@ -248,11 +248,12 @@ class Editor(QMainWindow):
def cursor_position(self):
c = self.editor.textCursor()
char = ''
col = c.positionInBlock()
if not c.atStart():
c.clearSelection()
c.setPosition(c.position()-1, c.KeepAnchor)
c.movePosition(c.PreviousCharacter, c.KeepAnchor)
char = unicode(c.selectedText()).rstrip('\0')
return (c.blockNumber() + 1, c.positionInBlock(), char)
return (c.blockNumber() + 1, col, char)
def cut(self):
self.editor.cut()