[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r9043 - in trunk/gnue-forms/src/uidrivers/curses: . widgets
From: |
johannes |
Subject: |
[gnue] r9043 - in trunk/gnue-forms/src/uidrivers/curses: . widgets |
Date: |
Thu, 16 Nov 2006 08:13:18 -0600 (CST) |
Author: johannes
Date: 2006-11-16 08:13:17 -0600 (Thu, 16 Nov 2006)
New Revision: 9043
Modified:
trunk/gnue-forms/src/uidrivers/curses/UIdriver.py
trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py
trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py
trunk/gnue-forms/src/uidrivers/curses/widgets/page.py
Log:
Support for multibyte strings (on input)
Modified: trunk/gnue-forms/src/uidrivers/curses/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/UIdriver.py 2006-11-14 14:25:42 UTC
(rev 9042)
+++ trunk/gnue-forms/src/uidrivers/curses/UIdriver.py 2006-11-16 14:13:17 UTC
(rev 9043)
@@ -206,9 +206,8 @@
try:
key = self.__current_form.wait()
- if key >= 0 and key <= 255:
- self._focus_widget._keypress(unicode(chr(key),
- i18n.encoding))
+ if isinstance(key, basestring):
+ self._focus_widget._keypress(key)
else:
if self.__shiftkeys.has_key(key): # translate shifted f-key
(key, shift, ctrl, meta) = self.__shiftkeys[key]
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py 2006-11-14
14:25:42 UTC (rev 9042)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py 2006-11-16
14:13:17 UTC (rev 9043)
@@ -80,11 +80,13 @@
def _setText (self, index, text, attr, selection = None):
+ gDebug(2, "TEXT=%s" % repr(text))
+ value = text
if selection:
(s1, s2) = selection
- self._parent.write (self._x, self._y + index, text[:s1], attr)
- self._parent.write (self._x + s1, self._y + index, text[s1:s2],
+ self._parent.write (self._x, self._y + index, value[:s1], attr)
+ self._parent.write (self._x + s1, self._y + index, value[s1:s2],
attr + curses.A_STANDOUT)
- self._parent.write (self._x + s2, self._y + index, text[s2:], attr)
+ self._parent.write (self._x + s2, self._y + index, value[s2:],
attr)
else:
- self._parent.write (self._x, self._y + index, text, attr)
+ self._parent.write (self._x, self._y + index, value, attr)
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py 2006-11-14
14:25:42 UTC (rev 9042)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py 2006-11-16
14:13:17 UTC (rev 9043)
@@ -41,7 +41,7 @@
self.__style = event.object.style
if self.__style in ['default', 'password', 'label', 'dropdown',
- 'listbox']:
+ 'listbox', 'multiline']:
self.__length = event.object['Char:width']
else:
self.__length = None
@@ -54,7 +54,7 @@
self.__voffset = {}
self.__isMultiline = (self.__style in ['default', 'password'] and \
- self.__height > 1)
+ self.__height > 1) or self.__style == 'multiline'
self.__focusIndex = None
@@ -317,6 +317,7 @@
elif self.__isMultiline:
# Create all visible, empty lines
+ gDebug(2, "LEN: %s, H: %s" % (self.__length, self.__height))
data = [''.ljust(self.__length)] * self.__height
hOffset = self.__offset[index]
vOffset = self.__voffset[index]
@@ -337,6 +338,7 @@
else:
value = self.__value[index]
offset = self.__offset[index]
+ text = ''
if self.__style in['default', 'label', 'dropdown']:
text = value or ''
@@ -356,6 +358,9 @@
else:
text = '[ ]'
+ else:
+ gDebug(2, "STYLE==%s" % self.__style)
+
attr = self.__getAttr(index)
self._setText(index, text, attr, self.__selection[index])
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/page.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/page.py 2006-11-14
14:25:42 UTC (rev 9042)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/page.py 2006-11-16
14:13:17 UTC (rev 9043)
@@ -24,6 +24,7 @@
import curses
from gnue.forms.uidrivers._base.widgets._base import UIWidget
+from gnue.common.apps import i18n
# =============================================================================
# Page class
@@ -31,60 +32,78 @@
class UIPage (UIWidget):
- # ---------------------------------------------------------------------------
- # Initialize page
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Initialize page
+ # -------------------------------------------------------------------------
- def create_widget (self, event, spacer):
+ def create_widget (self, event, spacer):
- if hasattr (event.object, 'caption'):
- caption = event.object.caption
- else:
- caption = event.object.name
+ if hasattr (event.object, 'caption'):
+ caption = event.object.caption
+ else:
+ caption = event.object.name
- event.parent.addPage (self, caption)
+ event.parent.addPage (self, caption)
- (self.__x1, self.__y1, self.__x2, self.__y2) = event.parent.getCanvas ()
+ (self.__x1, self.__y1, self.__x2, self.__y2) = event.parent.getCanvas
()
- self.__window = curses.newpad (self.__y2 - self.__y1, self.__x2 -
self.__x1)
- self.__window.keypad (1)
- self.__window.bkgd (' ', self._uiDriver.attr ['background'])
- self.__cursor = (0, 0)
+ self.__window = curses.newpad (self.__y2 - self.__y1, self.__x2 -
self.__x1)
+ self.__window.keypad (1)
+ self.__window.bkgd (' ', self._uiDriver.attr ['background'])
+ self.__cursor = (0, 0)
- # ---------------------------------------------------------------------------
- # Write a text to a given position
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Write a text to a given position
+ # -------------------------------------------------------------------------
- def write (self, x, y, text, attribute):
+ def write (self, x, y, text, attribute):
- self.__window.addstr (y, x, o(text), attribute)
+ self.__window.addstr (y, x, o(text), attribute)
- # ---------------------------------------------------------------------------
- # Write a special character to a given position
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Write a special character to a given position
+ # -------------------------------------------------------------------------
- def putchar (self, x, y, char, attribute):
+ def putchar (self, x, y, char, attribute):
- self.__window.addch (y, x, char, attribute)
+ self.__window.addch (y, x, char, attribute)
- # ---------------------------------------------------------------------------
- # Move the cursor to a given position
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Move the cursor to a given position
+ # -------------------------------------------------------------------------
- def move (self, x, y):
+ def move (self, x, y):
- self.__cursor = (x, y)
+ self.__cursor = (x, y)
- # ---------------------------------------------------------------------------
- # Update screen and wait for user input
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Update screen and wait for user input
+ # -------------------------------------------------------------------------
- def wait (self):
+ def wait (self):
- self.__window.move (self.__cursor [1], self.__cursor [0])
- self.__window.refresh (0, 0, self.__y1, self.__x1, self.__y2, self.__x2)
- return self.__window.getch ()
+ self.__window.move (self.__cursor [1], self.__cursor [0])
+ self.__window.refresh (0, 0, self.__y1, self.__x1, self.__y2,
self.__x2)
+ return self.__get_key()
+ # -------------------------------------------------------------------------
+
+ def __get_key(self):
+
+ key = self.__window.getch()
+
+ # Function keys are returned as key-code
+ if key > 255:
+ return key
+
+ result = [key]
+ if i18n.encoding == 'utf-8':
+ if (key > 127 and key <= 255):
+ result.append(self.__window.getch())
+
+ return unicode("".join([chr(i) for i in result]), i18n.encoding)
+
+
# =============================================================================
# Configuration data
# =============================================================================
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r9043 - in trunk/gnue-forms/src/uidrivers/curses: . widgets,
johannes <=