add "!" to character list on behalf of acid-burn
[enigma2.git] / lib / python / Tools / NumericalTextInput.py
index 87ac5486280b6c727844b6ad6b726fd12e41ab48..5954c9c3d0e704aa8fa38b13cc26dba5d47e2de7 100644 (file)
@@ -1,16 +1,16 @@
-# -*- coding: latin-1 -*-
-from enigma import *
+# -*- coding: iso-8859-1 -*-
+from enigma import eTimer
 from Components.Language import language
 
 class NumericalTextInput:
-       def __init__(self, nextFunc=None):
+       def __init__(self, nextFunc=None, handleTimeout = True):
                self.mapping = []
                self.lang = language.getLanguage()
                self.useableChars=None
                self.nextFunction=nextFunc
                
                if self.lang == 'de_DE':
-                       self.mapping.append (u".,?'\"0-()@/:_") # 0
+                       self.mapping.append (u".,?'+\"0-()@/:_$!") # 0
                        self.mapping.append (u" 1") # 1
                        self.mapping.append (u"aäbc2AÄBC") # 2
                        self.mapping.append (u"def3DEF") # 3
@@ -21,7 +21,7 @@ class NumericalTextInput:
                        self.mapping.append (u"tuüv8TUÜV") # 8
                        self.mapping.append (u"wxyz9WXYZ") # 9
                elif self.lang == 'es_ES':
-                       self.mapping.append (u".,?'\"0-()@/:_") # 0
+                       self.mapping.append (u".,?'+\"0-()@/:_$!") # 0
                        self.mapping.append (u" 1") # 1
                        self.mapping.append (u"abcáà2ABCÁÀ") # 2
                        self.mapping.append (u"deéèf3DEFÉÈ") # 3
@@ -31,8 +31,19 @@ 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".,?'+\"0-()@/:_$!") # 0
                        self.mapping.append (u" 1") # 1
                        self.mapping.append (u"abc2ABC") # 2
                        self.mapping.append (u"def3DEF") # 3
@@ -43,8 +54,11 @@ class NumericalTextInput:
                        self.mapping.append (u"tuv8TUV") # 8
                        self.mapping.append (u"wxyz9WXYZ") # 9
 
-               self.Timer = eTimer()
-               self.Timer.timeout.get().append(self.nextChar)
+               if handleTimeout:
+                       self.timer = eTimer()
+                       self.timer.callback.append(self.timeout)
+               else:
+                       self.timer = None
                self.lastKey = -1
                self.pos = -1
 
@@ -53,13 +67,16 @@ class NumericalTextInput:
 
        def getKey(self, num):
                cnt=0
-               self.Timer.start(1000, True)
-               if (self.lastKey != num):
+               if self.lastKey != num:
+                       if self.lastKey != -1:
+                               self.nextChar()
                        self.lastKey = num
                        self.pos = -1
-               while(True):
+               if self.timer is not None:
+                       self.timer.start(1000, True)
+               while True:
                        self.pos += 1
-                       if (len(self.mapping[num]) <= self.pos):
+                       if len(self.mapping[num]) <= self.pos:
                                self.pos = 0
                        if self.useableChars:
                                pos = self.useableChars.find(self.mapping[num][self.pos])
@@ -73,10 +90,15 @@ class NumericalTextInput:
                return self.mapping[num][self.pos]
 
        def nextKey(self):
-               self.Timer.stop()
+               if self.timer is not None:
+                       self.timer.stop()
                self.lastKey = -1
 
        def nextChar(self):
                self.nextKey()
                if self.nextFunction:
                        self.nextFunction()
+
+       def timeout(self):
+               if self.lastKey != -1:
+                       self.nextChar()