From: Andreas Monzner Date: Mon, 21 Aug 2006 23:02:23 +0000 (+0000) Subject: add support for umlauts X-Git-Tag: 2.6.0~3055 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/be481547e9c93583098b54a37034ff164b5804f5?hp=6bdfaadd65fe35ba568799b0e42c54e5a95e27ed add support for umlauts --- diff --git a/lib/python/Components/Input.py b/lib/python/Components/Input.py index b140ef51..e27ef524 100644 --- a/lib/python/Components/Input.py +++ b/lib/python/Components/Input.py @@ -10,10 +10,11 @@ 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 @@ -21,12 +22,13 @@ class Input(VariableText, HTMLComponent, GUIComponent): self.Text = text self.overwrite = 0 self.update() + def update(self): self.setMarkedPos(self.currPos) 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) @@ -87,7 +89,7 @@ class Input(VariableText, HTMLComponent, GUIComponent): 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+ " " @@ -95,11 +97,11 @@ class Input(VariableText, HTMLComponent, GUIComponent): 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 diff --git a/lib/python/Components/Language.py b/lib/python/Components/Language.py index f08ae34b..d825af95 100644 --- a/lib/python/Components/Language.py +++ b/lib/python/Components/Language.py @@ -49,14 +49,17 @@ class Language: for x in self.langlist: list.append((x, self.lang[x])) return list - + def getActiveLanguage(self): return self.activeLanguage - + def getLanguage(self): - return str(self.lang[self.activeLanguage][2]) + "_" + str(self.lang[self.activeLanguage][3]) - + try: + return str(self.lang[self.activeLanguage][2]) + "_" + str(self.lang[self.activeLanguage][3]) + except: + return '' + def addCallback(self, callback): self.callbacks.append(callback) - + language = Language() diff --git a/lib/python/Tools/NumericalTextInput.py b/lib/python/Tools/NumericalTextInput.py index 74497895..9969011c 100644 --- a/lib/python/Tools/NumericalTextInput.py +++ b/lib/python/Tools/NumericalTextInput.py @@ -1,45 +1,73 @@ +# -*- coding: latin-1 -*- from enigma import * +from Components.Language import language class NumericalTextInput: - mapping = [] - mapping.append (".,?'\"0-()@/:_") # 0 - mapping.append (" 1") # 1 - mapping.append ("abc2ABC") # 2 - mapping.append ("def3DEF") # 3 - mapping.append ("ghi4GHI") # 4 - mapping.append ("jkl5JKL") # 5 - mapping.append ("mno6MNO") # 6 - mapping.append ("pqrs7PQRS") # 7 - mapping.append ("tuv8TUV") # 8 - mapping.append ("wxyz9WXYZ") # 9 - - def __init__(self, nextFunction = None): - self.nextFunction = nextFunction - self.Timer = eTimer() - self.Timer.timeout.get().append(self.nextChar) - self.lastKey = -1 - self.pos = 0 - - def getKey(self, num): - self.Timer.stop() - self.Timer.start(1000) - if (self.lastKey != num): - self.lastKey = num - self.pos = 0 - else: - self.pos += 1 - if (len(self.mapping[num]) <= self.pos): - self.pos = 0 - return self.mapping[num][self.pos] - - def nextKey(self): - self.Timer.stop() - self.lastKey = -1 - - def nextChar(self): - self.Timer.stop() - print "Timer done" - self.nextKey() - if (self.nextFunction != None): - self.nextFunction() - \ No newline at end of file + mapping = [] + lang = language.getLanguage() + if lang == 'de_DE': + mapping.append (".,?'\"0-()@/:_") # 0 + mapping.append (" 1") # 1 + mapping.append ("aäbc2AABC") # 2 + mapping.append ("def3DEF") # 3 + mapping.append ("ghi4GHI") # 4 + mapping.append ("jkl5JKL") # 5 + mapping.append ("mnoö6MNOÖ") # 6 + mapping.append ("pqrsß7PQRSß") # 7 + mapping.append ("tuüv8TUÜV") # 8 + mapping.append ("wxyz9WXYZ") # 9 + elif lang == 'es_ES': + mapping.append (".,?'\"0-()@/:_") # 0 + mapping.append (" 1") # 1 + mapping.append ("abcáà2ABCÁÀ") # 2 + mapping.append ("deéèf3DEFÉÈ") # 3 + mapping.append ("ghiíì4GHIÍÌ") # 4 + mapping.append ("jkl5JKL") # 5 + mapping.append ("mnñoóò6MNÑOÓÒ") # 6 + mapping.append ("pqrs7PQRS") # 7 + mapping.append ("tuvúù8TUVÚÙ") # 8 + mapping.append ("wxyz9WXYZ") # 9 + else: + mapping.append (".,?'\"0-()@/:_") # 0 + mapping.append (" 1") # 1 + mapping.append ("abc2ABC") # 2 + mapping.append ("def3DEF") # 3 + mapping.append ("ghi4GHI") # 4 + mapping.append ("jkl5JKL") # 5 + mapping.append ("mno6MNO") # 6 + mapping.append ("pqrs7PQRS") # 7 + mapping.append ("tuv8TUV") # 8 + mapping.append ("wxyz9WXYZ") # 9 + + def __init__(self, nextFunction = None): + self.nextFunction = nextFunction + self.Timer = eTimer() + self.Timer.timeout.get().append(self.nextChar) + self.lastKey = -1 + self.pos = 0 + + def getKey(self, num): + self.Timer.stop() + self.Timer.start(1000) + if (self.lastKey != num): + self.lastKey = num + self.pos = 0 + else: + self.pos += 1 + if (len(self.mapping[num]) <= self.pos): + self.pos = 0 + return self.mapping[num][self.pos] + + def nextKey(self): + self.Timer.stop() + self.lastKey = -1 + + def nextChar(self): + self.Timer.stop() + print "Timer done" + try: + self.nextKey() + if (self.nextFunction != None): + self.nextFunction() + except: + pass