zsh-workers
 help / color / mirror / code / Atom feed
* combining char in vi-keybinding
@ 2008-04-19 15:21 Jun T.
  2008-04-20 16:50 ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: Jun T. @ 2008-04-19 15:21 UTC (permalink / raw)
  To: zsh-workers

Hre are two minor bugs related with the combining character support
in vi-keybinding.

(1) If the last character on the command line is a combining character,
and if I try to move the cursor to the end of line by vi commands
"l", "w", "$", etc., then cursor goes to the begining of the
previous line.

This may be fixed by repacing line 1054 of zle_main.c
		zlecs--;
by
		DECCS();


(2) If the cursor is on a combined character, vi command "x"
(vi-delete-char) deletes only the base character, leaving the
combining character (which is combined with the previous char).

It seems this can be fixed by replacing line 359 of zle_vi.c
	forekill(n, CUT_RAW);
by
	forekill(n, 0);
but I don't know what the side effect of this is.
Similar change may be needed in vibackwarddeletechar().

Jun


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: combining char in vi-keybinding
  2008-04-19 15:21 combining char in vi-keybinding Jun T.
@ 2008-04-20 16:50 ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2008-04-20 16:50 UTC (permalink / raw)
  To: zsh-workers

On Sun, 20 Apr 2008 00:21:43 +0900
"Jun T." <takimoto-j@kba.biglobe.ne.jp> wrote:
> (1) If the last character on the command line is a combining character,
> and if I try to move the cursor to the end of line by vi commands
> "l", "w", "$", etc., then cursor goes to the begining of the
> previous line.
> 
> This may be fixed by repacing line 1054 of zle_main.c
> 		zlecs--;
> by
> 		DECCS();

Yes, that looks fine.

> (2) If the cursor is on a combined character, vi command "x"
> (vi-delete-char) deletes only the base character, leaving the
> combining character (which is combined with the previous char).
> 
> It seems this can be fixed by replacing line 359 of zle_vi.c
> 	forekill(n, CUT_RAW);
> by
> 	forekill(n, 0);
> but I don't know what the side effect of this is.
> Similar change may be needed in vibackwarddeletechar().

I see what's happened here---I've assumed the case where the condition
just above is true, where indeed we have a raw character count, but if
it wasn't then we're deleting logical characters.

Strictlly, we need to do that test better:  we should see if moving
forward or back the given number of times with INCPOS()/DECPOS() takes
us past beginning or end of line, however as immediate surgery the
following will do.

Index: Src/Zle/zle_main.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
retrieving revision 1.108
diff -u -r1.108 zle_main.c
--- Src/Zle/zle_main.c	16 Apr 2008 09:59:34 -0000	1.108
+++ Src/Zle/zle_main.c	20 Apr 2008 16:49:13 -0000
@@ -1051,7 +1051,7 @@
 	    /* for vi mode, make sure the cursor isn't somewhere illegal */
 	    if (invicmdmode() && zlecs > findbol() &&
 		(zlecs == zlell || zleline[zlecs] == ZWC('\n')))
-		zlecs--;
+		DECCS();
 	    if (undoing)
 		handleundo();
 	} else {
Index: Src/Zle/zle_vi.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_vi.c,v
retrieving revision 1.17
diff -u -r1.17 zle_vi.c
--- Src/Zle/zle_vi.c	17 Apr 2008 16:18:42 -0000	1.17
+++ Src/Zle/zle_vi.c	20 Apr 2008 16:49:13 -0000
@@ -353,10 +353,14 @@
 	return 1;
     /* Put argument into the acceptable range -- it is not an error to  *
      * specify a greater count than the number of available characters. */
-    if (n > findeol() - zlecs)
+    /* HERE: we should do the test properly with INCPOS(). */
+    if (n > findeol() - zlecs) {
 	n = findeol() - zlecs;
-    /* do the deletion */
-    forekill(n, CUT_RAW);
+	/* do the deletion */
+	forekill(n, CUT_RAW);
+    } else {
+	forekill(n, 0);
+    }
     return 0;
 }
 
@@ -714,10 +718,13 @@
     }
     /* Put argument into the acceptable range -- it is not an error to  *
      * specify a greater count than the number of available characters. */
-    if (n > zlecs - findbol())
+    /* HERE: we should do the test properly with DECPOS(). */
+    if (n > zlecs - findbol()) {
 	n = zlecs - findbol();
-    /* do the deletion */
-    backkill(n, CUT_FRONT|CUT_RAW);
+	/* do the deletion */
+	backkill(n, CUT_FRONT|CUT_RAW);
+    } else
+	backkill(n, CUT_FRONT);
     return 0;
 }
 

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-04-20 16:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-19 15:21 combining char in vi-keybinding Jun T.
2008-04-20 16:50 ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).