cache movie filelengths in .meta file, by luke_s
[enigma2.git] / lib / gui / einput.cpp
index 7d411f9e4a1de67a91745af8ddb5cab87b2c73ca..5cde53bbb579dd4d9b8f0e361dc74146ba275e59 100644 (file)
@@ -55,7 +55,7 @@ int eInput::event(int event, void *data, void *data2)
                
                eDebug("cursor is %d", cursor);
                para->setFont(m_font);
-               para->renderString(text, 0);
+               para->renderString(text.empty()?0:text.c_str(), 0);
                int glyphs = para->size();
                
                if (m_have_focus)
@@ -94,40 +94,60 @@ int eInput::event(int event, void *data, void *data2)
        case evtAction:
                if (isVisible())
                {
-                       switch((int)data2)
+                       if ((long)data == ASCII_ACTIONS)
                        {
-                       case moveLeft:
-                               m_content->moveCursor(eInputContent::dirLeft);
-                               break;
-                       case moveRight:
-                               m_content->moveCursor(eInputContent::dirRight);
-                               break;
-                       case moveHome:
-                               m_content->moveCursor(eInputContent::dirHome);
-                               break;
-                       case moveEnd:
-                               m_content->moveCursor(eInputContent::dirEnd);
-                               break;
-                       case deleteForward:
-                               m_content->deleteChar(eInputContent::deleteForward);
-                               break;
-                       case deleteBackward:
-                               m_content->deleteChar(eInputContent::deleteBackward);
-                               break;
-                       case toggleOverwrite:
-                               setOverwriteMode(!m_mode);
-                               break;
-                       case accept:
-                               changed();
-                               mayKillFocus();
+                               if ((long)data2 == gotAsciiCode)
+                               {
+                                       if (m_content)
+                                       {
+                                               extern int getPrevAsciiCode();  // defined in enigma.cpp
+                                               return m_content->haveKey(getPrevAsciiCode(), m_mode);
+                                       }
+                               }
+                       }
+                       else if ((long)data == INPUT_ACTIONS)
+                       {
+                               switch((long)data2)
+                               {
+                               case moveLeft:
+                                       if (m_content)
+                                               m_content->moveCursor(eInputContent::dirLeft);
+                                       break;
+                               case moveRight:
+                                       if (m_content)
+                                               m_content->moveCursor(eInputContent::dirRight);
+                                       break;
+                               case moveHome:
+                                       if (m_content)
+                                               m_content->moveCursor(eInputContent::dirHome);
+                                       break;
+                               case moveEnd:
+                                       if (m_content)
+                                               m_content->moveCursor(eInputContent::dirEnd);
+                                       break;
+                               case deleteForward:
+                                       if (m_content)
+                                               m_content->deleteChar(eInputContent::deleteForward);
+                                       break;
+                               case deleteBackward:
+                                       if (m_content)
+                                               m_content->deleteChar(eInputContent::deleteBackward);
+                                       break;
+                               case toggleOverwrite:
+                                       setOverwriteMode(!m_mode);
+                                       break;
+                               case accept:
+                                       changed();
+                                       mayKillFocus();
+                               }
+                               return 1;
                        }
-                       return 1;
                }
                return 0;
        case evtKey:
        {
-               int key = (int)data;
-               int flags = (int)data2;
+               long key = (long)data;
+               long flags = (long)data2;
                if (m_content && !(flags & 1)) // only make/repeat, no break
                        return m_content->haveKey(key, m_mode);
                break;
@@ -137,9 +157,8 @@ int eInput::event(int event, void *data, void *data2)
                eDebug("focus got in %p", this);
                ePtr<eActionMap> ptr;
                eActionMap::getInstance(ptr);
-               ptr->bindAction("InputActions", 0, 0, this);
-                       // bind all keys
-               ptr->bindAction("", 0, 1, this);
+               ptr->bindAction("InputActions", 0, INPUT_ACTIONS, this);
+               ptr->bindAction("AsciiActions", 0, ASCII_ACTIONS, this);
                m_have_focus = 1;
                eRCInput::getInstance()->setKeyboardMode(eRCInput::kmAscii);
                        // fixme. we should use a style for this.
@@ -152,8 +171,8 @@ int eInput::event(int event, void *data, void *data2)
                eDebug("focus lostin %p", this);
                ePtr<eActionMap> ptr;
                eActionMap::getInstance(ptr);
-               ptr->unbindAction(this, 0);
-               ptr->unbindAction(this, 1);
+               ptr->unbindAction(this, INPUT_ACTIONS);
+               ptr->unbindAction(this, ASCII_ACTIONS);
                m_have_focus = 0;
                if (m_content)
                        m_content->validate();