w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

commit 1df8ab7e4530cb5a506ccb769528799b14150db3
parent 349a56a6766b6ba8ab2e2bb01d9373848ea5f023
Author: ukai <ukai>
Date:   Fri,  7 Dec 2001 07:20:26 +0000

[w3m-dev 02638]
From: Tsutomu Okada <okada@furuno.co.jp>

Diffstat:
MChangeLog | 8++++++++
Mlinein.c | 45++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,11 @@ +2001-12-07 Tsutomu Okada <okada@furuno.co.jp> + + * [w3m-dev 02638] completion for ! and/or @ + * linein.c (next_compl): check "\\ ", "\\\t" + * linein.c (escape_spaces): added + * linein.c (unescape_spaces): added + * linein.c (doComplete): use unescape_spaces, escape_spaces + 2001-12-07 Fumitoshi UKAI <ukai@debian.or.jp> * [w3m-dev 02637] diff --git a/linein.c b/linein.c @@ -681,7 +681,8 @@ next_compl(int next) } else { for (b = CPos - 1; b >= 0; b--) { - if (strBuf->ptr[b] == ' ' || strBuf->ptr[b] == CTRL_I) + if ((strBuf->ptr[b] == ' ' || strBuf->ptr[b] == CTRL_I) && + !((b > 0) && strBuf->ptr[b-1] == '\\')) break; } b++; @@ -854,6 +855,40 @@ next_dcompl(int next) } } +Str +escape_spaces(Str s) +{ + char *p; + + if (s == NULL) + return; + p = s->ptr; + s = Strnew(); + while(*p) { + if (*p == ' ') + Strcat_char(s, '\\'); + Strcat_char(s, *p++); + } + return s; +} + +Str +unescape_spaces(Str s) +{ + char *p; + + if (s == NULL) + return; + p = s->ptr; + s = Strnew(); + while (*p) { + if (!(*p == '\\' && *(p+1) && *(p+1) == ' ')) + Strcat_char(s, *p); + p++; + } + return s; +} + static Str doComplete(Str ifn, int *status, int next) { @@ -866,6 +901,8 @@ doComplete(Str ifn, int *status, int next) if (!cm_next) { NCFileBuf = 0; ifn = Str_conv_to_system(ifn); + if (cm_mode & CPL_ON) + ifn = unescape_spaces(ifn); CompleteBuf = Strdup(ifn); while (Strlastchar(CompleteBuf) != '/' && CompleteBuf->length > 0) Strshrink(CompleteBuf, 1); @@ -893,6 +930,8 @@ doComplete(Str ifn, int *status, int next) if ((d = opendir(expandName(CompleteBuf->ptr))) == NULL) { CompleteBuf = Strdup(ifn); *status = CPL_FAIL; + if (cm_mode & CPL_ON) + CompleteBuf = escape_spaces(CompleteBuf); return CompleteBuf; } fn = lastFileName(ifn->ptr); @@ -924,6 +963,8 @@ doComplete(Str ifn, int *status, int next) if (NCFileBuf == 0) { CompleteBuf = Strdup(ifn); *status = CPL_FAIL; + if (cm_mode & CPL_ON) + CompleteBuf = escape_spaces(CompleteBuf); return CompleteBuf; } qsort(CFileBuf, NCFileBuf, sizeof(CFileBuf[0]), strCmp); @@ -963,6 +1004,8 @@ doComplete(Str ifn, int *status, int next) if (stat(expandName(p), &st) != -1 && S_ISDIR(st.st_mode)) Strcat_char(CompleteBuf, '/'); } + if (cm_mode & CPL_ON) + CompleteBuf = escape_spaces(CompleteBuf); return Str_conv_from_system(CompleteBuf); }