improve text editing. Patch by Anders Holst
authorFelix Domke <tmbinc@elitedvb.net>
Wed, 28 Nov 2007 13:07:43 +0000 (13:07 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Wed, 28 Nov 2007 13:07:43 +0000 (13:07 +0000)
data/keymap.xml
lib/gdi/font.cpp
lib/gui/elabel.cpp
lib/gui/elistboxcontent.cpp
lib/python/Components/ConfigList.py
lib/python/Components/Input.py
lib/python/Components/config.py
lib/python/Screens/ChannelSelection.py
lib/python/Screens/InputBox.py
lib/python/Screens/TimerEntry.py
lib/python/Tools/NumericalTextInput.py

index 452bf4a..c10eec4 100644 (file)
@@ -38,7 +38,9 @@
                <key id="KEY_RIGHT" mapto="right" flags="mr" />
                <key id="KEY_RED" mapto="cancel" flags="m" />
                <key id="KEY_GREEN" mapto="save" flags="m" />
-               <key id="KEY_MUTE" mapto="delete" flags="mr" />
+               <key id="KEY_MUTE" mapto="deleteForward" flags="mr" />
+               <key id="KEY_NEXT" mapto="deleteForward" flags="mr" />
+               <key id="KEY_PREVIOUS" mapto="deleteBackward" flags="mr" />
                <key id="KEY_1" mapto="1" flags="m" />
                <key id="KEY_2" mapto="2" flags="m" />
                <key id="KEY_3" mapto="3" flags="m" />
                <key id="KEY_ENTER" mapto="ok" flags="m" />
                <key id="KEY_EXIT" mapto="back" flags="m" />
                <key id="KEY_ESC" mapto="back" flags="m" />
-               <key id="KEY_MUTE" mapto="delete" flags="mr" />
+               <key id="KEY_MUTE" mapto="deleteForward" flags="mr" />
+               <key id="KEY_NEXT" mapto="deleteForward" flags="mr" />
+               <key id="KEY_PREVIOUS" mapto="deleteBackward" flags="mr" />
                <key id="KEY_1" mapto="1" flags="m" />
                <key id="KEY_2" mapto="2" flags="m" />
                <key id="KEY_3" mapto="3" flags="m" />
        </map>
 
        <map context="TextEntryActions">
-               <key id="KEY_MUTE" mapto="delete" flags="mr" />
+               <key id="KEY_MUTE" mapto="deleteForward" flags="mr" />
+               <key id="KEY_NEXT" mapto="deleteForward" flags="mr" />
+               <key id="KEY_PREVIOUS" mapto="deleteBackward" flags="mr" />
        </map>  
 
        <map context="InfobarSeekActions">
index 6d445ed..ce1b3c4 100644 (file)
@@ -843,9 +843,6 @@ void eTextPara::realign(int dir)    // der code hier ist ein wenig merkwuerdig.
                        num++;
                }
 
