* PATCH: more combining character stuff
@ 2008-05-04 18:25 Peter Stephenson
0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2008-05-04 18:25 UTC (permalink / raw)
To: Zsh hackers list
More stuff to fix up combining characters, found just by looking
through the code.
I think the remaining job is to think about the function widget
interface. I'll look at Functions/Zle at some point to see what might
need doing there.
Index: Src/Zle/zle_hist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_hist.c,v
retrieving revision 1.54
diff -u -r1.54 zle_hist.c
--- Src/Zle/zle_hist.c 1 May 2008 11:33:06 -0000 1.54
+++ Src/Zle/zle_hist.c 4 May 2008 18:16:45 -0000
@@ -247,6 +247,11 @@
if (zlecs > findbol() && invicmdmode())
DECCS();
}
+#ifdef MULTIBYTE_SUPPORT
+ else
+ CCRIGHT();
+#endif
+
}
return n;
}
@@ -331,6 +336,10 @@
if (zlecs > findbol() && invicmdmode())
DECCS();
}
+#ifdef MULTIBYTE_SUPPORT
+ else
+ CCRIGHT();
+#endif
}
return n;
}
Index: Src/Zle/zle_misc.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_misc.c,v
retrieving revision 1.53
diff -u -r1.53 zle_misc.c
--- Src/Zle/zle_misc.c 23 Apr 2008 21:08:34 -0000 1.53
+++ Src/Zle/zle_misc.c 4 May 2008 18:16:47 -0000
@@ -801,10 +801,20 @@
for (;;) {
t1 = t0;
- while (t0 && !ZC_iword(zleline[t0-1]))
- t0--;
- while (t0 && ZC_iword(zleline[t0-1]))
- t0--;
+ while (t0) {
+ int prev = t0;
+ DECPOS(prev);
+ if (ZC_iword(zleline[prev]))
+ break;
+ t0 = prev;
+ }
+ while (t0) {
+ int prev = t0;
+ DECPOS(prev);
+ if (!ZC_iword(zleline[prev]))
+ break;
+ t0 = prev;
+ }
if (!--count)
break;
Index: Src/Zle/zle_move.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_move.c,v
retrieving revision 1.16
diff -u -r1.16 zle_move.c
--- Src/Zle/zle_move.c 21 Apr 2008 11:49:58 -0000 1.16
+++ Src/Zle/zle_move.c 4 May 2008 18:16:47 -0000
@@ -307,11 +307,19 @@
return ret;
}
while (n--) {
+ int pos;
+
if (zlecs == 0)
return 0;
- if (zleline[zlecs - 1] == '\n')
- if (!--zlecs)
+ pos = zlecs;
+ DECPOS(pos);
+ if (zleline[pos] == '\n') {
+ zlecs = pos;
+ if (!zlecs)
return 0;
+ }
+
+ /* works OK with combining chars since '\n' must be on its own */
while (zlecs && zleline[zlecs - 1] != '\n')
zlecs--;
}
@@ -359,11 +367,19 @@
return ret;
}
while (n) {
+ int pos;
+
if (zlecs == 0)
break;
- if (zleline[zlecs - 1] == '\n')
- if (!--zlecs)
+ pos = zlecs;
+ DECPOS(pos);
+ if (zleline[pos] == '\n') {
+ zlecs = pos;
+ if (!pos)
break;
+ }
+
+ /* works OK with combining chars since '\n' must be on its own */
while (zlecs && zleline[zlecs - 1] != '\n')
zlecs--;
n--;
@@ -554,12 +570,15 @@
oth = '[';
break;
default:
- zlecs++;
+ INCCS();
goto otog;
}
ct = 1;
while (zlecs >= 0 && zlecs < zlell && ct) {
- zlecs += dir;
+ if (dir < 0)
+ DECCS();
+ else
+ INCCS();
if (zleline[zlecs] == oth)
ct--;
else if (zleline[zlecs] == me)
@@ -634,7 +653,7 @@
}
zlecs = findeol() + 1;
}
- zlecs--;
+ DECCS();
lastcol = 1<<30;
return 0;
}
Index: Src/Zle/zle_vi.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_vi.c,v
retrieving revision 1.21
diff -u -r1.21 zle_vi.c
--- Src/Zle/zle_vi.c 23 Apr 2008 08:43:38 -0000 1.21
+++ Src/Zle/zle_vi.c 4 May 2008 18:16:47 -0000
@@ -262,7 +262,7 @@
zlecs = pos;
return 1;
}
- zlecs--;
+ DECCS();
} else {
while(n++ && zlecs >= 0)
zlecs = findbol() - 1;
@@ -270,7 +270,7 @@
zlecs = pos;
return 1;
}
- zlecs++;
+ INCCS();
}
virangeflag = 2;
return 0;
@@ -281,7 +281,7 @@
viaddnext(UNUSED(char **args))
{
if (zlecs != findeol())
- zlecs++;
+ INCCS();
startvitext(1);
return 0;
}
@@ -776,7 +776,7 @@
zlecs += buf->len;
}
if (zlecs)
- zlecs--;
+ DECCS();
}
return 0;
}
@@ -819,20 +819,27 @@
int
vijoin(UNUSED(char **args))
{
- int x;
+ int x, pos;
startvichange(-1);
if ((x = findeol()) == zlell)
return 1;
zlecs = x + 1;
- for (x = 1; zlecs != zlell && ZC_iblank(zleline[zlecs]); zlecs++, x++);
+ pos = zlecs;
+ for (; zlecs != zlell && ZC_iblank(zleline[zlecs]); INCPOS(zlecs))
+ ;
+ x = 1 + (zlecs - pos);
backdel(x, CUT_RAW);
- if (zlecs && ZC_iblank(zleline[zlecs-1]))
- zlecs--;
- else {
- spaceinline(1);
- zleline[zlecs] = ZWC(' ');
+ if (zlecs) {
+ int pos = zlecs;
+ DECPOS(pos);
+ if (ZC_iblank(zleline[pos])) {
+ zlecs = pos;
+ return 0;
+ }
}
+ spaceinline(1);
+ zleline[zlecs] = ZWC(' ');
return 0;
}
@@ -851,10 +858,10 @@
zleline[zlecs] = ZC_toupper(zleline[zlecs]);
else if (ZC_iupper(zleline[zlecs]))
zleline[zlecs] = ZC_tolower(zleline[zlecs]);
- zlecs++;
+ INCCS();
}
if (zlecs && zlecs == eol)
- zlecs--;
+ DECCS();
return 0;
}
@@ -909,7 +916,7 @@
return 1;
}
/* delete to end of line */
- forekill(findeol() - zlecs, 0);
+ forekill(findeol() - zlecs, CUT_RAW);
return 0;
}
@@ -925,13 +932,17 @@
spaceinline(1);
zleline[zlecs] = '#';
if(zlecs <= viinsbegin)
- viinsbegin++;
- zlecs = oldcs + (zlecs <= oldcs);
+ INCPOS(viinsbegin);
+ if (zlecs <= oldcs)
+ INCPOS(oldcs);
+ zlecs = oldcs;
} else {
foredel(1, 0);
if (zlecs < viinsbegin)
- viinsbegin--;
- zlecs = oldcs - (zlecs < oldcs);
+ DECPOS(viinsbegin);
+ if (zlecs < oldcs)
+ DECPOS(oldcs);
+ zlecs = oldcs;
}
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] only message in thread
only message in thread, other threads:[~2008-05-04 18:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-04 18:25 PATCH: more combining character stuff 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).