add support for umlauts
[enigma2.git] / lib / python / Tools / NumericalTextInput.py
1 # -*- coding: latin-1 -*-
2 from enigma import *
3 from Components.Language import language
4
5 class NumericalTextInput:
6         mapping = []
7         lang = language.getLanguage()
8         if lang == 'de_DE':
9                 mapping.append (".,?'\"0-()@/:_") # 0
10                 mapping.append (" 1") # 1
11                 mapping.append ("aäbc2AABC") # 2
12                 mapping.append ("def3DEF") # 3
13                 mapping.append ("ghi4GHI") # 4
14                 mapping.append ("jkl5JKL") # 5
15                 mapping.append ("mnoö6MNOÖ") # 6
16                 mapping.append ("pqrsß7PQRSß") # 7
17                 mapping.append ("tuüv8TUÜV") # 8
18                 mapping.append ("wxyz9WXYZ") # 9
19         elif lang == 'es_ES':
20                 mapping.append (".,?'\"0-()@/:_") # 0
21                 mapping.append (" 1") # 1
22                 mapping.append ("abcáà2ABCÁÀ") # 2
23                 mapping.append ("deéèf3DEFÉÈ") # 3
24                 mapping.append ("ghiíì4GHIÍÌ") # 4
25                 mapping.append ("jkl5JKL") # 5
26                 mapping.append ("mnñoóò6MNÑOÓÒ") # 6
27                 mapping.append ("pqrs7PQRS") # 7
28                 mapping.append ("tuvúù8TUVÚÙ") # 8
29                 mapping.append ("wxyz9WXYZ") # 9
30         else:
31                 mapping.append (".,?'\"0-()@/:_") # 0
32                 mapping.append (" 1") # 1
33                 mapping.append ("abc2ABC") # 2
34                 mapping.append ("def3DEF") # 3
35                 mapping.append ("ghi4GHI") # 4
36                 mapping.append ("jkl5JKL") # 5
37                 mapping.append ("mno6MNO") # 6
38                 mapping.append ("pqrs7PQRS") # 7
39                 mapping.append ("tuv8TUV") # 8
40                 mapping.append ("wxyz9WXYZ") # 9
41
42         def __init__(self, nextFunction = None):
43                 self.nextFunction = nextFunction
44                 self.Timer = eTimer()
45                 self.Timer.timeout.get().append(self.nextChar)
46                 self.lastKey = -1
47                 self.pos = 0
48
49         def getKey(self, num):
50                 self.Timer.stop()
51                 self.Timer.start(1000)
52                 if (self.lastKey != num):
53                         self.lastKey = num
54                         self.pos = 0
55                 else:
56                         self.pos += 1
57                         if (len(self.mapping[num]) <= self.pos):
58                                 self.pos = 0
59                 return self.mapping[num][self.pos]
60
61         def nextKey(self):
62                 self.Timer.stop()
63                 self.lastKey = -1
64
65         def nextChar(self):
66                 self.Timer.stop()
67                 print "Timer done"
68                 try:
69                         self.nextKey()
70                         if (self.nextFunction != None):
71                                 self.nextFunction()
72                 except:
73                         pass