-               if (!num)               // line mit nur einem space
-                       continue;
-
                switch (dir)
                {
                case dirRight:
index 6e53c85..87ad513 100644 (file)
@@ -51,7 +51,20 @@ int eLabel::event(int event, void *data, void *data2)
 
                        int glyphs = para->size();
 
-                       if ((m_pos < 0) || (m_pos >= glyphs))
+                       if (m_pos == -2) {  /* All glyphs inverted */
+                               eRect bbox;
+                               int left = 0, right = 0;
+                               for (int i=0; i<glyphs; i++)
+                                       para->setGlyphFlag(i, GS_INVERT);
+                               if (glyphs > 0) {
+                                       bbox = para->getGlyphBBox(0);
+                                       left = bbox.left();
+                                       bbox = para->getGlyphBBox(glyphs-1);
+                                       right = bbox.left() + bbox.width();
+                               }
+                               bbox = eRect(left, 0, right-left, size().height());
+                               painter.fill(bbox);
+                       } else if ((m_pos < 0) || (m_pos >= glyphs))
                                eWarning("glyph index %d in eLabel out of bounds!", m_pos);
                        else
                        {
index 191bc7e..585d6fe 100644 (file)
@@ -431,6 +431,8 @@ void eListboxPythonConfigContent::paint(gPainter &painter, eWindowStyle &style,
                                                if (plist && PyList_Check(plist))
                                                        entries = PyList_Size(plist);
                                                
+                                               int left=0, right=0, last=-1;
+                                               eRect bbox;
                                                for (int i = 0; i < entries; ++i)
                                                {
                                                        ePyObject entry = PyList_GET_ITEM(plist, i);
@@ -440,15 +442,23 @@ void eListboxPythonConfigContent::paint(gPainter &painter, eWindowStyle &style,
                                                                eWarning("glyph index %d in PythonConfigList out of bounds!", num);
                                                        else
                                                        {
+                                                               if (last+1 != num && last != -1) {
+                                                                       bbox = eRect(left, offset.y(), right-left, m_itemsize.height());
+                                                                       painter.fill(bbox);
+                                                               }
                                                                para->setGlyphFlag(num, GS_INVERT);
-                                                               eRect bbox;
                                                                bbox = para->getGlyphBBox(num);
-                                                               bbox = eRect(bbox.left(), offset.y(), bbox.width(), m_itemsize.height());
-                                                               painter.fill(bbox);
+                                                               if (last+1 != num || last == -1)
+                                                                       left = bbox.left();
+                                                               right = bbox.left() + bbox.width();
+                                                               last = num;
                                                        }
                                                                /* entry is borrowed */
                                                }
-                                               
+                                               if (last != -1) {
+                                                       bbox = eRect(left, offset.y(), right-left, m_itemsize.height());
+                                                       painter.fill(bbox);
+                                               }
                                                painter.renderPara(para, ePoint(0, 0));
                                                        /* pvalue is borrowed */
                                                        /* plist is 0 or borrowed */
index 47b577e..a54d27b 100644 (file)
@@ -1,8 +1,8 @@
 from HTMLComponent import HTMLComponent
 from GUIComponent import GUIComponent
-from config import KEY_LEFT, KEY_RIGHT, KEY_0, KEY_DELETE, KEY_OK, KEY_TIMEOUT, ConfigElement
+from config import KEY_LEFT, KEY_RIGHT, KEY_HOME, KEY_END, KEY_0, KEY_DELETE, KEY_BACKSPACE, KEY_OK, KEY_TOGGLEOW, KEY_ASCII, KEY_TIMEOUT, KEY_NUMBERS, ConfigElement
 from Components.ActionMap import NumberActionMap
-from enigma import eListbox, eListboxPythonConfigContent, eTimer
+from enigma import eListbox, eListboxPythonConfigContent, eRCInput, eTimer
 from Screens.MessageBox import MessageBox
 
 class ConfigList(HTMLComponent, GUIComponent, object):
@@ -18,9 +18,13 @@ class ConfigList(HTMLComponent, GUIComponent, object):
                self.setHelpWindowSession(session)
 
        def execBegin(self):
+               rcinput = eRCInput.getInstance()
+               rcinput.setKeyboardMode(rcinput.kmAscii)
                self.timer.timeout.get().append(self.timeout)
 
        def execEnd(self):
+               rcinput = eRCInput.getInstance()
+               rcinput.setKeyboardMode(rcinput.kmNone)
                self.timer.timeout.get().remove(self.timeout)
 
        def setHelpWindowSession(self, session):
@@ -39,7 +43,7 @@ class ConfigList(HTMLComponent, GUIComponent, object):
                        self.invalidateCurrent()
                        if self.help_window:
                                self.help_window.update(selection[1])
-                       if key not in [KEY_TIMEOUT, KEY_LEFT, KEY_RIGHT, KEY_DELETE, KEY_OK]:
+                       if key in KEY_NUMBERS:
                                self.timer.start(1000, 1)
 
        def getCurrent(self):
@@ -111,12 +115,20 @@ class ConfigList(HTMLComponent, GUIComponent, object):
 
 class ConfigListScreen:
        def __init__(self, list, session = None, on_change = None):
-               self["config_actions"] = NumberActionMap(["SetupActions", "TextInputActions"],
+               self["config_actions"] = NumberActionMap(["SetupActions", "InputAsciiActions", "KeyboardInputActions"],
                {
+                       "gotAsciiCode": self.keyGotAscii,
                        "ok": self.keyOK,
+                       "accept": self.keyOK,
                        "left": self.keyLeft,
                        "right": self.keyRight,
-                       "delete": self.keyDelete,
+                       "moveLeft": self.keyLeft,
+                       "moveRight": self.keyRight,
+                       "moveHome": self.keyHome,
+                       "moveEnd": self.keyEnd,
+                       "deleteForward": self.keyDelete,
+                       "deleteBackward": self.keyBackspace,
+                       "toggleOverwrite": self.keyToggleOW,
                        "1": self.keyNumberGlobal,
                        "2": self.keyNumberGlobal,
                        "3": self.keyNumberGlobal,
@@ -146,10 +158,30 @@ class ConfigListScreen:
                self["config"].handleKey(KEY_RIGHT)
                self.__changed()
 
+       def keyHome(self):
+               self["config"].handleKey(KEY_HOME)
+               self.__changed()
+
+       def keyEnd(self):
+               self["config"].handleKey(KEY_END)
+               self.__changed()
+
        def keyDelete(self):
                self["config"].handleKey(KEY_DELETE)
                self.__changed()
 
+       def keyBackspace(self):
+               self["config"].handleKey(KEY_BACKSPACE)
+               self.__changed()
+
+       def keyToggleOW(self):
+               self["config"].handleKey(KEY_TOGGLEOW)
+               self.__changed()
+
+       def keyGotAscii(self):
+               self["config"].handleKey(KEY_ASCII)
+               self.__changed()
+
        def keyNumberGlobal(self, number):
                self["config"].handleKey(KEY_0 + number)
                self.__changed()
index e0a7f44..64ffdf4 100644 (file)
@@ -11,25 +11,51 @@ class Input(VariableText, HTMLComponent, GUIComponent, NumericalTextInput):
        PIN = 1
        NUMBER = 2
 
-       def __init__(self, text="", maxSize = False, type = TEXT):
+       def __init__(self, text="", maxSize = False, visible_width = False, type = TEXT):
                NumericalTextInput.__init__(self, self.right)
                GUIComponent.__init__(self)
                VariableText.__init__(self)
                self.type = type
+               self.allmarked = (text != "") and (type != self.PIN)
                self.maxSize = maxSize
                self.currPos = 0
-               self.overwrite = 0
+               self.visible_width = visible_width
+               self.offset = 0
+               self.overwrite = maxSize
                self.setText(text)
                
        def __len__(self):
                return len(self.text)
 
        def update(self):
-               self.setMarkedPos(self.currPos)
-               if self.type == self.PIN:
-                       self.text = "*" * len(self.Text)
+               if self.visible_width:
+                       if self.currPos < self.offset:
+                               self.offset = self.currPos
+                       if self.currPos >= self.offset + self.visible_width:
+                               if self.currPos == len(self.Text):
+                                       self.offset = self.currPos - self.visible_width
+                               else:
+                                       self.offset = self.currPos - self.visible_width + 1
+                       if self.offset > 0 and self.offset + self.visible_width > len(self.Text):
+                               self.offset = max(0, len(self.Text) - self.visible_width)
+               if self.allmarked:
+                       self.setMarkedPos(-2)
                else:
-                       self.text = self.Text.encode("utf-8")
+                       self.setMarkedPos(self.currPos-self.offset)
+               if self.visible_width:
+                       if self.type == self.PIN:
+                               self.text = ""
+                               for x in self.Text[self.offset:self.offset+self.visible_width]:
+                                       self.text += (x==" " and " " or "*")
+                       else:
+                               self.text = self.Text[self.offset:self.offset+self.visible_width].encode("utf-8") + " "
+               else:
+                       if self.type == self.PIN:
+                               self.text = ""
+                               for x in self.Text:
+                                       self.text += (x==" " and " " or "*")
+                       else:
+                               self.text = self.Text.encode("utf-8") + " "
 
        def setText(self, text):
                if not len(text):
@@ -47,27 +73,46 @@ class Input(VariableText, HTMLComponent, GUIComponent, NumericalTextInput):
                return self.Text.encode("utf-8")
 
        def createWidget(self, parent):
-               return eLabel(parent, self.currPos)
+               if self.allmarked:
+                       return eLabel(parent, -2)
+               else:
+                       return eLabel(parent, self.currPos-self.offset)
 
        def getSize(self):
                s = self.instance.calculateSize()
                return (s.width(), s.height())
        
        def right(self):
-               self.currPos += 1
-               if self.currPos == len(self.Text):
-                       if self.maxSize:
-                               self.currPos -= 1
-                       else:
-                               self.Text = self.Text + " "
+               if self.type == self.TEXT:
+                       self.timeout()
+               if self.allmarked:
+                       self.currPos = 0
+                       self.allmarked = False
+               elif self.maxSize:
+                       if self.currPos < len(self.Text)-1:
+                               self.currPos += 1
+               else:
+                       if self.currPos < len(self.Text):
+                               self.currPos += 1
                self.update()
 
        def left(self):
-               if self.currPos > 0:
+               if self.type == self.TEXT:
+                       self.timeout()
+               if self.allmarked:
+                       if self.maxSize:
+                               self.currPos = len(self.Text) - 1
+                       else:
+                               self.currPos = len(self.Text)
+                       self.allmarked = False
+               elif self.currPos > 0:
                        self.currPos -= 1
-                       self.update()
+               self.update()
 
        def up(self):
+               self.allmarked = False
+               if self.type == self.TEXT:
+                       self.timeout()
                if self.Text[self.currPos] == "9" or self.Text[self.currPos] == " ":
                        newNumber = "0"
                else:
@@ -76,6 +121,9 @@ class Input(VariableText, HTMLComponent, GUIComponent, NumericalTextInput):
                self.update()
 
        def down(self):
+               self.allmarked = False
+               if self.type == self.TEXT:
+                       self.timeout()
                if self.Text[self.currPos] == "0" or self.Text[self.currPos] == " ":
                        newNumber = "9"
                else:
@@ -84,51 +132,110 @@ class Input(VariableText, HTMLComponent, GUIComponent, NumericalTextInput):
                self.update()
                
        def home(self):
+               self.allmarked = False
+               if self.type == self.TEXT:
+                       self.timeout()
                self.currPos = 0
                self.update()
        
        def end(self):
-               self.currPos = len(self.Text) - 1
+               self.allmarked = False
+               if self.type == self.TEXT:
+                       self.timeout()
+               if self.maxSize:
+                       self.currPos = len(self.Text) - 1
+               else:
+                       self.currPos = len(self.Text)
                self.update()
 
+       def insertChar(self, ch, pos, owr, ins):
+               if ins and not self.maxSize:
+                       self.Text = self.Text[0:pos] + ch + self.Text[pos:]
+               elif owr or self.overwrite:
+                       self.Text = self.Text[0:pos] + ch + self.Text[pos + 1:]
+               elif self.maxSize:
+                       self.Text = self.Text[0:pos] + ch + self.Text[pos:-1]
+               else:
+                       self.Text = self.Text[0:pos] + ch + self.Text[pos:]
+
+       def deleteChar(self, pos):
+               if not self.maxSize:
+                       self.Text = self.Text[0:pos] + self.Text[pos + 1:]
+               elif self.overwrite:
+                       self.Text = self.Text[0:pos] + " " + self.Text[pos + 1:]
+               else:
+                       self.Text = self.Text[0:pos] + self.Text[pos + 1:] + " "
+
+       def deleteAllChars(self):
+               if self.maxSize:
+                       self.Text = " " * len(self.Text)
+               else:
+                       self.Text = ""
+               self.currPos = 0
+
        def tab(self):
-               if self.currPos == len(self.Text) - 1:
-                       self.Text=self.Text+ " "
-                       self.end()
+               if self.type == self.TEXT:
+                       self.timeout()
+               if self.allmarked:
+                       self.deleteAllChars()
+                       self.allmarked = False
                else:
-                       self.Text = self.Text[0:self.currPos] + " " + self.Text[self.currPos:]
+                       self.insertChar(" ", self.currPos, False, True);
+                       self.currPos += 1
                self.update()
 
        def delete(self):
-               self.Text = self.Text[:self.currPos] + self.Text[self.currPos + 1:]
+               if self.type == self.TEXT:
+                       self.timeout()
+               if self.allmarked:
+                       self.deleteAllChars()
+                       self.allmarked = False
+               else:
+                       self.deleteChar(self.currPos);
+                       if self.maxSize and self.overwrite:
+                               self.currPos += 1
                self.update()
 
-       def toggleOverwrite(self):
-               if self.overwrite==1:
-                       self.overwrite=0
+       def deleteBackward(self):
+               if self.type == self.TEXT:
+                       self.timeout()
+               if self.allmarked:
+                       self.deleteAllChars()
+                       self.allmarked = False
                else:
-                       self.overwrite=1
+                       if self.currPos > 0:
+                               self.deleteChar(self.currPos-1);
+                               if not self.maxSize and self.offset > 0:
+                                       self.offset -= 1
+                               self.currPos -= 1
                self.update()
 
-       def deleteBackward(self):
-               self.Text = self.Text[:self.currPos - 1] + self.Text[self.currPos:]
-               self.left()
+       def toggleOverwrite(self):
+               if self.type == self.TEXT:
+                       self.timeout()
+               self.overwrite = not self.overwrite
                self.update()
 
        def handleAscii(self, code):
-               newChar = unichr(code)
-               if self.overwrite==1:
-                       self.Text = self.Text[0:self.currPos] + newChar + self.Text[self.currPos + 1:]
-               else:
-                       self.Text = self.Text[0:self.currPos] + newChar + self.Text[self.currPos:]
+               if self.type == self.TEXT:
+                       self.timeout()
+               if self.allmarked:
+                       self.deleteAllChars()
+                       self.allmarked = False
+               self.insertChar(unichr(code), self.currPos, False, False);
                self.right()
 
        def number(self, number):
                if self.type == self.TEXT:
+                       owr = self.lastKey == number
                        newChar = self.getKey(number)
                elif self.type == self.PIN or self.type == self.NUMBER:
+                       owr = False
                        newChar = str(number)
-               self.Text = self.Text[0:self.currPos] + newChar + self.Text[self.currPos + 1:]
+               if self.allmarked:
+                       self.deleteAllChars()
+                       self.allmarked = False
+               self.insertChar(newChar, self.currPos, owr, False);
                if self.type == self.PIN or self.type == self.NUMBER:
                        self.right()
                self.update()
index de06871..f8ef0ec 100644 (file)
@@ -1,4 +1,5 @@
 import time
+from enigma import getPrevAsciiCode
 from Tools.NumericalTextInput import NumericalTextInput
 from Tools.Directories import resolveFilename, SCOPE_CONFIG
 import copy
@@ -104,7 +105,12 @@ KEY_LEFT = 0
 KEY_RIGHT = 1
 KEY_OK = 2
 KEY_DELETE = 3
-KEY_TIMEOUT = 4
+KEY_BACKSPACE = 4
+KEY_HOME = 5
+KEY_END = 6
+KEY_TOGGLEOW = 7
+KEY_ASCII = 8
+KEY_TIMEOUT = 9
 KEY_NUMBERS = range(12, 12+10)
 KEY_0 = 12
 KEY_9 = 12+9
@@ -192,6 +198,10 @@ class ConfigSelection(ConfigElement):
                        self.value = self.choices[(i + nchoices - 1) % nchoices]
                elif key == KEY_RIGHT:
                        self.value = self.choices[(i + 1) % nchoices]
+               elif key == KEY_HOME:
+                       self.value = self.choices[0]
+               elif key == KEY_END:
+                       self.value = self.choices[nchoices - 1]
 
        def getText(self):
                descr = self.description[self.value]
@@ -233,6 +243,10 @@ class ConfigBoolean(ConfigElement):
        def handleKey(self, key):
                if key in [KEY_LEFT, KEY_RIGHT]:
                        self.value = not self.value
+               elif key == KEY_HOME:
+                       self.value = False
+               elif key == KEY_END:
+                       self.value = True
 
        def getText(self):
                descr = self.descriptions[self.value]
@@ -294,8 +308,10 @@ class ConfigDateTime(ConfigElement):
        def handleKey(self, key):
                if key == KEY_LEFT:
                        self.value = self.value - self.increment
-               if key == KEY_RIGHT:
+               elif key == KEY_RIGHT:
                        self.value = self.value + self.increment
+               elif key == KEY_HOME or key == KEY_END:
+                       self.value = self.default
 
        def getText(self):
                return time.strftime(self.formatstring, time.localtime(self.value))
@@ -374,7 +390,28 @@ class ConfigSequence(ConfigElement):
                        self.marked_pos += 1
                        self.validatePos()
                
-               if key in KEY_NUMBERS:
+               if key == KEY_HOME:
+                       self.marked_pos = 0
+                       self.validatePos()
+
+               if key == KEY_END:
+                       max_pos = 0
+                       num = 0
+                       for i in self._value:
+                               max_pos += len(str(self.limits[num][1]))
+                               num += 1
+                       self.marked_pos = max_pos - 1
+                       self.validatePos()
+               
+               if key in KEY_NUMBERS or key == KEY_ASCII:
+                       if key == KEY_ASCII:
+                               code = getPrevAsciiCode()
+                               if code < 48 or code > 57:
+                                       return
+                               number = code - 48
+                       else:
+                               number = getKeyNumber(key)
+                       
                        block_len = []
                        for x in self.limits:
                                block_len.append(len(str(x[1])))
@@ -392,8 +429,6 @@ class ConfigSequence(ConfigElement):
                                else:
                                        blocknumber += 1
 
-                       number = getKeyNumber(key)
-                       
                        # length of numberblock
                        number_len = len(str(self.limits[blocknumber][1]))
 
@@ -513,37 +548,124 @@ class ConfigFloat(ConfigSequence):
 
 # an editable text...
 class ConfigText(ConfigElement, NumericalTextInput):
-       def __init__(self, default = "", fixed_size = True):
+       def __init__(self, default = "", fixed_size = True, visible_width = False):
                ConfigElement.__init__(self)
                NumericalTextInput.__init__(self, nextFunc = self.nextFunc, handleTimeout = False)
                
                self.marked_pos = 0
+               self.allmarked = (default != "")
                self.fixed_size = fixed_size
+               self.visible_width = visible_width
+               self.offset = 0
+               self.overwrite = fixed_size
 
                self.value = self.default = default
 
        def validateMarker(self):
-               if self.marked_pos >= len(self.text):
-                       self.marked_pos = len(self.text) - 1
+               if self.fixed_size:
+                       if self.marked_pos > len(self.text)-1:
+                               self.marked_pos = len(self.text)-1
+               else:
+                       if self.marked_pos > len(self.text):
+                               self.marked_pos = len(self.text)
                if self.marked_pos < 0:
                        self.marked_pos = 0
+               if self.visible_width:
+                       if self.marked_pos < self.offset:
+                               self.offset = self.marked_pos
+                       if self.marked_pos >= self.offset + self.visible_width:
+                               if self.marked_pos == len(self.text):
+                                       self.offset = self.marked_pos - self.visible_width
+                               else:
+                                       self.offset = self.marked_pos - self.visible_width + 1
+                       if self.offset > 0 and self.offset + self.visible_width > len(self.text):
+                               self.offset = max(0, len(self.text) - self.visible_width)
+
+       def insertChar(self, ch, pos, owr):
+               if owr or self.overwrite:
+                       self.text = self.text[0:pos] + ch + self.text[pos + 1:]
+               elif self.fixed_size:
+                       self.text = self.text[0:pos] + ch + self.text[pos:-1]
+               else:
+                       self.text = self.text[0:pos] + ch + self.text[pos:]
 
-       #def nextEntry(self):
-       #       self.vals[1](self.getConfigPath())
+       def deleteChar(self, pos):
+               if not self.fixed_size:
+                       self.text = self.text[0:pos] + self.text[pos + 1:]
+               elif self.overwrite:
+                       self.text = self.text[0:pos] + " " + self.text[pos + 1:]
+               else:
+                       self.text = self.text[0:pos] + self.text[pos + 1:] + " "
+
+       def deleteAllChars(self):
+               if self.fixed_size:
+                       self.text = " " * len(self.text)
+               else:
+                       self.text = ""
+               self.marked_pos = 0
 
        def handleKey(self, key):
                # this will no change anything on the value itself
                # so we can handle it here in gui element
                if key == KEY_DELETE:
-                       self.text = self.text[0:self.marked_pos] + self.text[self.marked_pos + 1:]
+                       self.timeout()
+                       if self.allmarked:
+                               self.deleteAllChars()
+                               self.allmarked = False
+                       else:
+                               self.deleteChar(self.marked_pos)
+                               if self.fixed_size and self.overwrite:
+                                       self.marked_pos += 1
+               elif key == KEY_BACKSPACE:
+                       self.timeout()
+                       if self.allmarked:
+                               self.deleteAllChars()
+                               self.allmarked = False
+                       elif self.marked_pos > 0:
+                               self.deleteChar(self.marked_pos-1)
+                               if not self.fixed_size and self.offset > 0:
+                                       self.offset -= 1
+                               self.marked_pos -= 1
                elif key == KEY_LEFT:
-                       self.marked_pos -= 1
+                       self.timeout()
+                       if self.allmarked:
+                               self.marked_pos = len(self.text)
+                               self.allmarked = False
+                       else:
+                               self.marked_pos -= 1
                elif key == KEY_RIGHT:
+                       self.timeout()
+                       if self.allmarked:
+                               self.marked_pos = 0
+                               self.allmarked = False
+                       else:
+                               self.marked_pos += 1
+               elif key == KEY_HOME:
+                       self.timeout()
+                       self.allmarked = False
+                       self.marked_pos = 0
+               elif key == KEY_END:
+                       self.timeout()
+                       self.allmarked = False
+                       self.marked_pos = len(self.text)
+               elif key == KEY_TOGGLEOW:
+                       self.timeout()
+                       self.overwrite = not self.overwrite
+               elif key == KEY_ASCII:
+                       self.timeout()
+                       newChar = unichr(getPrevAsciiCode())
+                       if self.allmarked:
+                               self.deleteAllChars()
+                               self.allmarked = False
+                       self.insertChar(newChar, self.marked_pos, False)
                        self.marked_pos += 1
-                       self.maybeExpand()
                elif key in KEY_NUMBERS:
-                       number = self.getKey(getKeyNumber(key))
-                       self.text = self.text[0:self.marked_pos] + unicode(number) + self.text[self.marked_pos + 1:]
+                       owr = self.lastKey == getKeyNumber(key)
+                       newChar = self.getKey(getKeyNumber(key))
+                       if self.allmarked:
+                               self.deleteAllChars()
+                               self.allmarked = False
+                       self.insertChar(newChar, self.marked_pos, owr)
                elif key == KEY_TIMEOUT:
                        self.timeout()
                        return
@@ -551,14 +673,8 @@ class ConfigText(ConfigElement, NumericalTextInput):
                self.validateMarker()
                self.changed()
 
-       def maybeExpand(self):
-               if not self.fixed_size:
-                       if self.marked_pos >= len(self.text):
-                               self.text = self.text.ljust(len(self.text) + 1)
-
        def nextFunc(self):
                self.marked_pos += 1
-               self.maybeExpand()
                self.validateMarker()
                self.changed()
 
@@ -579,7 +695,18 @@ class ConfigText(ConfigElement, NumericalTextInput):
                return self.value
 
        def getMulti(self, selected):
-               return ("mtext"[1-selected:], self.value, [self.marked_pos])
+               if self.visible_width:
+                       if self.allmarked:
+                               mark = range(0, min(self.visible_width, len(self.text)))
+                       else:
+                               mark = [self.marked_pos-self.offset]
+                       return ("mtext"[1-selected:], self.text[self.offset:self.offset+self.visible_width].encode("utf-8")+" ", mark)
+               else:
+                       if self.allmarked:
+                               mark = range(0, len(self.text))
+                       else:
+                               mark = [self.marked_pos]
+                       return ("mtext"[1-selected:], self.value+" ", mark)
 
        def helpWindow(self):
                from Screens.NumericalTextInputHelpDialog import NumericalTextInputHelpDialog
@@ -612,6 +739,10 @@ class ConfigSlider(ConfigElement):
                        self.value -= self.increment
                elif key == KEY_RIGHT:
                        self.value += self.increment
+               elif key == KEY_HOME:
+                       self.value = self.min
+               elif key == KEY_END:
+                       self.value = self.max
                else:
                        return
 
index 2576516..5047d6d 100644 (file)
@@ -159,7 +159,7 @@ class ChannelContextMenu(Screen):
                self.session.open( ServiceInfo, self.csel.getCurrentSelection() )
 
        def showBouquetInputBox(self):
-               self.session.openWithCallback(self.bouquetInputCallback, InputBox, title=_("Please enter a name for the new bouquet"), text="bouquetname", maxSize=False, type=Input.TEXT)
+               self.session.openWithCallback(self.bouquetInputCallback, InputBox, title=_("Please enter a name for the new bouquet"), text="bouquetname", maxSize=False, visible_width = 56, type=Input.TEXT)
 
        def bouquetInputCallback(self, bouquet):
                if bouquet is not None:
@@ -205,7 +205,7 @@ class ChannelContextMenu(Screen):
                self.close()
 
        def showMarkerInputBox(self):
-               self.session.openWithCallback(self.markerInputCallback, InputBox, title=_("Please enter a name for the new marker"), text="markername", maxSize=False, type=Input.TEXT)
+               self.session.openWithCallback(self.markerInputCallback, InputBox, title=_("Please enter a name for the new marker"), text="markername", maxSize=False, visible_width = 56, type=Input.TEXT)
 
        def markerInputCallback(self, marker):
                if marker is not None:
index 6cdb42e..55334d2 100644 (file)
@@ -22,7 +22,6 @@ class InputBox(Screen):
                        "back": self.cancel,
                        "left": self.keyLeft,
                        "right": self.keyRight,
-                       "delete": self.keyDelete,
                        "moveLeft": self.keyLeft,
                        "moveRight": self.keyRight,
                        "moveHome": self.keyHome,
@@ -88,7 +87,7 @@ class InputBox(Screen):
 
 class PinInput(InputBox):
        def __init__(self, session, service = "", triesEntry = None, pinList = [], *args, **kwargs):
-               InputBox.__init__(self, session = session, text="9876", maxSize=True, type=Input.PIN, *args, **kwargs)
+               InputBox.__init__(self, session = session, text="    ", maxSize=True, type=Input.PIN, *args, **kwargs)
                
                self.waitTime = 15
                
@@ -117,7 +116,7 @@ class PinInput(InputBox):
                        InputBox.keyNumberGlobal(self, number)
                
        def checkPin(self, pin):
-               if pin is not None and int(pin) in self.pinList:
+               if pin is not None and pin.find(" ") == -1 and int(pin) in self.pinList:
                        return True
                return False
                
@@ -136,18 +135,22 @@ class PinInput(InputBox):
                                pass
        
        def closePinWrong(self, *args):
+               rcinput = eRCInput.getInstance()
+               rcinput.setKeyboardMode(rcinput.kmNone)
                print "args:", args
                self.close(False)
                
        def closePinCorrect(self, *args):
+               rcinput = eRCInput.getInstance()
+               rcinput.setKeyboardMode(rcinput.kmNone)
                self.close(True)
                
        def closePinCancel(self, *args):
+               rcinput = eRCInput.getInstance()
+               rcinput.setKeyboardMode(rcinput.kmNone)
                self.close(None)
                        
        def cancel(self):
-               rcinput = eRCInput.getInstance()
-               rcinput.setKeyboardMode(rcinput.kmNone)
                self.closePinCancel()
                
        def getTries(self):
index faf4f30..c6779e7 100644 (file)
@@ -84,8 +84,8 @@ class TimerEntry(Screen, ConfigListScreen):
                        self.timerentry_justplay = ConfigSelection(choices = [("zap", _("zap")), ("record", _("record"))], default = {0: "record", 1: "zap"}[justplay])
                        self.timerentry_afterevent = ConfigSelection(choices = [("nothing", _("do nothing")), ("standby", _("go to standby")), ("deepstandby", _("go to deep standby"))], default = afterevent)
                        self.timerentry_type = ConfigSelection(choices = [("once",_("once")), ("repeated", _("repeated"))], default = type)
-                       self.timerentry_name = ConfigText(default = self.timer.name, fixed_size = False)
-                       self.timerentry_description = ConfigText(default = self.timer.description, fixed_size = False)
+                       self.timerentry_name = ConfigText(default = self.timer.name, visible_width = 50, fixed_size = False)
+                       self.timerentry_description = ConfigText(default = self.timer.description, visible_width = 50, fixed_size = False)
 
                        self.timerentry_repeated = ConfigSelection(default = repeated, choices = [("daily", _("daily")), ("weekly", _("weekly")), ("weekdays", _("Mon-Fri")), ("user", _("user defined"))])
 
index 3379d9a..2cbc0f4 100644 (file)
@@ -31,6 +31,17 @@ class NumericalTextInput:
                        self.mapping.append (u"pqrs7PQRS") # 7
                        self.mapping.append (u"tuvúù8TUVÚÙ") # 8
                        self.mapping.append (u"wxyz9WXYZ") # 9
+               if self.lang in ['sv_SE', 'fi_FI']:
+                       self.mapping.append (u".,?'\"0-()@/:_") # 0
+                       self.mapping.append (u" 1") # 1
+                       self.mapping.append (u"abcåä2ABCÅÄ") # 2
+                       self.mapping.append (u"defé3DEFÉ") # 3
+                       self.mapping.append (u"ghi4GHI") # 4
+                       self.mapping.append (u"jkl5JKL") # 5
+                       self.mapping.append (u"mnoö6MNOÖ") # 6
+                       self.mapping.append (u"pqrs7PQRS") # 7
+                       self.mapping.append (u"tuv8TUV") # 8
+                       self.mapping.append (u"wxyz9WXYZ") # 9
                else:
                        self.mapping.append (u".,?'\"0-()@/:_") # 0
                        self.mapping.append (u" 1") # 1
@@ -56,11 +67,13 @@ class NumericalTextInput:
 
        def getKey(self, num):
                cnt=0
-               if self.timer is not None:
-                       self.timer.start(1000, True)
                if self.lastKey != num:
+                       if self.lastKey != -1:
+                               self.nextChar()
                        self.lastKey = num
                        self.pos = -1
+               if self.timer is not None:
+                       self.timer.start(1000, True)
                while True:
                        self.pos += 1
                        if len(self.mapping[num]) <= self.pos:
@@ -87,4 +100,5 @@ class NumericalTextInput:
                        self.nextFunction()
 
        def timeout(self):
-               self.nextChar()
+               if self.lastKey != -1:
+                       self.nextChar()