From 6798f163cf317e89a65d38377fb3dc1475b37ae6 Mon Sep 17 00:00:00 2001 From: Andreas Monzner Date: Thu, 8 Jun 2006 23:54:56 +0000 Subject: [PATCH] make umlauts working in class Input --- lib/python/Components/Input.py | 54 +++++++++++++++++----------------- lib/python/enigma_python.i | 15 ++++++++-- 2 files changed, 40 insertions(+), 29 deletions(-) diff --git a/lib/python/Components/Input.py b/lib/python/Components/Input.py index 42426114..f741eabe 100644 --- a/lib/python/Components/Input.py +++ b/lib/python/Components/Input.py @@ -2,7 +2,7 @@ from HTMLComponent import * from GUIComponent import * from VariableText import * -from enigma import eLabel +from enigma import eLabel, isUTF8, convertUTF8DVB, convertDVBUTF8 from Tools.NumericalTextInput import NumericalTextInput @@ -18,82 +18,82 @@ class Input(VariableText, HTMLComponent, GUIComponent): self.type = type self.maxSize = maxSize self.currPos = 0 - self.text = text + self.Text = text self.update() def update(self): self.setMarkedPos(self.currPos) - text = self.text if self.type == self.PIN: - text = "*" * len(self.text) - self.message = text + self.message = "*" * len(self.Text) + else: + self.message = convertDVBUTF8(self.Text, 0) if self.instance: self.instance.setText(self.message) def setText(self, text): if not len(text): self.currPos = 0 - self.text = text + elif isUTF8(text): + self.Text = convertUTF8DVB(text, 0) + else: + self.Text = text self.update() def getText(self): - return self.text - + return convertDVBUTF8(self.Text, 0) + def createWidget(self, parent): return eLabel(parent, self.currPos) - + def getSize(self): s = self.instance.calculateSize() return (s.width(), s.height()) def right(self): self.currPos += 1 - if self.currPos == len(self.text): + if self.currPos == len(self.Text): if self.maxSize: self.currPos -= 1 else: - self.text = self.text + " " - + self.Text = self.Text + " " self.update() - + def left(self): if self.currPos > 0: self.currPos -= 1 self.update() - + def up(self): - if self.text[self.currPos] == "9" or self.text[self.currPos] == " ": + if self.Text[self.currPos] == "9" or self.Text[self.currPos] == " ": newNumber = "0" else: - newNumber = str(int(self.text[self.currPos]) + 1) - self.text = self.text[0:self.currPos] + newNumber + self.text[self.currPos + 1:] + newNumber = str(int(self.Text[self.currPos]) + 1) + self.Text = self.Text[0:self.currPos] + newNumber + self.Text[self.currPos + 1:] self.update() - + def down(self): - if self.text[self.currPos] == "0" or self.text[self.currPos] == " ": + if self.Text[self.currPos] == "0" or self.Text[self.currPos] == " ": newNumber = "9" else: - newNumber = str(int(self.text[self.currPos]) - 1) - - self.text = self.text[0:self.currPos] + newNumber + self.text[self.currPos + 1:] + newNumber = str(int(self.Text[self.currPos]) - 1) + self.Text = self.Text[0:self.currPos] + newNumber + self.Text[self.currPos + 1:] self.update() - + def delete(self): - self.text = self.text[:self.currPos] + self.text[self.currPos + 1:] + self.Text = self.Text[:self.currPos] + self.Text[self.currPos + 1:] self.update() def handleAscii(self, code): newChar = chr(code) - self.text = self.text[0:self.currPos] + newChar + self.text[self.currPos + 1:] + self.Text = self.Text[0:self.currPos] + newChar + self.Text[self.currPos + 1:] self.right() - self.update() def number(self, number): if self.type == self.TEXT: newChar = self.numericalTextInput.getKey(number) elif self.type == self.PIN or self.type == self.NUMBER: newChar = str(number) - self.text = self.text[0:self.currPos] + newChar + self.text[self.currPos + 1:] + self.Text = self.Text[0:self.currPos] + newChar + self.Text[self.currPos + 1:] if self.type == self.PIN or self.type == self.NUMBER: self.right() self.update() diff --git a/lib/python/enigma_python.i b/lib/python/enigma_python.i index 8582de86..ad412293 100644 --- a/lib/python/enigma_python.i +++ b/lib/python/enigma_python.i @@ -92,8 +92,10 @@ is usually caused by not marking PSignals as immutable. extern void runMainloop(); extern void quitMainloop(int exit_code); extern eApplication *getApplication(); - extern int getPrevAsciiCode(); +extern int isUTF8(const std::string &); +extern std::string convertUTF8DVB(const std::string &, int); +extern std::string convertDVBUTF8(const unsigned char *data, int len, int table, int tsidonid); %} %feature("ref") iObject "$this->AddRef(); /* eDebug(\"AddRef (%s:%d)!\", __FILE__, __LINE__); */ " @@ -258,8 +260,17 @@ 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?text.c_str():"", len, table, 0); +} + RESULT SwigFromPython(ePtr &result, PyObject *obj) { ePtr *res; -- 2.30.2