py_ext/PythonEditor.py
author laurent
Mon, 21 May 2012 18:56:44 +0200
changeset 743 4645a3a398ad
parent 738 413946c04c87
child 751 a8dace95f965
permissions -rw-r--r--
Fix bugs with ConfigTreeNode
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
     1
import wx
413946c04c87 refactoring
laurent
parents: 734
diff changeset
     2
import wx.grid
413946c04c87 refactoring
laurent
parents: 734
diff changeset
     3
import wx.stc  as  stc
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
     4
import keyword
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
     5
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
     6
from ConfTreeNodeEditor import ConfTreeNodeEditor
657
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
     7
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
     8
if wx.Platform == '__WXMSW__':
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
     9
    faces = { 'times': 'Times New Roman',
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    10
              'mono' : 'Courier New',
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    11
              'helv' : 'Arial',
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    12
              'other': 'Comic Sans MS',
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    13
              'size' : 10,
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    14
              'size2': 8,
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    15
             }
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    16
elif wx.Platform == '__WXMAC__':
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    17
    faces = { 'times': 'Times New Roman',
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    18
              'mono' : 'Monaco',
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    19
              'helv' : 'Arial',
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    20
              'other': 'Comic Sans MS',
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    21
              'size' : 12,
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    22
              'size2': 10,
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    23
             }
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    24
else:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    25
    faces = { 'times': 'Times',
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    26
              'mono' : 'Courier',
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    27
              'helv' : 'Helvetica',
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    28
              'other': 'new century schoolbook',
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    29
              'size' : 12,
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    30
              'size2': 10,
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    31
             }
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    32
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    33
[ID_PYTHONEDITOR,
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    34
] = [wx.NewId() for _init_ctrls in range(1)]
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    35
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    36
def GetCursorPos(old, new):
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    37
    old_length = len(old)
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    38
    new_length = len(new)
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    39
    common_length = min(old_length, new_length)
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    40
    i = 0
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    41
    for i in xrange(common_length):
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    42
        if old[i] != new[i]:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    43
            break
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    44
    if old_length < new_length:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    45
        if common_length > 0 and old[i] != new[i]:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    46
            return i + new_length - old_length
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    47
        else:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    48
            return i + new_length - old_length + 1
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    49
    elif old_length > new_length or i < min(old_length, new_length) - 1:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    50
        if common_length > 0 and old[i] != new[i]:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    51
            return i
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    52
        else:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    53
            return i + 1
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    54
    else:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    55
        return None
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    56
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    57
class PythonEditor(ConfTreeNodeEditor):
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    58
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    59
    fold_symbols = 3
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    60
    
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    61
    def _init_ConfNodeEditor(self, prnt):
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    62
        self.ConfNodeEditor = stc.StyledTextCtrl(id=ID_PYTHONEDITOR, parent=prnt,
657
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
    63
                 name="TextViewer", pos=wx.DefaultPosition, 
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
    64
                 size=wx.DefaultSize, style=0)
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
    65
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    66
        self.ConfNodeEditor.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN)
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    67
        self.ConfNodeEditor.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    68
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    69
        self.ConfNodeEditor.SetLexer(stc.STC_LEX_PYTHON)
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    70
        self.ConfNodeEditor.SetKeyWords(0, " ".join(keyword.kwlist))
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    71
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    72
        self.ConfNodeEditor.SetProperty("fold", "1")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    73
        self.ConfNodeEditor.SetProperty("tab.timmy.whinge.level", "1")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    74
        self.ConfNodeEditor.SetMargins(0,0)
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    75
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    76
        self.ConfNodeEditor.SetViewWhiteSpace(False)
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    77
        
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    78
        self.ConfNodeEditor.SetEdgeMode(stc.STC_EDGE_BACKGROUND)
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    79
        self.ConfNodeEditor.SetEdgeColumn(78)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    80
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    81
        # Set up the numbers in the margin for margin #1
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    82
        self.ConfNodeEditor.SetMarginType(1, wx.stc.STC_MARGIN_NUMBER)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    83
        # Reasonable value for, say, 4-5 digits using a mono font (40 pix)
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    84
        self.ConfNodeEditor.SetMarginWidth(1, 40)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    85
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    86
        # Setup a margin to hold fold markers
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    87
        self.ConfNodeEditor.SetMarginType(2, stc.STC_MARGIN_SYMBOL)
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    88
        self.ConfNodeEditor.SetMarginMask(2, stc.STC_MASK_FOLDERS)
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    89
        self.ConfNodeEditor.SetMarginSensitive(2, True)
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    90
        self.ConfNodeEditor.SetMarginWidth(2, 12)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    91
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    92
        if self.fold_symbols == 0:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    93
            # Arrow pointing right for contracted folders, arrow pointing down for expanded
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    94
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN,    stc.STC_MARK_ARROWDOWN, "black", "black")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    95
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDER,        stc.STC_MARK_ARROW, "black", "black")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    96
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB,     stc.STC_MARK_EMPTY, "black", "black")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    97
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL,    stc.STC_MARK_EMPTY, "black", "black")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    98
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDEREND,     stc.STC_MARK_EMPTY,     "white", "black")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
    99
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID, stc.STC_MARK_EMPTY,     "white", "black")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   100
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL, stc.STC_MARK_EMPTY,     "white", "black")
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   101
            
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   102
        elif self.fold_symbols == 1:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   103
            # Plus for contracted folders, minus for expanded
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   104
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN,    stc.STC_MARK_MINUS, "white", "black")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   105
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDER,        stc.STC_MARK_PLUS,  "white", "black")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   106
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB,     stc.STC_MARK_EMPTY, "white", "black")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   107
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL,    stc.STC_MARK_EMPTY, "white", "black")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   108
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDEREND,     stc.STC_MARK_EMPTY, "white", "black")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   109
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID, stc.STC_MARK_EMPTY, "white", "black")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   110
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL, stc.STC_MARK_EMPTY, "white", "black")
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   111
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   112
        elif self.fold_symbols == 2:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   113
            # Like a flattened tree control using circular headers and curved joins
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   114
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN,    stc.STC_MARK_CIRCLEMINUS,          "white", "#404040")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   115
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDER,        stc.STC_MARK_CIRCLEPLUS,           "white", "#404040")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   116
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB,     stc.STC_MARK_VLINE,                "white", "#404040")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   117
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL,    stc.STC_MARK_LCORNERCURVE,         "white", "#404040")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   118
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDEREND,     stc.STC_MARK_CIRCLEPLUSCONNECTED,  "white", "#404040")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   119
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID, stc.STC_MARK_CIRCLEMINUSCONNECTED, "white", "#404040")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   120
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL, stc.STC_MARK_TCORNERCURVE,         "white", "#404040")
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   121
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   122
        elif self.fold_symbols == 3:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   123
            # Like a flattened tree control using square headers
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   124
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN,    stc.STC_MARK_BOXMINUS,          "white", "#808080")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   125
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDER,        stc.STC_MARK_BOXPLUS,           "white", "#808080")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   126
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB,     stc.STC_MARK_VLINE,             "white", "#808080")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   127
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL,    stc.STC_MARK_LCORNER,           "white", "#808080")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   128
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDEREND,     stc.STC_MARK_BOXPLUSCONNECTED,  "white", "#808080")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   129
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID, stc.STC_MARK_BOXMINUSCONNECTED, "white", "#808080")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   130
            self.ConfNodeEditor.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL, stc.STC_MARK_TCORNER,           "white", "#808080")
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   131
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   132
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   133
        self.ConfNodeEditor.Bind(stc.EVT_STC_UPDATEUI, self.OnUpdateUI)
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   134
        self.ConfNodeEditor.Bind(stc.EVT_STC_MARGINCLICK, self.OnMarginClick)
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   135
        self.ConfNodeEditor.Bind(wx.EVT_KEY_DOWN, self.OnKeyPressed)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   136
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   137
        # Global default style
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   138
        if wx.Platform == '__WXMSW__':
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   139
            self.ConfNodeEditor.StyleSetSpec(stc.STC_STYLE_DEFAULT, 'fore:#000000,back:#FFFFFF,face:Courier New')
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   140
        elif wx.Platform == '__WXMAC__':
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   141
            # TODO: if this looks fine on Linux too, remove the Mac-specific case 
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   142
            # and use this whenever OS != MSW.
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   143
            self.ConfNodeEditor.StyleSetSpec(stc.STC_STYLE_DEFAULT, 'fore:#000000,back:#FFFFFF,face:Monaco')
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   144
        else:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   145
            defsize = wx.SystemSettings.GetFont(wx.SYS_ANSI_FIXED_FONT).GetPointSize()
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   146
            self.ConfNodeEditor.StyleSetSpec(stc.STC_STYLE_DEFAULT, 'fore:#000000,back:#FFFFFF,face:Courier,size:%d'%defsize)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   147
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   148
        # Clear styles and revert to default.
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   149
        self.ConfNodeEditor.StyleClearAll()
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   150
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   151
        # Following style specs only indicate differences from default.
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   152
        # The rest remains unchanged.
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   153
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   154
        # Line numbers in margin
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   155
        self.ConfNodeEditor.StyleSetSpec(wx.stc.STC_STYLE_LINENUMBER,'fore:#000000,back:#99A9C2')    
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   156
        # Highlighted brace
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   157
        self.ConfNodeEditor.StyleSetSpec(wx.stc.STC_STYLE_BRACELIGHT,'fore:#00009D,back:#FFFF00')
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   158
        # Unmatched brace
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   159
        self.ConfNodeEditor.StyleSetSpec(wx.stc.STC_STYLE_BRACEBAD,'fore:#00009D,back:#FF0000')
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   160
        # Indentation guide
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   161
        self.ConfNodeEditor.StyleSetSpec(wx.stc.STC_STYLE_INDENTGUIDE, "fore:#CDCDCD")
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   162
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   163
        # Python styles
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   164
        self.ConfNodeEditor.StyleSetSpec(wx.stc.STC_P_DEFAULT, 'fore:#000000')
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   165
        # Comments
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   166
        self.ConfNodeEditor.StyleSetSpec(wx.stc.STC_P_COMMENTLINE,  'fore:#008000,back:#F0FFF0')
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   167
        self.ConfNodeEditor.StyleSetSpec(wx.stc.STC_P_COMMENTBLOCK, 'fore:#008000,back:#F0FFF0')
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   168
        # Numbers
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   169
        self.ConfNodeEditor.StyleSetSpec(wx.stc.STC_P_NUMBER, 'fore:#008080')
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   170
        # Strings and characters
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   171
        self.ConfNodeEditor.StyleSetSpec(wx.stc.STC_P_STRING, 'fore:#800080')
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   172
        self.ConfNodeEditor.StyleSetSpec(wx.stc.STC_P_CHARACTER, 'fore:#800080')
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   173
        # Keywords
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   174
        self.ConfNodeEditor.StyleSetSpec(wx.stc.STC_P_WORD, 'fore:#000080,bold')
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   175
        # Triple quotes
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   176
        self.ConfNodeEditor.StyleSetSpec(wx.stc.STC_P_TRIPLE, 'fore:#800080,back:#FFFFEA')
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   177
        self.ConfNodeEditor.StyleSetSpec(wx.stc.STC_P_TRIPLEDOUBLE, 'fore:#800080,back:#FFFFEA')
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   178
        # Class names
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   179
        self.ConfNodeEditor.StyleSetSpec(wx.stc.STC_P_CLASSNAME, 'fore:#0000FF,bold')
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   180
        # Function names
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   181
        self.ConfNodeEditor.StyleSetSpec(wx.stc.STC_P_DEFNAME, 'fore:#008080,bold')
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   182
        # Operators
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   183
        self.ConfNodeEditor.StyleSetSpec(wx.stc.STC_P_OPERATOR, 'fore:#800000,bold')
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   184
        # Identifiers. I leave this as not bold because everything seems
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   185
        # to be an identifier if it doesn't match the above criterae
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   186
        self.ConfNodeEditor.StyleSetSpec(wx.stc.STC_P_IDENTIFIER, 'fore:#000000')
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   187
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   188
        # Caret color
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   189
        self.ConfNodeEditor.SetCaretForeground("BLUE")
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   190
        # Selection background
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   191
        self.ConfNodeEditor.SetSelBackground(1, '#66CCFF')
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   192
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   193
        self.ConfNodeEditor.SetSelBackground(True, wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHT))
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   194
        self.ConfNodeEditor.SetSelForeground(True, wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHTTEXT))
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   195
        
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   196
        # register some images for use in the AutoComplete box.
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   197
        #self.RegisterImage(1, images.getSmilesBitmap())
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   198
        self.ConfNodeEditor.RegisterImage(1, 
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   199
            wx.ArtProvider.GetBitmap(wx.ART_DELETE, size=(16,16)))
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   200
        self.ConfNodeEditor.RegisterImage(2, 
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   201
            wx.ArtProvider.GetBitmap(wx.ART_NEW, size=(16,16)))
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   202
        self.ConfNodeEditor.RegisterImage(3, 
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   203
            wx.ArtProvider.GetBitmap(wx.ART_COPY, size=(16,16)))
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   204
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   205
        # Indentation and tab stuff
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   206
        self.ConfNodeEditor.SetIndent(4)               # Proscribed indent size for wx
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   207
        self.ConfNodeEditor.SetIndentationGuides(True) # Show indent guides
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   208
        self.ConfNodeEditor.SetBackSpaceUnIndents(True)# Backspace unindents rather than delete 1 space
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   209
        self.ConfNodeEditor.SetTabIndents(True)        # Tab key indents
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   210
        self.ConfNodeEditor.SetTabWidth(4)             # Proscribed tab size for wx
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   211
        self.ConfNodeEditor.SetUseTabs(False)          # Use spaces rather than tabs, or
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   212
                                        # TabTimmy will complain!    
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   213
        # White space
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   214
        self.ConfNodeEditor.SetViewWhiteSpace(False)   # Don't view white space
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   215
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   216
        # EOL: Since we are loading/saving ourselves, and the
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   217
        # strings will always have \n's in them, set the STC to
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   218
        # edit them that way.            
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   219
        self.ConfNodeEditor.SetEOLMode(wx.stc.STC_EOL_LF)
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   220
        self.ConfNodeEditor.SetViewEOL(False)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   221
        
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   222
        # No right-edge mode indicator
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   223
        self.ConfNodeEditor.SetEdgeMode(stc.STC_EDGE_NONE)
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   224
        
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   225
        self.ConfNodeEditor.SetModEventMask(wx.stc.STC_MOD_BEFOREINSERT|wx.stc.STC_MOD_BEFOREDELETE)
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   226
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   227
        self.ConfNodeEditor.Bind(wx.stc.EVT_STC_DO_DROP, self.OnDoDrop, id=ID_PYTHONEDITOR)
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   228
        self.ConfNodeEditor.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus)
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   229
        self.ConfNodeEditor.Bind(wx.stc.EVT_STC_MODIFIED, self.OnModification, id=ID_PYTHONEDITOR)
