26 import wx.stc as stc |
26 import wx.stc as stc |
27 |
27 |
28 from controls.CustomStyledTextCtrl import faces |
28 from controls.CustomStyledTextCtrl import faces |
29 from editors.CodeFileEditor import CodeFileEditor, CodeEditor |
29 from editors.CodeFileEditor import CodeFileEditor, CodeEditor |
30 |
30 |
|
31 |
31 class PythonCodeEditor(CodeEditor): |
32 class PythonCodeEditor(CodeEditor): |
32 |
33 |
33 KEYWORDS = keyword.kwlist |
34 KEYWORDS = keyword.kwlist |
34 COMMENT_HEADER = "#" |
35 COMMENT_HEADER = "#" |
35 |
36 |
36 def SetCodeLexer(self): |
37 def SetCodeLexer(self): |
37 self.SetLexer(stc.STC_LEX_PYTHON) |
38 self.SetLexer(stc.STC_LEX_PYTHON) |
38 |
39 |
39 # Line numbers in margin |
40 # Line numbers in margin |
40 self.StyleSetSpec(stc.STC_STYLE_LINENUMBER,'fore:#000000,back:#99A9C2,size:%(size)d' % faces) |
41 self.StyleSetSpec(stc.STC_STYLE_LINENUMBER, 'fore:#000000,back:#99A9C2,size:%(size)d' % faces) |
41 # Highlighted brace |
42 # Highlighted brace |
42 self.StyleSetSpec(stc.STC_STYLE_BRACELIGHT,'fore:#00009D,back:#FFFF00,size:%(size)d' % faces) |
43 self.StyleSetSpec(stc.STC_STYLE_BRACELIGHT, 'fore:#00009D,back:#FFFF00,size:%(size)d' % faces) |
43 # Unmatched brace |
44 # Unmatched brace |
44 self.StyleSetSpec(stc.STC_STYLE_BRACEBAD,'fore:#00009D,back:#FF0000,size:%(size)d' % faces) |
45 self.StyleSetSpec(stc.STC_STYLE_BRACEBAD, 'fore:#00009D,back:#FF0000,size:%(size)d' % faces) |
45 # Indentation guide |
46 # Indentation guide |
46 self.StyleSetSpec(stc.STC_STYLE_INDENTGUIDE, 'fore:#CDCDCD,size:%(size)d' % faces) |
47 self.StyleSetSpec(stc.STC_STYLE_INDENTGUIDE, 'fore:#CDCDCD,size:%(size)d' % faces) |
47 |
48 |
48 # Python styles |
49 # Python styles |
49 self.StyleSetSpec(stc.STC_P_DEFAULT, 'fore:#000000,size:%(size)d' % faces) |
50 self.StyleSetSpec(stc.STC_P_DEFAULT, 'fore:#000000,size:%(size)d' % faces) |
67 # Operators |
68 # Operators |
68 self.StyleSetSpec(stc.STC_P_OPERATOR, 'fore:#800000,bold,size:%(size)d' % faces) |
69 self.StyleSetSpec(stc.STC_P_OPERATOR, 'fore:#800000,bold,size:%(size)d' % faces) |
69 # Identifiers. I leave this as not bold because everything seems |
70 # Identifiers. I leave this as not bold because everything seems |
70 # to be an identifier if it doesn't match the above criterae |
71 # to be an identifier if it doesn't match the above criterae |
71 self.StyleSetSpec(stc.STC_P_IDENTIFIER, 'fore:#000000,size:%(size)d' % faces) |
72 self.StyleSetSpec(stc.STC_P_IDENTIFIER, 'fore:#000000,size:%(size)d' % faces) |
72 |
|
73 |
73 |
74 #------------------------------------------------------------------------------- |
74 |
|
75 # ------------------------------------------------------------------------------- |
75 # CFileEditor Main Frame Class |
76 # CFileEditor Main Frame Class |
76 #------------------------------------------------------------------------------- |
77 # ------------------------------------------------------------------------------- |
77 |
78 |
78 class PythonEditor(CodeFileEditor): |
79 class PythonEditor(CodeFileEditor): |
79 |
80 |
80 CONFNODEEDITOR_TABS = [ |
81 CONFNODEEDITOR_TABS = [ |
81 (_("Python code"), "_create_CodePanel")] |
82 (_("Python code"), "_create_CodePanel")] |
82 CODE_EDITOR = PythonCodeEditor |
83 CODE_EDITOR = PythonCodeEditor |
83 |
|