diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2005-02-18 13:57:25 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2005-02-18 13:57:25 +0000 |
commit | d7c13fb2c3b1b014acde9c1cb17a1e34239b9751 (patch) | |
tree | 7b31d7d08233e1cc1b1ab46af1ac44b25ed4f2c1 /Src/Zle/zle_hist.c | |
parent | 294ef9e87237bf1dc12b17a26bc4b22aa5604282 (diff) | |
download | zsh-d7c13fb2c3b1b014acde9c1cb17a1e34239b9751.tar.gz zsh-d7c13fb2c3b1b014acde9c1cb17a1e34239b9751.tar.xz zsh-d7c13fb2c3b1b014acde9c1cb17a1e34239b9751.zip |
20822: Initial code for Unicode/multibyte input
20823: Debugging test in stat wrong for 64-bit systems
Diffstat (limited to 'Src/Zle/zle_hist.c')
-rw-r--r-- | Src/Zle/zle_hist.c | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/Src/Zle/zle_hist.c b/Src/Zle/zle_hist.c index 8cd082b72..afad7ae44 100644 --- a/Src/Zle/zle_hist.c +++ b/Src/Zle/zle_hist.c @@ -420,11 +420,12 @@ endofhistory(UNUSED(char **args)) int insertlastword(char **args) { - int n, nwords, histstep = -1, wordpos = 0, deleteword = 0; + int n, nwords, histstep = -1, wordpos = 0, deleteword = 0, len, sz; char *s, *t; Histent he = NULL; LinkList l = NULL; LinkNode node; + ZLE_STRING_T zs; static char *lastinsert; static int lasthist, lastpos, lastlen; @@ -554,7 +555,10 @@ insertlastword(char **args) memcpy(lastinsert, s, lastlen); n = zmult; zmult = 1; - doinsert(s); + + zs = stringaszleline((unsigned char *)s, &len, &sz); + doinsert(zs, len); + zfree(zs, sz); zmult = n; *t = save; return 0; @@ -780,7 +784,7 @@ doisearch(char **args, int dir) char *arg; savekeys = kungetct; arg = getkeystring(*args, &len, 2, NULL); - ungetkeys(arg, len); + ungetbytes(arg, len); } strcpy(ibuf, ISEARCH_PROMPT); @@ -951,18 +955,23 @@ doisearch(char **args, int dir) sbuf[sbptr] = '^'; zrefresh(); } - if ((lastchar = getkey(0)) == EOF) + if (getfullchar(0) == ZLEEOF) feep = 1; else goto ins; } else { if(cmd == Th(z_selfinsertunmeta)) { - lastchar &= 0x7f; - if(lastchar == '\r') - lastchar = '\n'; - } else if (cmd == Th(z_magicspace)) - lastchar = ' '; - else if (cmd != Th(z_selfinsert)) { + fixunmeta(); + } else if (cmd == Th(z_magicspace)) { + fixmagicspace(); + } else if (cmd == Th(z_selfinsert)) { +#ifdef ZLE_UNICODE_SUPPORT + if (!lastchar_wide_valid) + getfullcharrest(lastchar); +#else + ; +#endif + } else { ungetkeycmd(); if (cmd == Th(z_sendbreak)) sbptr = 0; @@ -979,6 +988,8 @@ doisearch(char **args, int dir) sbuf = ibuf + FIRST_SEARCH_CHAR; sibuf *= 2; } + /* TODO: use lastchar_wide if available, convert back to + * multibyte string. Yuk. */ sbuf[sbptr++] = lastchar; } if (feep) @@ -1093,7 +1104,7 @@ getvisrchstr(void) break; } if(cmd == Th(z_magicspace)) { - lastchar = ' '; + fixmagicspace(); cmd = Th(z_selfinsert); } if(cmd == Th(z_redisplay)) { @@ -1128,15 +1139,20 @@ getvisrchstr(void) sbuf[sptr] = '^'; zrefresh(); } - if ((lastchar = getkey(0)) == EOF) + if (getfullchar(0) == ZLEEOF) feep = 1; else goto ins; } else if(cmd == Th(z_selfinsertunmeta) || cmd == Th(z_selfinsert)) { if(cmd == Th(z_selfinsertunmeta)) { - lastchar &= 0x7f; - if(lastchar == '\r') - lastchar = '\n'; + fixunmeta(); + } else { +#ifdef ZLE_UNICODE_SUPPORT + if (!lastchar_wide_valid) + getrestchar(lastchar); +#else + ; +#endif } ins: if(sptr == ssbuf - 1) { @@ -1144,6 +1160,7 @@ getvisrchstr(void) strcpy(newbuf, sbuf); statusline = sbuf = newbuf; } + /* TODO: may be wide char, convert back to multibyte string */ sbuf[sptr++] = lastchar; } else { feep = 1; |