author | Laurent Bessard |
Wed, 08 May 2013 23:13:10 +0200 | |
changeset 1100 | 1f46424c6220 |
parent 1097 | 233681f2a00e |
child 1110 | b6e252733c64 |
permissions | -rw-r--r-- |
1057
3837e165b3f9
Added support for search in PythonEditor and IECCodeViewer
Laurent Bessard
parents:
920
diff
changeset
|
1 |
import keyword |
3837e165b3f9
Added support for search in PythonEditor and IECCodeViewer
Laurent Bessard
parents:
920
diff
changeset
|
2 |
import wx.stc as stc |
3837e165b3f9
Added support for search in PythonEditor and IECCodeViewer
Laurent Bessard
parents:
920
diff
changeset
|
3 |
|
1097 | 4 |
from controls.CustomStyledTextCtrl import faces |
5 |
from editors.CodeFileEditor import CodeFileEditor, CodeEditor |
|
657
340c0b9caeca
Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents:
654
diff
changeset
|
6 |
|
1097 | 7 |
class PythonCodeEditor(CodeEditor): |
1057
3837e165b3f9
Added support for search in PythonEditor and IECCodeViewer
Laurent Bessard
parents:
920
diff
changeset
|
8 |
|
1097 | 9 |
KEYWORDS = keyword.kwlist |
10 |
COMMENT_HEADER = "##" |
|
11 |
||
12 |
def SetCodeLexer(self): |
|
13 |
self.SetLexer(stc.STC_LEX_PYTHON) |
|
14 |
||
15 |
# Line numbers in margin |
|
16 |
self.StyleSetSpec(stc.STC_STYLE_LINENUMBER,'fore:#000000,back:#99A9C2,size:%(size)d' % faces) |
|
17 |
# Highlighted brace |
|
18 |
self.StyleSetSpec(stc.STC_STYLE_BRACELIGHT,'fore:#00009D,back:#FFFF00,size:%(size)d' % faces) |
|
19 |
# Unmatched brace |
|
20 |
self.StyleSetSpec(stc.STC_STYLE_BRACEBAD,'fore:#00009D,back:#FF0000,size:%(size)d' % faces) |
|
21 |
# Indentation guide |
|
22 |
self.StyleSetSpec(stc.STC_STYLE_INDENTGUIDE, 'fore:#CDCDCD,size:%(size)d' % faces) |
|
1057
3837e165b3f9
Added support for search in PythonEditor and IECCodeViewer
Laurent Bessard
parents:
920
diff
changeset
|
23 |
|
1097 | 24 |
# Python styles |
25 |
self.StyleSetSpec(stc.STC_P_DEFAULT, 'fore:#000000,size:%(size)d' % faces) |
|
26 |
# Comments |
|
27 |
self.StyleSetSpec(stc.STC_P_COMMENTLINE, 'fore:#008000,back:#F0FFF0,size:%(size)d' % faces) |
|
28 |
self.StyleSetSpec(stc.STC_P_COMMENTBLOCK, 'fore:#008000,back:#F0FFF0,size:%(size)d' % faces) |
|
29 |
# Numbers |
|
30 |
self.StyleSetSpec(stc.STC_P_NUMBER, 'fore:#008080,size:%(size)d' % faces) |
|
31 |
# Strings and characters |
|
32 |
self.StyleSetSpec(stc.STC_P_STRING, 'fore:#800080,size:%(size)d' % faces) |
|
33 |
self.StyleSetSpec(stc.STC_P_CHARACTER, 'fore:#800080,size:%(size)d' % faces) |
|
34 |
# Keywords |
|
35 |
self.StyleSetSpec(stc.STC_P_WORD, 'fore:#000080,bold,size:%(size)d' % faces) |
|
36 |
# Triple quotes |
|
37 |
self.StyleSetSpec(stc.STC_P_TRIPLE, 'fore:#800080,back:#FFFFEA,size:%(size)d' % faces) |
|
38 |
self.StyleSetSpec(stc.STC_P_TRIPLEDOUBLE, 'fore:#800080,back:#FFFFEA,size:%(size)d' % faces) |
|
39 |
# Class names |
|
40 |
self.StyleSetSpec(stc.STC_P_CLASSNAME, 'fore:#0000FF,bold,size:%(size)d' % faces) |
|
41 |
# Function names |
|
42 |
self.StyleSetSpec(stc.STC_P_DEFNAME, 'fore:#008080,bold,size:%(size)d' % faces) |
|
43 |
# Operators |
|
44 |
self.StyleSetSpec(stc.STC_P_OPERATOR, 'fore:#800000,bold,size:%(size)d' % faces) |
|
45 |
# Identifiers. I leave this as not bold because everything seems |
|
46 |
# to be an identifier if it doesn't match the above criterae |
|
47 |
self.StyleSetSpec(stc.STC_P_IDENTIFIER, 'fore:#000000,size:%(size)d' % faces) |
|
48 |
||
366
cd90e4c10261
Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff
changeset
|
49 |
|
1097 | 50 |
#------------------------------------------------------------------------------- |
51 |
# CFileEditor Main Frame Class |
|
52 |
#------------------------------------------------------------------------------- |
|
366
cd90e4c10261
Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff
changeset
|
53 |
|
1097 | 54 |
class PythonEditor(CodeFileEditor): |
55 |
||
56 |
CONFNODEEDITOR_TABS = CodeFileEditor.CONFNODEEDITOR_TABS + [ |
|
920
1499a4d225db
Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents:
814
diff
changeset
|
57 |
(_("Python code"), "_create_PythonCodeEditor")] |
1499a4d225db
Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents:
814
diff
changeset
|
58 |
|
1499a4d225db
Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents:
814
diff
changeset
|
59 |
def _create_PythonCodeEditor(self, prnt): |
1097 | 60 |
self.PythonCodeEditor = PythonCodeEditor(prnt, self.ParentWindow, self.Controler) |
920
1499a4d225db
Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents:
814
diff
changeset
|
61 |
|
1499a4d225db
Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents:
814
diff
changeset
|
62 |
return self.PythonCodeEditor |
657
340c0b9caeca
Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents:
654
diff
changeset
|
63 |
|
1097 | 64 |
def RefreshView(self): |
65 |
CodeFileEditor.RefreshView(self) |
|
657
340c0b9caeca
Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents:
654
diff
changeset
|
66 |
|
1097 | 67 |
self.PythonCodeEditor.RefreshView() |
1057
3837e165b3f9
Added support for search in PythonEditor and IECCodeViewer
Laurent Bessard
parents:
920
diff
changeset
|
68 |
|
3837e165b3f9
Added support for search in PythonEditor and IECCodeViewer
Laurent Bessard
parents:
920
diff
changeset
|
69 |
def Find(self, direction, search_params): |
1097 | 70 |
self.PythonCodeEditor.Find(direction, search_params) |