home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume4 / curses-widgets / widgetlib.c < prev    next >
C/C++ Source or Header  |  1989-02-03  |  35KB  |  1,367 lines

  1. /*****************************************************************************
  2. /*  FILE:        widgetlib.c
  3. /*  DATE:        August 1988.
  4. /*  AUTHOR:        Richard A. Culshaw.
  5. /*  DESCRIPTION:    Contains the code to manipulate the widget structures
  6. /*            and the i/o. It forms a single library that should
  7. /*            be linked in with all code using these widgets.
  8. /* DISCLAIMER:        This file is deemed to be public-domain, on the simple
  9. /*            provisos that this section remains in this file and
  10. /*            that code using it do not do so for monetary gain.
  11. /*            Neither the author, nor the authors employees at the
  12. /*            time of developing this code, accept any liability or
  13. /*            responsibility for the use, abuse or misuse of this
  14. /*            code.
  15. /*****************************************************************************/
  16.  
  17. #include <widget.h>
  18.  
  19. extern char     *malloc();
  20. int        textwindowdefined = FALSE;
  21. int            widx, widy;    
  22. int        maxwidy;
  23. int            scry;
  24. int            curid;
  25. int        sizescreg;
  26. int        screenborder = 0;
  27.  
  28. WINDOW    *screen;
  29. WINDOW    *screenbox;
  30. WINDOW    *edge1;
  31. WINDOW      *edge2;
  32.  
  33.  
  34. initialisewidgets ()
  35. /* sets up screen and initialises global variables */
  36. {
  37.     int i, endwidgets();
  38.  
  39.     widx = widy = scry = 0;
  40.     curid = 1;
  41.     maxwidy = LINES - 3;
  42.     initscr ();
  43.     crmode ();
  44.     noecho ();
  45.     cmdlist = NULLCMD;
  46.     lbllist = NULLLBL;
  47.     tgllist = NULLTGL;
  48.     inplist = NULLINP;
  49.     actlist = NULLCH;
  50.     for (i=0; i<18; i++)
  51.     signal (i, endwidgets);
  52. }
  53.  
  54. drawtextwindow (y)
  55. /* draws the text window and draws a box around it */
  56. int y;
  57. {
  58.     int i;
  59.  
  60.     if ((screenborder & VERTICAL) && (screenborder & HORIZONTAL)) {
  61.         box (screenbox, '|', '-');
  62.         mvwaddch (screenbox, 0, 0, '.');
  63.         mvwaddch (screenbox, 0, COLS-2, '.');
  64.         mvwaddch (screenbox, LINES-y-1, 0, '`');
  65.         mvwaddch (screenbox, LINES-y-1, COLS-2, '\'');
  66.         touchwin (screenbox);
  67.         wrefresh (screenbox);
  68.     }
  69.     else if (screenborder & HORIZONTAL) {
  70.     waddstr (edge1, "-------------------------------------------------------------------------------");
  71.         waddstr (edge2, "-------------------------------------------------------------------------------");
  72.     wrefresh (edge1);
  73.     wrefresh (edge2);
  74.     }
  75.     else if (screenborder & VERTICAL) {
  76.     for (i=0; i<=sizescreg; i++) {
  77.         mvwaddch (edge1, i, 0, '|');
  78.         mvwaddch (edge2, i, 0, '|');
  79.        }
  80.     wrefresh (edge1);
  81.     wrefresh (edge2);
  82.     }
  83.     touchwin (screen);
  84.     wrefresh (screen);
  85. }
  86.  
  87. int opentextwindow (position, border)
  88. /* define the text window from current position down + position * widget depth*/
  89. int    position;
  90. int    border;
  91. {
  92.     if ((position >= 0) && (!textwindowdefined) && (widy + 3*position < 21)) {
  93.         maxwidy = widy + position * 3 + 3;
  94.     if ((border & VERTICAL) && (border & HORIZONTAL)) {
  95.             screenbox = newwin (LINES-maxwidy, COLS-1, maxwidy, 0);
  96.         screen = newwin (LINES-2-maxwidy, COLS-3, maxwidy+1, 1);
  97.         sizescreg = LINES-2-maxwidy;
  98.         }
  99.     else if (border & HORIZONTAL) {
  100.         screen = newwin (LINES-2-maxwidy, COLS-1, maxwidy+1, 0);
  101.             edge1 = newwin (1, COLS-1, maxwidy, 0);
  102.             edge2 = newwin (1, COLS-1, LINES-1, 0);
  103.         sizescreg = LINES-2-maxwidy;
  104.         }
  105.     else if (border & VERTICAL) {
  106.         screen = newwin (LINES-maxwidy, COLS-3, maxwidy, 1);
  107.         edge1 = newwin (LINES-maxwidy, 1, maxwidy, 0);
  108.         edge2 = newwin (LINES-maxwidy, 1, maxwidy, COLS-2);
  109.         sizescreg = LINES-maxwidy;
  110.         }
  111.     else {
  112.         screen = newwin (LINES-maxwidy, COLS-1, maxwidy, 0);
  113.         sizescreg = LINES-maxwidy;
  114.         }
  115.         screenborder = border;
  116.         scrollok (screen, TRUE);
  117.     drawtextwindow (maxwidy);
  118.         wmove (screen, scry, 0);
  119.     wrefresh (screen);
  120.     textwindowdefined = 1;
  121.     return sizescreg;
  122.     }
  123. }
  124.  
  125. int addtochlist (ch, id, type)
  126. /* add a new character to array of activation chars.
  127.  * returns TRUE if successful (char not already in list) else FALSE
  128.  */
  129. char           ch;
  130. int            id;
  131. WIDGETTYPE  type;    
  132. {
  133.     struct chentry  *chlist;
  134.     struct chentry  *newentry;
  135.     /* search list to see char already entered in the list */    
  136.     chlist = actlist;
  137.     if (chlist != NULLCH) {
  138.     while (chlist -> next != NULLCH) 
  139.        if (chlist -> ch == ch)
  140.         return FALSE;           /* char exists => error */
  141.         else
  142.         chlist = chlist -> next;
  143.         newentry = (struct chentry*)malloc((unsigned)sizeof(struct chentry));
  144.     chlist -> next = newentry;
  145.     }
  146.     else {
  147.         newentry = (struct chentry*)malloc((unsigned)sizeof(struct chentry));
  148.     actlist = newentry;
  149.     }
  150.     /* char not there so add to list */
  151.     newentry -> ch = ch;
  152.     newentry -> id = id;
  153.     newentry -> type = type;
  154.     newentry -> next = NULLCH;
  155.     return TRUE;
  156. }
  157.  
  158.  
  159. WIDGETTYPE widgettype (ptr)
  160. /* given a widget pointer returns the type of widget.
  161.  */
  162. WIDGET    ptr;
  163. {
  164.     struct cmdwid    *clist;
  165.     struct tglwid    *tlist;
  166.     struct lblwid    *llist;
  167.     struct inpwid    *ilist;
  168.  
  169.     /* is it a command widget ? */
  170.     for (clist = cmdlist; clist != NULLCMD; clist = clist -> next)       
  171.         if ((clist != NULLCMD) && (clist -> id == ptr))
  172.             return CMD;
  173.  
  174.     /* is it a toggle widget ? */
  175.     for (tlist = tgllist; tlist != NULLTGL; tlist = tlist -> next)       
  176.         if ((tlist != NULLTGL) && (tlist -> id == ptr))
  177.             return TGL;
  178.  
  179.     /* is it a label widget ? */
  180.     for (llist = lbllist; llist != NULLLBL; llist = llist -> next)       
  181.         if ((llist != NULLLBL) && (llist -> id == ptr))
  182.             return LBL;
  183.  
  184.     /* is in an input widget ? */
  185.     for (ilist = inplist; ilist != NULLINP; ilist = ilist -> next)       
  186.         if ((ilist != NULLINP) && (ilist -> id == ptr))
  187.             return INP;
  188.  
  189.     /* doesn't exist, return error */
  190.     return FALSE;             
  191. }
  192.  
  193. boxwidget (widget, length)
  194. WINDOW    *widget;
  195. int    length;
  196. {
  197.     int i;
  198.  
  199.     wmove (widget, 0, 1);
  200.     for (i=1; i < length; i++)
  201.            waddch (widget, '-');
  202.     wmove (widget, 2, 1);
  203.     for (i=1; i < length; i++)
  204.            waddch (widget, '-');
  205.     mvwaddch (widget, 1, 0, '|');
  206.     mvwaddch (widget, 1, length, '|');
  207.     mvwaddch (widget, 0, 0, '.');
  208.     mvwaddch (widget, 0, length, '.');
  209.     mvwaddch (widget, 2, 0, '`');
  210.     mvwaddch (widget, 2, length, '\'');
  211. }
  212.  
  213. drawcmdwidget (widget, info, ch, length, boolean)
  214. WINDOW    *widget;
  215. char    info[];
  216. char    ch;
  217. int    length;
  218. int    boolean;
  219. {
  220.     boxwidget (widget, length-1);
  221.     wmove (widget, 1, 1);
  222.     wstandout (widget);
  223.     waddch (widget, ch);
  224.     if (!boolean)
  225.         wstandend (widget);
  226.     wprintw (widget, ":%s", info);
  227.     if (boolean)
  228.         wstandend (widget);
  229.     wrefresh (widget);
  230. }
  231.  
  232. drawlblwidget (widget, info, pos, difference, space, boolean)
  233. WINDOW    *widget;
  234. char    info[];
  235. char    pos;
  236. int    difference;
  237. int    space;
  238. int    boolean;
  239. {
  240.     boxwidget (widget, space+1);
  241.  
  242.     /* work out justification */
  243.     if ((pos & LEFTJUST) || (difference == 0))
  244.     wmove (widget, 1, 1);
  245.     else if (pos & RIGHTJUST)
  246.     wmove (widget, 1, 1+difference);
  247.     else if (pos & CENTRE)
  248.     wmove (widget, 1, difference / 2 + 1);
  249.     if (boolean)
  250.         wstandout (widget);
  251.     wprintw (widget, "%s", info);
  252.     if (boolean)
  253.         wstandend (widget);
  254.     wrefresh (widget);
  255. }
  256.   
  257.  
  258. drawtglwidget (widget, info, tgl, toggle, length, boolean)
  259. WINDOW    *widget;
  260. char    info[];
  261. char    tgl[];
  262. char    toggle;
  263. int    length;
  264. int    boolean;
  265. {
  266.     boxwidget (widget, length-1);
  267.     wmove (widget, 1, 1);
  268.     wstandout (widget);
  269.     wprintw (widget, "%c", toggle);
  270.     if (!boolean)
  271.         wstandend (widget);
  272.     wprintw (widget, ":%s:", info);
  273.     if (!boolean)
  274.         wstandout (widget);
  275.     wprintw (widget, "%s", tgl);
  276.     wstandend (widget);
  277.     wrefresh (widget);
  278. }
  279.  
  280. drawinpwidget (widget, info, ch, length, boolean, exec)
  281. WINDOW    *widget;
  282. char    info[];
  283. char    ch;
  284. int    length;
  285. int    boolean;
  286. {
  287.     boxwidget (widget, length-1);
  288.     wmove (widget, 1, 1);
  289.     if (boolean)
  290.         wstandout (widget);
  291.     if (exec)
  292.      wprintw (widget, "%s", info);
  293.     else
  294.         wprintw (widget, "%c:%s", ch, info);
  295.     if (boolean)
  296.         wstandend (widget);
  297.     waddch (widget, '>');
  298.     wrefresh (widget);
  299. }
  300.  
  301. screenrefresh ()
  302. /* clear the screen and redraw all the widgets and the text screen if present */
  303. {
  304.     struct cmdwid *clist;
  305.     struct lblwid *llist;
  306.     struct tglwid *tlist;
  307.     struct inpwid *ilist;
  308.  
  309.     /* clear the entire screen */
  310.     clear();
  311.     refresh();
  312.  
  313.     /* redraw all the command widgets */
  314.     clist = cmdlist;
  315.     while (clist != NULLCMD) {
  316.     touchwin (clist -> widget);
  317.     wrefresh (clist -> widget);
  318.     clist = clist -> next;
  319.     }
  320.  
  321.     /* redraw all the label widgets */
  322.     llist = lbllist;
  323.     while (llist != NULLLBL) {
  324.     touchwin (llist -> widget);
  325.     wrefresh (llist -> widget);
  326.     llist = llist -> next;
  327.     }
  328.  
  329.     /* redraw all the toggle widgets */
  330.     tlist = tgllist;
  331.     while (tlist != NULLTGL) {
  332.     touchwin (tlist -> widget);
  333.     wrefresh (tlist -> widget);
  334.     tlist = tlist -> next;
  335.     }
  336.  
  337.     /* redraw all the input widgets */
  338.     ilist = inplist;
  339.     while (ilist != NULLINP) {
  340.     touchwin (ilist -> widget);
  341.     wrefresh (ilist -> widget);
  342.     ilist = ilist -> next;
  343.     }
  344.  
  345.     /* redraw text window if present */
  346.     if (textwindowdefined) {
  347.     touchwin (screen);
  348.     touchwin (screenbox);
  349.         wrefresh (screenbox);
  350.         wrefresh (screen);
  351.     }
  352. }
  353.  
  354. WIDGET widgetinput ()
  355. /* scan standard input for chars and act on them */
  356. {
  357.     struct cmdwid *list;    
  358.     struct chentry *chlist;
  359.     char      ch;
  360.     int          i;
  361.     int          j;
  362.  
  363.     for (;;)
  364.     {
  365.         ch = getchar ();
  366.  
  367.     if (ch == '\014') {
  368.         screenrefresh ();
  369.         continue;
  370.     }
  371.     
  372.     chlist = actlist;
  373.     while ((chlist != NULLCH) && (chlist -> ch != ch))
  374.         chlist = chlist -> next; 
  375.     
  376.     if (chlist == NULLCH)
  377.         continue;
  378.  
  379.         if (chlist -> type == 1) {  /* does char activate a command widget ? */
  380.             for (list = cmdlist; list != NULLCMD; list = list->next)
  381.             if (list -> id == chlist -> id)
  382.             if (list -> active)
  383.                       return (*(list -> func))();
  384.         }
  385.         else if (chlist -> type == 2) /* does char activate a toggle widget ?*/
  386.             togglewidget (chlist -> id);
  387.         else 
  388.             return (getinput (chlist -> id)); /* must activate input widget */    
  389.     }
  390. }
  391.  
  392.     
  393. togglewidget (id)
  394. /* toggle widget given its id */
  395. WIDGET id;
  396. {
  397.     struct tglwid *list;
  398.     int       i=0;
  399.     int       x,y;
  400.     int       pos;
  401.  
  402.  
  403.     list = tgllist;    
  404.     /* find toggle widget with given id */
  405.     while (list -> id != id)
  406.         list = list -> next;
  407.  
  408.     if (!list -> active)
  409.     return;
  410.  
  411.     /* increase its toggle value */
  412.     pos = ++(list -> cur);
  413.     if (pos == list -> total)   /* do we need to wrap round values */
  414.     {    pos = 0;
  415.         list -> cur = 0;
  416.     }
  417.  
  418.     /* output new toggle value */
  419.     wstandout (list -> widget);
  420.     mvwaddstr (list -> widget, 1, list -> xtgl, list -> tgl[pos]);
  421.     wstandend (list -> widget);
  422.     getyx (list -> widget, y, x);
  423.     for (; x < list -> length-1; x++)
  424.         waddch (list -> widget, ' ');
  425.     wrefresh (list -> widget);
  426.     if (textwindowdefined)
  427.         wrefresh (screen);
  428. }
  429.  
  430.  
  431. int getinput (id)
  432. /* get input from an input widget and put value into given place */
  433. WIDGET id;
  434. {
  435.     struct inpwid *list;    
  436.     int       i = 0;
  437.     int         j;
  438.     int         cursor = 0;
  439.     int         index = 0;
  440.     WINDOW      *widgy;
  441.     int      max;
  442.     char     ch = '\0';
  443.     int         flag = 0;
  444.     int         sofi;
  445.  
  446.     highlight (id);
  447.     list = inplist;
  448.     /* find the input widget with the given id */
  449.     while (list -> id != id)
  450.         list = list -> next;
  451.  
  452.     if (!list -> active)
  453.     return;
  454.  
  455.     widgy = list -> widget;
  456.     sofi = list -> sofi;
  457.     max = list -> length - sofi - 1;
  458.     wmove (widgy, 1, sofi);
  459.     wrefresh (widgy);
  460.  
  461.     /* repeatidly get chars from stdin until carriage return is pressed */
  462.     while ((ch = getchar()) != '\n') {
  463.         if ((ch > 31) || (ch == '\025') || (ch == '\014'))
  464.         {
  465.         switch (ch) {
  466.     
  467.     /* delete ? */
  468.         case '\177' : if ((!flag) && (cursor > 0)){ /* chars don't spill over */
  469.                    cursor -= 1;
  470.                    mvwaddch (widgy, 1, cursor + sofi, ' ');
  471.                    wmove (widgy, 1, cursor + sofi);
  472.                    index -= 1;
  473.                    wrefresh (widgy);
  474.                    break;
  475.                   }
  476.                   else if (cursor > 0){  /* chars spill over */
  477.                       index -= 1;
  478.                   if (index == max-1) {
  479.                       flag = 0;
  480.                       mvwaddch (widgy, 1, sofi-1, '>');
  481.                   }
  482.                   for (j=0; j < max-1; j++)
  483.                       mvwaddch (widgy, 1, j+sofi, list -> input [index-max+j+1]);
  484.                       wmove (widgy, 1, cursor + sofi);
  485.                       wrefresh (widgy);
  486.                       break;
  487.                   }
  488.  
  489.                   else        /* nothing to delete ! */    
  490.                   break;
  491.  
  492.     /* ^U pressed (delete all) */
  493.         case '\025' : index = cursor = 0;
  494.                   wmove (widgy, 1, sofi);
  495.                   for (j=0; j < max; j++)
  496.                   waddch (widgy, ' ');
  497.                   mvwaddch (widgy, 1, sofi-1, '>');
  498.                   wrefresh (widgy);
  499.                   break;
  500.  
  501.     /* ^L pressed (screen refresh) */
  502.     case '\014' : screenrefresh ();
  503.                   wmove (widgy,1,cursor+sofi);
  504.               wrefresh (widgy);
  505.               break;
  506.  
  507.     /* default = all other chars except remaining control chars */
  508.         default :    if (index < list -> lofs) {  /* space still remaining ? */
  509.                  list -> input [index++] = ch;
  510.                        if (cursor == (max-1)) { /* about to spill over ? */
  511.                     mvwaddch (widgy, 1, sofi-1, '<');
  512.                     for (j=0; j < max-2; j++)
  513.                     mvwaddch (widgy, 1, j+sofi, list ->input [index-max+j+1]);
  514.                     mvwaddch (widgy, 1, cursor+sofi-1, ch);
  515.                     flag = 1;
  516.                     }            
  517.                     else    /* not spilt over */
  518.                       mvwaddch (widgy, 1, (cursor++) +sofi, ch);
  519.                     wrefresh (widgy);
  520.                     break;
  521.                       }
  522.                  else         /* no room left ! */
  523.                  break;
  524.                  }
  525.         }
  526.         }        
  527.     /* terminate input */
  528.     list -> input [index] = '\0';
  529.  
  530.     /* clean up input line */
  531.     wmove (widgy, 1, sofi);
  532.     for (j=0; j < max; j++)
  533.         waddch (widgy, ' ');
  534.     mvwaddch (widgy, 1, sofi-1, '>');
  535.     wrefresh (widgy);
  536.     if (textwindowdefined)
  537.         wrefresh (screen);
  538.     dehighlight (id);
  539.     return id;
  540. }
  541.  
  542. WIDGET mkcmdwidget (info, acpt, func, line)
  543. /* make a new command widget */
  544. char    info[];
  545. char    acpt;
  546. int    (*func)();
  547. int    line;
  548. {
  549.     struct cmdwid     *list;
  550.     struct cmdwid     *temp;
  551.     int         length = 0;
  552.  
  553.     while (info [length++] != '\0')   /* work out length of command */
  554.         ;    
  555.     length += 3;
  556.     if ((line == 1) || ((length + widx) > COLS-1) || widx == COLS-1)
  557.         if (widy + 3 == maxwidy) /* go onto next line */
  558.             return NULLWIDGET;
  559.     else {
  560.             widy += 3;
  561.             widx = 0;          
  562.     }
  563.     if (!addtochlist (acpt, curid, 1))  /* activation char in use ? */
  564.         return NULLWIDGET;
  565.     
  566.     /* find end of list and allocate memory for new entry */
  567.     temp = cmdlist; 
  568.     if (temp != NULLCMD) {
  569.         while (temp -> next != NULLCMD)
  570.             temp = temp -> next;
  571.         list = (struct cmdwid *)malloc((unsigned)sizeof(struct cmdwid));
  572.         temp -> next = list;
  573.     }
  574.     else {
  575.         list = (struct cmdwid *)malloc((unsigned)sizeof(struct cmdwid));
  576.         cmdlist = list;
  577.     }
  578.  
  579.     /* create and display new widget */
  580.     list -> widget = newwin (3, length, widy, widx);
  581.  
  582.     drawcmdwidget (list -> widget, info, acpt, length, FALSE);
  583.  
  584.     /* assign information to be withheld */
  585.     list -> x = widx;
  586.     list -> y = widy;
  587.     list -> id = curid;
  588.     strcpy (list -> msg ,info);
  589.     list -> func = func;
  590.     list -> acpt = acpt;
  591.     list -> length = length;
  592.     list -> next = NULLCMD;
  593.     list -> active = TRUE;
  594.     curid += 1;
  595.     widx += length;
  596.     if (textwindowdefined)
  597.         wrefresh (screen);
  598.     return (curid-1);
  599. }
  600.  
  601. WIDGET mklblwidget (info, pos, space, line)
  602. /* make a new label widget */
  603. char    info[];
  604. int     pos;
  605. int     space;
  606. int     line;
  607. {
  608.     struct lblwid    *list;
  609.     struct lblwid    *temp;
  610.     int         length = 0;
  611.     int         difference;
  612.  
  613.     if (!((pos & CENTRE) || (pos & LEFTJUST) || (pos & RIGHTJUST)))
  614.     pos = pos|LEFTJUST;
  615.  
  616.     /* calculate length of label widget */
  617.     while (info [length++] != '\0')    
  618.         ;    
  619.     length -= 1;
  620.     if ((space < length) && (space > 0))    /* not given enough room so error */
  621.         return NULLWIDGET; 
  622.     
  623.     if (space <= 0)
  624.         if ((line == 1) || (widx == COLS-1))
  625.         space += COLS - 3;
  626.     else
  627.         space += COLS - 3 - widx;
  628.  
  629.     difference = space - length;
  630.  
  631.     if ((line == 1) || ((space + 2 + widx) > COLS-1) || (widx == COLS-1))
  632.     /* not enough room on existing line so go onto next */
  633.         if (widy + 3 == maxwidy)
  634.             return NULLWIDGET;
  635.     else {
  636.         widx = 0;
  637.         widy += 3;
  638.      }
  639.  
  640.     /* find end of list and alllocate memory for new entry */
  641.     temp = lbllist;
  642.     if (temp != NULLLBL) {
  643.         while (temp -> next != NULLLBL)
  644.             temp = temp -> next;
  645.         list = (struct lblwid *)malloc((unsigned)sizeof(struct lblwid));
  646.         temp -> next = list;
  647.     }
  648.     else {
  649.         list = (struct lblwid *)malloc((unsigned)sizeof(struct lblwid));
  650.         lbllist = list;
  651.     }
  652.  
  653.     /* create new and display new widget */
  654.     list -> widget = newwin (3, space+2, widy, widx);
  655.  
  656.     drawlblwidget (list -> widget, info, pos, difference, space, !(pos & NOHIGH));
  657.  
  658.     /* assign information to be withheld */
  659.     list -> x = widx;
  660.     list -> y = widy;
  661.     list -> id = curid;
  662.     strcpy (list -> msg ,info);
  663.     list -> pos = pos;
  664.     list -> length = space+2;
  665.     list -> difference = difference;
  666.     list -> next = NULLLBL;
  667.     curid += 1;
  668.     widx += space+2;
  669.     if (textwindowdefined)
  670.         wrefresh (screen);
  671.     return (curid - 1);
  672. }
  673.  
  674. WIDGET mktglwidget (info, num, tgl, toggle, line)
  675. /* make a new toggle widget */
  676. char  info[];
  677. int   num;    
  678. char  *tgl[10];
  679. char  toggle;
  680. int   line;
  681. {
  682.     int         length = 0;
  683.     struct tglwid    *list;
  684.     struct tglwid    *temp;
  685.     int         xtgl;
  686.     int         max = 0;
  687.     int         i, j, x;
  688.     
  689.     /* calculate maximum length of toggle */
  690.     for (i=0; i < num; i++)  
  691.         {
  692.         for (j=0, x=0; tgl[i][j] != '\0'; j++)
  693.                x++;
  694.         if ((x-1)>max)
  695.             max = x-1;
  696.         }
  697.     
  698.     while (info [length++] != '\0') 
  699.         ;    
  700.     xtgl = length + 3;
  701.     length = length + max + 5;
  702.  
  703.     if ((line == 1) || ((length + widx) > COLS-1) || (widx == COLS-1))
  704.         /* not enough room on existing line so go onto next */
  705.         if (widy + 3 == maxwidy)
  706.             return NULLWIDGET;
  707.     else {
  708.         widx = 0;
  709.         widy += 3;
  710.     }
  711.  
  712.     /* add char to activation list if not already in use */
  713.     if (!addtochlist (toggle, curid, 2)) 
  714.         return NULLWIDGET;
  715.  
  716.     /* find end of list and allocate memory for new entry */
  717.     temp = tgllist;
  718.     if (temp != NULLTGL) {
  719.         while (temp -> next != NULLTGL)
  720.             temp = temp -> next;
  721.         list = (struct tglwid *)malloc((unsigned)sizeof(struct tglwid));
  722.         temp -> next = list;
  723.     }
  724.     else {
  725.         list = (struct tglwid *)malloc((unsigned)sizeof(struct tglwid));
  726.         tgllist = list;
  727.     }
  728.  
  729.     /* create and display new widget */
  730.     list -> widget = newwin (3, length, widy, widx);
  731.  
  732.     drawtglwidget (list -> widget, info, tgl[0], toggle, length, FALSE);
  733.  
  734.     /* assign information to be withheld */
  735.     list -> x = widx;
  736.     list -> y = widy;
  737.     list -> id = curid;
  738.     strcpy (list -> msg ,info);
  739.     list -> xtgl = xtgl;
  740.     list -> total = num;
  741.     for (i=0; i<num; i++) 
  742.     strcpy (list -> tgl[i], tgl[i]);
  743.     list -> cur = 0;
  744.     list -> toggle = toggle;
  745.     list -> length = length;
  746.     list -> next = NULLTGL;
  747.     list -> active = TRUE;
  748.     curid += 1;
  749.     widx += length;
  750.     if (textwindowdefined)
  751.         wrefresh (screen);
  752.     return (curid-1);
  753. }
  754.  
  755. WIDGET mkinpwidget (info, acpt, input, lofs, length, line, exec)
  756. /* make a new input widget */
  757. char    info[];
  758. char    acpt;
  759. char    input[];
  760. int     lofs;
  761. int     length;
  762. int     line;
  763. int    exec;
  764. {
  765.     struct inpwid    *list;
  766.     struct inpwid    *temp;
  767.     int            count = 0;
  768.     int            offset;
  769.  
  770.     if (exec)
  771.           offset = 3;
  772.     else
  773.     offset = 5;
  774.  
  775.     while (info [count++] != '\0')
  776.     ;
  777.  
  778.     if (length <= 0)
  779.     if ((line == 1) || (widx == COLS-1))
  780.         length += COLS-offset-count;
  781.     else
  782.         length += COLS-offset-widx-count;
  783.     length += offset-1+count;
  784.     if ((line == 1) || ((length + widx) > COLS-1) || (widx == COLS -1))
  785.         /* if no room on existing line go onto next */
  786.         if (widy + 3 == maxwidy)
  787.             return NULLWIDGET;
  788.     else {
  789.         widx = 0;
  790.         widy += 3;
  791.     }
  792.  
  793.     /* add activation char to list if not already in use */
  794.     if (!addtochlist (acpt, curid, 3)) 
  795.         return NULLWIDGET;
  796.  
  797.     /* find end of list and allocate memory for new entry */
  798.     temp = inplist;
  799.     if (temp != NULLINP) {
  800.         while (temp -> next != NULLINP)
  801.             temp = temp -> next;
  802.         list = (struct inpwid *)malloc((unsigned)sizeof(struct inpwid));
  803.         temp -> next = list;
  804.     }
  805.     else {
  806.         list = (struct inpwid *)malloc((unsigned)sizeof(struct inpwid));
  807.         inplist = list;
  808.     }
  809.  
  810.     /* create and display new widget */
  811.     list -> widget = newwin (3, length, widy, widx);
  812.  
  813.     drawinpwidget (list -> widget, info, acpt, length, FALSE, exec);
  814.  
  815.     /* assign information to be withheld */
  816.     list -> x = widx;
  817.     list -> y = widy;
  818.     list -> id = curid;
  819.     strcpy (list -> msg ,info);
  820.     list -> acpt = acpt;
  821.     list -> input = input;
  822.     list -> lofs = lofs;
  823.  
  824.     if (exec)
  825.     list -> sofi = count+1;
  826.     else
  827.         list -> sofi = count+3;
  828.  
  829.     list -> length = length;
  830.     list -> next = NULLINP;
  831.     list -> exec = exec;
  832.     list -> active = TRUE;
  833.     curid += 1;
  834.     widx += length;
  835.     if (textwindowdefined)
  836.         wrefresh (screen);
  837.     if (exec)
  838.     getinput (curid-1);
  839.     return (curid-1);
  840. }
  841.  
  842. cleartextwindow ()
  843. {
  844.     werase (screen);
  845.     wrefresh (screen);
  846.     scry = 0;
  847. }
  848.  
  849. report (info)
  850. /* place given info into data screen */
  851. char    *info;
  852. {
  853.     int i, count = 0;
  854.  
  855.     if (textwindowdefined) {
  856.         if (scry == sizescreg)    /* scroll window if reached bottom */
  857.         {
  858.             scroll (screen);
  859.             scry -= 1;
  860.         }
  861.     for (i=0; info[i] != '\0'; i++)
  862.         if (info[i] == '\n')
  863.         count += 1;
  864.  
  865.         mvwaddstr (screen, scry, 0, info);
  866.         scry += 1+count;
  867.         wrefresh (screen);
  868.     }
  869. }
  870.  
  871. int tsttglwidget (ptr)
  872. /* return the index value of the current state of the given toggle widget */
  873. WIDGET ptr;
  874. {
  875.     struct tglwid *list;
  876.     int          i=0;
  877.  
  878.     /* locate the record of the given toggle widget pointer */
  879.     list = tgllist;
  880.     while ((list != NULLTGL) && (list -> id != ptr)) 
  881.         list = list -> next;
  882.  
  883.     /* if it exists return index value else return error FALSE */
  884.     if (list -> id == ptr)
  885.         return list -> cur;
  886.     else
  887.         return FALSE;
  888. }
  889.  
  890. deletechentry (ch)
  891. /* remove the entry from character list for killed widget */
  892. char ch;
  893. {
  894.     struct chentry    *chlist;
  895.     struct chentry    *previous;
  896.    
  897.     chlist = actlist;
  898.     if (chlist -> ch == ch) {        /* is required entry at head of list ? */
  899.     actlist = chlist -> next;    
  900.     free ((char*)chlist);        /* deallocate memory for deleted entry */
  901.     }
  902.     else {
  903.     while (chlist -> ch != ch) {  /* locate required entry in the list */
  904.         previous = chlist;
  905.         chlist = chlist -> next;
  906.     }
  907.     previous -> next = chlist -> next;  /* remove entry by skiping it */
  908.     free ((char*)chlist);        /* deallocate memory for deleted entry */
  909.     }
  910. }
  911.  
  912. killcmdwidget (ptr)
  913. /* kill a command widget given a valid pointer */
  914. WIDGET ptr;
  915. {
  916.     struct cmdwid    *clist;
  917.     struct cmdwid    *previous;
  918.  
  919.     clist = cmdlist;
  920.     if (clist -> id == ptr) {         /* required widget at head of list ? */
  921.     cmdlist = clist -> next;
  922.     werase (clist -> widget);
  923.     wrefresh (clist -> widget);
  924.     delwin (clist -> widget);
  925.     deletechentry (clist -> acpt);
  926.     if ((clist -> x + clist -> length) == widx)   /* if last widget added */
  927.         widx -= clist -> length;              /* pull back widx       */
  928.     free ((char*)clist);
  929.     }
  930.     else {
  931.     while (clist -> id != ptr) {    /* find widget in list */
  932.        previous = clist;
  933.        clist = clist -> next;
  934.     }
  935.     previous -> next = clist -> next;   /* skip unrequired widget in list */
  936.     werase (clist -> widget);
  937.     wrefresh (clist -> widget);
  938.     delwin (clist -> widget);
  939.     deletechentry (clist -> acpt);
  940.     if ((clist -> x + clist -> length) == widx)   /* if last widget added */
  941.         widx -= clist -> length;              /* pull back widx       */
  942.     free ((char*)clist);
  943.     }
  944. }
  945.  
  946. killlblwidget (ptr)
  947. /* kill label widget given a valid pointer */
  948. WIDGET ptr;
  949. {
  950.     struct lblwid    *clist;
  951.     struct lblwid    *previous;
  952.  
  953.     clist = lbllist;
  954.     if (clist -> id == ptr) {         /* is widget at head of list ? */
  955.     lbllist = clist -> next;
  956.     werase (clist -> widget);
  957.     wrefresh (clist -> widget);
  958.     delwin (clist -> widget);
  959.     if ((clist -> x + clist -> length) == widx)  /* pull back widx if */
  960.         widx -= clist -> length;             /* last widget added */
  961.     free ((char*)clist);
  962.     }
  963.     else {
  964.     while (clist -> id != ptr) {    /* find widget in linked list */
  965.        previous = clist;
  966.        clist = clist -> next;
  967.     }
  968.     previous -> next = clist -> next;   /* skip widget in list */
  969.     werase (clist -> widget);
  970.     wrefresh (clist -> widget);
  971.     delwin (clist -> widget);
  972.     if ((clist -> x + clist -> length) == widx)  /* pull back widx if */
  973.         widx -= clist -> length;             /* last widget added */
  974.     free ((char*)clist);
  975.     }
  976. }
  977.  
  978. killtglwidget (ptr)
  979. /* kill toggle widget given a valid pointer */
  980. WIDGET ptr;
  981. {
  982.     struct tglwid    *clist;
  983.     struct tglwid    *previous;
  984.  
  985.     clist = tgllist;
  986.     if (clist -> id == ptr) {       /* is widget at head of list ? */
  987.     tgllist = clist -> next;
  988.     werase (clist -> widget);
  989.     wrefresh (clist -> widget);
  990.     delwin (clist -> widget);
  991.     deletechentry (clist -> toggle);
  992.     if ((clist -> x + clist -> length) == widx)  /* pull back widx if */
  993.         widx -= clist -> length;             /* last widget added */
  994.     free ((char*)clist);
  995.     }
  996.     else {
  997.     while (clist -> id != ptr) {    /* find widget in linked list */
  998.        previous = clist;
  999.        clist = clist -> next;
  1000.     }
  1001.     previous -> next = clist -> next;   /* skip widget in list */
  1002.     werase (clist -> widget);
  1003.     wrefresh (clist -> widget);
  1004.     delwin (clist -> widget);
  1005.     deletechentry (clist -> toggle);
  1006.     if ((clist -> x + clist -> length) == widx)   /* pull back widx if */
  1007.         widx -= clist -> length;              /* last widget added */
  1008.     free ((char*)clist);
  1009.     }
  1010. }
  1011.  
  1012. killinpwidget (ptr)
  1013. /* kill an input widget given a valid pointer */
  1014. WIDGET ptr;
  1015. {
  1016.     struct inpwid    *clist;
  1017.     struct inpwid    *previous;
  1018.  
  1019.     clist = inplist;
  1020.     if (clist -> id == ptr) {        /* is widget at head of list ? */
  1021.     inplist = clist -> next;
  1022.     werase (clist -> widget);
  1023.     wrefresh (clist -> widget);
  1024.     delwin (clist -> widget);
  1025.     deletechentry (clist -> acpt);
  1026.     if ((clist -> x + clist -> length) == widx)   /* pull back widx if */
  1027.         widx -= clist -> length;              /* last widget added */
  1028.     free ((char*)clist);
  1029.     }
  1030.     else {
  1031.     while (clist -> id != ptr) {   /* locate widget in linked list */
  1032.        previous = clist;
  1033.        clist = clist -> next;
  1034.     }
  1035.     previous -> next = clist -> next;   /* skip entry in linked list */
  1036.     werase (clist -> widget);
  1037.     wrefresh (clist -> widget);
  1038.     delwin (clist -> widget);
  1039.     deletechentry (clist -> acpt);
  1040.     if ((clist -> x + clist -> length) == widx)   /* pull back widx if */
  1041.         widx -= clist -> length;              /* last widget added */
  1042.     free ((char*)clist);
  1043.     }
  1044. }
  1045.     
  1046. int killwidget (ptr)
  1047. /* kills the widget identified by ptr */
  1048. WIDGET ptr;
  1049. {
  1050.     switch (widgettype (ptr)) {
  1051.         case CMD : killcmdwidget (ptr);    /* command widget */
  1052.          home ();
  1053.          return TRUE;
  1054.     case TGL : killtglwidget (ptr);    /* toggle widget */
  1055.          home ();
  1056.          return TRUE;
  1057.     case LBL : killlblwidget (ptr);    /* label widget */
  1058.          home ();
  1059.          return TRUE;
  1060.     case INP : killinpwidget (ptr);    /* input widget */
  1061.          home ();
  1062.          return TRUE;
  1063.     case FALSE : return FALSE;           /* doesn't exist */
  1064.     }
  1065. }
  1066.  
  1067. int chactive (ptr, boolean, blank)
  1068. /* given a widget ptr and a boolean value will activate/deactivate a widget */
  1069. WIDGET ptr;
  1070. int boolean;
  1071. int blank;
  1072. {
  1073.     struct cmdwid *clist;
  1074.     struct tglwid *tlist;
  1075.     struct inpwid *ilist;
  1076.     int          i;
  1077.  
  1078.     switch (widgettype (ptr)) {
  1079.     case CMD: for (clist = cmdlist; clist != NULLCMD; clist = clist -> next)
  1080.           if ((clist != NULLCMD) && (clist -> id == ptr)) {
  1081.             if ((!boolean) && (blank)) {
  1082.                 wmove (clist->widget, 1, 1);
  1083.                 for (i=0; i < clist->length-2; i++)
  1084.                 waddch (clist->widget, ' ');
  1085.                 wrefresh (clist->widget);
  1086.             }
  1087.               if (textwindowdefined)
  1088.                     wrefresh (screen);
  1089.             return(clist -> active = boolean);
  1090.           }
  1091.           break;
  1092.     case TGL: for (tlist = tgllist; tlist != NULLTGL; tlist = tlist -> next)
  1093.           if ((tlist != NULLTGL) && (tlist -> id == ptr)) {
  1094.             if ((!boolean) && (blank)) {
  1095.                 wmove (tlist->widget, 1, 1);
  1096.                 for (i=0; i < tlist->length-2; i++)
  1097.                 waddch (tlist->widget, ' ');
  1098.                 wrefresh (tlist->widget);
  1099.             }
  1100.               if (textwindowdefined)
  1101.                     wrefresh (screen);
  1102.             return(tlist -> active = boolean);
  1103.           }
  1104.           break;
  1105.     case INP: for (ilist = inplist; ilist != NULLINP; ilist = ilist -> next)
  1106.           if ((ilist != NULLINP) && (ilist -> id == ptr)) {
  1107.             if ((!boolean) && (blank)) {
  1108.                 wmove (ilist->widget, 1, 1);
  1109.                 for (i=0; i < ilist->length-2; i++)
  1110.                 waddch (ilist->widget, ' ');
  1111.                 wrefresh (ilist->widget);
  1112.             }
  1113.               if (textwindowdefined)
  1114.                     wrefresh (screen);
  1115.             return (ilist -> active = boolean);
  1116.           }
  1117.           break;
  1118.     default : return FALSE;
  1119.     }
  1120. }
  1121.  
  1122. int activate (ptr)
  1123. /* reactivate a widget given its ptr */
  1124. WIDGET ptr;
  1125. {
  1126.     int boolean;
  1127.  
  1128.     boolean = (chactive (ptr, TRUE));
  1129.     light (ptr, FALSE);
  1130.     return boolean;
  1131. }
  1132.  
  1133. int deactivate (ptr, blank)
  1134. /* deactivates a widget given its ptr */
  1135. WIDGET ptr;
  1136. int    blank;
  1137. {
  1138.     return (chactive (ptr, FALSE, blank));
  1139. }
  1140.  
  1141. int light (ptr, boolean)
  1142. /* will highlight or dehighlight a given widget */
  1143. WIDGET ptr;
  1144. int boolean;
  1145. {
  1146.     struct cmdwid *clist;
  1147.     struct tglwid *tlist;
  1148.     struct lblwid *llist;
  1149.     struct inpwid *ilist;
  1150.  
  1151.     switch (widgettype (ptr)) {
  1152.     case CMD: for (clist = cmdlist; clist != NULLCMD; clist = clist -> next)
  1153.           if ((clist != NULLCMD) && (clist -> id == ptr)) {
  1154.               if (clist -> active)
  1155.                       drawcmdwidget (clist->widget,clist->msg,clist->acpt,clist->length,boolean);
  1156.           if (textwindowdefined)
  1157.                 wrefresh (screen);
  1158.           return (clist -> active);
  1159.           }
  1160.           break;
  1161.  
  1162.     case TGL: for (tlist = tgllist; tlist != NULLTGL; tlist = tlist -> next)
  1163.           if ((tlist != NULLTGL) && (tlist -> id == ptr)) {
  1164.               if (tlist -> active)
  1165.                     drawtglwidget (tlist->widget,tlist->msg,tlist->tgl[tlist->cur],tlist->toggle,tlist->length,boolean);
  1166.           if (textwindowdefined)
  1167.                 wrefresh (screen);
  1168.           return (tlist -> active);
  1169.           }
  1170.           break;
  1171.  
  1172.     case LBL: for (llist = lbllist; llist != NULLLBL; llist = llist -> next)
  1173.           if ((llist != NULLLBL) && (llist -> id == ptr))
  1174.               drawlblwidget (llist->widget,llist->msg,llist->pos,llist->difference,llist->length-2,boolean);
  1175.           if (textwindowdefined)
  1176.                 wrefresh (screen);
  1177.           return TRUE;
  1178.           break;
  1179.  
  1180.     case INP: for (ilist = inplist; ilist != NULLINP; ilist = ilist -> next)
  1181.           if ((ilist != NULLINP) && (ilist -> id == ptr)) {
  1182.               if (ilist -> active)
  1183.                     drawinpwidget (ilist->widget,ilist->msg,ilist->acpt,ilist->length,boolean,ilist->exec);
  1184.           if (textwindowdefined)
  1185.                 wrefresh (screen);
  1186.           return (ilist -> active);
  1187.           }
  1188.           break;
  1189.  
  1190.     }
  1191.     return FALSE;
  1192. }
  1193.  
  1194. int highlight (ptr)
  1195. /* highlights the given ACTIVE widget */
  1196. WIDGET ptr;
  1197. {
  1198.     return (light (ptr, TRUE));
  1199. }
  1200.  
  1201. int dehighlight (ptr)
  1202. /* dehighlights the given ACTIVE widget */
  1203. WIDGET ptr;
  1204. {
  1205.     return (light (ptr, FALSE));
  1206. }
  1207.  
  1208. home ()
  1209. /* scans the current state of the screen and places the x,y cursor coordinates
  1210.    at the end of widget furthest down and to the right */
  1211. {
  1212.     struct cmdwid *clist = cmdlist;
  1213.     struct lblwid *llist = lbllist;
  1214.     struct tglwid *tlist = tgllist;
  1215.     struct inpwid *ilist = inplist;
  1216.     int           x, y;
  1217.  
  1218.     x = y = 0;
  1219.  
  1220.     /* look through command widgets */
  1221.     while (clist != NULLCMD) {
  1222.     if (clist -> y > y) {
  1223.         y = clist -> y;
  1224.         x = clist->x + clist->length;
  1225.     }
  1226.     else if ((clist->x + clist->length > x) && (clist -> y == y)) {
  1227.         x = clist->x + clist->length;
  1228. }
  1229.        clist = clist -> next;
  1230.     }
  1231.  
  1232.     /* look through toggle widgets */
  1233.     while (tlist != NULLTGL) {
  1234.     if (tlist -> y > y) {
  1235.         y = tlist -> y;
  1236.         x = tlist->x + tlist->length;
  1237.     }
  1238.     else if ((tlist->x + tlist->length > x) && (tlist -> y == y)) {
  1239.         x = tlist->x + tlist->length;
  1240. }
  1241.     tlist = tlist -> next;
  1242.     }
  1243.  
  1244.     /* look through label widgets */
  1245.     while (llist != NULLLBL) {
  1246.     if (llist -> y > y) {
  1247.         y = llist -> y;
  1248.         x = llist->x + llist->length;
  1249.     }
  1250.     else if ((llist->x + llist->length > x) && (llist -> y == y)) {
  1251.         x = llist->x + llist->length;
  1252. }
  1253.     llist = llist -> next;
  1254.     }
  1255.  
  1256.     /* look through input widgets */
  1257.     while (ilist != NULLINP) {
  1258.     if (ilist -> y > y) {
  1259.         y = ilist -> y;
  1260.         x = ilist->x + ilist->length;
  1261.     }
  1262.     else if ((ilist->x + ilist->length > x) && (ilist -> y == y)) {
  1263.         x = ilist->x + ilist->length;
  1264. }
  1265.     ilist = ilist -> next;
  1266.     }
  1267.    
  1268.     /* update screen x,y coordinates */
  1269.     widx = x;
  1270.     widy = y;
  1271. }
  1272.  
  1273. int changelblwidget (ptr, info, pos)
  1274. WIDGET ptr;
  1275. char   info[];
  1276. int    pos;
  1277. {
  1278.     struct lblwid *list = lbllist;
  1279.     int          length = 0;
  1280.  
  1281.     while ((list != NULLLBL) && (list->id != ptr))
  1282.     list = list -> next;
  1283.  
  1284.     if (list == NULLLBL)
  1285.     return FALSE;
  1286.  
  1287.     if (!((pos & CENTRE) || (pos & LEFTJUST) || (pos & RIGHTJUST)))
  1288.     pos = pos|LEFTJUST;
  1289.  
  1290.     /* calculate length of label widget */
  1291.     while (info [length++] != '\0')    
  1292.         ;    
  1293.     length -= 1;
  1294.     if (list->length-2 < length) /* not given enough room so error */
  1295.         return FALSE;
  1296.     
  1297.     list -> difference = list->length-2 - length;
  1298.  
  1299.     strcpy (list -> msg, info);
  1300.     list -> pos = pos;
  1301.     werase (list->widget);
  1302.     drawlblwidget (list->widget,info,pos,list->difference,list->length-2,!(pos & NOHIGH));
  1303.  
  1304.     if (textwindowdefined)
  1305.     wrefresh (screen);
  1306.     return (TRUE);
  1307. }
  1308.  
  1309. endwidgets ()
  1310. /* tidy up at the end */
  1311. {
  1312.     struct cmdwid *clist = cmdlist;
  1313.     struct lblwid *llist = lbllist;
  1314.     struct tglwid *tlist = tgllist;
  1315.     struct inpwid *ilist = inplist;
  1316.  
  1317.     while (clist != NULLCMD) {
  1318.     killcmdwidget (clist -> id);
  1319.         clist = cmdlist;
  1320.     }
  1321.  
  1322.     while (llist != NULLLBL) {
  1323.     killlblwidget (llist -> id);
  1324.     llist = lbllist;
  1325.     }
  1326.  
  1327.     while (tlist != NULLTGL) {
  1328.     killtglwidget (tlist -> id);
  1329.     tlist = tgllist;
  1330.     }
  1331.  
  1332.     while (ilist != NULLINP) {
  1333.     killinpwidget (ilist -> id);
  1334.     ilist = inplist;
  1335.     }
  1336.  
  1337.     killtextwindow ();
  1338.     endwin ();
  1339.     exit (0);
  1340. }
  1341.  
  1342. killtextwindow ()
  1343. /* destroy screen and any borders */
  1344. {
  1345.     if (textwindowdefined) {
  1346.     werase (screen);
  1347.     wrefresh (screen);
  1348.     delwin (screen);
  1349.     textwindowdefined = FALSE;
  1350.     if ((screenborder & VERTICAL) && (screenborder & HORIZONTAL)) {
  1351.         werase (screenbox);
  1352.         wrefresh (screenbox);
  1353.         delwin (screenbox);
  1354.      }
  1355.     else if ((screenborder & VERTICAL) || (screenborder & HORIZONTAL)) {
  1356.         werase (edge1);
  1357.         werase (edge2);
  1358.         wrefresh (edge1);
  1359.         wrefresh (edge2);
  1360.         delwin (edge1);
  1361.         delwin (edge2);
  1362.         }
  1363.     maxwidy = LINES - 2;
  1364.     screenborder = 0;
  1365.     }
  1366. }
  1367.