Changeset 1459 for trunk/peppy/mainmenu.py
- Timestamp:
- 07/06/08 16:09:42 (5 months ago)
- Files:
-
- 1 modified
-
trunk/peppy/mainmenu.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,
