From 1761a3b14674350f51a074f104a4b141b6c0caa8 Mon Sep 17 00:00:00 2001 From: Clint Adams Date: Tue, 25 Mar 2003 05:33:18 +0000 Subject: users/5986, 18380: arg support for echoti builtin. --- ChangeLog | 5 +++++ Doc/Zsh/mod_terminfo.yo | 4 ++-- Src/Modules/terminfo.c | 27 +++++++++++++++++++++++---- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index d4a63dd95..401e302df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-03-25 Clint Adams + + * users/5986, 18380: Src/Modules/terminfo.c, + Doc/Zsh/mod_terminfo.yo: arg support for echoti builtin. + 2003-03-24 Peter Stephenson * 18378: Src/Zle/params.c: memory management for $killring diff --git a/Doc/Zsh/mod_terminfo.yo b/Doc/Zsh/mod_terminfo.yo index 7132b44d1..82c93a452 100644 --- a/Doc/Zsh/mod_terminfo.yo +++ b/Doc/Zsh/mod_terminfo.yo @@ -6,9 +6,9 @@ The tt(zsh/terminfo) module makes available one builtin command: startitem() findex(echoti) cindex(terminfo value, printing) -item(tt(echoti) var(cap))( +item(tt(echoti) var(cap) [ var(arg) ])( Output the terminfo value corresponding to the capability -var(cap). +var(cap), instantiated with var(arg) if applicable. ) enditem() diff --git a/Src/Modules/terminfo.c b/Src/Modules/terminfo.c index 744defc8c..c8e5c23fb 100644 --- a/Src/Modules/terminfo.c +++ b/Src/Modules/terminfo.c @@ -59,8 +59,8 @@ static Param terminfo_pm; static int bin_echoti(char *name, char **argv, Options ops, int func) { - char *s, *t; - int num; + char *s, *t, *u; + int num, argct; s = *argv++; /* This depends on the termcap stuff in init.c */ @@ -92,9 +92,28 @@ bin_echoti(char *name, char **argv, Options ops, int func) zwarnnam(name, "no such terminfo capability: %s", s, 0); return 1; } - - tputs(t, 1, putchar); + /* count the number of arguments required */ + for (argct = 0, u = t; *u; u++) + if (*u == '%') { + if (u++, (*u == 'd' || *u == '2' || *u == '3' || *u == '.' || + *u == '+')) + argct++; + } + /* check that the number of arguments provided is correct */ + if (arrlen(argv) != argct) { + zwarnnam(name, (arrlen(argv) < argct) ? "not enough arguments" : + "too many arguments", NULL, 0); + return 1; + } + /* output string, through the proper termcap functions */ + if (!argct) + tputs(t, 1, putraw); + else { + num = (argv[1]) ? atoi(argv[1]) : atoi(*argv); + tputs(tparm(t, atoi(*argv)), num, putraw); + } return 0; + } /**/ -- cgit 1.4.1