[shpy-commit] r2865 - shpy/trunk/dist/shpy
mwh@codespeak.net
mwh@codespeak.net
Tue, 20 Jan 2004 17:12:07 +0100 (MET)
Author: mwh
Date: Tue Jan 20 17:12:07 2004
New Revision: 2865
Modified:
shpy/trunk/dist/shpy/ui_pygame.py
Log:
Simple support for control key bindings, and C-a, C-e implementations
to match (not just to annoy Holger by implementing bits of emacs :-)
Modified: shpy/trunk/dist/shpy/ui_pygame.py
==============================================================================
--- shpy/trunk/dist/shpy/ui_pygame.py (original)
+++ shpy/trunk/dist/shpy/ui_pygame.py Tue Jan 20 17:12:07 2004
@@ -19,7 +19,8 @@
KEYMAP = {}
for name, value in pygame.locals.__dict__.items():
if name.startswith('K_'):
- KEYMAP[value] = name
+ KEYMAP[(value, False)] = name
+ KEYMAP[(value, True)] = 'CTRL_' + name
##LINECACHE = {}
##def rendertext(font, text, fgcolor, bgcolor=(255,255,255,255)):
@@ -111,6 +112,12 @@
self.cell.lines[y] = line
self.cursor.x += len(event.unicode)
self.changed[self.cell] = 1
+
+ def CTRL_K_a(self, event):
+ self.cursor.x = 0
+
+ def CTRL_K_e(self, event):
+ self.cursor.x = len(self.cell.lines[self.cursor.y])
def K_UP(self, event):
if self.cursor.y > 0:
@@ -169,8 +176,9 @@
print event
if event.type == KEYDOWN:
keynames = []
- if event.key in KEYMAP:
- keynames.append(KEYMAP[event.key])
+ k = (event.key, bool(event.mod&KMOD_CTRL))
+ if k in KEYMAP:
+ keynames.append(KEYMAP[k])
if event.unicode:
keynames.append("PRINTABLE_KEY")
for keyname in keynames: