diff options
author | Sven Wischnowsky <wischnow@users.sourceforge.net> | 2000-05-23 08:20:56 +0000 |
---|---|---|
committer | Sven Wischnowsky <wischnow@users.sourceforge.net> | 2000-05-23 08:20:56 +0000 |
commit | 7f9f81f3e22a58d6a8af77f05cd05c94faf88d93 (patch) | |
tree | ea885f65d2b29f8fe5b733683333973a7e7351db /Src | |
parent | de2c2a89c6341adeb4e033ec8877d67eb0c2110c (diff) | |
download | zsh-7f9f81f3e22a58d6a8af77f05cd05c94faf88d93.tar.gz zsh-7f9f81f3e22a58d6a8af77f05cd05c94faf88d93.tar.xz zsh-7f9f81f3e22a58d6a8af77f05cd05c94faf88d93.zip |
save and restore more variables in bufferwords(); move gotword() into core (11523)
Diffstat (limited to 'Src')
-rw-r--r-- | Src/Zle/zle.h | 77 | ||||
-rw-r--r-- | Src/Zle/zle_main.c | 2 | ||||
-rw-r--r-- | Src/Zle/zle_tricky.c | 18 | ||||
-rw-r--r-- | Src/hist.c | 7 | ||||
-rw-r--r-- | Src/init.c | 3 | ||||
-rw-r--r-- | Src/lex.c | 18 | ||||
-rw-r--r-- | Src/zsh.h | 1 |
7 files changed, 92 insertions, 34 deletions
diff --git a/Src/Zle/zle.h b/Src/Zle/zle.h index faf6cf878..a611fd58b 100644 --- a/Src/Zle/zle.h +++ b/Src/Zle/zle.h @@ -30,15 +30,14 @@ #undef trashzle #undef zleread #undef spaceinline -#undef gotword -#undef refresh +#undef zrefresh typedef struct widget *Widget; typedef struct thingy *Thingy; /* widgets (ZLE functions) */ -typedef void (*ZleIntFunc) _((void)); +typedef int (*ZleIntFunc) _((char **)); struct widget { int flags; /* flags (see below) */ @@ -46,16 +45,24 @@ struct widget { union { ZleIntFunc fn; /* pointer to internally implemented widget */ char *fnnam; /* name of the shell function for user-defined widget */ + struct { + ZleIntFunc fn; /* internal widget function to call */ + char *wid; /* name of widget to call */ + char *func; /* name of shell function to call */ + } comp; } u; }; -#define WIDGET_INT (1<<0) /* widget is internally implemented */ -#define ZLE_MENUCMP (1<<1) /* DON'T invalidate completion list */ +#define WIDGET_INT (1<<0) /* widget is internally implemented */ +#define WIDGET_NCOMP (1<<1) /* new style completion widget */ +#define ZLE_MENUCMP (1<<2) /* DON'T invalidate completion list */ #define ZLE_YANK (1<<3) -#define ZLE_LINEMOVE (1<<4) /* command is a line-oriented movement */ -#define ZLE_LASTCOL (1<<5) /* command maintains lastcol correctly */ +#define ZLE_LINEMOVE (1<<4) /* command is a line-oriented movement */ +#define ZLE_LASTCOL (1<<5) /* command maintains lastcol correctly */ #define ZLE_KILL (1<<6) -#define ZLE_KEEPSUFFIX (1<<9) /* DON'T remove added suffix */ +#define ZLE_KEEPSUFFIX (1<<7) /* DON'T remove added suffix */ +#define ZLE_NOTCOMMAND (1<<8) /* widget should not alter lastcmd */ +#define ZLE_ISCOMP (1<<9) /* usable for new style completion */ /* thingies */ @@ -99,6 +106,7 @@ struct change { int off; /* offset of the text changes */ char *del; /* characters to delete (metafied) */ char *ins; /* characters to insert (metafied) */ + int old_cs, new_cs; /* old and new cursor positions */ }; #define CH_NEXT (1<<0) /* next structure is also part of this change */ @@ -118,7 +126,7 @@ typedef void (*KeyScanFunc) _((char *, Thingy, char *, void *)); /* Standard type of suffix removal. */ -#define removesuffix() iremovesuffix(256) +#define removesuffix() iremovesuffix(256, 0) /* Cut/kill buffer type. The buffer itself is purely binary data, * * not NUL-terminated. len is a length count. flags uses the * @@ -135,3 +143,54 @@ typedef struct cutbuffer *Cutbuffer; #define CUTBUFFER_LINE 1 /* for vi: buffer contains whole lines of data */ #define KRINGCT 8 /* number of buffers in the kill ring */ + +/* Types of completion. */ + +#define COMP_COMPLETE 0 +#define COMP_LIST_COMPLETE 1 +#define COMP_SPELL 2 +#define COMP_EXPAND 3 +#define COMP_EXPAND_COMPLETE 4 +#define COMP_LIST_EXPAND 5 +#define COMP_ISEXPAND(X) ((X) >= COMP_EXPAND) + +/* Information about one brace run. */ + +typedef struct brinfo *Brinfo; + +struct brinfo { + Brinfo next; /* next in list */ + Brinfo prev; /* previous (only for closing braces) */ + char *str; /* the string to insert */ + int pos; /* original position */ + int qpos; /* original position, with quoting */ + int curpos; /* position for current match */ +}; + +/* Convenience macros for the hooks */ + +#define LISTMATCHESHOOK (zlehooks + 0) +#define COMPLETEHOOK (zlehooks + 1) +#define BEFORECOMPLETEHOOK (zlehooks + 2) +#define AFTERCOMPLETEHOOK (zlehooks + 3) +#define ACCEPTCOMPHOOK (zlehooks + 4) +#define REVERSEMENUHOOK (zlehooks + 5) +#define INVALIDATELISTHOOK (zlehooks + 6) + +/* complete hook data struct */ + +typedef struct compldat *Compldat; + +struct compldat { + char *s; + int lst; + int incmd; +}; + +/* List completion matches. */ + +#define listmatches() runhookdef(LISTMATCHESHOOK, NULL) + +/* Invalidate the completion list. */ + +#define invalidatelist() runhookdef(INVALIDATELISTHOOK, NULL) diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index 178133fae..0b5735332 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -1039,7 +1039,6 @@ setup_(Module m) { /* Set up editor entry points */ trashzleptr = trashzle; - gotwordptr = gotword; refreshptr = zrefresh; spaceinlineptr = spaceinline; zlereadptr = zleread; @@ -1116,7 +1115,6 @@ finish_(Module m) /* editor entry points */ trashzleptr = noop_function; - gotwordptr = noop_function; refreshptr = noop_function; spaceinlineptr = noop_function_int; zlereadptr = fallback_zleread; diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c index 0d10a0446..beed90704 100644 --- a/Src/Zle/zle_tricky.c +++ b/Src/Zle/zle_tricky.c @@ -58,11 +58,6 @@ mod_export int clwsize, clwnum, clwpos; /**/ mod_export char **clwords; -/* wb and we hold the beginning/end position of the word we are completing. */ - -/**/ -mod_export int wb, we; - /* offs is the cursor position within the tokenized * * current word after removing nulargs. */ @@ -1692,19 +1687,6 @@ doexpansion(char *s, int lst, int olst, int explincmd) return ret; } -/* This is called from the lexer to give us word positions. */ - -/**/ -void -gotword(void) -{ - we = ll + 1 - inbufct + (addedx == 2 ? 1 : 0); - if (cs <= we) { - wb = ll - wordbeg + addedx; - zleparse = 0; - } -} - /**/ static int docompletion(char *s, int lst, int incmd) diff --git a/Src/hist.c b/Src/hist.c index 9f35c4cd2..a3d8fa7ef 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -2059,6 +2059,7 @@ mod_export LinkList bufferwords(LinkList list, char *buf, int *index) { int num = 0, cur = -1, got = 0, ne = noerrs, ocs = cs; + int owb = wb, owe = we, oadx = addedx, ozp = zleparse; char *p; if (!list) @@ -2131,10 +2132,14 @@ bufferwords(LinkList list, char *buf, int *index) noaliases = 0; strinend(); inpop(); - errflag = zleparse = 0; + errflag = 0; + zleparse = ozp; noerrs = ne; lexrestore(); cs = ocs; + wb = owb; + we = owe; + addedx = oadx; if (index) *index = cur; diff --git a/Src/init.c b/Src/init.c index ac62b481a..131b50606 100644 --- a/Src/init.c +++ b/Src/init.c @@ -1025,8 +1025,6 @@ noop_function_int(int nothing) /**/ mod_export ZleVoidFn trashzleptr = noop_function; /**/ -mod_export ZleVoidFn gotwordptr = noop_function; -/**/ mod_export ZleVoidFn refreshptr = noop_function; /**/ mod_export ZleVoidIntFn spaceinlineptr = noop_function_int; @@ -1036,7 +1034,6 @@ mod_export ZleReadFn zlereadptr = autoload_zleread; #else /* !LINKED_XMOD_zshQszle */ mod_export ZleVoidFn trashzleptr = noop_function; -mod_export ZleVoidFn gotwordptr = noop_function; mod_export ZleVoidFn refreshptr = noop_function; mod_export ZleVoidIntFn spaceinlineptr = noop_function_int; # ifdef UNLINKED_XMOD_zshQszle diff --git a/Src/lex.c b/Src/lex.c index 53c46f5d3..0c16db60c 100644 --- a/Src/lex.c +++ b/Src/lex.c @@ -93,6 +93,11 @@ mod_export int inwhat; /**/ mod_export int addedx; +/* wb and we hold the beginning/end position of the word we are completing. */ + +/**/ +mod_export int wb, we; + /* 1 if aliases should not be expanded */ /**/ @@ -1483,6 +1488,19 @@ parse_subst_string(char *s) return 0; } +/* Called below to report word positions. */ + +/**/ +mod_export void +gotword(void) +{ + we = ll + 1 - inbufct + (addedx == 2 ? 1 : 0); + if (cs <= we) { + wb = ll - wordbeg + addedx; + zleparse = 0; + } +} + /* expand aliases and reserved words */ /**/ diff --git a/Src/zsh.h b/Src/zsh.h index 34cde8b54..007a84acc 100644 --- a/Src/zsh.h +++ b/Src/zsh.h @@ -30,7 +30,6 @@ #define trashzle() trashzleptr() #define zleread(X,Y,H) zlereadptr(X,Y,H) #define spaceinline(X) spaceinlineptr(X) -#define gotword() gotwordptr() #define zrefresh() refreshptr() #define compctlread(N,A,O,R) compctlreadptr(N,A,O,R) |