From 0aff3a6d4c708ee1e589843a9b212b7b76c88339 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Fri, 22 Nov 2019 11:00:39 +0200 Subject: [PATCH] - working on adding line numbers to the TextPlainEdit --- FlatCAMObj.py | 4 ++-- README.md | 1 + flatcamEditors/FlatCAMTextEditor.py | 4 +++- flatcamGUI/GUIElements.py | 9 +++------ 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/FlatCAMObj.py b/FlatCAMObj.py index 2ae03215..7e6ad524 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -5072,13 +5072,13 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): with self.app.proc_container.new(_("Generating CNC Code")): if app_obj.new_object("cncjob", outname, job_init_single_geometry, plot=plot) != 'fail': app_obj.inform.emit('[success] %s: %s' % - (_("CNCjob created")), outname) + (_("CNCjob created"), outname)) app_obj.progress.emit(100) else: with self.app.proc_container.new(_("Generating CNC Code")): if app_obj.new_object("cncjob", outname, job_init_multi_geometry) != 'fail': app_obj.inform.emit('[success] %s: %s' % - (_("CNCjob created")), outname) + (_("CNCjob created"), outname)) app_obj.progress.emit(100) # Create a promise with the name diff --git a/README.md b/README.md index f5ae1a93..2414ee74 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ CAD program, and create G-Code for Isolation routing. - Tool Fiducials - added GUI in Preferences and entries in self.defaults dict - Tool Fiducials - updated the source_file object for the modified Gerber files +- working on adding line numbers to the TextPlainEdit 21.11.2019 diff --git a/flatcamEditors/FlatCAMTextEditor.py b/flatcamEditors/FlatCAMTextEditor.py index fd7ab3e5..24ddca52 100644 --- a/flatcamEditors/FlatCAMTextEditor.py +++ b/flatcamEditors/FlatCAMTextEditor.py @@ -40,7 +40,9 @@ class TextEditor(QtWidgets.QWidget): self.t_frame.setLayout(self.work_editor_layout) if plain_text: - self.code_editor = FCPlainTextAreaExtended() + self.editor_class = FCTextAreaLineNumber() + self.code_editor = self.editor_class.edit + stylesheet = """ QPlainTextEdit { selection-background-color:yellow; selection-color:black; diff --git a/flatcamGUI/GUIElements.py b/flatcamGUI/GUIElements.py index f98039f9..89ae9d5c 100644 --- a/flatcamGUI/GUIElements.py +++ b/flatcamGUI/GUIElements.py @@ -2341,7 +2341,7 @@ class MyCompleter(QCompleter): return self.lastSelected -class LNTextEdit(QtWidgets.QFrame): +class FCTextAreaLineNumber(QtWidgets.QFrame): textChanged = QtCore.pyqtSignal() class NumberBar(QtWidgets.QWidget): @@ -2372,14 +2372,14 @@ class LNTextEdit(QtWidgets.QFrame): # selected. self.update() - class PlainTextEdit(QtWidgets.QPlainTextEdit): + class PlainTextEdit(FCPlainTextAreaExtended): """ TextEdit with line numbers and highlight From here: https://nachtimwald.com/2009/08/19/better-qplaintextedit-with-line-numbers/ """ def __init__(self, *args): - QtWidgets.QPlainTextEdit.__init__(self, *args) + FCPlainTextAreaExtended.__init__(self, *args) #self.setFrameStyle(QFrame.NoFrame) @@ -2453,9 +2453,6 @@ class LNTextEdit(QtWidgets.QFrame): self.edit.blockCountChanged.connect(self.number_bar.adjustWidth) self.edit.updateRequest.connect(self.number_bar.updateContents) - def set_model_data(self, kwd): - pass - def getText(self): return str(self.edit.toPlainText())