diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index ec1802aa..ad90fe13 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -120,6 +120,16 @@ class GuiDocEditor(QTextEdit): theText = self.toPlainText() return theText + def setCursorPosition(self, thePosition): + theCursor = self.textCursor() + theCursor.setPosition(thePosition) + self.setTextCursor(theCursor) + return True + + def getCursorPosition(self): + theCursor = self.textCursor() + return theCursor.position() + ## # Spell Checking ## diff --git a/nw/gui/winmain.py b/nw/gui/winmain.py index 87386287..72aa6977 100644 --- a/nw/gui/winmain.py +++ b/nw/gui/winmain.py @@ -206,15 +206,19 @@ class GuiMain(QMainWindow): self.saveDocument() self.stackPane.setCurrentIndex(self.stackDoc) self.docEditor.setText(self.theDocument.openDocument(tHandle)) + self.docEditor.setCursorPosition(self.theDocument.theItem.cursorPos) self.docEditor.changeWidth() + self.docEditor.setFocus() return True def saveDocument(self): if self.theDocument.theItem is not None: docHtml = self.docEditor.getText() + cursPos = self.docEditor.getCursorPosition() self.theDocument.theItem.setCharCount(self.docEditor.charCount) self.theDocument.theItem.setWordCount(self.docEditor.wordCount) self.theDocument.theItem.setParaCount(self.docEditor.paraCount) + self.theDocument.theItem.setCursorPos(cursPos) self.theDocument.saveDocument(docHtml) self.docEditor.setDocumentChanged(False) return True diff --git a/sample/sampleNovel/data_6/36b6aa9b697b_main.nwd b/sample/sampleNovel/data_6/36b6aa9b697b_main.nwd index a185866f..8c9d288a 100644 --- a/sample/sampleNovel/data_6/36b6aa9b697b_main.nwd +++ b/sample/sampleNovel/data_6/36b6aa9b697b_main.nwd @@ -13,7 +13,7 @@ Some text here would look good as well, and maybe some "dialogue"? So, this is some __text__ that we’ve been adding to this document. It is utterly meaningless text, _but_ since this is just dummy text, that doesn’t really matter. The text is perfectly happy to live in this document reggardless. -This paragraph is also meaningless. At least a bit. +This paragraph is also meaningless. At least a bit. # ## diff --git a/sample/sampleNovel/nwProject.nwx b/sample/sampleNovel/nwProject.nwx index 30997158..acaad669 100644 --- a/sample/sampleNovel/nwProject.nwx +++ b/sample/sampleNovel/nwProject.nwx @@ -1,5 +1,5 @@ - + Sample Project Sample Project @@ -27,6 +27,7 @@ 23 5 1 + 0 Some Chapter @@ -45,6 +46,7 @@ 2571 377 5 + 0 File With Stuff @@ -53,9 +55,10 @@ 1 False SCENE - 417 + 405 71 5 + 421 New File @@ -67,6 +70,7 @@ 69 17 1 + 0 Characters @@ -92,6 +96,7 @@ 42 8 1 + 0 Jane Smith @@ -103,6 +108,7 @@ 51 9 1 + 0 Locations @@ -121,6 +127,7 @@ 66 13 1 + 0 Trash @@ -139,6 +146,7 @@ 0 0 0 + 0 New File @@ -150,6 +158,7 @@ 0 0 0 + 0