657
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   230
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   231
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   232
    def __init__(self, parent, controler, window):
743
4645a3a398ad Fix bugs with ConfigTreeNode
laurent
parents: 738
diff changeset
   233
        ConfTreeNodeEditor.__init__(self, parent, controler, window)
657
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   234
        
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   235
        self.DisableEvents = False
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   236
        self.CurrentAction = None
657
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   237
    
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   238
    def GetBufferState(self):
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   239
        return self.Controler.GetBufferState()
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   240
        
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   241
    def Undo(self):
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   242
        self.Controler.LoadPrevious()
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   243
        self.RefreshView()
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   244
            
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   245
    def Redo(self):
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   246
        self.Controler.LoadNext()
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   247
        self.RefreshView()
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   248
    
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   249
    def OnModification(self, event):
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   250
        if not self.DisableEvents:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   251
            mod_type = event.GetModificationType()
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   252
            if not (mod_type&wx.stc.STC_PERFORMED_UNDO or mod_type&wx.stc.STC_PERFORMED_REDO):
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   253
                if mod_type&wx.stc.STC_MOD_BEFOREINSERT:
657
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   254
                    if self.CurrentAction is None:
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   255
                        self.StartBuffering()
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   256
                    elif self.CurrentAction[0] != "Add" or self.CurrentAction[1] != event.GetPosition() - 1:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   257
                        self.Controler.EndBuffering()
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   258
                        self.StartBuffering()
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   259
                    self.CurrentAction = ("Add", event.GetPosition())
