diff options
author | Alexander Naumov <alexander_naumov@opensuse.org> | 2016-11-05 15:56:08 +0100 |
---|---|---|
committer | Alexander Naumov <alexander_naumov@opensuse.org> | 2016-11-05 15:56:08 +0100 |
commit | af78ba71b8901fae6b5ab52727b03c7c6d669259 (patch) | |
tree | 83a35b6272b4d9c27ff001d3eae8e920b143b766 | |
parent | 51a84088f05b35b2e19672b8a0ea02e5497abc6e (diff) | |
download | screen-af78ba71b8901fae6b5ab52727b03c7c6d669259.tar.gz |
Code reformating (help.c)
Signed-off-by: Alexander Naumov <alexander_naumov@opensuse.org>
-rw-r--r-- | src/help.c | 789 |
1 files changed, 335 insertions, 454 deletions
@@ -32,10 +32,8 @@ #include <sys/types.h> #include "config.h" - #include "screen.h" #include "extern.h" - #include "list_generic.h" char version[60]; /* initialised by main() */ @@ -60,9 +58,7 @@ static void PadStr __P((char *, int, int, int)); extern char *wliststr; extern char *wlisttit; -void -exit_with_usage(myname, message, arg) -char *myname, *message, *arg; +void exit_with_usage(char *myname, char *message, char *arg) { printf("Use: %s [-opts] [cmd [args]]\n", myname); printf(" or: %s -r [host.tty]\n\nOptions:\n", myname); @@ -109,18 +105,16 @@ char *myname, *message, *arg; printf("-x Attach to a not detached screen. (Multi display mode).\n"); #endif /* MULTI */ printf("-X Execute <cmd> as a screen command in the specified session.\n"); - if (message && *message) - { - printf("\nError: "); - printf(message, arg); - printf("\n"); - } + + if (message && *message) { + printf("\nError: "); + printf(message, arg); + printf("\n"); + } exit(1); } -/* -** Here come the help page routines -*/ +/* Here come the help page routines */ extern struct comm comms[]; extern struct action ktab[]; @@ -132,8 +126,7 @@ static void add_key_to_buf __P((char *, int)); static void AddAction __P((struct action *, int, int)); static int helppage __P((void)); -struct helpdata -{ +struct helpdata { char *class; struct action *ktabp; int maxrow, grow, numcols, numrows, num_names; @@ -159,20 +152,14 @@ static struct LayFuncs HelpLf = }; -void -display_help(class, ktabp) -char *class; -struct action *ktabp; -{ - int i, n, key, mcom, mkey, l; +void display_help(char *class, struct action *ktabp) { + int i, n, key, mcom, mkey, l, used[RC_LAST + 1]; struct helpdata *helpdata; - int used[RC_LAST + 1]; - if (flayer->l_height < 6) - { - LMsg(0, "Window height too small for help page"); - return; - } + if (flayer->l_height < 6) { + LMsg(0, "Window height too small for help page"); + return; + } if (InitOverlayPage(sizeof(*helpdata), &HelpLf, 0)) return; @@ -185,29 +172,26 @@ struct action *ktabp; used[n] = 0; mcom = 0; mkey = 0; - for (key = 0; key < 256 + KMAP_KEYS; key++) - { - n = ktabp[key].nr; - if (n == RC_ILLEGAL) - continue; - if (ktabp[key].args == noargs) - { - used[n] += (key <= ' ' || key == 0x7f) ? 3 : - (key > 0x7f) ? 5 : 2; - } - else - helpdata->command_bindings++; + for (key = 0; key < 256 + KMAP_KEYS; key++) { + n = ktabp[key].nr; + if (n == RC_ILLEGAL) + continue; + if (ktabp[key].args == noargs) { + used[n] += (key <= ' ' || key == 0x7f) ? 3 : (key > 0x7f) ? 5 : 2; } + else + helpdata->command_bindings++; + } for (n = i = 0; n <= RC_LAST; n++) - if (used[n]) - { - l = strlen(comms[n].name); - if (l > mcom) - mcom = l; - if (used[n] > mkey) - mkey = used[n]; - helpdata->nact[i++] = n; - } + if (used[n]) { + l = strlen(comms[n].name); + if (l > mcom) + mcom = l; + if (used[n] > mkey) + mkey = used[n]; + helpdata->nact[i++] = n; + } + debug1("help: %d commands bound to keys with no arguments\n", i); debug2("mcom: %d mkey: %d\n", mcom, mkey); helpdata->num_names = i; @@ -215,12 +199,12 @@ struct action *ktabp; if (mkey > MAXKLEN) mkey = MAXKLEN; helpdata->numcols = flayer->l_width / (mcom + mkey + 1); - if (helpdata->numcols == 0) - { - HelpAbort(); - LMsg(0, "Width too small"); + if (helpdata->numcols == 0) { + HelpAbort(); + LMsg(0, "Width too small"); return; - } + } + helpdata->inter = (flayer->l_width - (mcom + mkey) * helpdata->numcols) / (helpdata->numcols + 1); if (helpdata->inter <= 0) helpdata->inter = 1; @@ -230,10 +214,12 @@ struct action *ktabp; helpdata->numrows = (helpdata->num_names + helpdata->numcols - 1) / helpdata->numcols; debug1("Numrows: %d\n", helpdata->numrows); helpdata->numskip = flayer->l_height-5 - (2 + helpdata->numrows); + while (helpdata->numskip < 0) helpdata->numskip += flayer->l_height-5; helpdata->numskip %= flayer->l_height-5; debug1("Numskip: %d\n", helpdata->numskip); + if (helpdata->numskip > flayer->l_height/3 || helpdata->numskip > helpdata->command_bindings) helpdata->numskip = 1; helpdata->maxrow = 2 + helpdata->numrows + helpdata->numskip + helpdata->command_bindings; @@ -245,46 +231,35 @@ struct action *ktabp; helppage(); } -static void -HelpProcess(ppbuf, plen) -char **ppbuf; -int *plen; -{ +static void HelpProcess(char **ppbuf, int *plen) { int done = 0; - while (!done && *plen > 0) - { - switch (**ppbuf) - { - case ' ': - if (helppage() == 0) - break; - /* FALLTHROUGH */ - case '\r': - case '\n': - done = 1; - break; - default: - break; - } - ++*ppbuf; - --*plen; + while (!done && *plen > 0) { + switch (**ppbuf) { + case ' ': + if (helppage() == 0) + break; + /* FALLTHROUGH */ + case '\r': + case '\n': + done = 1; + break; + default: + break; } + ++*ppbuf; + --*plen; + } if (done) HelpAbort(); } -static void -HelpAbort() -{ +static void HelpAbort() { LAY_CALL_UP(LRefreshAll(flayer, 0)); ExitOverlayPage(); } - -static int -helppage() -{ +static int helppage() { struct helpdata *helpdata; int col, crow, n, key, x; char buf[MAXKLEN], Esc_buf[5], cbuf[256]; @@ -308,84 +283,74 @@ helppage() *Esc_buf = '\0'; *buf = '\0'; /* XXX fix escape character */ - if (flayer->l_cvlist && flayer->l_cvlist->c_display) - { - add_key_to_buf(buf, flayer->l_cvlist->c_display->d_user->u_MetaEsc); - add_key_to_buf(Esc_buf, flayer->l_cvlist->c_display->d_user->u_Esc); + if (flayer->l_cvlist && flayer->l_cvlist->c_display) { + add_key_to_buf(buf, flayer->l_cvlist->c_display->d_user->u_MetaEsc); + add_key_to_buf(Esc_buf, flayer->l_cvlist->c_display->d_user->u_Esc); + } + else { + strcpy(Esc_buf, "??"); + strcpy(buf, "??"); + } + + for (; crow < flayer->l_height - 3; crow++) { + if (helpdata->grow < 1) { + if (ktabp == ktab) + sprintf(cbuf,"Command key: %s Literal %s: %s", Esc_buf, Esc_buf, buf); + else + sprintf(cbuf,"Command class: '%.80s'", helpdata->class); + + centerline(cbuf, crow); + helpdata->grow++; } - else - { - strcpy(Esc_buf, "??"); - strcpy(buf, "??"); + + else if (helpdata->grow >= 2 && helpdata->grow-2 < helpdata->numrows) { + x = 0; + for (col = 0; col < helpdata->numcols && (n = helpdata->numrows * col + (helpdata->grow-2)) < helpdata->num_names; col++) { + x += helpdata->inter - !col; + n = helpdata->nact[n]; + buf[0] = '\0'; + for (key = 0; key < 256 + KMAP_KEYS; key++) + if (ktabp[key].nr == n && ktabp[key].args == noargs && strlen(buf) < sizeof(buf) - 7) { + strcat(buf, " "); + add_key_to_buf(buf, key); + } + + PadStr(comms[n].name, helpdata->mcom, x, crow); + x += helpdata->mcom; + PadStr(buf, helpdata->mkey, x, crow); + x += helpdata->mkey; + } + helpdata->grow++; } - for (; crow < flayer->l_height - 3; crow++) - { - if (helpdata->grow < 1) - { - if (ktabp == ktab) - sprintf(cbuf,"Command key: %s Literal %s: %s", Esc_buf, Esc_buf, buf); - else - sprintf(cbuf,"Command class: '%.80s'", helpdata->class); - centerline(cbuf, crow); - helpdata->grow++; - } - else if (helpdata->grow >= 2 && helpdata->grow-2 < helpdata->numrows) - { - x = 0; - for (col = 0; col < helpdata->numcols && (n = helpdata->numrows * col + (helpdata->grow-2)) < helpdata->num_names; col++) - { - x += helpdata->inter - !col; - n = helpdata->nact[n]; - buf[0] = '\0'; - for (key = 0; key < 256 + KMAP_KEYS; key++) - if (ktabp[key].nr == n && ktabp[key].args == noargs && strlen(buf) < sizeof(buf) - 7) - { - strcat(buf, " "); - add_key_to_buf(buf, key); - } - PadStr(comms[n].name, helpdata->mcom, x, crow); - x += helpdata->mcom; - PadStr(buf, helpdata->mkey, x, crow); - x += helpdata->mkey; - } - helpdata->grow++; - } - else if (helpdata->grow-2-helpdata->numrows >= helpdata->numskip - && helpdata->grow-2-helpdata->numrows-helpdata->numskip < helpdata->command_bindings) - { - while ((n = ktabp[helpdata->command_search].nr) == RC_ILLEGAL - || ktabp[helpdata->command_search].args == noargs) - { - if (++helpdata->command_search >= 256 + KMAP_KEYS) - return -1; - } - buf[0] = '\0'; - add_key_to_buf(buf, helpdata->command_search); - PadStr(buf, 5, 0, crow); - AddAction(&ktabp[helpdata->command_search++], 5, crow); - helpdata->grow++; - } - else - helpdata->grow++; + else if (helpdata->grow-2-helpdata->numrows >= helpdata->numskip + && helpdata->grow-2-helpdata->numrows-helpdata->numskip < helpdata->command_bindings) { + while ((n = ktabp[helpdata->command_search].nr) == RC_ILLEGAL || ktabp[helpdata->command_search].args == noargs) { + if (++helpdata->command_search >= 256 + KMAP_KEYS) + return -1; + } + + buf[0] = '\0'; + add_key_to_buf(buf, helpdata->command_search); + PadStr(buf, 5, 0, crow); + AddAction(&ktabp[helpdata->command_search++], 5, crow); + helpdata->grow++; } - sprintf(cbuf,"[Press Space %s Return to end.]", - helpdata->grow < helpdata->maxrow ? "for next page;" : "or"); + + else + helpdata->grow++; + } + sprintf(cbuf,"[Press Space %s Return to end.]", helpdata->grow < helpdata->maxrow ? "for next page;" : "or"); centerline(cbuf, flayer->l_height - 2); LaySetCursor(); return 0; } -static void -AddAction(act, x, y) -struct action *act; -int x, y; -{ +static void AddAction(struct action *act, int x, int y) { char buf[256]; - int del, l; + int del, l, fr; char *bp, *cp, **pp; int *lp, ll; - int fr; struct mchar mchar_dol; mchar_dol = mchar_blank; @@ -405,80 +370,69 @@ int x, y; pp = act->args; lp = act->argl; - while (pp && (cp = *pp) != NULL) - { - del = 0; - bp = buf; - ll = *lp++; - if (!ll || (index(cp, ' ') != NULL)) - { - if (index(cp, '\'') != NULL) - *bp++ = del = '"'; - else - *bp++ = del = '\''; - } - while (ll-- && bp < buf + 250) - bp += AddXChar(bp, *(unsigned char *)cp++); - if (del) - *bp++ = del; - *bp = 0; - if ((fr -= (bp - buf) + 1) < 0) - { - fr += bp - buf; - if (fr > 0) - PadStr(buf, fr, x, y); - if (fr == 0) - LPutChar(flayer, &mchar_dol, x, y); - return; - } - PadStr(buf, strlen(buf), x, y); - x += strlen(buf); - pp++; - if (*pp) - LPutChar(flayer, fr ? &mchar_blank : &mchar_dol, x++, y); + while (pp && (cp = *pp) != NULL) { + del = 0; + bp = buf; + ll = *lp++; + if (!ll || (index(cp, ' ') != NULL)) { + if (index(cp, '\'') != NULL) + *bp++ = del = '"'; + else + *bp++ = del = '\''; + } + + while (ll-- && bp < buf + 250) + bp += AddXChar(bp, *(unsigned char *)cp++); + if (del) + *bp++ = del; + *bp = 0; + if ((fr -= (bp - buf) + 1) < 0) { + fr += bp - buf; + if (fr > 0) + PadStr(buf, fr, x, y); + if (fr == 0) + LPutChar(flayer, &mchar_dol, x, y); + return; } + + PadStr(buf, strlen(buf), x, y); + x += strlen(buf); + pp++; + if (*pp) + LPutChar(flayer, fr ? &mchar_blank : &mchar_dol, x++, y); + } } -static void -add_key_to_buf(buf, key) -char *buf; -int key; -{ +static void add_key_to_buf(char *buf, int key) { buf += strlen(buf); if (key < 0) strcpy(buf, "unset"); else if (key == ' ') strcpy(buf, "sp"); #ifdef MAPKEYS - else if (key >= 256) - { - key = key - 256 + T_CAPS; - buf[0] = ':'; - buf[1] = term[key].tcname[0]; - buf[2] = term[key].tcname[1]; - buf[3] = ':'; - buf[4] = 0; - } + else if (key >= 256) { + key = key - 256 + T_CAPS; + buf[0] = ':'; + buf[1] = term[key].tcname[0]; + buf[2] = term[key].tcname[1]; + buf[3] = ':'; + buf[4] = 0; + } #endif else buf[AddXChar(buf, key)] = 0; } +static void HelpRedisplayLine(int y, int xs, int xe, int isblank) { + if (y < 0) { + struct helpdata *helpdata; -static void -HelpRedisplayLine(y, xs, xe, isblank) -int y, xs, xe, isblank; -{ - if (y < 0) - { - struct helpdata *helpdata; - - helpdata = (struct helpdata *)flayer->l_data; - helpdata->grow = helpdata->refgrow; - helpdata->command_search = helpdata->refcommand_search; - helppage(); - return; - } + helpdata = (struct helpdata *)flayer->l_data; + helpdata->grow = helpdata->refgrow; + helpdata->command_search = helpdata->refcommand_search; + helppage(); + return; + } if (y != 0 && y != flayer->l_height - 1) return; if (!isblank) @@ -486,25 +440,19 @@ int y, xs, xe, isblank; } -/* -** -** here is all the copyright stuff -** -*/ +/* here is all the copyright stuff */ static void CopyrightProcess __P((char **, int *)); static void CopyrightRedisplayLine __P((int, int, int, int)); static void CopyrightAbort __P((void)); static void copypage __P((void)); -struct copydata -{ +struct copydata { char *cps, *savedcps; /* position in the message */ char *refcps, *refsavedcps; /* backup for redisplaying */ }; -static struct LayFuncs CopyrightLf = -{ +static struct LayFuncs CopyrightLf = { CopyrightProcess, CopyrightAbort, CopyrightRedisplayLine, @@ -517,7 +465,7 @@ static struct LayFuncs CopyrightLf = static const char cpmsg[] = "\ \n\ -Screen version %v\n\ +GNU Screen version %v\n\ \n\ Copyright (c) 2010 Juergen Weigert, Sadrul Habib Chowdhury\n\ Copyright (c) 2008, 2009 Juergen Weigert, Michael Schroeder, Micah Cowan, Sadrul Habib Chowdhury\n\ @@ -609,56 +557,44 @@ screen-devel@gnu.org\n\n\n" #endif ; -static void -CopyrightProcess(ppbuf, plen) -char **ppbuf; -int *plen; -{ +static void CopyrightProcess(char **ppbuf, int *plen) { int done = 0; struct copydata *copydata; copydata = (struct copydata *)flayer->l_data; - while (!done && *plen > 0) - { - switch (**ppbuf) - { - case ' ': - if (*copydata->cps) - { - copypage(); - break; - } - /* FALLTHROUGH */ - case '\r': - case '\n': - CopyrightAbort(); - done = 1; - break; - default: - break; - } - ++*ppbuf; - --*plen; + while (!done && *plen > 0) { + switch (**ppbuf) { + case ' ': + if (*copydata->cps) { + copypage(); + break; + } + /* FALLTHROUGH */ + case '\r': + case '\n': + CopyrightAbort(); + done = 1; + break; + default: + break; } + ++*ppbuf; + --*plen; + } } -static void -CopyrightAbort() -{ +static void CopyrightAbort() { LAY_CALL_UP(LRefreshAll(flayer, 0)); ExitOverlayPage(); } -void -display_copyright() -{ +void display_copyright() { struct copydata *copydata; - if (flayer->l_width < 10 || flayer->l_height < 5) - { + if (flayer->l_width < 10 || flayer->l_height < 5) { LMsg(0, "Window size too small for copyright page"); return; - } + } if (InitOverlayPage(sizeof(*copydata), &CopyrightLf, 0)) return; copydata = (struct copydata *)flayer->l_data; @@ -669,9 +605,7 @@ display_copyright() copypage(); } -static void -copypage() -{ +static void copypage() { register char *cps; char *ws; int x, y, l; @@ -686,67 +620,62 @@ copypage() cps = copydata->cps; copydata->refcps = cps; copydata->refsavedcps = copydata->savedcps; - while (*cps && y < flayer->l_height - 3) - { - ws = cps; - while (*cps == ' ') - cps++; - if (strncmp(cps, "%v", 2) == 0) - { - copydata->savedcps = cps + 2; - cps = version; - continue; - } - while (*cps && *cps != ' ' && *cps != '\n') - cps++; - l = cps - ws; - cps = ws; - if (l > flayer->l_width - 1) - l = flayer->l_width - 1; - if (x && x + l >= flayer->l_width - 2) - { - x = 0; - y++; - continue; - } - if (x) - { - LPutChar(flayer, &mchar_blank, x, y); - x++; - } - if (l) - LPutStr(flayer, ws, l, &mchar_blank, x, y); - x += l; - cps += l; - if (*cps == 0 && copydata->savedcps) - { - cps = copydata->savedcps; - copydata->savedcps = 0; - } - if (*cps == '\n') - { - x = 0; - y++; - } - if (*cps == ' ' || *cps == '\n') - cps++; + while (*cps && y < flayer->l_height - 3) { + ws = cps; + while (*cps == ' ') + cps++; + if (strncmp(cps, "%v", 2) == 0) { + copydata->savedcps = cps + 2; + cps = version; + continue; } + while (*cps && *cps != ' ' && *cps != '\n') + cps++; + + l = cps - ws; + cps = ws; + if (l > flayer->l_width - 1) + l = flayer->l_width - 1; + + if (x && x + l >= flayer->l_width - 2) { + x = 0; + y++; + continue; + } + + if (x) { + LPutChar(flayer, &mchar_blank, x, y); + x++; + } + + if (l) + LPutStr(flayer, ws, l, &mchar_blank, x, y); + x += l; + cps += l; + if (*cps == 0 && copydata->savedcps) { + cps = copydata->savedcps; + copydata->savedcps = 0; + } + + if (*cps == '\n') { + x = 0; + y++; + } + + if (*cps == ' ' || *cps == '\n') + cps++; + } while (*cps == '\n') cps++; - sprintf(cbuf,"[Press Space %s Return to end.]", - *cps ? "for next page;" : "or"); + sprintf(cbuf,"[Press Space %s Return to end.]", *cps ? "for next page;" : "or"); centerline(cbuf, flayer->l_height - 2); copydata->cps = cps; LaySetCursor(); } -static void -CopyrightRedisplayLine(y, xs, xe, isblank) -int y, xs, xe, isblank; -{ +static void CopyrightRedisplayLine(int y, int xs, int xe, int isblank) { ASSERT(flayer); - if (y < 0) - { + if (y < 0) { struct copydata *copydata; copydata = (struct copydata *)flayer->l_data; @@ -754,7 +683,7 @@ int y, xs, xe, isblank; copydata->savedcps = copydata->refsavedcps; copypage(); return; - } + } if (y != 0 && y != flayer->l_height - 1) return; if (isblank) @@ -763,11 +692,7 @@ int y, xs, xe, isblank; } -/* -** -** The bindkey help page -** -*/ +/* The bindkey help page */ #ifdef MAPKEYS extern struct kmap_ext *kmap_exts; @@ -775,14 +700,12 @@ extern int kmap_extn; extern struct action dmtab[]; extern struct action mmtab[]; - static void BindkeyProcess __P((char **, int *)); static void BindkeyAbort __P((void)); static void BindkeyRedisplayLine __P((int, int, int, int)); static void bindkeypage __P((void)); -struct bindkeydata -{ +struct bindkeydata { char *title; struct action *tab; int pos; @@ -791,8 +714,7 @@ struct bindkeydata int pages; }; -static struct LayFuncs BindkeyLf = -{ +static struct LayFuncs BindkeyLf = { BindkeyProcess, BindkeyAbort, BindkeyRedisplayLine, @@ -804,19 +726,14 @@ static struct LayFuncs BindkeyLf = }; -void -display_bindkey(title, tab) -char *title; -struct action *tab; -{ +void display_bindkey(char *title, struct action *tab) { struct bindkeydata *bindkeydata; int i, n; - if (flayer->l_height < 6) - { - LMsg(0, "Window height too small for bindkey page"); - return; - } + if (flayer->l_height < 6) { + LMsg(0, "Window height too small for bindkey page"); + return; + } if (InitOverlayPage(sizeof(*bindkeydata), &BindkeyLf, 0)) return; @@ -825,11 +742,10 @@ struct action *tab; bindkeydata->tab = tab; n = 0; - for (i = 0; i < KMAP_KEYS+KMAP_AKEYS+kmap_extn; i++) - { - if (tab[i].nr != RC_ILLEGAL) - n++; - } + for (i = 0; i < KMAP_KEYS+KMAP_AKEYS+kmap_extn; i++) { + if (tab[i].nr != RC_ILLEGAL) + n++; + } bindkeydata->pos = 0; bindkeydata->page = 1; bindkeydata->pages = (n + flayer->l_height - 6) / (flayer->l_height - 5); @@ -840,16 +756,12 @@ struct action *tab; bindkeypage(); } -static void -BindkeyAbort() -{ +static void BindkeyAbort() { LAY_CALL_UP(LRefreshAll(flayer, 0)); ExitOverlayPage(); } -static void -bindkeypage() -{ +static void bindkeypage() { struct bindkeydata *bindkeydata; struct kmap_ext *kme; char tbuf[256]; @@ -858,65 +770,65 @@ bindkeypage() char *xch, *s, *p; bindkeydata = (struct bindkeydata *)flayer->l_data; - LClearAll(flayer, 0); sprintf(tbuf, "%s key bindings, page %d of %d.", bindkeydata->title, bindkeydata->page, bindkeydata->pages); centerline(tbuf, 0); y = 2; - for (i = bindkeydata->pos; i < KMAP_KEYS+KMAP_AKEYS+kmap_extn && y < flayer->l_height - 3; i++) - { - p = tbuf; - xch = " "; - if (i < KMAP_KEYS) - { - act = &bindkeydata->tab[i]; - if (act->nr == RC_ILLEGAL) - continue; - del = *p++ = ':'; - s = term[i + T_CAPS].tcname; - sl = s ? strlen(s) : 0; - } - else if (i < KMAP_KEYS+KMAP_AKEYS) - { - act = &bindkeydata->tab[i]; - if (act->nr == RC_ILLEGAL) - continue; - del = *p++ = ':'; - s = term[i + (T_CAPS - T_OCAPS + T_CURSOR)].tcname; - sl = s ? strlen(s) : 0; - xch = "[A]"; - } - else - { - kme = kmap_exts + (i - (KMAP_KEYS+KMAP_AKEYS)); - del = 0; - s = kme->str; - sl = kme->fl & ~KMAP_NOTIMEOUT; - if ((kme->fl & KMAP_NOTIMEOUT) != 0) - xch = "[T]"; - act = bindkeydata->tab == dmtab ? &kme->dm : bindkeydata->tab == mmtab ? &kme->mm : &kme->um; - if (act->nr == RC_ILLEGAL) - continue; - } - while (sl-- > 0) - p += AddXChar(p, *(unsigned char *)s++); - if (del) - *p++ = del; + for (i = bindkeydata->pos; i < KMAP_KEYS+KMAP_AKEYS+kmap_extn && y < flayer->l_height - 3; i++) { + p = tbuf; + xch = " "; + if (i < KMAP_KEYS) { + act = &bindkeydata->tab[i]; + if (act->nr == RC_ILLEGAL) + continue; + del = *p++ = ':'; + s = term[i + T_CAPS].tcname; + sl = s ? strlen(s) : 0; + } + + else if (i < KMAP_KEYS+KMAP_AKEYS) { + act = &bindkeydata->tab[i]; + if (act->nr == RC_ILLEGAL) + continue; + del = *p++ = ':'; + s = term[i + (T_CAPS - T_OCAPS + T_CURSOR)].tcname; + sl = s ? strlen(s) : 0; + xch = "[A]"; + } + + else { + kme = kmap_exts + (i - (KMAP_KEYS+KMAP_AKEYS)); + del = 0; + s = kme->str; + sl = kme->fl & ~KMAP_NOTIMEOUT; + if ((kme->fl & KMAP_NOTIMEOUT) != 0) + xch = "[T]"; + act = bindkeydata->tab == dmtab ? &kme->dm : bindkeydata->tab == mmtab ? &kme->mm : &kme->um; + if (act->nr == RC_ILLEGAL) + continue; + } + + while (sl-- > 0) + p += AddXChar(p, *(unsigned char *)s++); + + if (del) + *p++ = del; + + *p++ = ' '; + while (p < tbuf + 15) *p++ = ' '; - while (p < tbuf + 15) - *p++ = ' '; - sprintf(p, "%s -> ", xch); - p += 7; - if (p - tbuf > flayer->l_width - 1) - { - tbuf[flayer->l_width - 2] = '$'; - tbuf[flayer->l_width - 1] = 0; - } - PadStr(tbuf, strlen(tbuf), 0, y); - AddAction(act, strlen(tbuf), y); - y++; + sprintf(p, "%s -> ", xch); + p += 7; + if (p - tbuf > flayer->l_width - 1) { + tbuf[flayer->l_width - 2] = '$'; + tbuf[flayer->l_width - 1] = 0; } + + PadStr(tbuf, strlen(tbuf), 0, y); + AddAction(act, strlen(tbuf), y); + y++; + } y++; bindkeydata->last = i; sprintf(tbuf,"[Press Space %s Return to end.]", bindkeydata->page < bindkeydata->pages ? "for next page;" : "or"); @@ -924,51 +836,40 @@ bindkeypage() LaySetCursor(); } -static void -BindkeyProcess(ppbuf, plen) -char **ppbuf; -int *plen; -{ +static void BindkeyProcess(char **ppbuf, int *plen) { int done = 0; struct bindkeydata *bindkeydata; bindkeydata = (struct bindkeydata *)flayer->l_data; - while (!done && *plen > 0) - { - switch (**ppbuf) - { - case ' ': - if (bindkeydata->page < bindkeydata->pages) - { - bindkeydata->pos = bindkeydata->last; - bindkeydata->page++; - bindkeypage(); - break; - } - /* FALLTHROUGH */ - case '\r': - case '\n': - done = 1; - break; - default: - break; - } - ++*ppbuf; - --*plen; + while (!done && *plen > 0) { + switch (**ppbuf) { + case ' ': + if (bindkeydata->page < bindkeydata->pages) { + bindkeydata->pos = bindkeydata->last; + bindkeydata->page++; + bindkeypage(); + break; + } + /* FALLTHROUGH */ + case '\r': + case '\n': + done = 1; + break; + default: + break; } + ++*ppbuf; + --*plen; + } if (done) BindkeyAbort(); } -static void -BindkeyRedisplayLine(y, xs, xe, isblank) -int y, xs, xe, isblank; -{ - if (y < 0) - { - bindkeypage(); - return; - } +static void BindkeyRedisplayLine(int y, int xs, int xe, int isblank) { + if (y < 0) { + bindkeypage(); + return; + } if (y != 0 && y != flayer->l_height - 1) return; if (!isblank) @@ -977,20 +878,14 @@ int y, xs, xe, isblank; #endif /* MAPKEYS */ - -/* -** -** The zmodem active page -** -*/ +/* The zmodem active page */ #ifdef ZMODEM static void ZmodemRedisplayLine __P((int, int, int, int)); static int ZmodemResize __P((int, int)); -static struct LayFuncs ZmodemLf = -{ +static struct LayFuncs ZmodemLf = { DefProcess, 0, ZmodemRedisplayLine, @@ -1002,28 +897,20 @@ static struct LayFuncs ZmodemLf = }; /*ARGSUSED*/ -static int -ZmodemResize(wi, he) -int wi, he; -{ +static int ZmodemResize(int wi, int he) { flayer->l_width = wi; flayer->l_height = he; flayer->l_x = flayer->l_width > 32 ? 32 : 0; return 0; } -static void -ZmodemRedisplayLine(y, xs, xe, isblank) -int y, xs, xe, isblank; -{ +static void ZmodemRedisplayLine(int y, int xs, int xe, int isblank) { DefRedisplayLine(y, xs, xe, isblank); if (y == 0 && xs == 0) LPutStr(flayer, "Zmodem active on another display", flayer->l_width > 32 ? 32 : flayer->l_width, &mchar_blank, 0, 0); } -void -ZmodemPage() -{ +void ZmodemPage() { if (InitOverlayPage(1, &ZmodemLf, 1)) return; LRefreshAll(flayer, 0); @@ -1033,13 +920,7 @@ ZmodemPage() #endif - - -static void -PadStr(str, n, x, y) -char *str; -int n, x, y; -{ +static void PadStr(char *str, int n, int x, int y) { int l; l = strlen(str); |