From: Andreas Monzner Date: Wed, 23 Aug 2006 23:53:30 +0000 (+0000) Subject: use uncode for textinput component X-Git-Tag: 2.6.0~3049 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/e09309bd7f69dbc98f471e28e01e2ad21ab7a757 use uncode for textinput component --- diff --git a/lib/python/Components/Input.py b/lib/python/Components/Input.py index e27ef524..e7713d6d 100644 --- a/lib/python/Components/Input.py +++ b/lib/python/Components/Input.py @@ -2,48 +2,46 @@ from HTMLComponent import * from GUIComponent import * from VariableText import * -from enigma import eLabel, isUTF8, convertUTF8DVB, convertDVBUTF8 +from enigma import eLabel from Tools.NumericalTextInput import NumericalTextInput class Input(VariableText, HTMLComponent, GUIComponent): TEXT = 0 PIN = 1 - NUMBER = 2 + 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() + self.numericalTextInput = NumericalTextInput(self.right) + self.setText(text) def update(self): self.setMarkedPos(self.currPos) if self.type == self.PIN: - self.message = "*" * len(self.Text) + self.text = "*" * len(self.Text) else: - self.message = convertDVBUTF8(self.Text, self.table) - if self.instance: - self.instance.setText(self.message) + self.text = self.Text.encode("utf-8") def setText(self, text): if not len(text): self.currPos = 0 - self.Text = "" - elif isUTF8(text): - self.Text = convertUTF8DVB(text, self.table) + self.Text = u"" else: - self.Text = text + try: + self.Text = text.decode("utf-8") + except UnicodeDecodeError: + print "utf8 kaputt!" + self.Text = text self.update() def getText(self): - return convertDVBUTF8(self.Text, self.table) + return self.Text.encode("utf-8") def createWidget(self, parent): return eLabel(parent, self.currPos) @@ -115,7 +113,7 @@ class Input(VariableText, HTMLComponent, GUIComponent): self.update() def handleAscii(self, code): - newChar = chr(code) + newChar = unichr(code) if self.overwrite==1: self.Text = self.Text[0:self.currPos] + newChar + self.Text[self.currPos + 1:] else: diff --git a/lib/python/Tools/NumericalTextInput.py b/lib/python/Tools/NumericalTextInput.py index d923290d..1acd2548 100644 --- a/lib/python/Tools/NumericalTextInput.py +++ b/lib/python/Tools/NumericalTextInput.py @@ -8,38 +8,38 @@ class NumericalTextInput: self.lang = language.getLanguage() if self.lang == 'de_DE': - self.mapping.append (".,?'\"0-()@/:_") # 0 - self.mapping.append (" 1") # 1 - self.mapping.append ("aäbc2AÄBC") # 2 - self.mapping.append ("def3DEF") # 3 - self.mapping.append ("ghi4GHI") # 4 - self.mapping.append ("jkl5JKL") # 5 - self.mapping.append ("mnoö6MNOÖ") # 6 - self.mapping.append ("pqrsß7PQRSß") # 7 - self.mapping.append ("tuüv8TUÜV") # 8 - self.mapping.append ("wxyz9WXYZ") # 9 + 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 + self.mapping.append (u"ghi4GHI") # 4 + self.mapping.append (u"jkl5JKL") # 5 + self.mapping.append (u"mnoö6MNOÖ") # 6 + self.mapping.append (u"pqrsß7PQRSß") # 7 + self.mapping.append (u"tuüv8TUÜV") # 8 + self.mapping.append (u"wxyz9WXYZ") # 9 elif self.lang == 'es_ES': - self.mapping.append (".,?'\"0-()@/:_") # 0 - self.mapping.append (" 1") # 1 - self.mapping.append ("abcáà2ABCÁÀ") # 2 - self.mapping.append ("deéèf3DEFÉÈ") # 3 - self.mapping.append ("ghiíì4GHIÍÌ") # 4 - self.mapping.append ("jkl5JKL") # 5 - self.mapping.append ("mnñoóò6MNÑOÓÒ") # 6 - self.mapping.append ("pqrs7PQRS") # 7 - self.mapping.append ("tuvúù8TUVÚÙ") # 8 - self.mapping.append ("wxyz9WXYZ") # 9 + 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 + self.mapping.append (u"ghiíì4GHIÍÌ") # 4 + self.mapping.append (u"jkl5JKL") # 5 + self.mapping.append (u"mnñoóò6MNÑOÓÒ") # 6 + self.mapping.append (u"pqrs7PQRS") # 7 + self.mapping.append (u"tuvúù8TUVÚÙ") # 8 + self.mapping.append (u"wxyz9WXYZ") # 9 else: - self.mapping.append (".,?'\"0-()@/:_") # 0 - self.mapping.append (" 1") # 1 - self.mapping.append ("abc2ABC") # 2 - self.mapping.append ("def3DEF") # 3 - self.mapping.append ("ghi4GHI") # 4 - self.mapping.append ("jkl5JKL") # 5 - self.mapping.append ("mno6MNO") # 6 - self.mapping.append ("pqrs7PQRS") # 7 - self.mapping.append ("tuv8TUV") # 8 - self.mapping.append ("wxyz9WXYZ") # 9 + self.mapping.append (u".,?'\"0-()@/:_") # 0 + self.mapping.append (u" 1") # 1 + self.mapping.append (u"abc2ABC") # 2 + self.mapping.append (u"def3DEF") # 3 + self.mapping.append (u"ghi4GHI") # 4 + self.mapping.append (u"jkl5JKL") # 5 + self.mapping.append (u"mno6MNO") # 6 + self.mapping.append (u"pqrs7PQRS") # 7 + self.mapping.append (u"tuv8TUV") # 8 + self.mapping.append (u"wxyz9WXYZ") # 9 self.nextFunction = nextFunction self.Timer = eTimer() @@ -48,8 +48,7 @@ class NumericalTextInput: self.pos = 0 def getKey(self, num): - self.Timer.stop() - self.Timer.start(1000) + self.Timer.start(1000, True) if (self.lastKey != num): self.lastKey = num self.pos = 0 @@ -64,11 +63,10 @@ class NumericalTextInput: self.lastKey = -1 def nextChar(self): - self.Timer.stop() print "Timer done" try: self.nextKey() if (self.nextFunction != None): self.nextFunction() - except: - pass + except AttributeError: + print "Text Input object deleted with running nextChar timer?" diff --git a/lib/python/enigma_python.i b/lib/python/enigma_python.i index 47d25ae8..103889b9 100644 --- a/lib/python/enigma_python.i +++ b/lib/python/enigma_python.i @@ -261,17 +261,7 @@ int getPrevAsciiCode(); void runMainloop(); void quitMainloop(int exit_code); eApplication *getApplication(); -int isUTF8(const std::string &); -std::string convertUTF8DVB(const std::string &, int); -std::string convertDVBUTF8(std::string text, int table); %{ - -std::string convertDVBUTF8(std::string text, int table) -{ - int len = text.length(); - return convertDVBUTF8(len?(unsigned char*)text.c_str():(unsigned char*)"", len, table, 0); -} - RESULT SwigFromPython(ePtr &result, PyObject *obj) { ePtr *res;