Udo Richter wrote:
Klaus Schmidinger wrote:
I agree with the 'if...' part of your fix, but I don't like the 'else...' part.
If I do just
[..]
it works as I would expect it.


I know it looks a bit strange. But that way the delete key does nothing if the cursor is at the end of the string. In overwrite mode, the delete key continues to delete towards left if there are no chars on the right.

Well, in overwrite mode the delete key deletes the character "under" the
cursor. If this was the last character in the string, the cursor has
nowhere to go but to the new last character, which is the one that was
previously "before" the cursor. In insert mode, however, the delete key
deletes the character *after* the cursor. If this was the last character,
then there's nothing more to delete. Just try this in any string entry
field, for instance the "Subject" line of your email client. These are
usually always in insert mode. If you press "Del" several times it will
delete everything after the cursor, but nothing before it.

By the way, in your short form, the inner if is not necessary any more:

                     if (strlen(value) > 1) {
                        if (!insert || pos < int(strlen(value)) - 1)
memmove(value + pos, value + pos + 1, strlen(value) - pos);
+                       else if (insert && pos == int(strlen(value)) - 1)
+ // in insert mode, deleting the last character replaces it with a blank to keep the cursor position
+                          value[pos] = ' ';
// reduce position, if we removed the last character
                        if (pos == int(strlen(value)))
                           pos--;

Thanks, this makes it even better ;-)

Klaus


_______________________________________________
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr

Reply via email to