657
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   260
                    wx.CallAfter(self.RefreshModel)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   261
                elif mod_type&wx.stc.STC_MOD_BEFOREDELETE:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   262
                    if self.CurrentAction == None:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   263
                        self.StartBuffering()
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   264
                    elif self.CurrentAction[0] != "Delete" or self.CurrentAction[1] != event.GetPosition() + 1:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   265
                        self.Controler.EndBuffering()
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   266
                        self.StartBuffering()
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   267
                    self.CurrentAction = ("Delete", event.GetPosition())
657
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   268
                    wx.CallAfter(self.RefreshModel)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   269
        event.Skip()
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   270
    
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   271
    def OnDoDrop(self, event):
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   272
        self.ResetBuffer()
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   273
        wx.CallAfter(self.RefreshModel)
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   274
        event.Skip()
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   275
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   276
    # Buffer the last model state
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   277
    def RefreshBuffer(self):
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   278
        self.Controler.BufferPython()
657
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   279
        if self.ParentWindow is not None:
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   280
            self.ParentWindow.RefreshTitle()
534
80f05b17de1e Bug on FileMenu not refreshed when modifications fixed
laurent
parents: 427
diff changeset
   281
            self.ParentWindow.RefreshFileMenu()
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   282
            self.ParentWindow.RefreshEditMenu()
