myadm

Simple MySQL client for the terminal
git clone git://git.bitsmanent.org/myadm
Log | Files | Refs | README | LICENSE

commit b6f0ff0c9cfe38c111a0d86303e3e58fe346bafe
parent 79d312e7ad142b97c29aebe7065ddb73028d1cc3
Author: Claudio Alessi <smoppy@gmail.com>
Date:   Tue,  1 Mar 2016 23:07:11 +0100

Add stfl_setf().
The status() function has been removed. Also the stext and itext STFL variables has been renamed respectively to statustext and infotext.

Diffstat:
Mcore.c | 22++++++++++++----------
Mitems.stfl | 4++--
2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/core.c b/core.c @@ -52,7 +52,7 @@ struct View { /* function declarations */ void die(const char *errstr, ...); -void status(const char *fmtstr, ...); +void stfl_setf(const char *name, const char *fmtstr, ...); void databases(void); void tables(void); void records(void); @@ -95,7 +95,7 @@ char choose(const char *msg, char *opts) { char *o, c; - status(msg); + stfl_setf("statustext", msg); stfl_run(selview->form, -1); while((c = getchar())) { if(c == '\r') { @@ -109,7 +109,7 @@ choose(const char *msg, char *opts) { break; } - status(""); + stfl_setf("statustext", ""); return *o; } @@ -137,7 +137,6 @@ detach(View *v) { *tv = v->next; } -/* XXX attachto(void, void)? */ void attachitemto(Item *i, Item **ii) { i->next = *ii; @@ -198,7 +197,7 @@ setmode(const Arg *arg) { selview->mode->func(); if(selview->choice && selview->choice->nfields) - status("[%s]", selview->choice->fields[0]); + stfl_setf("infotext", "[%s]", selview->choice->fields[0]); stfl_set(selview->form, L"pos", 0); } @@ -303,6 +302,8 @@ mysql_listview(MYSQL_RES *res) { if(!selview->form) selview->form = stfl_create(L"<items.stfl>"); + /* XXX columns row */ + stfl_modify(selview->form, L"items", L"replace_inner", L"vbox"); /* clear */ /* XXX actually in reverse order */ for(item = selview->items; item; item = item->next) @@ -411,20 +412,20 @@ apply(const Arg *arg) { return; } - status("Applied!"); + /* XXX ... */ - /* XXX */ + stfl_setf("statustext", "Changes applied."); } void -status(const char *fmtstr, ...) { +stfl_setf(const char *name, const char *fmtstr, ...) { va_list ap; char s[512]; va_start(ap, fmtstr); vsnprintf(s, sizeof s, fmtstr, ap); va_end(ap); - stfl_set(selview->form, L"stext", stfl_ipool_towc(ipool, s)); + stfl_set(selview->form, stfl_ipool_towc(ipool, name), stfl_ipool_towc(ipool, s)); } void @@ -459,11 +460,12 @@ main(int argc, char **argv) { ipool = stfl_ipool_create(nl_langinfo(CODESET)); setmode(&a); - status("Welcome to %s-%s", __FILE__, VERSION); + stfl_setf("statustext", "Welcome to %s-%s", __FILE__, VERSION); while(running) { if(!(ev = stfl_run(selview->form, 0))) continue; + stfl_setf("statustext", ""); k = NULL; for(i = 0; i < LENGTH(keys); ++i) if(!((keys[i].mode && strcmp(selview->mode->name, keys[i].mode)) diff --git a/items.stfl b/items.stfl @@ -10,7 +10,7 @@ vbox[main] label @style_normal:fg=black,bg=white .expand:0 - text[stext]:"" + text[infotext]:"" label .expand:0 - text[cmdline]:"" + text[statustext]:""