[Patch] Cannot delete last char in insert mode

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

 



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.

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--;


Cheers,

Udo




[Index of Archives]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Big List of Linux Books]     [Fedora Users]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux