[DIFF]: Source code mods to enable tkui for OS X
Eliezer Flores <[email protected]> Thu, 29 Dec 2005 12:38:15 -0500
| Newsgroups | gmane.comp.games.mud.client.lyntin |
|---|---|
| Message-ID | <[email protected]> |
The mods to tkui.py do the following:
- fix the keybindings so the tkui can actually start up in os x
- remapped the function mapped to ctrl-key to cmd-key (which is the
expected behaviour on os x) and modified the help text to indicate it
- added a keybinding mapped to cmd-q to quit (also expected behaviour on
os x)
Also, I'd like to shout to Sven from three kingdoms if he's lurking out
this list. This is arahnapogue. Finally got around to teaching myself
python and kicking your (and others) codebase around for os x ;)
Without further ado:
Index: lyntin40/lyntin/ui/tkui.py
===================================================================
RCS file: /cvsroot/lyntin/lyntin40/lyntin/ui/tkui.py,v
retrieving revision 1.25
diff -r1.25 tkui.py
16c16
< import os, tkFont, types, Queue
---
> import os, tkFont, types, Queue, sys
73a74,76
> """
> if sys.platform != 'darwin':
> HELP_TEXT = HELP_TEXT + """
84c87,97
< """
---
> """
> else:
> HELP_TEXT = HELP_TEXT + """
> - cmd-u removal of text
> - cmd-c copy from the text buffer and cmd-v paste into the command
> buffer
> - cmd-t autotyper
> - NamedWindow handling
>
> To bind function key and numpad bindings, create an alias for the
> symbol. For example:
85a99,100
> #alias {VK_NUMPAD2} {south}
> """
318,320c333,337
< # kludge so that ctrl-c doesn't get caught allowing windows
< # users to copy the buffer....
< if tkevent.keycode == 17 or tkevent.keycode == 67:
---
> # kludge so that ctrl-c doesn't get caught allowing windows users
to copy
> # the buffer. It also allows OS X user to cut using cmd-c.
> if tkevent.keycode == 17 or tkevent.keycode == 67 or \
> (sys.platform=='darwin' and (tkevent.keycode == 524387 or \
> tkevent.keycode == 256 )):
322c339
<
---
>
534,538c551,562
<
< self.bind("<Control-KeyPress-t>", self.startAutotyper)
< self.bind("<Control-KeyPress-u>", self.callKillLine)
< self.bind("<Control-KeyPress-Up>", self.callPushInputStack)
< self.bind("<Control-KeyPress-Down>", self.callPopInputStack)
---
> #bind the keys correctly for OS X
> if sys.platform=='darwin':
> self.bind("<M1-KeyPress-t>", self.startAutotyper)
> self.bind("<M1-KeyPress-u>", self.callKillLine)
> self.bind("<M1-KeyPress-Up>", self.callPushInputStack)
> self.bind("<M1-KeyPress-Down>", self.callPopInputStack)
> else:
> self.bind("<Control-KeyPress-t>", self.startAutotyper)
> self.bind("<Control-KeyPress-u>", self.callKillLine)
> self.bind("<Control-KeyPress-Up>", self.callPushInputStack)
> self.bind("<Control-KeyPress-Down>", self.callPopInputStack)
>
568a593,605
> elif sys.platform=='darwin':
> # this section is for systems running OS X (which =='darwin')
> self.bind("<M1-KeyPress-q>", self.callMacShutdown)
> self.bind("<KeyPress-8>", self.callKP8)
> self.bind("<KeyPress-6>", self.callKP6)
> self.bind("<KeyPress-4>", self.callKP4)
> self.bind("<KeyPress-2>", self.callKP2)
> self.bind("<KeyPress-9>", self.callKP9)
> self.bind("<KeyPress-7>", self.callKP7)
> self.bind("<KeyPress-5>", self.callKP5)
> self.bind("<KeyPress-3>", self.callKP3)
> self.bind("<KeyPress-1>", self.callKP1)
> self.bind("<KeyPress-KP_Enter>", self.createInputEvent)
569a607
>
632d669
<
646a684,689
> def callMacShutdown(self, tkevent):
> """ Handles cmd-q for os x (darwin) platform. Shuts it down."""
> # handle all the function keys except F1
> self._partk.quit()
> return "break"
>
648c691,692
< if tkevent.keycode == 105 or os.name=='posix':
---
> if tkevent.keycode == 105 or (os.name=='posix' and
sys.platform!='darwin') \
> or (sys.platform=='darwin' and tkevent.keycode == 6029369):
653c697,698
< if tkevent.keycode == 104 or os.name=='posix':
---
> if tkevent.keycode == 104 or (os.name=='posix' and
sys.platform!='darwin') \
> or (sys.platform=='darwin' and tkevent.keycode == 5963832):
658,659c703,704
< if tkevent.keycode == 103 or os.name=='posix':
< if self._executeBinding("VK_NUMPAD7") == 1:
---
> if tkevent.keycode == 103 or (os.name=='posix' and
sys.platform!='darwin') \
> or (sys.platform=='darwin' and tkevent.keycode == 5832759):
663c708,709
< if tkevent.keycode == 102 or os.name=='posix':
---
> if tkevent.keycode == 102 or (os.name=='posix' and
sys.platform!='darwin') \
> or (sys.platform=='darwin' and tkevent.keycode == 5767222):
668c714,715
< if tkevent.keycode == 101 or os.name=='posix':
---
> if tkevent.keycode == 101 or (os.name=='posix' and
sys.platform!='darwin') \
> or (sys.platform=='darwin' and tkevent.keycode == 5701685):
673c720,721
< if tkevent.keycode == 100 or os.name=='posix':
---
> if tkevent.keycode == 100 or (os.name=='posix' and
sys.platform!='darwin') \
> or (sys.platform=='darwin' and tkevent.keycode == 5636148):
678c726,727
< if tkevent.keycode == 99 or os.name=='posix':
---
> if tkevent.keycode == 99 or (os.name=='posix' and
sys.platform!='darwin') \
> or (sys.platform=='darwin' and tkevent.keycode == 5570611):
683c732,733
< if tkevent.keycode == 98 or os.name=='posix':
---
> if tkevent.keycode == 98 or (os.name=='posix' and
sys.platform!='darwin') \
> or (sys.platform=='darwin' and tkevent.keycode == 5505074):
688c738,739
< if tkevent.keycode == 97 or os.name=='posix':
---
> if tkevent.keycode == 97 or (os.name=='posix' and
sys.platform!='darwin') \
> or (sys.platform=='darwin' and tkevent.keycode == 5439537):
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click