Changeset 1459
- Timestamp:
- 07/06/08 16:09:42 (2 months ago)
- Location:
- trunk/peppy
- Files:
-
- 3 modified
-
mainmenu.py (modified) (5 diffs)
-
major.py (modified) (2 diffs)
-
plugins/error_log.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/peppy/mainmenu.py
r1453 r1459 469 469 self.frame.open("about:demo.txt") 470 470 471 class RunScript(SelectAction): 471 472 class RunMixin(object): 473 @classmethod 474 def worksWithMajorMode(cls, mode): 475 return hasattr(mode, 'startInterpreter') 476 477 def isEnabled(self): 478 return hasattr(self.mode, 'startInterpreter') and not hasattr(self.mode, 'process') 479 480 class RunScript(RunMixin, SelectAction): 472 481 alias = "run-script" 473 482 name = "Run" … … 477 486 key_bindings = {'default': "F5"} 478 487 479 @classmethod480 def worksWithMajorMode(cls, mode):481 return hasattr(mode, 'startInterpreter')482 483 def isEnabled(self):484 return hasattr(self.mode, 'startInterpreter') and not hasattr(self.mode, 'process')485 486 488 def action(self, index=-1, multiplier=1): 487 489 self.mode.startInterpreter() 488 490 489 490 class RunScriptWithArgs(RunScript): 491 class RunScriptWithArgs(RunMixin, SelectAction): 491 492 alias = "run-script-with-args" 492 493 name = "Run with Args" … … 494 495 icon = "icons/script_edit.png" 495 496 default_menu = ("Tools", 2) 496 497 # If subclassing another action, make sure to reset global_id, or the498 # menu system will use the existing global id for the new action499 global_id = None500 497 key_bindings = {'default': "C-F5"} 501 498 … … 508 505 self.mode.startInterpreter(text) 509 506 510 511 class StopScript(RunScript): 507 class RunFilter(RunMixin, SelectAction): 508 """Run an external program on this file""" 509 alias = "run-filter" 510 name = "Run Filter" 511 default_menu = ("Tools", 3) 512 513 def action(self, index=-1, multiplier=1): 514 minibuffer = TextMinibuffer(self.mode, self, label="Command line:", 515 initial = self.mode.getScriptArgs()) 516 self.mode.setMinibuffer(minibuffer) 517 self.mode.setStatusText("Enter command line, %s will be replaced by full path to file") 518 519 def processMinibuffer(self, minibuffer, mode, text): 520 self.mode.startCommandLine(text) 521 522 class StopScript(RunMixin, SelectAction): 512 523 alias = "stop-script" 513 524 name = "Stop" 514 525 tooltip = "Stop the currently running script" 515 526 icon = 'icons/stop.png' 516 default_menu = ("Tools", 3) 517 global_id = None 527 default_menu = ("Tools", 9) 518 528 key_bindings = {'win': "C-CANCEL", 'emacs': "C-CANCEL", 'mac': 'C-.'} 519 529 … … 884 894 Undo, Redo, Cut, Copy, Paste, PasteAtColumn, SelectAll, 885 895 886 RunScript, RunScriptWithArgs, StopScript,896 RunScript, RunScriptWithArgs, RunFilter, StopScript, 887 897 888 898 MajorModeSelect, MinorModeShow, SidebarShow, -
trunk/peppy/major.py
r1457 r1459 1034 1034 self.scriptArgs = argstring 1035 1035 1036 if self.buffer.readonly or not self.classprefs.autosave_before_run:1037 msg = "You must save this file to the local filesystem\nbefore you can run it through the interpreter."1038 dlg = wx.MessageDialog(wx.GetApp().GetTopWindow(), msg, "Save the file!", wx.OK | wx.ICON_ERROR )1039 retval=dlg.ShowModal()1040 return1041 else:1042 self.save()1043 1044 1036 bangpath = None 1045 1037 first = self.GetLine(0) … … 1063 1055 else: 1064 1056 cmd = self.getCommandLine(bangpath) 1057 self.startCommandLine(cmd) 1058 1059 def expandCommandLine(self, cmd): 1060 """Expand the command line to include the filename of the buffer""" 1061 if '%' in cmd: 1062 cmd = cmd % self.buffer.getFilename() 1063 else: 1064 cmd = "%s %s" % (cmd, self.buffer.getFilename()) 1065 return cmd 1066 1067 def startCommandLine(self, cmd): 1068 """Attempt to create a process using the command line""" 1069 if hasattr(self, 'process'): 1070 self.frame.setStatusText("Already running a process.") 1071 else: 1072 if self.buffer.readonly or not self.classprefs.autosave_before_run: 1073 msg = "You must save this file to the local filesystem\nbefore you can run it through the interpreter." 1074 dlg = wx.MessageDialog(wx.GetApp().GetTopWindow(), msg, "Save the file!", wx.OK | wx.ICON_ERROR ) 1075 retval=dlg.ShowModal() 1076 return 1077 else: 1078 self.save() 1079 1080 cmd = self.expandCommandLine(cmd) 1065 1081 if self.classprefs.output_log == 0: 1066 1082 output = self -
trunk/peppy/plugins/error_log.py
r1451 r1459 21 21 BoolParam('show', False), 22 22 BoolParam('always_scroll', False), 23 StrParam('filename_match_regex', " File \"(.+)\", line ([0-9]+)", 'Regular expression used to match pathnames in the output'),23 StrParam('filename_match_regex', "^ File \"(.+)\", line ([0-9]+)", 'Regular expression used to match pathnames in the output'), 24 24 ) 25 25 … … 32 32 33 33 self.filere = re.compile(self.classprefs.filename_match_regex) 34 self.stdre = re.compile("^((?:[a-zA-Z]:)?.+):([0-9]+):") 34 35 35 36 def addMessage(self, text): … … 57 58 self.scanForFilenames() 58 59 60 def matchLine(self, text, i=0): 61 match = self.filere.search(text, i) 62 if match: 63 return match 64 match = self.stdre.search(text, i) 65 if match: 66 return match 67 return None 68 59 69 def scanForFilenames(self): 60 70 if not hasattr(self, 'last_matched_filename'): … … 67 77 i = 0 68 78 while i < len(text): 69 match = self. filere.search(text, i)79 match = self.matchLine(text, i) 70 80 if not match: 71 81 break … … 87 97 text = self.GetLine(line) 88 98 #dprint("text=%s" % text) 89 match = self. filere.search(text)99 match = self.matchLine(text) 90 100 if match: 91 101 filename = match.group(1)
