add support for umlauts
[enigma2.git] / lib / python / Components / Input.py
index e6e27fab6e12c1351ce81ca7c215ef4fec8f4ffe..e27ef524048b810b3353285c8d7a985c5375876c 100644 (file)
@@ -10,15 +10,17 @@ class Input(VariableText, HTMLComponent, GUIComponent):
        TEXT = 0
        PIN = 1
        NUMBER = 2      
-       
+
        def __init__(self, text="", maxSize = False, type = TEXT):
                GUIComponent.__init__(self)
                VariableText.__init__(self)
+               self.table = 0
                self.numericalTextInput = NumericalTextInput(self.right)
                self.type = type
                self.maxSize = maxSize
                self.currPos = 0
                self.Text = text
+               self.overwrite = 0
                self.update()
 
        def update(self):
@@ -26,7 +28,7 @@ class Input(VariableText, HTMLComponent, GUIComponent):
                if self.type == self.PIN:
                        self.message = "*" * len(self.Text)
                else:
-                       self.message = convertDVBUTF8(self.Text, 0)
+                       self.message = convertDVBUTF8(self.Text, self.table)
                if self.instance:
                        self.instance.setText(self.message)
 
@@ -35,13 +37,13 @@ class Input(VariableText, HTMLComponent, GUIComponent):
                        self.currPos = 0
                        self.Text = ""
                elif isUTF8(text):
-                       self.Text = convertUTF8DVB(text, 0)
+                       self.Text = convertUTF8DVB(text, self.table)
                else:
                        self.Text = text
                self.update()
 
        def getText(self):
-               return convertDVBUTF8(self.Text, 0)
+               return convertDVBUTF8(self.Text, self.table)
 
        def createWidget(self, parent):
                return eLabel(parent, self.currPos)
@@ -79,14 +81,45 @@ class Input(VariableText, HTMLComponent, GUIComponent):
                        newNumber = str(int(self.Text[self.currPos]) - 1)
                self.Text = self.Text[0:self.currPos] + newNumber + self.Text[self.currPos + 1:]
                self.update()
+               
+       def home(self):
+               self.currPos = 0
+               self.update()
+       
+       def end(self):
+               self.currPos = len(self.Text) - 1
+               self.update()
+
+       def tab(self):
+               if self.currPos == len(self.Text) - 1:
+                       self.Text=self.Text+ " "
+                       self.end()
+               else:
+                       self.Text = self.Text[0:self.currPos] + " " + self.Text[self.currPos:]
+               self.update()
 
        def delete(self):
                self.Text = self.Text[:self.currPos] + self.Text[self.currPos + 1:]
                self.update()
 
+       def toggleOverwrite(self):
+               if self.overwrite==1:
+                       self.overwrite=0
+               else:
+                       self.overwrite=1
+               self.update()
+
+       def deleteBackward(self):
+               self.Text = self.Text[:self.currPos - 1] + self.Text[self.currPos:]
+               self.left()
+               self.update()
+
        def handleAscii(self, code):
                newChar = chr(code)
-               self.Text = self.Text[0:self.currPos] + newChar + self.Text[self.currPos + 1:]
+               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:]
                self.right()
 
        def number(self, number):