Added select all and select paragraph features.
This commit is contained in:
+13
-11
@@ -57,16 +57,18 @@ class nwItemAction(Enum):
|
|||||||
|
|
||||||
class nwDocAction(Enum):
|
class nwDocAction(Enum):
|
||||||
|
|
||||||
NONE = 0
|
NONE = 0
|
||||||
UNDO = 1
|
UNDO = 1
|
||||||
REDO = 2
|
REDO = 2
|
||||||
CUT = 3
|
CUT = 3
|
||||||
COPY = 4
|
COPY = 4
|
||||||
PASTE = 5
|
PASTE = 5
|
||||||
BOLD = 6
|
BOLD = 6
|
||||||
ITALIC = 7
|
ITALIC = 7
|
||||||
U_LINE = 8
|
U_LINE = 8
|
||||||
S_QUOTE = 9
|
S_QUOTE = 9
|
||||||
D_QUOTE = 10
|
D_QUOTE = 10
|
||||||
|
SEL_ALL = 11
|
||||||
|
SEL_PARA = 12
|
||||||
|
|
||||||
# END Enum nwDocAction
|
# END Enum nwDocAction
|
||||||
|
|||||||
+19
-10
@@ -113,16 +113,18 @@ class GuiDocEditor(QTextEdit):
|
|||||||
|
|
||||||
def docAction(self, theAction):
|
def docAction(self, theAction):
|
||||||
logger.verbose("Requesting action: %s" % theAction.name)
|
logger.verbose("Requesting action: %s" % theAction.name)
|
||||||
if theAction == nwDocAction.UNDO: self.undo()
|
if theAction == nwDocAction.UNDO: self.undo()
|
||||||
elif theAction == nwDocAction.REDO: self.redo()
|
elif theAction == nwDocAction.REDO: self.redo()
|
||||||
elif theAction == nwDocAction.CUT: self.cut()
|
elif theAction == nwDocAction.CUT: self.cut()
|
||||||
elif theAction == nwDocAction.COPY: self.copy()
|
elif theAction == nwDocAction.COPY: self.copy()
|
||||||
elif theAction == nwDocAction.PASTE: self.paste()
|
elif theAction == nwDocAction.PASTE: self.paste()
|
||||||
elif theAction == nwDocAction.BOLD: self._wrapSelection("**","**")
|
elif theAction == nwDocAction.BOLD: self._wrapSelection("**","**")
|
||||||
elif theAction == nwDocAction.ITALIC: self._wrapSelection("_","_")
|
elif theAction == nwDocAction.ITALIC: self._wrapSelection("_","_")
|
||||||
elif theAction == nwDocAction.U_LINE: self._wrapSelection("__","__")
|
elif theAction == nwDocAction.U_LINE: self._wrapSelection("__","__")
|
||||||
elif theAction == nwDocAction.S_QUOTE: self._wrapSelection(self.typSQOpen,self.typSQClose)
|
elif theAction == nwDocAction.S_QUOTE: self._wrapSelection(self.typSQOpen,self.typSQClose)
|
||||||
elif theAction == nwDocAction.D_QUOTE: self._wrapSelection(self.typDQOpen,self.typDQClose)
|
elif theAction == nwDocAction.D_QUOTE: self._wrapSelection(self.typDQOpen,self.typDQClose)
|
||||||
|
elif theAction == nwDocAction.SEL_ALL: self._makeSelection(QTextCursor.Document)
|
||||||
|
elif theAction == nwDocAction.SEL_PARA: self._makeSelection(QTextCursor.BlockUnderCursor)
|
||||||
else:
|
else:
|
||||||
logger.error("Unknown or unsupported document action %s" % str(theAction))
|
logger.error("Unknown or unsupported document action %s" % str(theAction))
|
||||||
return
|
return
|
||||||
@@ -256,4 +258,11 @@ class GuiDocEditor(QTextEdit):
|
|||||||
logger.warning("No selection made, nothing to do")
|
logger.warning("No selection made, nothing to do")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def _makeSelection(self, selMode):
|
||||||
|
theCursor = self.textCursor()
|
||||||
|
theCursor.clearSelection()
|
||||||
|
theCursor.select(selMode)
|
||||||
|
self.setTextCursor(theCursor)
|
||||||
|
return
|
||||||
|
|
||||||
# END Class GuiDocEditor
|
# END Class GuiDocEditor
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
|||||||
self.colDialD = (184,200, 0,255)
|
self.colDialD = (184,200, 0,255)
|
||||||
self.colDialS = (136,200, 0,255)
|
self.colDialS = (136,200, 0,255)
|
||||||
self.colComm = (150,150,150,255)
|
self.colComm = (150,150,150,255)
|
||||||
self.colKey = (200, 0, 0,255)
|
self.colKey = (200, 46, 0,255)
|
||||||
self.colVal = (184,200, 0,255)
|
self.colVal = (184,200, 0,255)
|
||||||
|
|
||||||
self.hStyles = {
|
self.hStyles = {
|
||||||
|
|||||||
@@ -369,6 +369,23 @@ class GuiMain(QMainWindow):
|
|||||||
# Edit > Separator
|
# Edit > Separator
|
||||||
editMenu.addSeparator()
|
editMenu.addSeparator()
|
||||||
|
|
||||||
|
# Edit > Select All
|
||||||
|
menuItem = QAction(QIcon.fromTheme("edit-select-all"), "Select All", menuBar)
|
||||||
|
menuItem.setStatusTip("Select All Text in Document")
|
||||||
|
menuItem.setShortcut("Ctrl+A")
|
||||||
|
menuItem.triggered.connect(lambda: self.docEditor.docAction(nwDocAction.SEL_ALL))
|
||||||
|
editMenu.addAction(menuItem)
|
||||||
|
|
||||||
|
# Edit > Select Paragraph
|
||||||
|
menuItem = QAction(QIcon.fromTheme("edit-select-all"), "Select Paragraph", menuBar)
|
||||||
|
menuItem.setStatusTip("Select All Text in Paragraph")
|
||||||
|
menuItem.setShortcut("Ctrl+Shift+A")
|
||||||
|
menuItem.triggered.connect(lambda: self.docEditor.docAction(nwDocAction.SEL_PARA))
|
||||||
|
editMenu.addAction(menuItem)
|
||||||
|
|
||||||
|
# Edit > Separator
|
||||||
|
editMenu.addSeparator()
|
||||||
|
|
||||||
# Edit > Settings
|
# Edit > Settings
|
||||||
menuItem = QAction(QIcon.fromTheme("applications-system"), "Program Setting", menuBar)
|
menuItem = QAction(QIcon.fromTheme("applications-system"), "Program Setting", menuBar)
|
||||||
menuItem.setStatusTip("Change %s Settings" % nw.__package__)
|
menuItem.setStatusTip("Change %s Settings" % nw.__package__)
|
||||||
|
|||||||
Reference in New Issue
Block a user