From: Clint Adams <clint@zsh.org>
To: Peter Stephenson <pws@csr.com>
Cc: Zsh hackers list <zsh-workers@sunsite.dk>
Subject: Re: PATCH: Unicode additions, next phase.
Date: Tue, 25 Jan 2005 21:29:47 -0500 [thread overview]
Message-ID: <20050126022947.GA12574@scowler.net> (raw)
In-Reply-To: <200501251446.j0PEkoFJ024136@news01.csr.com>
> The key missing bits are screen output from zle_refresh.c and key
Here's a stab at that, though any line containing the string "error" is
broken.
M Src/Zle/zle_refresh.c
M Src/system.h
* modified files
--- orig/Src/Zle/zle_refresh.c
+++ mod/Src/Zle/zle_refresh.c
@@ -86,7 +86,7 @@
* add non-editable text to that being displayed.
*/
/**/
-unsigned char *predisplay, *postdisplay;
+ZLE_STRING_T predisplay, postdisplay;
/**/
int predisplaylen, postdisplaylen;
@@ -284,13 +284,17 @@
t0 = -1, /* tmp */
tosln = 0; /* tmp in statusline stuff */
unsigned char *s, /* pointer into the video buffer */
- *t, /* pointer into the real buffer */
*sen, /* pointer to end of the video buffer (eol) */
+ *u; /* pointer for status line stuff */
+ ZLE_STRING_T t, /* pointer into the real buffer */
*scs; /* pointer to cursor position in real buffer */
char **qbuf; /* tmp */
- unsigned char *tmpline; /* line with added pre/post text */
+ ZLE_STRING_T tmpline; /* line with added pre/post text */
int tmpcs, tmpll; /* ditto cursor position and line length */
int tmpalloced; /* flag to free tmpline when finished */
+#ifdef ZLE_UNICODE_SUPPORT
+ mbstate_t shiftstate; /* wcrtomb shift state */
+#endif
if (trashedzle)
reexpandprompt();
@@ -304,13 +308,13 @@
if (predisplaylen || postdisplaylen) {
/* There is extra text to display at the start or end of the line */
- tmpline = zalloc(zlell + predisplaylen + postdisplaylen);
+ tmpline = zalloc((zlell + predisplaylen + postdisplaylen)*ZLE_CHAR_SIZE);
if (predisplaylen)
- memcpy(tmpline, predisplay, predisplaylen);
+ ZS_memcpy(tmpline, predisplay, predisplaylen);
if (zlell)
- memcpy(tmpline+predisplaylen, zleline, zlell);
+ ZS_memcpy(tmpline+predisplaylen, zleline, zlell);
if (postdisplaylen)
- memcpy(tmpline+predisplaylen+zlell, postdisplay, postdisplaylen);
+ ZS_memcpy(tmpline+predisplaylen+zlell, postdisplay, postdisplaylen);
tmpcs = zlecs + predisplaylen;
tmpll = predisplaylen + zlell + postdisplaylen;
tmpalloced = 1;
@@ -455,10 +459,10 @@
if (t == scs) /* if cursor is here, remember it */
nvcs = s - (unsigned char *)(nbuf[nvln = ln]);
- if (*t == '\n') { /* newline */
+ if (*t == ZLENL){ /* newline */
nbuf[ln][winw + 1] = '\0'; /* text not wrapped */
nextline
- } else if (*t == '\t') { /* tab */
+ } else if (*t == ZLETAB) { /* tab */
t0 = (char *)s - nbuf[ln];
if ((t0 | 7) + 1 >= winw) {
nbuf[ln][winw + 1] = '\n'; /* text wrapped */
@@ -467,15 +471,31 @@
do
*s++ = ' ';
while ((++t0) & 7);
- } else if (icntrl(*t)) { /* other control character */
+ } else if (ZC_icntrl(*t)) { /* other control character */
*s++ = '^';
if (s == sen) {
nbuf[ln][winw + 1] = '\n'; /* text wrapped */
nextline
}
+#ifdef ZLE_UNICODE_SUPPORT
+# error What to do here
+#else
*s++ = (*t == 127) ? '?' : (*t | '@');
- } else /* normal character */
+#endif
+ } else { /* normal character */
+#ifdef ZLE_UNICODE_SUPPORT
+ size_t i;
+
+ i = wcrtomb(s, *t, &shiftstate);
+ if (i == -1) {
+ /* error; what to do? */
+ } else {
+ s += i;
+ }
+#else
*s++ = *t;
+#endif
+ }
if (s == sen) {
nbuf[ln][winw + 1] = '\n'; /* text wrapped */
nextline
@@ -501,17 +521,17 @@
tosln = ln + 1;
nbuf[ln][winw + 1] = '\0'; /* text not wrapped */
snextline
- t = (unsigned char *)statusline;
- for (; t < (unsigned char *)statusline + statusll; t++) {
- if (icntrl(*t)) { /* simplified processing in the status line */
+ u = (unsigned char *)statusline;
+ for (; u < (unsigned char *)statusline + statusll; u++) {
+ if (icntrl(*u)) { /* simplified processing in the status line */
*s++ = '^';
if (s == sen) {
nbuf[ln][winw + 1] = '\n'; /* text wrapped */
snextline
}
- *s++ = (*t == 127) ? '?' : (*t | '@');
+ *s++ = (*u == 127) ? '?' : (*u | '@');
} else
- *s++ = *t;
+ *s++ = *u;
if (s == sen) {
nbuf[ln][winw + 1] = '\n'; /* text wrapped */
snextline
--- orig/Src/system.h
+++ mod/Src/system.h
@@ -724,6 +724,9 @@
#define ZLENL L'\n'
#define ZLENUL L'\0'
+#define ZLETAB L'\t'
+#define ZS_memcpy wmemcpy
+#define ZC_icntrl iswcntrl
#else
typedef int ZLE_CHAR_T;
typedef unsigned char *ZLE_STRING_T;
@@ -731,4 +734,7 @@
#define ZLENL '\n'
#define ZLENUL '\0'
+#define ZLETAB '\t'
+#define ZS_memcpy memcpy
+#define ZC_icntrl icntrl
#endif
next prev parent reply other threads:[~2005-01-26 2:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-25 14:46 Peter Stephenson
2005-01-25 16:02 ` Clint Adams
[not found] ` <clint@zsh.org>
2005-01-25 16:37 ` Peter Stephenson
2005-01-26 2:29 ` Clint Adams [this message]
2005-01-26 10:33 ` Peter Stephenson
2005-01-26 14:26 ` Clint Adams
2005-01-27 11:30 ` Matthias B.
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=20050126022947.GA12574@scowler.net \
--to=clint@zsh.org \
--cc=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).