zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: Column alignment with print -c -P
@ 2009-03-24 23:11 Michael Hwang
  2009-03-25  9:53 ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Hwang @ 2009-03-24 23:11 UTC (permalink / raw)
  To: zsh-workers

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

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

end of thread, other threads:[~2009-03-25  9:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-24 23:11 PATCH: Column alignment with print -c -P Michael Hwang
2009-03-25  9:53 ` 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).