Changeset f2e199e in sasview
- Timestamp:
- Nov 22, 2018 1:47:13 AM (6 years ago)
- Branches:
- ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- 72651df
- Parents:
- 21e71f1
- Location:
- src/sas/qtgui/Utilities
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Utilities/ModelEditor.py
r3933ee9 rf2e199e 12 12 """ 13 13 modelModified = QtCore.pyqtSignal() 14 def __init__(self, parent=None ):14 def __init__(self, parent=None, is_python=True): 15 15 super(ModelEditor, self).__init__(parent) 16 16 self.setupUi(self) 17 18 self.is_python = is_python 17 19 18 20 self.setupWidgets() … … 29 31 # DO NOT MOVE TO TOP 30 32 from sas.qtgui.Utilities.PythonSyntax import PythonHighlighter 31 self.highlight = PythonHighlighter(self.txtEditor.document() )33 self.highlight = PythonHighlighter(self.txtEditor.document(), is_python=self.is_python) 32 34 33 35 self.txtEditor.setFont(GuiUtils.getMonospaceFont()) -
src/sas/qtgui/Utilities/PythonSyntax.py
r8b480d27 rf2e199e 36 36 """ 37 37 # Python keywords 38 keywords = [38 python_keywords = [ 39 39 'and', 'assert', 'break', 'class', 'continue', 'def', 40 40 'del', 'elif', 'else', 'except', 'exec', 'finally', … … 43 43 'raise', 'return', 'try', 'while', 'yield', 44 44 'None', 'True', 'False', 45 ] 46 47 # C keywords 48 c_keywords = [ 49 'auto', 'break', 'case', 'char', 50 'const', 'continue', 'default', 'do', 51 'double', 'else', 'enum', 'extern', 52 'float', 'for', 'goto', 'if', 53 'int', 'long', 'register', 'return', 54 'short', 'signed', 'sizeof', 'static', 55 'struct', 'switch', 'typedef', 'union', 56 'unsigned', 'void', 'volatile', 'while' 45 57 ] 46 58 … … 62 74 '\{', '\}', '\(', '\)', '\[', '\]', 63 75 ] 64 def __init__(self, document ):76 def __init__(self, document, is_python=True): 65 77 QSyntaxHighlighter.__init__(self, document) 66 78 … … 74 86 75 87 # Keyword, operator, and brace rules 88 keywords = PythonHighlighter.python_keywords if is_python \ 89 else PythonHighlighter.c_keywords 76 90 rules += [(r'\b%s\b' % w, 0, STYLES['keyword']) 77 for w in PythonHighlighter.keywords]91 for w in keywords] 78 92 rules += [(r'%s' % o, 0, STYLES['operator']) 79 93 for o in PythonHighlighter.operators] … … 104 118 (r'\b[+-]?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\b', 0, STYLES['numbers']), 105 119 ] 120 # Add "//" to comments for C 121 if not is_python: 122 rules.append((r'//[^\n]*', 0, STYLES['comment']),) 106 123 107 124 # Build a QRegExp for each pattern -
src/sas/qtgui/Utilities/TabbedModelEditor.py
rc5e0d84 rf2e199e 117 117 return 118 118 119 # remove c-plugin tab, if present. 120 if self.tabWidget.count()>1: 121 self.tabWidget.removeTab(1) 119 122 self.loadFile(filename) 120 123 … … 130 133 self.filename = filename 131 134 display_name, _ = os.path.splitext(os.path.basename(filename)) 132 133 135 self.setWindowTitle(self.window_title + " - " + display_name) 136 # Name the tab with .py filename 137 display_name = os.path.basename(filename) 138 self.tabWidget.setTabText(0, display_name) 139 140 # See if there is filename.c present 141 c_path = self.filename.replace(".py", ".c") 142 if not os.path.isfile(c_path): return 143 # add a tab with the same highlighting 144 display_name = os.path.basename(c_path) 145 self.c_editor_widget = ModelEditor(self, is_python=False) 146 self.tabWidget.addTab(self.c_editor_widget, display_name) 147 # Read in the file and set in on the widget 148 with open(c_path, 'r') as plugin: 149 self.c_editor_widget.txtEditor.setPlainText(plugin.read()) 150 self.c_editor_widget.modelModified.connect(self.editorModelModified) 134 151 135 152 def onModifiedExit(self):
Note: See TracChangeset
for help on using the changeset viewer.