From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk
Subject: Re: vi-backward-kill-word
Date: Mon, 21 Apr 2008 18:57:02 +0100 [thread overview]
Message-ID: <20080421185702.19659d5a@news01> (raw)
In-Reply-To: <20080421182728.3450104d@news01>
On Mon, 21 Apr 2008 18:27:28 +0100
Peter Stephenson <pws@csr.com> wrote:
> I think there's still a problem
> in overstrike mode when you enter a combining character; it'll advance too
> far right. I'll look at that separately.
I think this deals with it.
I saw some oddities with undo, but that may simply be because in a version
I hadn't quite got right the cursor position was screwy. I didn't see them
with the final version.
Index: Src/Zle/zle_misc.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_misc.c,v
retrieving revision 1.50
diff -u -r1.50 zle_misc.c
--- Src/Zle/zle_misc.c 21 Apr 2008 17:30:35 -0000 1.50
+++ Src/Zle/zle_misc.c 21 Apr 2008 17:53:42 -0000
@@ -50,19 +50,43 @@
if (insmode)
spaceinline(m * len);
else {
- int pos = zlecs, count = m * len, i = count, diff;
+ int pos = zlecs, diff, i;
+
+ /*
+ * Calculate the number of character positions we are
+ * going to be using. The algorithm is that
+ * anything that shows up as a logical single character
+ * (i.e. even if control, or double width, or with combining
+ * characters) is treated as 1 for the purpose of replacing
+ * what's there already.
+ */
+ for (i = 0, count = 0; i < len; i++) {
+ int width = wcwidth(zstr[i]);
+ count += (width != 0) ? 1 : 0;
+ }
/*
* Ensure we replace a complete combining character
* for each character we overwrite.
*/
- while (pos < zlell && i--) {
+ for (i = count; pos < zlell && i--; ) {
INCPOS(pos);
}
- diff = pos - zlecs - count;
+ /*
+ * Calculate how many raw line places we need.
+ * pos - zlecs is the raw line distance we're replacing,
+ * m * len the number we're inserting.
+ */
+ diff = pos - zlecs - m * len;
if (diff < 0) {
spaceinline(-diff);
- } else if (diff > 0)
- foredel(diff, CUT_RAW);
+ } else if (diff > 0) {
+ /*
+ * We use shiftchars() here because we don't
+ * want combining char alignment fixed up: we
+ * are going to write over any that remain.
+ */
+ shiftchars(zlecs, diff);
+ }
}
while (m--)
for (s = zstr, count = len; count; s++, count--)
Index: Src/Zle/zle_utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_utils.c,v
retrieving revision 1.51
diff -u -r1.51 zle_utils.c
--- Src/Zle/zle_utils.c 21 Apr 2008 10:13:31 -0000 1.51
+++ Src/Zle/zle_utils.c 21 Apr 2008 17:53:42 -0000
@@ -450,7 +450,7 @@
}
/**/
-static void
+void
shiftchars(int to, int cnt)
{
if (mark >= to + cnt)
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
next prev parent reply other threads:[~2008-04-21 17:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-21 16:10 vi-backward-kill-word Jun T.
2008-04-21 17:27 ` vi-backward-kill-word Peter Stephenson
2008-04-21 17:57 ` Peter Stephenson [this message]
2008-04-22 17:56 ` vi-backward-kill-word Jun T.
2008-04-23 8:32 ` vi-backward-kill-word Peter Stephenson
2008-04-24 10:35 vi-backward-kill-word Jun T.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080421185702.19659d5a@news01 \
--to=pws@csr.com \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).