mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-20 03:51:07 +02:00
* 20747: some wide char support in the zle refresh code.
This commit is contained in:
parent
77bd05014d
commit
9453ea957e
3 changed files with 47 additions and 16 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2005-01-26 Clint Adams <clint@zsh.org>
|
||||||
|
|
||||||
|
* 20747: Src/Zle/zle_refresh.c, Src/system.h: some wide char
|
||||||
|
support in the zle refresh code.
|
||||||
|
|
||||||
2005-01-26 Peter Stephenson <pws@csr.com>
|
2005-01-26 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
* 20750: Src/zle_utils.c: 20742 could cause hang when line
|
* 20750: Src/zle_utils.c: 20742 could cause hang when line
|
||||||
|
|
|
@ -86,7 +86,7 @@ int trashedzle;
|
||||||
* add non-editable text to that being displayed.
|
* add non-editable text to that being displayed.
|
||||||
*/
|
*/
|
||||||
/**/
|
/**/
|
||||||
unsigned char *predisplay, *postdisplay;
|
ZLE_STRING_T predisplay, postdisplay;
|
||||||
/**/
|
/**/
|
||||||
int predisplaylen, postdisplaylen;
|
int predisplaylen, postdisplaylen;
|
||||||
|
|
||||||
|
@ -284,13 +284,17 @@ zrefresh(void)
|
||||||
t0 = -1, /* tmp */
|
t0 = -1, /* tmp */
|
||||||
tosln = 0; /* tmp in statusline stuff */
|
tosln = 0; /* tmp in statusline stuff */
|
||||||
unsigned char *s, /* pointer into the video buffer */
|
unsigned char *s, /* pointer into the video buffer */
|
||||||
*t, /* pointer into the real buffer */
|
|
||||||
*sen, /* pointer to end of the video buffer (eol) */
|
*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 */
|
*scs; /* pointer to cursor position in real buffer */
|
||||||
char **qbuf; /* tmp */
|
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 tmpcs, tmpll; /* ditto cursor position and line length */
|
||||||
int tmpalloced; /* flag to free tmpline when finished */
|
int tmpalloced; /* flag to free tmpline when finished */
|
||||||
|
#ifdef ZLE_UNICODE_SUPPORT
|
||||||
|
mbstate_t shiftstate; /* wcrtomb shift state */
|
||||||
|
#endif
|
||||||
|
|
||||||
if (trashedzle)
|
if (trashedzle)
|
||||||
reexpandprompt();
|
reexpandprompt();
|
||||||
|
@ -304,13 +308,13 @@ zrefresh(void)
|
||||||
|
|
||||||
if (predisplaylen || postdisplaylen) {
|
if (predisplaylen || postdisplaylen) {
|
||||||
/* There is extra text to display at the start or end of the line */
|
/* 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)
|
if (predisplaylen)
|
||||||
memcpy(tmpline, predisplay, predisplaylen);
|
ZS_memcpy(tmpline, predisplay, predisplaylen);
|
||||||
if (zlell)
|
if (zlell)
|
||||||
memcpy(tmpline+predisplaylen, zleline, zlell);
|
ZS_memcpy(tmpline+predisplaylen, zleline, zlell);
|
||||||
if (postdisplaylen)
|
if (postdisplaylen)
|
||||||
memcpy(tmpline+predisplaylen+zlell, postdisplay, postdisplaylen);
|
ZS_memcpy(tmpline+predisplaylen+zlell, postdisplay, postdisplaylen);
|
||||||
tmpcs = zlecs + predisplaylen;
|
tmpcs = zlecs + predisplaylen;
|
||||||
tmpll = predisplaylen + zlell + postdisplaylen;
|
tmpll = predisplaylen + zlell + postdisplaylen;
|
||||||
tmpalloced = 1;
|
tmpalloced = 1;
|
||||||
|
@ -455,10 +459,10 @@ zrefresh(void)
|
||||||
if (t == scs) /* if cursor is here, remember it */
|
if (t == scs) /* if cursor is here, remember it */
|
||||||
nvcs = s - (unsigned char *)(nbuf[nvln = ln]);
|
nvcs = s - (unsigned char *)(nbuf[nvln = ln]);
|
||||||
|
|
||||||
if (*t == '\n') { /* newline */
|
if (*t == ZLENL){ /* newline */
|
||||||
nbuf[ln][winw + 1] = '\0'; /* text not wrapped */
|
nbuf[ln][winw + 1] = '\0'; /* text not wrapped */
|
||||||
nextline
|
nextline
|
||||||
} else if (*t == '\t') { /* tab */
|
} else if (*t == ZLETAB) { /* tab */
|
||||||
t0 = (char *)s - nbuf[ln];
|
t0 = (char *)s - nbuf[ln];
|
||||||
if ((t0 | 7) + 1 >= winw) {
|
if ((t0 | 7) + 1 >= winw) {
|
||||||
nbuf[ln][winw + 1] = '\n'; /* text wrapped */
|
nbuf[ln][winw + 1] = '\n'; /* text wrapped */
|
||||||
|
@ -467,15 +471,31 @@ zrefresh(void)
|
||||||
do
|
do
|
||||||
*s++ = ' ';
|
*s++ = ' ';
|
||||||
while ((++t0) & 7);
|
while ((++t0) & 7);
|
||||||
} else if (icntrl(*t)) { /* other control character */
|
} else if (ZC_icntrl(*t)) { /* other control character */
|
||||||
*s++ = '^';
|
*s++ = '^';
|
||||||
if (s == sen) {
|
if (s == sen) {
|
||||||
nbuf[ln][winw + 1] = '\n'; /* text wrapped */
|
nbuf[ln][winw + 1] = '\n'; /* text wrapped */
|
||||||
nextline
|
nextline
|
||||||
}
|
}
|
||||||
|
#ifdef ZLE_UNICODE_SUPPORT
|
||||||
|
# error What to do here
|
||||||
|
#else
|
||||||
*s++ = (*t == 127) ? '?' : (*t | '@');
|
*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;
|
*s++ = *t;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
if (s == sen) {
|
if (s == sen) {
|
||||||
nbuf[ln][winw + 1] = '\n'; /* text wrapped */
|
nbuf[ln][winw + 1] = '\n'; /* text wrapped */
|
||||||
nextline
|
nextline
|
||||||
|
@ -501,17 +521,17 @@ zrefresh(void)
|
||||||
tosln = ln + 1;
|
tosln = ln + 1;
|
||||||
nbuf[ln][winw + 1] = '\0'; /* text not wrapped */
|
nbuf[ln][winw + 1] = '\0'; /* text not wrapped */
|
||||||
snextline
|
snextline
|
||||||
t = (unsigned char *)statusline;
|
u = (unsigned char *)statusline;
|
||||||
for (; t < (unsigned char *)statusline + statusll; t++) {
|
for (; u < (unsigned char *)statusline + statusll; u++) {
|
||||||
if (icntrl(*t)) { /* simplified processing in the status line */
|
if (icntrl(*u)) { /* simplified processing in the status line */
|
||||||
*s++ = '^';
|
*s++ = '^';
|
||||||
if (s == sen) {
|
if (s == sen) {
|
||||||
nbuf[ln][winw + 1] = '\n'; /* text wrapped */
|
nbuf[ln][winw + 1] = '\n'; /* text wrapped */
|
||||||
snextline
|
snextline
|
||||||
}
|
}
|
||||||
*s++ = (*t == 127) ? '?' : (*t | '@');
|
*s++ = (*u == 127) ? '?' : (*u | '@');
|
||||||
} else
|
} else
|
||||||
*s++ = *t;
|
*s++ = *u;
|
||||||
if (s == sen) {
|
if (s == sen) {
|
||||||
nbuf[ln][winw + 1] = '\n'; /* text wrapped */
|
nbuf[ln][winw + 1] = '\n'; /* text wrapped */
|
||||||
snextline
|
snextline
|
||||||
|
|
|
@ -724,6 +724,9 @@ typedef wchar_t *ZLE_STRING_T;
|
||||||
|
|
||||||
#define ZLENL L'\n'
|
#define ZLENL L'\n'
|
||||||
#define ZLENUL L'\0'
|
#define ZLENUL L'\0'
|
||||||
|
#define ZLETAB L'\t'
|
||||||
|
#define ZS_memcpy wmemcpy
|
||||||
|
#define ZC_icntrl iswcntrl
|
||||||
#else
|
#else
|
||||||
typedef int ZLE_CHAR_T;
|
typedef int ZLE_CHAR_T;
|
||||||
typedef unsigned char *ZLE_STRING_T;
|
typedef unsigned char *ZLE_STRING_T;
|
||||||
|
@ -731,4 +734,7 @@ typedef unsigned char *ZLE_STRING_T;
|
||||||
|
|
||||||
#define ZLENL '\n'
|
#define ZLENL '\n'
|
||||||
#define ZLENUL '\0'
|
#define ZLENUL '\0'
|
||||||
|
#define ZLETAB '\t'
|
||||||
|
#define ZS_memcpy memcpy
|
||||||
|
#define ZC_icntrl icntrl
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue