Changeset f2e199e in sasview for src/sas/qtgui/Utilities/PythonSyntax.py
- Timestamp:
- Nov 22, 2018 3: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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.