Changeset 1471
- Timestamp:
- 07/08/08 12:20:56 (2 months ago)
- Location:
- trunk/peppy
- Files:
-
- 3 modified
-
lib/wxemacskeybindings.py (modified) (9 diffs)
-
mainmenu.py (modified) (4 diffs)
-
plugins/keyboard.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/peppy/lib/wxemacskeybindings.py
r1433 r1471 21 21 import wx 22 22 23 wxkeynames = ( 24 "BACK", "TAB", "RETURN", "ESCAPE", "SPACE", "DELETE", "START", 25 "LBUTTON", "RBUTTON", "CANCEL", "MBUTTON", "CLEAR", "PAUSE", 26 "CAPITAL", "PRIOR", "NEXT", "END", "HOME", "LEFT", "UP", "RIGHT", 27 "DOWN", "SELECT", "PRINT", "EXECUTE", "SNAPSHOT", "INSERT", "HELP", 28 "NUMPAD0", "NUMPAD1", "NUMPAD2", "NUMPAD3", "NUMPAD4", "NUMPAD5", 29 "NUMPAD6", "NUMPAD7", "NUMPAD8", "NUMPAD9", "MULTIPLY", "ADD", 30 "SEPARATOR", "SUBTRACT", "DECIMAL", "DIVIDE", "F1", "F2", "F3", "F4", 31 "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "F13", "F14", 32 "F15", "F16", "F17", "F18", "F19", "F20", "F21", "F22", "F23", "F24", 33 "NUMLOCK", "SCROLL", "PAGEUP", "PAGEDOWN", "NUMPAD_SPACE", 34 "NUMPAD_TAB", "NUMPAD_ENTER", "NUMPAD_F1", "NUMPAD_F2", "NUMPAD_F3", 35 "NUMPAD_F4", "NUMPAD_HOME", "NUMPAD_LEFT", "NUMPAD_UP", 36 "NUMPAD_RIGHT", "NUMPAD_DOWN", "NUMPAD_PRIOR", "NUMPAD_PAGEUP", 37 "NUMPAD_NEXT", "NUMPAD_PAGEDOWN", "NUMPAD_END", "NUMPAD_BEGIN", 38 "NUMPAD_INSERT", "NUMPAD_DELETE", "NUMPAD_EQUAL", "NUMPAD_MULTIPLY", 39 "NUMPAD_ADD", "NUMPAD_SEPARATOR", "NUMPAD_SUBTRACT", "NUMPAD_DECIMAL", 40 "NUMPAD_DIVIDE", 41 ) 23 # The list of all the wx keynames (without the WXK_ prefix) is needed by both 24 # KeyMap and KeyProcessor objects 25 wxkeynames = [i[4:] for i in dir(wx) if i.startswith('WXK_')] 26 42 27 43 28 class DuplicateKeyError(Exception): … … 333 318 """ 334 319 debug = False 335 320 321 # Mapping of wx keystroke numbers to keystroke names 322 wxkeys = {} 323 for i in wxkeynames: 324 wxkeys[getattr(wx, "WXK_"+i)] = i 325 for i in ("SHIFT", "ALT", "COMMAND", "CONTROL", "MENU"): 326 if wx.Platform == '__WXGTK__': 327 # unix doesn't create a keystroke when a modifier key 328 # is also modified by another modifier key, so we 329 # create entries here so that decode() doesn't have to 330 # have platform-specific code 331 wxkeys[getattr(wx, "WXK_"+i)] = i[0:1]+'-' 332 else: 333 wxkeys[getattr(wx, "WXK_"+i)] = '' 334 336 335 def __init__(self,status=None): 337 336 self.keymaps=[] … … 367 366 self.universalArgument="C-U" 368 367 self.processingArgument=0 368 369 # If reportNext is not None, instead of being processed the next action 370 # is reported to a caller by using reportNext as a callback. 371 self.reportNext = None 369 372 370 373 self.hasshown=False 371 374 self.reset() 372 373 # Mapping of wx keystroke numbers to keystroke names374 self.wxkeys={}375 # set up the wxkeys{} dict376 self.wxkeymap()377 378 def wxkeymap(self):379 for i in wxkeynames:380 self.wxkeys[getattr(wx, "WXK_"+i)] = i381 for i in ("SHIFT", "ALT", "COMMAND", "MENU"):382 if wx.Platform == '__WXGTK__':383 # unix doesn't create a keystroke when a modifier key384 # is also modified by another modifier key, so we385 # create entries here so that decode() doesn't have to386 # have platform-specific code387 self.wxkeys[getattr(wx, "WXK_"+i)] = i[0:1]+'-'388 else:389 self.wxkeys[getattr(wx, "WXK_"+i)] = ''390 375 391 376 def findStickyMeta(self): … … 486 471 keyname = chr(keycode) 487 472 else: 488 keyname = " (%s)unknown" % keycode473 keyname = "unknown-%s" % keycode 489 474 if self.debug: print("modifiers: raw=%d processed='%s' keyname=%s keycode=%s key=%s" % (emods, modifiers, keyname, keycode, modifiers+keyname)) 490 475 return modifiers + keyname … … 514 499 """ 515 500 if self.status: 501 if self.reportNext: 502 text = "Describe Key: %s" % text 516 503 self.status.SetStatusText(text) 517 504 self.hasshown=True … … 608 595 self.args+=key + ' ' 609 596 self.processingArgument+=1 597 598 def setReportNext(self, callback): 599 self.reportNext = callback 600 self.show('') 610 601 611 602 def process(self, evt): … … 635 626 skip, unknown, function = self.add(key) 636 627 self.reset() 637 self.show("Quit") 638 if function: 639 function(evt, printable=False) 628 if self.reportNext: 629 self.reportNext(function) 630 self.reportNext = None 631 else: 632 self.show("Quit") 633 if function: 634 function(evt, printable=False) 640 635 elif self.metaNext: 641 636 # OK, the meta sticky key is down, but it's not a quit … … 679 674 printable = not self.modifier 680 675 self.reset() 681 if save is not None: 682 function(evt,save, printable=printable) 676 if self.reportNext: 677 self.reportNext(function) 678 self.reportNext = None 683 679 else: 684 function(evt, printable=printable) 680 if save is not None: 681 function(evt,save, printable=printable) 682 else: 683 function(evt, printable=printable) 685 684 elif unknown: 686 685 # This is an unknown keystroke combo 687 686 sf = "%s not defined."%(self.sofar) 688 687 self.reset() 688 if self.reportNext: 689 self.reportNext(None) 690 self.reportNext = None 689 691 self.show(sf) 690 692 elif skip: … … 693 695 # to get processed elsewhere. 694 696 self.reset() 695 evt.Skip() 697 if self.reportNext: 698 self.reportNext(None) 699 self.reportNext = None 700 else: 701 evt.Skip() 696 702 else: 697 703 self.show(self.args+self.sofar) -
trunk/peppy/mainmenu.py
r1460 r1471 799 799 tooltip = "Describe an action by name" 800 800 default_menu = ("&Help", -200) 801 key_bindings = {'emacs': "C-h a", } 801 802 802 803 def __init__(self, *args, **kwargs): … … 825 826 826 827 828 class DescribeKey(SelectAction): 829 """Look up the action from the keystroke""" 830 name = "&Describe Key" 831 alias = "describe-key" 832 default_menu = ("&Help", 201) 833 key_bindings = {'emacs': "C-h k", } 834 835 def action(self, index=-1, multiplier=1): 836 self.frame.keys.setReportNext(self.displayAction) 837 838 def displayAction(self, action): 839 if action: 840 dprint("looking up docs for %s" % action) 841 Publisher().sendMessage('peppy.log.info', action.getHelp()) 842 self.frame.SetStatusText("Keystroke found.") 843 else: 844 self.frame.SetStatusText("Unbound keystroke.") 845 846 827 847 class CancelMinibuffer(SelectAction): 828 848 alias = "cancel-minibuffer" … … 841 861 tooltip = "Show help for the currently active minibuffer" 842 862 default_menu = ("&Help", 210) 843 key_bindings = {'emacs': " M-S-/m", }863 key_bindings = {'emacs': "C-h m", } 844 864 845 865 def isEnabled(self): … … 903 923 NewWindow, DeleteWindow, WindowList, 904 924 905 ExecuteActionByName, DescribeAction, HelpMinibuffer,925 ExecuteActionByName, DescribeAction, DescribeKey, HelpMinibuffer, 906 926 907 927 CancelMinibuffer, -
trunk/peppy/plugins/keyboard.py
r1290 r1471 25 25 alias = "describe-keys" 26 26 default_menu = ("&Help", 210) 27 key_bindings = {'emacs': " M-/ B", }27 key_bindings = {'emacs': "C-h b", } 28 28 29 29 def action(self, index=-1, multiplier=1):
