53 SEARCH_RESULT_HIGHLIGHT: STC_CODE_SEARCH_RESULT, |
53 SEARCH_RESULT_HIGHLIGHT: STC_CODE_SEARCH_RESULT, |
54 } |
54 } |
55 |
55 |
56 EDGE_COLUMN = 80 |
56 EDGE_COLUMN = 80 |
57 |
57 |
|
58 |
|
59 def GetSectionsText(controler, sections_headers): |
|
60 parts = controler.GetTextParts() |
|
61 text = "" |
|
62 for section in controler.SECTIONS_NAMES: |
|
63 text += sections_headers(section) |
|
64 if parts[section] == "": |
|
65 text += "\n" |
|
66 else: |
|
67 if not parts[section].startswith("\n"): |
|
68 text += "\n" |
|
69 text += parts[section] |
|
70 if not parts[section].endswith("\n"): |
|
71 text += "\n" |
|
72 return text |
58 |
73 |
59 class CodeEditor(CustomStyledTextCtrl): |
74 class CodeEditor(CustomStyledTextCtrl): |
60 |
75 |
61 KEYWORDS = [] |
76 KEYWORDS = [] |
62 COMMENT_HEADER = "" |
77 COMMENT_HEADER = "" |
237 if self.CurrentAction is not None: |
252 if self.CurrentAction is not None: |
238 self.Controler.EndBuffering() |
253 self.Controler.EndBuffering() |
239 self.CurrentAction = None |
254 self.CurrentAction = None |
240 |
255 |
241 def GetCodeText(self): |
256 def GetCodeText(self): |
242 parts = self.Controler.GetTextParts() |
257 return GetSectionsText( |
243 text = "" |
258 self.Controler, |
244 for section in self.Controler.SECTIONS_NAMES: |
259 lambda section : self.SectionsComments[section]["comment"]) |
245 section_comments = self.SectionsComments[section] |
|
246 text += section_comments["comment"] |
|
247 if parts[section] == "": |
|
248 text += "\n" |
|
249 else: |
|
250 if not parts[section].startswith("\n"): |
|
251 text += "\n" |
|
252 text += parts[section] |
|
253 if not parts[section].endswith("\n"): |
|
254 text += "\n" |
|
255 return text |
|
256 |
260 |
257 def RefreshView(self, scroll_to_highlight=False): |
261 def RefreshView(self, scroll_to_highlight=False): |
258 self.ResetBuffer() |
262 self.ResetBuffer() |
259 self.DisableEvents = True |
263 self.DisableEvents = True |
260 old_cursor_pos = self.GetCurrentPos() |
264 old_cursor_pos = self.GetCurrentPos() |
642 |
646 |
643 Otherwise default to the default renderer. |
647 Otherwise default to the default renderer. |
644 """ |
648 """ |
645 |
649 |
646 for row in range(self.GetNumberRows()): |
650 for row in range(self.GetNumberRows()): |
|
651 row_highlights = self.Highlights.get(row, {}) |
647 for col in range(self.GetNumberCols()): |
652 for col in range(self.GetNumberCols()): |
648 editor = None |
653 editor = None |
649 renderer = None |
654 renderer = None |
650 colname = self.GetColLabelValue(col, False) |
655 colname = self.GetColLabelValue(col, False) |
651 |
656 |
654 editor = editortype(self, row, col) |
659 editor = editortype(self, row, col) |
655 |
660 |
656 grid.SetCellEditor(row, col, editor) |
661 grid.SetCellEditor(row, col, editor) |
657 grid.SetCellRenderer(row, col, renderer) |
662 grid.SetCellRenderer(row, col, renderer) |
658 |
663 |
659 grid.SetCellBackgroundColour(row, col, wx.WHITE) |
664 highlight_colours = row_highlights.get(colname.lower(), [(wx.WHITE, wx.BLACK)])[-1] |
|
665 grid.SetCellBackgroundColour(row, col, highlight_colours[0]) |
|
666 grid.SetCellTextColour(row, col, highlight_colours[1]) |
660 self.ResizeRow(grid, row) |
667 self.ResizeRow(grid, row) |
661 |
668 |
662 |
669 |
663 class VariablesEditor(wx.Panel): |
670 class VariablesEditor(wx.Panel): |
664 |
671 |
857 dragSource.SetData(data) |
864 dragSource.SetData(data) |
858 dragSource.DoDragDrop() |
865 dragSource.DoDragDrop() |
859 return |
866 return |
860 event.Skip() |
867 event.Skip() |
861 |
868 |
|
869 def AddVariableHighlight(self, infos, highlight_type): |
|
870 self.Table.AddHighlight(infos, highlight_type) |
|
871 cell_visible = infos[0] |
|
872 colnames = [colname.lower() for colname in self.Table.colnames] |
|
873 self.VariablesGrid.MakeCellVisible(cell_visible, colnames.index(infos[1])) |
|
874 self.Table.ResetView(self.VariablesGrid) |
|
875 |
|
876 def RemoveVariableHighlight(self, infos, highlight_type): |
|
877 self.Table.RemoveHighlight(infos, highlight_type) |
|
878 self.Table.ResetView(self.VariablesGrid) |
|
879 |
|
880 def ClearHighlights(self, highlight_type=None): |
|
881 self.Table.ClearHighlights(highlight_type) |
|
882 self.Table.ResetView(self.VariablesGrid) |
862 |
883 |
863 # ------------------------------------------------------------------------------- |
884 # ------------------------------------------------------------------------------- |
864 # CodeFileEditor Main Frame Class |
885 # CodeFileEditor Main Frame Class |
865 # ------------------------------------------------------------------------------- |
886 # ------------------------------------------------------------------------------- |
866 |
887 |
912 self.VariablesPanel.RefreshView() |
933 self.VariablesPanel.RefreshView() |
913 self.CodeEditor.RefreshView() |
934 self.CodeEditor.RefreshView() |
914 |
935 |
915 def Find(self, direction, search_params): |
936 def Find(self, direction, search_params): |
916 self.CodeEditor.Find(direction, search_params) |
937 self.CodeEditor.Find(direction, search_params) |
|
938 |
|
939 def AddHighlight(self, infos, start, end, highlight_type): |
|
940 if self.VariablesPanel is not None and infos[0] == "var_inout": |
|
941 self.VariablesPanel.AddVariableHighlight(infos[1:], highlight_type) |
|
942 else: |
|
943 self.CodeEditor.AddHighlight(start, end, highlight_type) |
|
944 |
|
945 def RemoveHighlight(self, infos, start, end, highlight_type): |
|
946 if self.VariablesPanel is not None and infos[0] == "var_inout": |
|
947 self.VariablesPanel.RemoveVariableHighlight(infos[1:], highlight_type) |
|
948 else: |
|
949 self.CodeEditor.RemoveHighlight(start, end, highlight_type) |
|
950 |
|
951 def ClearHighlights(self, highlight_type=None): |
|
952 if self.VariablesPanel is not None: |
|
953 self.VariablesPanel.ClearHighlights(highlight_type) |
|
954 else: |
|
955 self.CodeEditor.ClearHighlights(highlight_type) |