Added Ctrl+Enter as a shortcut for hard line break

This commit is contained in:
Veronica K. B. Olsen
2019-10-28 21:43:05 +01:00
parent 57bc837056
commit 62254e1ec0
4 changed files with 14 additions and 4 deletions
+1 -1
View File
@@ -81,7 +81,7 @@ class ToText(Tokenizer):
if tType == self.T_EMPTY: if tType == self.T_EMPTY:
if len(thisPar) > 0: if len(thisPar) > 0:
tTemp = " ".join(thisPar) tTemp = " ".join(thisPar)
self.theResult += "%s\n\n" % tTemp.rstrip()) self.theResult += "%s\n\n" % tTemp.rstrip()
thisPar = [] thisPar = []
elif tType == self.T_HEAD1: elif tType == self.T_HEAD1:
+9 -1
View File
@@ -81,6 +81,8 @@ class GuiDocEditor(QTextEdit):
# Custom Shortcuts # Custom Shortcuts
QShortcut(QKeySequence("Ctrl+."), self, context=Qt.WidgetShortcut, activated=self._openSpellContext) QShortcut(QKeySequence("Ctrl+."), self, context=Qt.WidgetShortcut, activated=self._openSpellContext)
QShortcut(Qt.Key_Return | Qt.ControlModifier, self, context=Qt.WidgetShortcut, activated=self._insertHardBreak)
QShortcut(Qt.Key_Enter | Qt.ControlModifier, self, context=Qt.WidgetShortcut, activated=self._insertHardBreak)
# Set Up Word Count Thread and Timer # Set Up Word Count Thread and Timer
self.wcInterval = self.mainConf.wordCountTimer self.wcInterval = self.mainConf.wordCountTimer
@@ -323,6 +325,13 @@ class GuiDocEditor(QTextEdit):
# Internal Functions # Internal Functions
## ##
def _insertHardBreak(self):
theCursor = self.textCursor()
theCursor.beginEditBlock()
theCursor.insertText(" \n")
theCursor.endEditBlock()
return
def _openSpellContext(self): def _openSpellContext(self):
self._openContextMenu(self.cursorRect().center()) self._openContextMenu(self.cursorRect().center())
return return
@@ -388,7 +397,6 @@ class GuiDocEditor(QTextEdit):
self.wcTimer.start() self.wcTimer.start()
if self.mainConf.doReplace and not self.hasSelection: if self.mainConf.doReplace and not self.hasSelection:
self._docAutoReplace(self.qDocument.findBlock(thePos)) self._docAutoReplace(self.qDocument.findBlock(thePos))
# logger.verbose("Doc change signal took %.3f µs" % ((time()-self.lastEdit)*1e6))
return return
def _docAutoReplace(self, theBlock): def _docAutoReplace(self, theBlock):
@@ -14,3 +14,5 @@ With many cheerful facts about the square of the hypotenuse
With many cheerful facts about the square of the hypotenuse With many cheerful facts about the square of the hypotenuse
With many cheerful facts about the square of the hypotepotenuse With many cheerful facts about the square of the hypotepotenuse
+2 -2
View File
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="0.3.2" fileVersion="1.0" timeStamp="2019-10-28 21:28:10"> <novelWriterXML appVersion="0.3.2" fileVersion="1.0" timeStamp="2019-10-28 21:42:26">
<project> <project>
<name>Sample Project</name> <name>Sample Project</name>
<title>Sample Project</title> <title>Sample Project</title>
@@ -103,7 +103,7 @@
<status>Finished</status> <status>Finished</status>
<expanded>False</expanded> <expanded>False</expanded>
<layout>UNNUMBERED</layout> <layout>UNNUMBERED</layout>
<charCount>628</charCount> <charCount>626</charCount>
<wordCount>101</wordCount> <wordCount>101</wordCount>
<paraCount>3</paraCount> <paraCount>3</paraCount>
<cursorPos>583</cursorPos> <cursorPos>583</cursorPos>