[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r7550 - in trunk/gnue-forms/src: . uidrivers/curses
From: |
johannes |
Subject: |
[gnue] r7550 - in trunk/gnue-forms/src: . uidrivers/curses |
Date: |
Fri, 20 May 2005 03:48:45 -0500 (CDT) |
Author: johannes
Date: 2005-05-20 03:48:44 -0500 (Fri, 20 May 2005)
New Revision: 7550
Modified:
trunk/gnue-forms/src/GFKeyMapper.py
trunk/gnue-forms/src/uidrivers/curses/UIdriver.py
trunk/gnue-forms/src/uidrivers/curses/dialogs.py
Log:
Added jumptoRecord to curses; KeyMapper.loadUserKeyMap () does accept proper
maps now
Modified: trunk/gnue-forms/src/GFKeyMapper.py
===================================================================
--- trunk/gnue-forms/src/GFKeyMapper.py 2005-05-20 07:57:59 UTC (rev 7549)
+++ trunk/gnue-forms/src/GFKeyMapper.py 2005-05-20 08:48:44 UTC (rev 7550)
@@ -35,10 +35,7 @@
from gnue.common.apps import errors
-class InvalidKeystrokeName(StandardError):
- """
- Exception class used by the loadUserKeyMap function.
- """
+class InvalidKeystrokeName (errors.SystemError):
pass
@@ -84,8 +81,8 @@
def loadUserKeyMap(self, dict):
usermap = {}
- for event in dict.keys():
- val = string.upper(dict[event])
+ for event in dict.keys ():
+ val = dict [event]
# Save any actual '+' keystrokes
if val[:1] == '-':
@@ -94,25 +91,28 @@
val = val[:-2] + 'NEG'
val = string.replace(string.replace(val,' ',''),'--','-NEG')
- keys = string.split(val,'-')
+ keys = val.split ('-')
- base = None
+ base = None
shifted = False
- meta = False
- ctrl = False
+ meta = False
+ ctrl = False
for key in keys:
- if key in ('CTRL','CONTROL'):
+ current = key.upper ()
+
+ if current in ('CTRL','CONTROL'):
ctrl = True
- elif key in ('META','ALT'):
+ elif current in ('META','ALT'):
meta = True
- elif key in ('SHFT','SHIFT'):
+ elif current in ('SHFT','SHIFT'):
shifted = True
- elif vk.__dict__.has_key(key):
- base = vk.__dict__[key]
- elif len(key) == 1:
- # TODO: This might not be necessary
- key = ord(key)
+ elif vk.__dict__.has_key (current):
+ base = vk.__dict__ [current]
+
+ elif len(current) == 1:
+ # We have to use the given key, so Ctrl-r is different than Ctrl-R
+ base = ord (key)
else:
raise InvalidKeystrokeName, \
u_("Invalid keystroke id '%(key)s' in keymap for '%(event)s'") \
@@ -125,7 +125,7 @@
% {'comb' : dict [event],
'event': event}
- usermap[(base, shifted, ctrl, meta)] = string.upper(event)
+ usermap [(base, shifted, ctrl, meta)] = event.upper ()
# Now, load any default keys they forgot to bind
Modified: trunk/gnue-forms/src/uidrivers/curses/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/UIdriver.py 2005-05-20 07:57:59 UTC
(rev 7549)
+++ trunk/gnue-forms/src/uidrivers/curses/UIdriver.py 2005-05-20 08:48:44 UTC
(rev 7550)
@@ -76,7 +76,7 @@
self.attr ['infomsg'] = curses.color_pair (8) + curses.A_BOLD
self.attr ['warnmsg'] = curses.color_pair (9) + curses.A_BOLD
self.attr ['errormsg'] = curses.color_pair (9) + curses.A_BOLD \
- + curses.A_BLINK
+ + curses.A_BLINK
self.attr ['window 1'] = curses.color_pair (5)
self.__currentForm = None
@@ -100,6 +100,7 @@
self.__exiting = False
KeyMapper.setUIKeyMap (self._keymap)
+ KeyMapper.loadUserKeyMap ({'JUMPPROMPT': 'Ctrl-r'})
# Find out all functions mapped to function keys
# Both hold [eventname, enabled] pairs:
@@ -339,96 +340,33 @@
# ---------------------------------------------------------------------------
- # Ask for login info
+ # Clean up everything
# ---------------------------------------------------------------------------
- def askLogin (self, text, fields, error):
+ def _exit (self, formName):
- l = 0
- for field in fields:
- if l < len (field [1]):
- l = len (field [1])
- w = l + 18
- if w < len (text):
- w = len (text)
- if error and w < len (error):
- w = len (error)
- w += 4
+ self.__exiting = True
- h = len (fields) + 4
- if error:
- h += 2
- (screenX, screenY) = self.screenSize ()
+ # ---------------------------------------------------------------------------
+ # Get input data for a given set of fields
+ # ---------------------------------------------------------------------------
- win = curses.newwin (h, w, (screenY - h) / 2, (screenX - w) / 2)
- win.keypad (1)
- win.bkgd (' ', self.attr ['background'])
- win.box ()
+ def _getInput (self, title, fields, cancel = True):
- win.addstr (1, (w - len (text)) / 2, o(text))
+ if self.__currentForm:
+ (left, top, right, bottom) = self.__currentForm.getCanvas ()
+ else:
+ (right, bottom) = self.__screen.getmaxyx ()
+ left = top = 0
- y = 3
- for field in fields:
- win.addstr (y, 2, o(field [1]))
- win.addstr (y, l + 3, ':')
- win.addstr (y, l + 5, ' ' * 16, self.attr ['entry'])
- y += 1
+ dialog = dialogs.InputDialog (title, fields, self.attr, cancel, left, top,
+ right, bottom)
+ dialog.run ()
+ return dialog.inputData
- if error:
- win.addstr (h - 2, (w - len (error)) / 2, o(error))
- result = {}
-
- y = 3
- for field in fields:
- input = ''
- while True:
-
- if field [2]:
- out = '*' * len (input)
- else:
- out = input
- out = out + ' ' * (16 - len (out))
- win.addstr (y, l + 5, out, self.attr ['focusentry'])
-
- win.move (y, l + 5 + len (input))
- k = win.getkey ()
-
- if k == 'KEY_BACKSPACE': # backspace
- if len (input):
- input = input [:-1]
- continue
- elif len (k) > 1: # ignore other function keys
- continue
- elif k == chr (10): # enter key
- break
- elif k == chr (27): # esc key
- raise GLoginHandler.UserCanceledLogin
- elif k < ' ': # ignore other control keys
- continue
-
- input = input + k
- if len (input) > 16:
- input = input [:16]
-
- win.addstr (y, l + 5, out, self.attr ['entry']) # remove focus color
- result [field [0]] = input
- y += 1
-
- self.__screen.refresh () # remove login box
-
- return result
-
# ---------------------------------------------------------------------------
- # Clean up everything
- # ---------------------------------------------------------------------------
-
- def _exit (self, formName):
-
- self.__exiting = True
-
- # ---------------------------------------------------------------------------
# Helper method for forms to get screen size
# ---------------------------------------------------------------------------
Modified: trunk/gnue-forms/src/uidrivers/curses/dialogs.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/dialogs.py 2005-05-20 07:57:59 UTC
(rev 7549)
+++ trunk/gnue-forms/src/uidrivers/curses/dialogs.py 2005-05-20 08:48:44 UTC
(rev 7550)
@@ -184,6 +184,7 @@
self.attrs = attrs
self.fields = fields
+ self.cancel = cancel
self.__buildWindow (title, left, top, right, bottom)
self.inputData = {}
@@ -250,7 +251,7 @@
else:
self.inputData [name] = value
- if code == 27:
+ if code == 27 and self.cancel:
self.inputData = None
break
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r7550 - in trunk/gnue-forms/src: . uidrivers/curses,
johannes <=