From 1df022599350ae3882843b772b2bc0869348b894 Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Tue, 23 Feb 2010 20:35:03 -0500 Subject: Remove old code. --- src/canvas.c | 3 +- src/extern.h | 1 - src/help.c | 626 ---------------------------------------------------------- src/process.c | 5 +- src/socket.c | 5 +- 5 files changed, 8 insertions(+), 632 deletions(-) diff --git a/src/canvas.c b/src/canvas.c index 4cc4fe2..0121892 100644 --- a/src/canvas.c +++ b/src/canvas.c @@ -30,6 +30,7 @@ #include "screen.h" #include "extern.h" #include "canvas.h" +#include "list_generic.h" extern struct display *display; extern struct win *fore, *windows; @@ -307,7 +308,7 @@ struct win *wi; struct display *d = display; struct layer *oldflayer = flayer; flayer = l; - display_wlist(0, 0, wi); + display_windows(0, 0, wi); flayer = oldflayer; display = d; } diff --git a/src/extern.h b/src/extern.h index dc5857e..ee655f5 100644 --- a/src/extern.h +++ b/src/extern.h @@ -132,7 +132,6 @@ extern void display_help __P((char *, struct action *)); extern void display_copyright __P((void)); extern void display_displays __P((void)); extern void display_bindkey __P((char *, struct action *)); -extern void display_wlist __P((int, int, struct win *)); extern int InWList __P((void)); extern void WListUpdatecv __P((struct canvas *, struct win *)); extern void WListLinkChanged __P((void)); diff --git a/src/help.c b/src/help.c index 7b3e3b5..f8ae2fc 100644 --- a/src/help.c +++ b/src/help.c @@ -685,632 +685,6 @@ int y, xs, xe, isblank; } -/* -** -** here is the windowlist -** -*/ - -#if 0 -struct wlistdata; - -static void WListProcess __P((char **, int *)); -static void WListAbort __P((void)); -static void WListRedisplayLine __P((int, int, int, int)); -static void wlistpage __P((void)); -static void WListLine __P((int, int, int, int)); -static void WListLines __P((int, int)); -static void WListMove __P((int, int)); -static void WListUpdate __P((struct win *)); -static int WListNormalize __P((void)); -static int WListResize __P((int, int)); -static int WListNext __P((struct wlistdata *, int, int)); - -struct wlistdata { - int pos; - int ypos; - int npos; - int numwin; - int first; - int last; - int start; - int order; - struct win *group; - int nested; - int *list; -}; - -static struct LayFuncs WListLf = -{ - WListProcess, - WListAbort, - WListRedisplayLine, - DefClearLine, - DefRewrite, - WListResize, - DefRestore -}; - -#define WTAB_GROUP_MATCHES(i) (group == wtab[i]->w_group) - -static int -WListResize(wi, he) -int wi, he; -{ - struct wlistdata *wlistdata; - if (wi < 10 || he < 5) - return -1; - wlistdata = (struct wlistdata *)flayer->l_data; - flayer->l_width = wi; - flayer->l_height = he; - wlistdata->numwin = he - 3; - if (wlistdata->ypos >= wlistdata->numwin) - wlistdata->ypos = wlistdata->numwin - 1; - flayer->l_y = he - 1; - return 0; -} - -static void -WListAbort() -{ - struct wlistdata * wlistdata = (struct wlistdata *)flayer->l_data; - if (wlistdata->list) - Free(wlistdata->list); - LAY_CALL_UP(LRefreshAll(flayer, 0)); - ExitOverlayPage(); -} - -static void -WListProcess(ppbuf, plen) -char **ppbuf; -int *plen; -{ - int done = 0; - struct wlistdata *wlistdata; - struct display *olddisplay = display; - int h; - struct win *group; - - ASSERT(flayer); - wlistdata = (struct wlistdata *)flayer->l_data; - group = wlistdata->group; - h = wlistdata->numwin; - while (!done && *plen > 0) - { - if ((unsigned char)**ppbuf >= '0' && (unsigned char)**ppbuf <= '9') - { - int n = (unsigned char)**ppbuf - '0'; - int d = 0; - if (n < maxwin && wtab[n] && WTAB_GROUP_MATCHES(n)) - { - int i; - for (d = -wlistdata->npos, i = WListNext(wlistdata, -1, 0); i != n; i = WListNext(wlistdata, i, 1), d++) - ; - } - if (d) - WListMove(d, -1); - } - switch ((unsigned char)**ppbuf) - { - case 0220: /* up */ - case 16: /* ^P like emacs */ - case 'k': - WListMove(-1, -1); - break; - case 0216: /* down */ - case 14: /* ^N like emacs */ - case 'j': - WListMove(1, -1); - break; - case '\025': - WListMove(-(h / 2), wlistdata->ypos); - break; - case '\004': - WListMove(h / 2, wlistdata->ypos); - break; - case 0002: - case 'b': - WListMove(-h, -1); - break; - case 0006: - case 'f': - WListMove(h, -1); - break; - case 0201: /* home */ - WListMove(-wlistdata->pos, -1); - break; - case 0205: /* end */ - WListMove(maxwin, -1); - break; - case 'a': - /* All-window view */ - wlistdata->group = 0; - wlistdata->nested = WLIST_NESTED; - wlistpage(); - break; - case 'g': - /* Toggle nested view */ - wlistdata->nested ^= WLIST_NESTED; - wlistpage(); - break; - case 'm': - /* Toggle MRU view */ - wlistdata->order ^= 1; - wlistpage(); - break; - case '\r': - case '\n': - case ' ': - h = wlistdata->pos; - if (h == maxwin && Layer2Window(flayer) && Layer2Window(flayer)->w_type == W_TYPE_GROUP) - break; - if (display && h != maxwin && wtab[h] && (wtab[h]->w_type == W_TYPE_GROUP) && Layer2Window(flayer) == wtab[h]) - { - wlistdata->group = wtab[h]; - wlistdata->pos = wtab[h]->w_number; - wlistpage(); - break; - } - done = 1; - if (!display || h == maxwin || !wtab[h] || wtab[h] == D_fore || (flayer->l_cvlist && flayer->l_cvlist->c_lnext)) - WListAbort(); -#ifdef MULTIUSER - else if (AclCheckPermWin(D_user, ACL_READ, wtab[h])) - WListAbort(); -#endif - else - { - if (wlistdata->list) - Free(wlistdata->list); - ExitOverlayPage(); /* no need to redisplay */ - } - /* restore display, don't switch wrong user */ - display = olddisplay; - if (h != maxwin) - SwitchWindow(h); - break; - case 0222: /* Mouse event */ - break; - case 0033: - case 0007: - h = wlistdata->start; - if (h == -1 && Layer2Window(flayer) && Layer2Window(flayer)->w_type == W_TYPE_GROUP) - { - struct win *p = Layer2Window(flayer); - if (wlistdata->group != p) - { - wlistdata->group = p; - wlistpage(); - } - break; - } - WListAbort(); - display = olddisplay; - if (h >= 0 && wtab[h]) - SwitchWindow(h); - else if (h == -2) - { - struct win *p = FindNiceWindow(display ? D_other : (struct win *)0, 0); - if (p) - SwitchWindow(p->w_number); - } - done = 1; - break; - case '\010': /* ctrl-h */ - case 0177: - if (!wlistdata->group) - break; - wlistdata->pos = wlistdata->group->w_number; - wlistdata->group = wlistdata->group->w_group; - if (wlistdata->group) - wlistdata->pos = wlistdata->group->w_number; - wlistpage(); - break; - default: - break; - } - ++*ppbuf; - --*plen; - } -} - -static void -WListLine(y, i, pos, isblank) -int y, i; -int pos; -int isblank; -{ - char *str; - int n; - int yoff, xoff = 0; - struct wlistdata *wlistdata; - struct win *group; - struct mchar mchar_rend = mchar_blank; - struct mchar *mchar = (struct mchar *)0; - - if (i == maxwin) - return; - wlistdata = (struct wlistdata *)flayer->l_data; - if (wlistdata->nested && wtab[i]) - for (group = wtab[i]->w_group, xoff = 0; group != wlistdata->group; - group = group->w_group, xoff += 2) - ; - yoff = wlistdata->group ? 3 : 2; - display = Layer2Window(flayer) ? 0 : flayer->l_cvlist ? flayer->l_cvlist->c_display : 0; - str = MakeWinMsgEv(wliststr, wtab[i], '%', flayer->l_width - xoff, (struct event *)0, 0); - n = strlen(str); - if (i != pos && isblank) - while (n && str[n - 1] == ' ') - n--; - if (i == pos) - mchar = &mchar_so; - else if (wtab[i]->w_monitor == MON_DONE && renditions[REND_MONITOR] != -1) - { - mchar = &mchar_rend; - ApplyAttrColor(renditions[REND_MONITOR], mchar); - } - else if ((wtab[i]->w_bell == BELL_DONE || wtab[i]->w_bell == BELL_FOUND) && renditions[REND_BELL] != -1) - { - mchar = &mchar_rend; - ApplyAttrColor(renditions[REND_BELL], mchar); - } - else - mchar = &mchar_blank; - LPutWinMsg(flayer, str, (i == pos || !isblank) ? flayer->l_width : n, mchar, xoff, y + yoff); - if (xoff) - LPutWinMsg(flayer, "", xoff, mchar, 0, y + yoff); - if (mchar == &mchar_so) - flayer->l_y = y + yoff; -#if 0 - LPutStr(flayer, str, n, i == pos ? &mchar_so : &mchar_blank, 0, y + yoff); - if (i == pos || !isblank) - while(n < flayer->l_width) - LPutChar(flayer, i == pos ? &mchar_so : &mchar_blank, n++, y + yoff); -#endif - return; -} - - -static int -WListNext(wlistdata, old, delta) -struct wlistdata *wlistdata; -int old, delta; -{ - int i; - - if (old == maxwin) - return maxwin; - if (old == -1) - old = 0; - else - { - for (i = 0; i < maxwin && wlistdata->list[i] != -1; i++) - if (wlistdata->list[i] == old) - break; - if (i < maxwin && wlistdata->list[i] != -1) - old = i; - } - - old += delta; - if (old < 0 || old >= maxwin || wlistdata->list[old] == -1) - old -= delta; - return wlistdata->list[old]; -} - -static void -WListLines(up, oldpos) -int up, oldpos; -{ - struct wlistdata *wlistdata; - int ypos, pos; - int y, i, oldi; - - wlistdata = (struct wlistdata *)flayer->l_data; - ypos = wlistdata->ypos; - pos = wlistdata->pos; - - i = WListNext(wlistdata, pos, -ypos); - for (y = 0; y < wlistdata->numwin; y++) - { - if (i == maxwin || !wtab[i]) - return; - if (y == 0) - wlistdata->first = i; - wlistdata->last = i; - if (((i == oldpos || i == pos) && pos != oldpos) || (up > 0 && y >= wlistdata->numwin - up) || (up < 0 && y < -up)) - WListLine(y, i, pos, i != oldpos); - if (i == pos) - wlistdata->ypos = y; - oldi = i; - i = WListNext(wlistdata, i, 1); - if (i == maxwin || i == oldi) - break; - } -} - -static int -WListNormalize() -{ - struct wlistdata *wlistdata; - int i, oldi, n; - int ypos, pos; - - wlistdata = (struct wlistdata *)flayer->l_data; - ypos = wlistdata->ypos; - pos = wlistdata->pos; - if (ypos < 0) - ypos = 0; - if (ypos >= wlistdata->numwin) - ypos = wlistdata->numwin - 1; - for (n = 0, oldi = maxwin, i = pos; i != maxwin && i != oldi && n < wlistdata->numwin; oldi = i, i = WListNext(wlistdata, i, 1)) - n++; - if (ypos < wlistdata->numwin - n) - ypos = wlistdata->numwin - n; - for (n = 0, oldi = maxwin, i = WListNext(wlistdata, -1, 0); i != maxwin && i != oldi && i != pos; oldi = i, i = WListNext(wlistdata, i, 1)) - n++; - if (ypos > n) - ypos = n; - wlistdata->ypos = ypos; - wlistdata->npos = n; - return ypos; -} - -static void -WListMove(num, ypos) -int num; -int ypos; -{ - struct wlistdata *wlistdata; - int oldpos, oldypos, oldnpos; - int pos, up; - - wlistdata = (struct wlistdata *)flayer->l_data; - oldpos = wlistdata->pos; - oldypos = wlistdata->ypos; - oldnpos = wlistdata->npos; - wlistdata->ypos = ypos == -1 ? oldypos + num : ypos; - pos = WListNext(wlistdata, oldpos, num); - wlistdata->pos = pos; - ypos = WListNormalize(); - up = wlistdata->npos - ypos - (oldnpos - oldypos); - if (up) - { - LScrollV(flayer, up, 2, 2 + wlistdata->numwin - 1, 0); - WListLines(up, oldpos); - LaySetCursor(); - return; - } - if (pos == oldpos) - return; - WListLine(oldypos, oldpos, pos, 0); - WListLine(ypos, pos, pos, 1); - LaySetCursor(); -} - -static void -WListRedisplayLine(y, xs, xe, isblank) -int y, xs, xe, isblank; -{ - ASSERT(flayer); - if (y < 0) - { - wlistpage(); - return; - } - if (y != 0 && y != flayer->l_height - 1) - return; - if (!isblank) - LClearArea(flayer, xs, y, xe, y, 0, 0); -} - -static int -WListOrder(wlistdata, ind, start, group) -struct wlistdata *wlistdata; -int ind, start; -struct win *group; -{ - int i; - - if (ind >= maxwin) - return ind; - if (ind == 0) - for (i = 0; i < maxwin; i++) - wlistdata->list[i] = -1; - - if (wlistdata->order == WLIST_MRU) - { - if (start == -1) - start = windows->w_number; - } - else - { - if (start == -1) - start = 0; - while (start < maxwin && !wtab[start]) - start++; - } - - if (start >= maxwin || !wtab[start]) - return ind; - - if (!WTAB_GROUP_MATCHES(start)) - { - while (start < maxwin && (!wtab[start] || !WTAB_GROUP_MATCHES(start))) - if (wlistdata->order != WLIST_MRU) - start++; - else if (wtab[start]->w_next) - start = wtab[start]->w_next->w_number; - else - start = maxwin; - if (start >= maxwin || !wtab[start]) - return ind; - } - - wlistdata->list[ind++] = start; - if (wlistdata->nested && wtab[start]->w_type == W_TYPE_GROUP) - ind = WListOrder(wlistdata, ind, -1, wtab[start]); - - if (wlistdata->order != WLIST_MRU) - start++; - else if (wtab[start]->w_next) - start = wtab[start]->w_next->w_number; - else - return ind; - return WListOrder(wlistdata, ind, start, group); -} -#endif - -void -display_wlist(onblank, order, group) -int onblank; -int order; -struct win *group; -{ - display_windows(onblank, order, group); - return; -#if 0 - struct win *p; - struct wlistdata *wlistdata; - - - if (flayer->l_width < 10 || flayer->l_height < 6) - { - LMsg(0, "Window size too small for window list page"); - return; - } - if (onblank) - { - debug3("flayer %x %d %x\n", flayer, flayer->l_width, flayer->l_height); - if (!display) - { - LMsg(0, "windowlist -b: display required"); - return; - } - p = D_fore; - if (p) - { - SetForeWindow((struct win *)0); - if (p->w_group) - { - D_fore = p->w_group; - flayer->l_data = (char *)p->w_group; - } - Activate(0); - } - if (flayer->l_width < 10 || flayer->l_height < 6) - { - LMsg(0, "Window size too small for window list page"); - return; - } - } - else - p = Layer2Window(flayer); - if (!group && p) - group = p->w_group; - if (InitOverlayPage(sizeof(*wlistdata), &WListLf, 0)) - return; - wlistdata = (struct wlistdata *)flayer->l_data; - wlistdata->list = calloc(maxwin, sizeof(int)); - flayer->l_mode = 1; - flayer->l_x = 0; - flayer->l_y = flayer->l_height - 1; - wlistdata->start = onblank && p ? p->w_number : -1; - wlistdata->order = (order & 0x1); - wlistdata->group = group; - wlistdata->pos = p ? p->w_number : WListNext(wlistdata, -1, 0); - wlistdata->ypos = wlistdata->npos = 0; - wlistdata->numwin = flayer->l_height - (group ? 4 : 3); - wlistdata->nested = (order & WLIST_NESTED); - wlistpage(); -#endif -} - -#if 0 -static void -wlistpage() -{ - struct wlistdata *wlistdata; - char *str; - int pos; - struct win *group; - - wlistdata = (struct wlistdata *)flayer->l_data; - group = wlistdata->group; - - LClearAll(flayer, 0); - if (wlistdata->start >= 0 && wtab[wlistdata->start] == 0) - wlistdata->start = -2; - - WListOrder(wlistdata, 0, -1, group); - pos = wlistdata->pos; - if (pos == maxwin || !wtab[pos] || !WTAB_GROUP_MATCHES(pos)) - { - if (wlistdata->order == WLIST_MRU) - pos = WListNext(wlistdata, -1, wlistdata->npos); - else - { - /* find new position */ - if (pos < maxwin) - while(++pos < maxwin) - if (wtab[pos] && WTAB_GROUP_MATCHES(pos)) - break; - if (pos == maxwin) - while (--pos >= 0) - if (wtab[pos] && WTAB_GROUP_MATCHES(pos)) - break; - if (pos == -1) - pos = maxwin; - } - } - wlistdata->pos = pos; - - display = 0; - str = MakeWinMsgEv(wlisttit, (struct win *)0, '%', flayer->l_width, (struct event *)0, 0); - if (wlistdata->group) - { - LPutWinMsg(flayer, "Group: ", 7, &mchar_blank, 0, 0); - LPutWinMsg(flayer, wlistdata->group->w_title, strlen(wlistdata->group->w_title), &mchar_blank, 7, 0); - LPutWinMsg(flayer, str, strlen(str), &mchar_blank, 0, 1); - } - else - { - LPutWinMsg(flayer, str, strlen(str), &mchar_blank, 0, 0); - } - WListNormalize(); - WListLines(wlistdata->numwin, -1); - LaySetCursor(); -} - -static void -WListUpdate(p) -struct win *p; -{ - struct wlistdata *wlistdata; - int i, n, y; - - if (p == 0) - { - wlistpage(); - return; - } - wlistdata = (struct wlistdata *)flayer->l_data; - n = p->w_number; - if (wlistdata->order == WLIST_NUM && (n < wlistdata->first || n > wlistdata->last)) - return; - i = wlistdata->first; - for (y = 0; y < wlistdata->numwin; y++) - { - if (i == n) - break; - i = WListNext(wlistdata, i, 1); - } - if (y == wlistdata->numwin) - return; - WListLine(y, i, wlistdata->pos, 0); - LaySetCursor(); -} -#endif - /* ** ** The bindkey help page diff --git a/src/process.c b/src/process.c index b12eafb..add2c2a 100644 --- a/src/process.c +++ b/src/process.c @@ -51,6 +51,7 @@ #include "logfile.h" #include "layout.h" #include "viewport.h" +#include "list_generic.h" extern struct comm comms[]; extern char *rc_name; @@ -2202,7 +2203,7 @@ int key; #endif case RC_WINDOWLIST: if (!*args) - display_wlist(0, WLIST_NUM, (struct win *)0); + display_windows(0, WLIST_NUM, (struct win *)0); else if (!strcmp(*args, "string")) { if (args[1]) @@ -2244,7 +2245,7 @@ int key; break; } if (i == argc) - display_wlist(blank, flag, (struct win *)0); + display_windows(blank, flag, (struct win *)0); } break; case RC_HELP: diff --git a/src/socket.c b/src/socket.c index 0f08d60..680a150 100644 --- a/src/socket.c +++ b/src/socket.c @@ -49,6 +49,7 @@ #endif #include "extern.h" +#include "list_generic.h" static int CheckPid __P((int)); static void ExecCreate __P((struct msg *)); @@ -1442,9 +1443,9 @@ struct msg *m; { struct display *olddisplay = display; flayer = D_forecv->c_layer; - display_wlist(1, WLIST_NUM, (struct win *)0); + display_windows(1, WLIST_NUM, (struct win *)0); noshowwin = 1; - display = olddisplay; /* display_wlist can change display */ + display = olddisplay; /* display_windows can change display */ } } Activate(0); -- cgit v1.2.1