Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] menu.c - cMenuEditStrItem




high!

cMenuEditStrItem is an editable String like in file names of timers

I wondered since longer time, why it is not that easy possible to write
spaces: If I want to create a name like "a b", I have to do following:
press Right   (begin editing)
press Up      (make the first letter become 'a')
press Right   (add second character and make it ' ')
-- at this point it's not possible to press Right to add a third letter --
press Up      (and make the second letter become 'a')
press Right   (and add third letter)
press 3xUp    (make the character become "b")
press Left    (go back to second letter)
press Down    (and make it ' ' again)
press Ok      (and leave editing)

below is a patch against plain vdr-1.0.0pre5, the second part of it
changes this behaviour - now you're able to add as many spaces as you like
at the end of a string (pressing Ok strips them anyway if the spaces stay
at the end of the string)

so the previous example ("a b") would require pressing
press Right   (start editing)
press Up      ("a")
press 2xRight (go to third character)
press 3xUp    ("b")
press Ok      (end editing)


the first part of the patch is a new "feature": you can press 1 or 3 while
editing such a string. Pressing 1 inserts a space at current position
pressing 3 removes the character at current position.

One exaple where this is useful:
you go to the shedule menu, press Red, the title of the programme is
automatically put into the File field. But often you want to add a
"StarTrek~" or "ST~" just "Movies~" in front of it. without the patch you
have to type ST~ and then to retype whole name of the episode...
(ok, you could just type it from the console, but the console is not
available all the time)


here is the patch:
======================================================================================
--- vdr-1.0.0pre5/menu.c        Sun Mar 31 23:17:42 2002
+++ vdr-1.0.0pre5-my/menu.c     Fri Apr  5 21:32:06 2002
@@ -568,6 +568,25 @@
 eOSState cMenuEditStrItem::ProcessKey(eKeys Key)
 {
   switch (Key) {
+    case k1|k_Repeat:
+    case k1: /* insert a character */
+             if (int(strlen(value)) < length) {
+                memmove(value+pos+1, value+pos, int(strlen(value)-pos+1));
+                value[pos] = ' ';
+             }
+             break;
+    case k3|k_Repeat:
+    case k3: /* remove a character */
+             if (int(strlen(value)) > 1) {
+                memmove(value+pos, value+pos+1, int(strlen(value)-pos));
+                /* reduce position, if we removed the last character */
+                if (pos == int(strlen(value))) pos--;
+             }
+             else if (int(strlen(value)) == 1) {
+                /* This is the last character in the string. */
+                value[0] = ' ';
+             }
+             break;
     case kLeft|k_Repeat:
     case kLeft:  if (pos > 0) {
                     if (value[pos] == '^')
@@ -576,7 +595,7 @@
                     }
                  break;
     case kRight|k_Repeat:
-    case kRight: if (pos < length && value[pos] != '^' && (pos < int(strlen(value) - 1) || value[pos] != ' ')) {
+    case kRight: if (pos < length && value[pos] != '^' && pos < int(strlen(value)) ) {
                     if (++pos >= int(strlen(value))) {
                        value[pos] = ' ';
                        value[pos + 1] = 0;
======================================================================================


Have Fun

c ya
        Sergei
--
--------------------------------------------------------------------
         eMail:       Sergei.Haller@math.uni-giessen.de
--------------------------------------------------------------------
Be careful of reading health books, you might die of a misprint.
                -- Mark Twain





Home | Main Index | Thread Index