657
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   283
            self.ParentWindow.RefreshPageTitles()
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   284
    
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   285
    def StartBuffering(self):
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   286
        self.Controler.StartBuffering()
657
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   287
        if self.ParentWindow is not None:
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   288
            self.ParentWindow.RefreshTitle()
534
80f05b17de1e Bug on FileMenu not refreshed when modifications fixed
laurent
parents: 427
diff changeset
   289
            self.ParentWindow.RefreshFileMenu()
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   290
            self.ParentWindow.RefreshEditMenu()
657
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   291
            self.ParentWindow.RefreshPageTitles()
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   292
    
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   293
    def ResetBuffer(self):
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   294
        if self.CurrentAction != None:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   295
            self.Controler.EndBuffering()
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   296
            self.CurrentAction = None
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   297
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   298
    def RefreshView(self):
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   299
        self.ResetBuffer()
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   300
        self.DisableEvents = True
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   301
        old_cursor_pos = self.ConfNodeEditor.GetCurrentPos()
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   302
        old_text = self.ConfNodeEditor.GetText()
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   303
        new_text = self.Controler.GetPythonCode()
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   304
        self.ConfNodeEditor.SetText(new_text)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   305
        new_cursor_pos = GetCursorPos(old_text, new_text)
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   306
        if new_cursor_pos != None:
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   307
            self.ConfNodeEditor.GotoPos(new_cursor_pos)
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   308
        else:
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   309
            self.ConfNodeEditor.GotoPos(old_cursor_pos)
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   310
        self.ConfNodeEditor.ScrollToColumn(0)
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   311
        self.ConfNodeEditor.EmptyUndoBuffer()
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   312
        self.DisableEvents = False
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   313
        
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   314
        self.ConfNodeEditor.Colourise(0, -1)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   315
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   316
    def RefreshModel(self):
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   317
        self.Controler.SetPythonCode(self.ConfNodeEditor.GetText())
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   318
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   319
    def OnKeyPressed(self, event):
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   320
        if self.ConfNodeEditor.CallTipActive():
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   321
            self.ConfNodeEditor.CallTipCancel()
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   322
        key = event.GetKeyCode()
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   323
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   324
        if key == 32 and event.ControlDown():
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   325
            pos = self.ConfNodeEditor.GetCurrentPos()
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   326
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   327
            # Code completion
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   328
            if not event.ShiftDown():
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   329
                self.ConfNodeEditor.AutoCompSetIgnoreCase(False)  # so this needs to match
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   330
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   331
                # Images are specified with a appended "?type"
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   332
                self.ConfNodeEditor.AutoCompShow(0, " ".join([word + "?1" for word in keyword.kwlist]))
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   333
        else:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   334
            event.Skip()
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   335
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   336
    def OnKillFocus(self, event):
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   337
        self.ConfNodeEditor.AutoCompCancel()
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   338
        event.Skip()
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   339
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   340
    def OnUpdateUI(self, evt):
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   341
        # check for matching braces
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   342
        braceAtCaret = -1
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   343
        braceOpposite = -1
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   344
        charBefore = None
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   345
        caretPos = self.ConfNodeEditor.GetCurrentPos()
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   346
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   347
        if caretPos > 0:
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   348
            charBefore = self.ConfNodeEditor.GetCharAt(caretPos - 1)
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   349
            styleBefore = self.ConfNodeEditor.GetStyleAt(caretPos - 1)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   350
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   351
        # check before
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   352
        if charBefore and chr(charBefore) in "[]{}()" and styleBefore == stc.STC_P_OPERATOR:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   353
            braceAtCaret = caretPos - 1
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   354
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   355
        # check after
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   356
        if braceAtCaret < 0:
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   357
            charAfter = self.ConfNodeEditor.GetCharAt(caretPos)
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   358
            styleAfter = self.ConfNodeEditor.GetStyleAt(caretPos)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   359
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   360
            if charAfter and chr(charAfter) in "[]{}()" and styleAfter == stc.STC_P_OPERATOR:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   361
                braceAtCaret = caretPos
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   362
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   363
        if braceAtCaret >= 0:
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   364
            braceOpposite = self.ConfNodeEditor.BraceMatch(braceAtCaret)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   365
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   366
        if braceAtCaret != -1  and braceOpposite == -1:
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   367
            self.ConfNodeEditor.BraceBadLight(braceAtCaret)
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   368
        else:
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   369
            self.ConfNodeEditor.BraceHighlight(braceAtCaret, braceOpposite)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   370
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   371
    def OnMarginClick(self, evt):
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   372
        # fold and unfold as needed
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   373
        if evt.GetMargin() == 2:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   374
            if evt.GetShift() and evt.GetControl():
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   375
                self.FoldAll()
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   376
            else:
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   377
                lineClicked = self.ConfNodeEditor.LineFromPosition(evt.GetPosition())
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   378
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   379
                if self.ConfNodeEditor.GetFoldLevel(lineClicked) & stc.STC_FOLDLEVELHEADERFLAG:
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   380
                    if evt.GetShift():
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   381
                        self.ConfNodeEditor.SetFoldExpanded(lineClicked, True)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   382
                        self.Expand(lineClicked, True, True, 1)
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   383
                    elif evt.GetControl():
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   384
                        if self.ConfNodeEditor.GetFoldExpanded(lineClicked):
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   385
                            self.ConfNodeEditor.SetFoldExpanded(lineClicked, False)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   386
                            self.Expand(lineClicked, False, True, 0)
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   387
                        else:
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   388
                            self.ConfNodeEditor.SetFoldExpanded(lineClicked, True)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   389
                            self.Expand(lineClicked, True, True, 100)
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   390
                    else:
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   391
                        self.ConfNodeEditor.ToggleFold(lineClicked)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   392
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   393
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   394
    def FoldAll(self):
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   395
        lineCount = self.ConfNodeEditor.GetLineCount()
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   396
        expanding = True
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   397
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   398
        # find out if we are folding or unfolding
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   399
        for lineNum in range(lineCount):
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   400
            if self.ConfNodeEditor.GetFoldLevel(lineNum) & stc.STC_FOLDLEVELHEADERFLAG:
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   401
                expanding = not self.ConfNodeEditor.GetFoldExpanded(lineNum)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   402
                break
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   403
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   404
        lineNum = 0
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   405
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   406
        while lineNum < lineCount:
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   407
            level = self.ConfNodeEditor.GetFoldLevel(lineNum)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   408
            if level & stc.STC_FOLDLEVELHEADERFLAG and \
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   409
               (level & stc.STC_FOLDLEVELNUMBERMASK) == stc.STC_FOLDLEVELBASE:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   410
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   411
                if expanding:
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   412
                    self.ConfNodeEditor.SetFoldExpanded(lineNum, True)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   413
                    lineNum = self.Expand(lineNum, True)
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   414
                    lineNum = lineNum - 1
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   415
                else:
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   416
                    lastChild = self.ConfNodeEditor.GetLastChild(lineNum, -1)
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   417
                    self.ConfNodeEditor.SetFoldExpanded(lineNum, False)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   418
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   419
                    if lastChild > lineNum:
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   420
                        self.ConfNodeEditor.HideLines(lineNum+1, lastChild)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   421
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   422
            lineNum = lineNum + 1
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   423
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   424
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   425
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   426
    def Expand(self, line, doExpand, force=False, visLevels=0, level=-1):
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   427
        lastChild = self.ConfNodeEditor.GetLastChild(line, level)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   428
        line = line + 1
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   429
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   430
        while line <= lastChild:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   431
            if force:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   432
                if visLevels > 0:
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   433
                    self.ConfNodeEditor.ShowLines(line, line)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   434
                else:
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   435
                    self.ConfNodeEditor.HideLines(line, line)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   436
            else:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   437
                if doExpand:
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   438
                    self.ConfNodeEditor.ShowLines(line, line)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   439
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   440
            if level == -1:
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   441
                level = self.ConfNodeEditor.GetFoldLevel(line)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   442
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   443
            if level & stc.STC_FOLDLEVELHEADERFLAG:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   444
                if force:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   445
                    if visLevels > 1:
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   446
                        self.ConfNodeEditor.SetFoldExpanded(line, True)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   447
                    else:
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   448
                        self.ConfNodeEditor.SetFoldExpanded(line, False)
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   449
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   450
                    line = self.Expand(line, doExpand, force, visLevels-1)
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   451
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   452
                else:
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   453
                    if doExpand and self.ConfNodeEditor.GetFoldExpanded(line):
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   454
                        line = self.Expand(line, True, force, visLevels-1)
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   455
                    else:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   456
                        line = self.Expand(line, False, force, visLevels-1)
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   457
            else:
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   458
                line = line + 1
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   459
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
   460
        return line
657
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   461
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   462
    def Cut(self):
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   463
        self.ResetBuffer()
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   464
        self.DisableEvents = True
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   465
        self.ConfNodeEditor.CmdKeyExecute(wx.stc.STC_CMD_CUT)
657
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   466
        self.DisableEvents = False
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   467
        self.RefreshModel()
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   468
        self.RefreshBuffer()
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   469
    
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   470
    def Copy(self):
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   471
        self.ConfNodeEditor.CmdKeyExecute(wx.stc.STC_CMD_COPY)
657
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   472
    
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   473
    def Paste(self):
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   474
        self.ResetBuffer()
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   475
        self.DisableEvents = True
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   476
        self.ConfNodeEditor.CmdKeyExecute(wx.stc.STC_CMD_PASTE)
657
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   477
        self.DisableEvents = False
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   478
        self.RefreshModel()
340c0b9caeca Adding support for integrating Python code Editor into Beremiz frame.
laurent
parents: 654
diff changeset
   479
        self.RefreshBuffer()