From a8d8f92e9f437cf322556bf16f0ce15878823d4e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 6 Mar 2014 17:30:35 +0530 Subject: [PATCH] Edit book: Fix column number of cursor one less than it should be. Also fix non-BMP characters before cursor not being reported correctly. --- src/calibre/gui2/tweak_book/editor/widget.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/tweak_book/editor/widget.py b/src/calibre/gui2/tweak_book/editor/widget.py index ea21c4737e..a15514b28a 100644 --- a/src/calibre/gui2/tweak_book/editor/widget.py +++ b/src/calibre/gui2/tweak_book/editor/widget.py @@ -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()