- working on adding line numbers to the TextPlainEdit

This commit is contained in:
Marius Stanciu
2019-11-22 11:00:39 +02:00
committed by Marius
parent 67d31982ef
commit 0aff3a6d4c
4 changed files with 9 additions and 9 deletions

View File

@@ -5072,13 +5072,13 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
with self.app.proc_container.new(_("Generating CNC Code")): with self.app.proc_container.new(_("Generating CNC Code")):
if app_obj.new_object("cncjob", outname, job_init_single_geometry, plot=plot) != 'fail': if app_obj.new_object("cncjob", outname, job_init_single_geometry, plot=plot) != 'fail':
app_obj.inform.emit('[success] %s: %s' % app_obj.inform.emit('[success] %s: %s' %
(_("CNCjob created")), outname) (_("CNCjob created"), outname))
app_obj.progress.emit(100) app_obj.progress.emit(100)
else: else:
with self.app.proc_container.new(_("Generating CNC Code")): with self.app.proc_container.new(_("Generating CNC Code")):
if app_obj.new_object("cncjob", outname, job_init_multi_geometry) != 'fail': if app_obj.new_object("cncjob", outname, job_init_multi_geometry) != 'fail':
app_obj.inform.emit('[success] %s: %s' % app_obj.inform.emit('[success] %s: %s' %
(_("CNCjob created")), outname) (_("CNCjob created"), outname))
app_obj.progress.emit(100) app_obj.progress.emit(100)
# Create a promise with the name # Create a promise with the name

View File

@@ -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 - added GUI in Preferences and entries in self.defaults dict
- Tool Fiducials - updated the source_file object for the modified Gerber files - Tool Fiducials - updated the source_file object for the modified Gerber files
- working on adding line numbers to the TextPlainEdit
21.11.2019 21.11.2019

View File

@@ -40,7 +40,9 @@ class TextEditor(QtWidgets.QWidget):
self.t_frame.setLayout(self.work_editor_layout) self.t_frame.setLayout(self.work_editor_layout)
if plain_text: if plain_text:
self.code_editor = FCPlainTextAreaExtended() self.editor_class = FCTextAreaLineNumber()
self.code_editor = self.editor_class.edit
stylesheet = """ stylesheet = """
QPlainTextEdit { selection-background-color:yellow; QPlainTextEdit { selection-background-color:yellow;
selection-color:black; selection-color:black;

View File

@@ -2341,7 +2341,7 @@ class MyCompleter(QCompleter):
return self.lastSelected return self.lastSelected
class LNTextEdit(QtWidgets.QFrame): class FCTextAreaLineNumber(QtWidgets.QFrame):
textChanged = QtCore.pyqtSignal() textChanged = QtCore.pyqtSignal()
class NumberBar(QtWidgets.QWidget): class NumberBar(QtWidgets.QWidget):
@@ -2372,14 +2372,14 @@ class LNTextEdit(QtWidgets.QFrame):
# selected. # selected.
self.update() self.update()
class PlainTextEdit(QtWidgets.QPlainTextEdit): class PlainTextEdit(FCPlainTextAreaExtended):
""" """
TextEdit with line numbers and highlight TextEdit with line numbers and highlight
From here: https://nachtimwald.com/2009/08/19/better-qplaintextedit-with-line-numbers/ From here: https://nachtimwald.com/2009/08/19/better-qplaintextedit-with-line-numbers/
""" """
def __init__(self, *args): def __init__(self, *args):
QtWidgets.QPlainTextEdit.__init__(self, *args) FCPlainTextAreaExtended.__init__(self, *args)
#self.setFrameStyle(QFrame.NoFrame) #self.setFrameStyle(QFrame.NoFrame)
@@ -2453,9 +2453,6 @@ class LNTextEdit(QtWidgets.QFrame):
self.edit.blockCountChanged.connect(self.number_bar.adjustWidth) self.edit.blockCountChanged.connect(self.number_bar.adjustWidth)
self.edit.updateRequest.connect(self.number_bar.updateContents) self.edit.updateRequest.connect(self.number_bar.updateContents)
def set_model_data(self, kwd):
pass
def getText(self): def getText(self):
return str(self.edit.toPlainText()) return str(self.edit.toPlainText())