| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Editra
Revision: 55450
Author: CJP
Date: 03 Sep 2008 22:43:52
Changes:Lint, general cleanup, and documentation
Files:| ... | ...@@ -22,12 +22,14 @@ | |
| 22 | 22 | __revision__ = "$Revision$" |
| 23 | 23 | |
| 24 | 24 | #--------------------------------------------------------------------------# |
| 25 | # Dependancies | |
| 25 | # Imports | |
| 26 | 26 | import os |
| 27 | 27 | import wx |
| 28 | 28 | import wx.lib.langlistctrl as langlist |
| 29 | 29 | import wx.combo |
| 30 | 30 | import glob |
| 31 | ||
| 32 | # Editra Imports | |
| 31 | 33 | import ed_glob |
| 32 | 34 | |
| 33 | 35 | #----------------------------------------------------------------------------# |
| ... | ...@@ -20,7 +20,7 @@ | |
| 20 | 20 | __revision__ = "$Revision$" |
| 21 | 21 | |
| 22 | 22 | #--------------------------------------------------------------------------# |
| 23 | # Dependancies | |
| 23 | # Imports | |
| 24 | 24 | import os |
| 25 | 25 | import re |
| 26 | 26 | import wx |
| ... | ...@@ -111,12 +111,13 @@ | |
| 111 | 111 | self.Bind(wx.EVT_BUTTON, |
| 112 | 112 | lambda evt: self._buffer.Clear(), id=wx.ID_CLEAR) |
| 113 | 113 | self.Bind(wx.EVT_CHOICE, self.OnChoice, self._srcfilter) |
| 114 | ||
| 115 | # Message Handlers | |
| 114 | 116 | ed_msg.Subscribe(self.OnThemeChange, ed_msg.EDMSG_THEME_CHANGED) |
| 115 | 117 | |
| 116 | 118 | def __del__(self): |
| 117 | 119 | """Cleanup and unsubscribe from messages""" |
| 118 | 120 | ed_msg.Unsubscribe(self.OnThemeChange) |
| 119 | super(LogViewer).__del__() | |
| 120 | 121 | |
| 121 | 122 | def __DoLayout(self): |
| 122 | 123 | """Layout the log viewer window""" |
| ... | ...@@ -228,7 +229,9 @@ | |
| 228 | 229 | sty_s = start + group.start() |
| 229 | 230 | sty_e = start + group.end() |
| 230 | 231 | self.StartStyling(sty_s, 0xff) |
| 231 | self.SetStyling(sty_e - sty_s, self.ERROR_STYLE) | |
| 232 | ||
| 233 | # Highlight error messages with ERROR_STYLE | |
| 234 | self.SetStyling(sty_e - sty_s, LogBuffer.ERROR_STYLE) | |
| 232 | 235 | |
| 233 | 236 | def SetFilter(self, src): |
| 234 | 237 | """Set the level of what is shown in the display |
| ... | ...@@ -260,7 +263,7 @@ | |
| 260 | 263 | if self._filter == SHOW_ALL_MSG: |
| 261 | 264 | self.AppendUpdate(unicode(logmsg) + os.linesep) |
| 262 | 265 | elif self._filter == logmsg.Origin: |
| 263 | msg = "[%s][%s]%s" % (logmsg.ClockTime, logmsg.Type, logmsg.Value) | |
| 266 | msg = u"[%s][%s]%s" % (logmsg.ClockTime, logmsg.Type, logmsg.Value) | |
| 264 | 267 | self.AppendUpdate(msg + os.linesep) |
| 265 | 268 | else: |
| 266 | 269 | pass |
| ... | ...@@ -25,7 +25,6 @@ | |
| 25 | 25 | import sys |
| 26 | 26 | import re |
| 27 | 27 | import types |
| 28 | import threading | |
| 29 | 28 | import wx |
| 30 | 29 | |
| 31 | 30 | # Local imports |
| ... | ...@@ -323,13 +322,12 @@ | |
| 323 | 322 | return |
| 324 | 323 | self._finddlg.SetTransparent(240) |
| 325 | 324 | self._finddlg.Show() |
| 326 | self._finddlg.SetFocus() | |
| 327 | 325 | # self._finddlg.SetExtraStyle(wx.WS_EX_PROCESS_UI_UPDATES) |
| 328 | 326 | else: |
| 329 | 327 | # Dialog is open already so just update it |
| 330 | 328 | self._UpdateDialogState(eid) |
| 331 | 329 | self._finddlg.Raise() |
| 332 | self._finddlg.SetFocus() | |
| 330 | self._finddlg.SetFocus() | |
| 333 | 331 | |
| 334 | 332 | @staticmethod |
| 335 | 333 | def ReplaceInStc(stc, matches, rstring): |
| ... | ...@@ -506,7 +504,6 @@ | |
| 506 | 504 | @todo: unicode handling |
| 507 | 505 | |
| 508 | 506 | """ |
| 509 | results = list() | |
| 510 | 507 | fchecker = FileTypeChecker() |
| 511 | 508 | if fchecker.IsReadableText(fname): |
| 512 | 509 | try: |
| ... | ...@@ -836,7 +833,6 @@ | |
| 836 | 833 | wx.WXK_UP, wx.WXK_DOWN]: |
| 837 | 834 | return |
| 838 | 835 | |
| 839 | s_cmd = wx.wxEVT_COMMAND_FIND | |
| 840 | 836 | if e_key == wx.WXK_RETURN or e_key == wx.WXK_F3: |
| 841 | 837 | if evt.ShiftDown(): |
| 842 | 838 | self.DoSearch(next=False) |
| ... | ...@@ -977,8 +973,10 @@ | |
| 977 | 973 | self._cancelb.Disable() |
| 978 | 974 | |
| 979 | 975 | # Event Handlers |
| 980 | self.Bind(wx.EVT_BUTTON, lambda evt: self._list.Clear(), id=wx.ID_CLEAR) | |
| 981 | self.Bind(wx.EVT_BUTTON, lambda evt: self.CancelSearch(), id=wx.ID_CANCEL) | |
| 976 | self.Bind(wx.EVT_BUTTON, | |
| 977 | lambda evt: self._list.Clear(), id=wx.ID_CLEAR) | |
| 978 | self.Bind(wx.EVT_BUTTON, | |
| 979 | lambda evt: self.CancelSearch(), id=wx.ID_CANCEL) | |
| 982 | 980 | self._list.Bind(outbuff.EVT_TASK_START, self.OnTaskStart) |
| 983 | 981 | self._list.Bind(outbuff.EVT_TASK_COMPLETE, self.OnTaskComplete) |
| 984 | 982 | |
| ... | ...@@ -1087,6 +1085,12 @@ | |
| 1087 | 1085 | #-----------------------------------------------------------------------------# |
| 1088 | 1086 | |
| 1089 | 1087 | class SearchResultList(outbuff.OutputBuffer): |
| 1088 | """Outputbuffer for listing matching lines from the search results that | |
| 1089 | a L{SearchEngine} dispatches. The matching lines are turned into hotspots | |
| 1090 | that allow them to be clicked on for instant navigation to the matching | |
| 1091 | line. | |
| 1092 | ||
| 1093 | """ | |
| 1090 | 1094 | STY_SEARCH_MATCH = outbuff.OPB_STYLE_MAX + 1 |
| 1091 | 1095 | RE_FIND_MATCH = re.compile('(.+) \(([0-9]+)\)\: .+') |
| 1092 | 1096 | def __init__(self, parent): |
| ... | ...@@ -1129,7 +1133,7 @@ | |
| 1129 | 1133 | self.SetStyling(len(txt), outbuff.OPB_STYLE_DEFAULT) |
| 1130 | 1134 | |
| 1131 | 1135 | def DoHotSpotClicked(self, pos, line): |
| 1132 | """Handle a click on a hotspot | |
| 1136 | """Handle a click on a hotspot and open the file to the matched line | |
| 1133 | 1137 | @param pos: long |
| 1134 | 1138 | @param line: int |
| 1135 | 1139 | |
| ... | ...@@ -1169,24 +1173,17 @@ | |
| 1169 | 1173 | |
| 1170 | 1174 | """ |
| 1171 | 1175 | mainw = wx.GetApp().GetActiveWindow() |
| 1172 | nb = mainw.GetNotebook() | |
| 1173 | buffers = [ page.GetFileName() for page in nb.GetTextControls() ] | |
| 1176 | nbook = mainw.GetNotebook() | |
| 1177 | buffers = [ page.GetFileName() for page in nbook.GetTextControls() ] | |
| 1174 | 1178 | if fname in buffers: |
| 1175 | 1179 | page = buffers.index(fname) |
| 1176 | nb.ChangePage(page) | |
| 1177 | cpage = nb.GetPage(page) | |
| 1180 | nbook.ChangePage(page) | |
| 1181 | cpage = nbook.GetPage(page) | |
| 1178 | 1182 | else: |
| 1179 | nb.OnDrop([fname]) | |
| 1180 | cpage = nb.GetPage(nb.GetSelection()) | |
| 1183 | nbook.OnDrop([fname]) | |
| 1184 | cpage = nbook.GetPage(nbook.GetSelection()) | |
| 1181 | 1185 | |
| 1182 | 1186 | cpage.GotoLine(line) |
| 1183 | 1187 | cpage.SetFocus() |
| 1184 | 1188 | |
| 1185 | 1189 | #-----------------------------------------------------------------------------# |
| 1186 | ||
| 1187 | if __name__ == '__main__': | |
| 1188 | import sys | |
| 1189 | engine = SearchEngine('ParseStyleData') | |
| 1190 | arg = u' '.join(sys.argv[1:]) | |
| 1191 | for x in engine.SearchInDirectory(arg): | |
| 1192 | print x.rstrip() |