zsh-workers
 help / color / mirror / code / Atom feed
From: Michael Hwang <nomex45@yahoo.com>
To: zsh-workers@sunsite.dk
Subject: PATCH: Column alignment with print -c -P
Date: Tue, 24 Mar 2009 16:11:12 -0700 (PDT)	[thread overview]
Message-ID: <729130.32040.qm@web37303.mail.mud.yahoo.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 190 bytes --]

This fixes misaligned columns when using %B, %U, %S, %F, or %K prompt expansions with the -c/-C option of the print builtin. This fix only affects those who have multibyte enabled.



      

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: col_align.patch --]
[-- Type: text/x-diff; name="col_align.patch", Size: 674 bytes --]

diff --git a/Src/builtin.c b/Src/builtin.c
index 95aca06..250aa3e 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3741,6 +3741,16 @@ bin_print(char *name, char **args, Options ops, int func)
 
 		memset(&mbs, 0, sizeof(mbstate_t));
 		while (l > 0) {
+		    /* Prevent misaligned columns due to escape sequences by
+		     * skipping over them. Octals \033 and \233 are the
+		     * possible escape characters recognized by ANSI. */
+		    if (*aptr == '\033' || *aptr == '\233') {
+			for (aptr++, l--; l && !isalpha(*aptr); aptr++, l--);
+			aptr++;
+			l--;
+			continue;
+		    }
+
 		    wchar_t wc;
 		    size_t cnt = mbrtowc(&wc, aptr, l, &mbs);
 		    int wcw;

             reply	other threads:[~2009-03-24 23:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-24 23:11 Michael Hwang [this message]
2009-03-25  9:53 ` Peter Stephenson

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=729130.32040.qm@web37303.mail.mud.yahoo.com \
    --to=nomex45@yahoo.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).