home *** CD-ROM | disk | FTP | other *** search
- /*--------------------------------------------------------------------------*/
- /* */
- /* XBBS SOURCE CODE copyright (c) 1990 by M. Kimes */
- /* All Rights Reserved */
- /* */
- /* For complete details of the licensing restrictions, please refer */
- /* to the License agreement, which is published in its entirety in */
- /* the in the file LICENSE.XBS. */
- /* */
- /* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
- /* XBBS LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
- /* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
- /* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT M. KIMES */
- /* AT THE ADDRESS LISTED BELOW. IN NO EVENT SHOULD YOU PROCEED TO USE */
- /* THIS FILE WITHOUT HAVING ACCEPTED THE TERMS OF THE XBBS LICENSING */
- /* AGREEMENT, OR SUCH OTHER AGREEMENT AS YOU ARE ABLE TO REACH WITH */
- /* M. KIMES */
- /* */
- /* */
- /* You can contact M. Kimes at the following address: */
- /* */
- /* M. Kimes 1:380/16.0@FidoNet */
- /* 542 Merrick (318)222-3455 data */
- /* Shreveport, LA 71104 */
- /* */
- /* */
- /* Please feel free to contact me at any time to share your comments about */
- /* my software and/or licensing policies. */
- /* */
- /*--------------------------------------------------------------------------*/
-
- /* AWINDOW.C File */
-
- #include <stdio.h>
- #include <ctype.h>
- #include <stdarg.h>
- #include <dos.h>
- #include <alloc.h>
- #include <stdlib.h>
- #include <string.h>
- #include <conio.h>
- #include "awindow.h"
- #include "xkeys.h"
-
- #define TABS 4
- #define ON 1
- #define OFF 0
- #define ERROR -1
-
- /* Local prototypes */
-
- void pascal redraw(WINDOW *wnd);
- void pascal dtitle(WINDOW *wnd);
- int * pascal waddr(WINDOW *wnd,int x,int y);
- void pascal vswap(WINDOW *wnd);
- void pascal vsave(WINDOW *wnd);
- void pascal vrstr(WINDOW *wnd);
- void pascal add_list(WINDOW *wnd);
- void pascal beg_list(WINDOW *wnd);
- void pascal remove_list(WINDOW *wnd);
- void pascal insert_list(WINDOW *w1,WINDOW *w2);
- #ifndef FASTWINDOWS
- int pascal dget(WINDOW *wnd,int x,int y);
- int pascal verify_wnd(WINDOW **w1);
- #endif
-
- #ifdef USEMOUSE
- extern int hcount;
- extern int vcount;
- extern int hysterisis;
- #endif
-
-
- /* Array of border character sets */
-
- struct {
- int nw,ne,se,sw,side,line;
- } wcs[]={
- {218,191,217,192,179,196}, /* single line */
- {201,187,188,200,186,205}, /* double line */
- {214,183,189,211,186,196}, /* single top, double side */
- {213,184,190,212,179,205}, /* double top, single side */
- {194,194,217,192,179,196}, /* pop-down menu */
- {'+','+','+','+','|','-'}, /* std ASCII chars */
- {0,0,0,0,0,0} /* No border */
- };
-
- /* Window structure linked list head & tail */
-
- WINDOW *listhead = NULL;
- WINDOW *listtail = NULL;
-
- WINDOW *ewnd=NULL; /* Global error/note window */
-
- int VSG; /* video segment address */
-
- unsigned int vbase=0;
- unsigned int maxx=80;
- unsigned int maxy=22;
- unsigned char current_color=7;
- unsigned int videomethod=0;
-
- /*
- SCREEN:
- black=0 blue=1 green=2 aqua=3 red=4 magenta=5 yellow=6 white=7
- ANSI:
- 30 black foreground 40 black background
- 31 red foreground 41 red background
- 32 green foreground 42 green background
- 33 yellow foreground 43 yellow background
- 34 blue foreground 44 blue background
- 35 magenta foreground 45 magenta foreground
- 36 cyan foreground 46 cyan background
- 37 white foreground 47 white background
- */
-
- char ansifg[8][4]={"30;","34;","32;","36;","31;","35;","33;","37;"};
- char ansibg[8][4]={"40m","44m","42m","46m","41m","45m","43m","47m"};
-
- extern char cdecl gprintf(char,char *,...);
- extern char pascal printm(char *);
-
- extern unsigned int baud;
-
-
-
- /* Establish a new window */
-
- WINDOW * pascal establish_window (int x,int y,int h,int w) {
-
- WINDOW *wnd;
-
- VSG=(vmode()==7 ? 0xb000: 0xb800);
- if ((wnd=(WINDOW *) mmalloc(sizeof(WINDOW)))==NULL) return NULL;
-
- /* Adjust for out-of-bounds parameters */
-
- WTITLE="";
- HEIGHT=min(h,maxy);
- WIDTH=min(w,maxx);
- COL=max(0,min(x,maxx-WIDTH));
- ROW=max(0,min(y,maxy-HEIGHT));
- WCURS=0;
- SCROLL=0;
- SELECT=1;
- BTYPE=0;
- VISIBLE=HIDDEN=0;
- PREV=NEXT=NULL;
- FHEAD=FTAIL=NULL;
- WBORDER=WNORMAL=PNORMAL=WTITLEC=clr(BLACK,WHITE,BRIGHT);
- WACCENT=clr(WHITE,BLACK,DIM);
- if ((SAV=mmalloc(WIDTH * HEIGHT * 2))==(char *)0) {
- ffree(wnd);
- return NULL;
- }
- add_list(wnd);
- #ifndef FASTWINDOWS
- clear_window(wnd);
- wframe(wnd);
- #endif
- return(wnd);
- }
-
-
- /* Establish screen as window */
-
- WINDOW * pascal establish_screen (int x, int y, int h, int w) {
-
- WINDOW *wnd;
-
- VSG=(vmode()==7 ? 0xb000: 0xb800);
- if ((wnd=(WINDOW *) mmalloc(sizeof(WINDOW)))==NULL) return NULL;
- WTITLE="";
- HEIGHT=min(h,maxy);
- WIDTH=min(w,maxx);
- COL=max(0,min(x,maxx-WIDTH));
- ROW=max(0,min(y,maxy-HEIGHT));
- WCURS=0;
- SCROLL=min(h,maxy);
- SCROLL-=2;
- SELECT=0;
- BTYPE=6;
- VISIBLE=1;
- HIDDEN=0;
- PREV=NEXT=NULL;
- FHEAD=FTAIL=NULL;
- WBORDER=WNORMAL=PNORMAL=WTITLEC=clr(BLACK,WHITE,BRIGHT);
- WACCENT=clr(WHITE,BLACK,DIM);
- if ((SAV=mmalloc(WIDTH * HEIGHT * 2))==(char *)0) {
- ffree(wnd);
- return NULL;
- }
- add_list(wnd);
- return(wnd);
- }
-
-
- /* Set the window's border */
-
- void pascal set_border (WINDOW *wnd,int btype) {
-
- if (verify_wnd(&wnd)) {
- BTYPE=btype;
- redraw(wnd);
- }
- }
-
- /* Set colors */
-
- void pascal set_colors (WINDOW *wnd,int area,int bg,int fg,int inten) {
-
- if (vmode()==7) {
- if (bg != WHITE && bg !=BLACK) return;
- if (fg !=WHITE && fg!=BLACK) return;
- }
- if(fg==bg) return;
- if (verify_wnd(&wnd)) {
- if (area==ALL){
- while (area) WCOLOR[--area]=clr(bg,fg,inten);
- }
- else WCOLOR[area]=clr(bg,fg,inten);
- redraw (wnd);
- }
- }
-
- /* Set intensity of window */
-
- void pascal set_intensity (WINDOW *wnd,int inten) {
-
- int area=ALL;
-
- if (verify_wnd(&wnd)) {
- while (area) {
- WCOLOR[--area]&= ~BRIGHT;
- WCOLOR[area] |= inten;
- }
- redraw(wnd);
- }
- }
-
- /* Set title */
-
- void pascal set_title (WINDOW *wnd,char *title) {
- if (verify_wnd(&wnd)) {
- WTITLE=title;
- redraw(wnd);
- }
- }
-
- /* Redraw a window when an attribute changes */
-
- static void pascal redraw (WINDOW *wnd) {
-
- #ifndef FASTWINDOWS
- int x,y,chat,atr;
-
- for (y=1-(BTYPE==6);y<HEIGHT-(1-(BTYPE==6));y++)
- for (x=1-(BTYPE==6);x<WIDTH-(1-(BTYPE==6));x++) {
- chat=dget(wnd,x,y);
- atr=(((chat>>8)&255) == PNORMAL ? WNORMAL : WACCENT);
- displ(wnd,x,y,chat&255,atr);
- }
- wframe(wnd);
- #endif
- PNORMAL=WNORMAL;
- }
-
- /* Display an established window */
-
- void pascal display_window (WINDOW *wnd) {
-
- if (verify_wnd(&wnd)&& !VISIBLE) {
- VISIBLE=1;
- #ifdef FASTWINDOWS
- if (HIDDEN) {
- HIDDEN=0;
- vrstr(wnd);
- wframe(wnd);
- }
- else {
- vsave (wnd);
- clear_window(wnd);
- wframe(wnd);
- }
- #else
- vswap(wnd);
- #endif
- }
- }
-
- /* Close all windows */
-
- void pascal close_all() {
-
- WINDOW *sav,*wnd=listtail;
-
- while(wnd) {
- sav=PREV;
- delete_window(wnd);
- wnd=sav;
- }
- }
-
- /* Remove a window */
-
- void pascal delete_window (WINDOW *wnd) {
-
- if (verify_wnd(&wnd)) {
- if(BTYPE!=6) hide_window(wnd);
- ffree(SAV);
- remove_list(wnd); /* remove window from list */
- ffree(wnd);
- }
- }
-
- /* Hide a window */
-
- void pascal hide_window (WINDOW *wnd) {
-
- if (verify_wnd(&wnd) && VISIBLE) {
- #ifndef FASTWINDOWS
- vswap(wnd);
- #else
- vrstr(wnd);
- #endif
- HIDDEN=1;
- VISIBLE=0;
- }
- }
-
- #ifndef FASTWINDOWS
-
- /* Reposition the window in its 3-axis plane */
-
- void pascal repos_wnd(WINDOW *wnd,int x,int y,int z) {
-
- WINDOW *twnd;
- int x1,y1,chat;
-
- if (!verify_wnd(&wnd)) return;
- twnd=establish_window(x+COL,y+ROW,HEIGHT,WIDTH);
- twnd->_tl=WTITLE;
- twnd->btype=BTYPE;
- twnd->wcolor[BORDER]=WBORDER;
- twnd->wcolor[TITLE]=WTITLEC;
- twnd->wcolor[ACCENT]=WACCENT;
- twnd->wcolor[NORMAL]=WNORMAL;
- twnd->_wsp=SCROLL;
- twnd->_cr=WCURS;
- if (z!=1) {
- remove_list(twnd);
- if (z==0)
- insert_list(twnd,wnd);
- else
- beg_list(twnd);
- }
- for(y1=0;y1<twnd->_wh;y1++)
- for (x1=0;x1<twnd->_ww;x1++) {
- chat = dget(wnd,x1,y1);
- displ(twnd,x1,y1,chat&255,(chat>>8)&255);
- }
- twnd->_wv=1;
- vswap(twnd);
- hide_window(wnd);
- ffree(SAV);
- remove_list(wnd);
- *wnd=*twnd;
- insert_list(wnd,twnd);
- remove_list(twnd);
- ffree(twnd);
- }
- #endif
-
- /* Clear window */
-
- void pascal clear_window (WINDOW *wnd) {
-
- register int x1,y1;
-
- if (verify_wnd(&wnd))
- for(y1=1-(BTYPE==6);y1<HEIGHT-(1-(BTYPE==6));y1++)
- for(x1=1-(BTYPE==6);x1<WIDTH-(1-(BTYPE==6));x1++)
- displ(wnd,x1,y1,' ',WNORMAL);
- }
-
- /* Draw the window frame */
-
- void pascal wframe (WINDOW *wnd) {
-
- register int x1,y1;
-
- if (!verify_wnd(&wnd)) return;
- if (BTYPE==6) return;
- /* Window title */
- displ(wnd,0,0,NW,WBORDER);
- dtitle(wnd);
- displ(wnd,WIDTH-1,0,NE,WBORDER);
- /* Window sides */
- for (y1=1;y1<HEIGHT-1;y1++) {
- displ(wnd,0,y1,SIDE,WBORDER);
- displ(wnd,WIDTH-1,y1,SIDE,WBORDER);
- }
- /* Bottom of frame */
- displ(wnd,0,y1,SW,WBORDER);
- for(x1=1;x1<WIDTH-1;x1++)
- displ(wnd,x1,y1,LINE,WBORDER);
- displ(wnd,x1,y1,SE,WBORDER);
- }
-
-
- static void pascal dtitle (WINDOW *wnd) {
-
- int x1=1,i,ln;
- char *s=WTITLE;
-
- if (!verify_wnd(&wnd)) return;
- if (BTYPE==6) return;
- if (s) {
- ln=strlen(s);
- if (ln>WIDTH-2) i=0;
- else i=((WIDTH-2-ln)/2);
- if (i>0) {
- while (i--) displ(wnd,x1++,0,LINE,WBORDER);
- }
- while(*s && x1<WIDTH-1) displ(wnd,x1++,0,*s++,WTITLEC);
- }
- while(x1<WIDTH-1) displ(wnd,x1++,0,LINE,WBORDER);
- }
-
- /* Window-oriented printf */
-
- void cdecl wprintf (WINDOW *wnd,char *ln,...) {
-
- char dlin[100],*dl=dlin;
-
- if (verify_wnd(&wnd)) {
- va_list ap;
- va_start(ap,ln);
- vsprintf(dlin,ln,ap);
- va_end(ap);
- while(*dl) wputchar(wnd,*dl++);
- }
- }
-
-
- /* Window-oriented 'raw' printf */
-
- void cdecl wprintfraw (WINDOW *wnd,char *ln,...) {
-
- char dlin[100],*dl=dlin;
-
- if (verify_wnd(&wnd)) {
- va_list ap;
- va_start(ap,ln);
- vsprintf(dlin,ln,ap);
- va_end(ap);
- while(*dl) wputchar(wnd,*dl++);
- }
- }
-
- /* Write a character to the window */
-
- void pascal wputchar (WINDOW *wnd,int c) {
-
- if (!verify_wnd(&wnd)) return;
- switch(c) {
- case '\n':
- if (SCROLL==HEIGHT-(3-(BTYPE==6))) scroll(wnd,UP);
- else SCROLL++;
- WCURS=0;
- break;
- case '\t':
- do displ(wnd,(WCURS++)+3,SCROLL+1,' ',WNORMAL);
- while ((WCURS%TABS) && (WCURS+1)<WIDTH-1);
- break;
- default:
- if ((WCURS+1)<WIDTH-(1*(BTYPE!=6))) {
- displ(wnd,WCURS+(1-(BTYPE==6)),SCROLL+(1-(BTYPE==6)),c,WNORMAL);
- WCURS++;
- }
- break;
- }
- }
-
-
- /* Write a raw character to the window */
-
- void pascal wputcharaw (WINDOW *wnd,int c) {
-
- if (!verify_wnd(&wnd)) return;
- if ((WCURS+1)<WIDTH-1) {
- displ(wnd,WCURS+(1-(BTYPE==6)),SCROLL+(1-(BTYPE==6)),c,WNORMAL);
- WCURS++;
- }
- }
-
- /* Set window cursor */
-
- void pascal wcursor (WINDOW *wnd,int x,int y) {
-
- if (verify_wnd(&wnd) && x<WIDTH-(1-(BTYPE==6)) && y<HEIGHT-(1-(BTYPE==6))) {
- WCURS=x;
- SCROLL=y;
- if(!baud) cursor(COL+x+(1-(BTYPE==6)),ROW+y+(1-(BTYPE==6)));
- else gprintf(0,"\x1b[%d;%dH",ROW+y+1+(1-(BTYPE==6)),COL+x+1+(1-(BTYPE==6)));
- }
- }
-
- /* Allow user to select from window */
-
- int pascal get_selection (WINDOW *wnd,int s,char *keys) {
-
- int c=0,ky;
- #ifdef USEMOUSE
- int temph,tempv;
- #endif
-
- if (!verify_wnd(&wnd)) return(0);
- #ifdef USEMOUSE
- temph=hcount;
- tempv=vcount;
- hcount=2*hysterisis;
- vcount=hysterisis;
- #endif
- SELECT=s;
- while (c !=ESC && c!='\r' && c !=BS && c!=FWD) {
- accent(wnd);
- c=get_char();
- deaccent(wnd);
- switch(c) {
- case '8':
- case UP: if (SELECT > 1-(BTYPE==6)) SELECT --;
- else SELECT = SCROLL+1;
- break;
- case '2':
- case DN: if (SELECT < SCROLL+1) SELECT++;
- else SELECT=1-(BTYPE==6);
- break;
- case HOME:
- case CTRL_HOME:
- case END:
- case CTRL_END:
- case PGUP:
- case PGDN:
- #ifdef USEMOUSE
- hcount=temph;
- vcount=tempv;
- #endif
- return c;
- case FWD:
- case '6': return 205;
- case BS:
- case '4': return 203;
- case 0: c='\r';
- case '\r':
- case ESC:
- case CTRL_K:
- break;
- default: if (keys) {
- ky=0;
- while(*(keys+ky)) {
- if (*(keys+ky)==toupper(c) || *(keys+ky)==tolower(c)) {
- #ifdef USEMOUSE
- hcount=temph;
- vcount=tempv;
- #endif
- return ky+1;
- }
- ky++;
- }
- }
- break;
- }
- }
- #ifdef USEMOUSE
- hcount=temph;
- vcount=tempv;
- #endif
- return (c=='\r' || c==0) ? (SELECT + (BTYPE==6)) : c==ESC ? 0 : c;
- }
-
- union REGS rg;
-
- /* Scroll a window's contents up or down */
-
- void pascal scroll (WINDOW *wnd,int dir) {
-
- int row=HEIGHT-(1-(BTYPE==6)),col,chat;
-
- if (!verify_wnd(&wnd)) return;
-
- if (NEXT == NULL && HEIGHT > 3-((BTYPE==6)*2) && VISIBLE && !baud) {
- rg.h.ah=dir==UP ? 6:7;
- rg.h.al=1;
- rg.h.bh=WNORMAL;
- rg.h.cl=COL+(1-(BTYPE==6));
- rg.h.ch=ROW+(1-(BTYPE==6));
- rg.h.dl=COL+WIDTH-(2*(BTYPE!=6));
- rg.h.dh=ROW+HEIGHT-(2*(BTYPE!=6));
- int86(16,&rg,&rg);
- return;
- }
-
- if (dir==UP) {
- for (row=(2*(BTYPE!=6));row<HEIGHT-(1+((BTYPE==6)* -2));row++)
- for (col = 1-(BTYPE==6);col<WIDTH-(1+((BTYPE==6)* -2));col++) {
- chat=dget(wnd,col,row);
- displ(wnd,col,row-1,chat&255,(chat>>8)&255);
- }
- for (col=1-(BTYPE==6);col<WIDTH-(1+((BTYPE==6)* -2));col++)
- displ(wnd,col,row-1,' ',WNORMAL);
- }
- else {
- for (row=HEIGHT-(2*(BTYPE==6));row>1-(BTYPE==6);--row)
- for(col=1-(BTYPE==6);col<WIDTH-(1+(BTYPE==6)* -2);col++) {
- chat=dget(wnd,col,row-1);
- displ(wnd,col,row,chat&255,(chat>>8)&255);
- }
- for (col=1-(BTYPE==6);col < WIDTH-(1+(BTYPE==6)* -2);col++)
- displ(wnd,col,row,' ',WNORMAL);
- }
- }
-
- #ifndef FASTWINDOWS
-
- /* Compute address of a window's display character */
-
- static int * pascal waddr (WINDOW *wnd,int x,int y) {
-
- WINDOW *nxt=NEXT;
- int *vp;
-
- if (!VISIBLE) return(int *) (SAV+y*(WIDTH*2)+x*2);
- x+=COL;
- y+=ROW;
- while(nxt) {
- if (nxt->_wv) {
- if (x>=nxt->_wx && x<= nxt->_wx+nxt->_ww-1)
- if (y>=nxt->_wy && y<=nxt->_wy +nxt->_wh-1) {
- x-=nxt->_wx;
- y-=nxt->_wy;
- vp=(int *) ((nxt->_ws)+y*(nxt->_ww*2)+x*2);
- return vp;
- }
- }
- nxt=nxt->_nx;
- }
- return NULL;
- }
-
- #endif
-
- /* Display a character to a window */
-
- void pascal displ (WINDOW *wnd,int x,int y,int ch,int at) {
-
- int *vp;
- int vch = (ch & 255) | (at<<8);
- int fg,bg,in,fl;
- char s[24];
- static int last_at=0;
- static int last_x=0;
- static int last_y=0;
-
- #ifndef FASTWINDOWS
-
- if((vp=waddr(wnd,x,y))!=NULL) *vp=vch;
- else {
-
- #endif
- if(!baud) {
- vpoke(VSG,vad(x+COL,y+ROW),vch);
- return;
- }
- else {
- if(last_x!=x+COL+1 || last_y!=y+ROW+1)
- gprintf(0,"\x1b[%d;%dH",y+ROW+1,x+COL+1);
- if(last_at!=at) {
- fg=at & 7; /* Foreground */
- bg=((at & (~7))>>4); /* Background */
- in=at & 8; /* Intensity */
- fl=at & 128; /* Flash */
- strcpy(s,"\x1b[0;");
- if(in) {
- strcat(s,"1;");
- }
- else strcat(s,"2;");
- if(fl) {
- strcat(s,"5;");
- }
- strcat(s,ansifg[fg]);
- strcat(s,ansibg[bg]);
- printm(s);
- }
- gprintf(0,"%c",(char)ch);
- }
-
- #ifndef FASTWINDOWS
-
- }
-
- #endif
-
- last_x=wherex();
- last_y=wherey();
- last_at=at;
-
- }
-
- #ifndef FASTWINDOWS
-
- /* Get a displayed character from a window */
-
- static int pascal dget (WINDOW *wnd,int x,int y) {
-
- int *vp;
-
- if((vp=waddr(wnd,x,y))!=NULL) return *vp;
- return vpeek(VSG,vad(x+COL,y+ROW));
- }
-
- /* Low-level video functions */
-
- /* Swap the video image with the save buffer */
-
- static void pascal vswap (WINDOW *wnd) {
-
- int x,y,chat;
- int *bf=(int *)SAV;
-
- for (y=0;y<HEIGHT;y++)
- for (x=0;x<WIDTH;x++) {
- chat=*bf;
- *bf++=dget(wnd,x,y);
- displ(wnd,x,y,chat&255,(chat>>8)&255);
- }
- }
-
- #else
-
- /* Save video memory into the save buffer */
-
- static void pascal vsave (WINDOW *wnd) {
-
- int x,y;
- int *bf=(int *) SAV;
-
- for(y=0;y<HEIGHT;y++)
- for(x=0;x<WIDTH;x++)
- *bf++=vpeek(VSG,vad(x+COL,y+ROW));
- }
-
- /* Restore video memory from the save buffer */
-
- static void pascal vrstr (WINDOW *wnd) {
-
- int x,y;
- int *bf=(int *)SAV;
-
- for(y=0;y<HEIGHT;y++) {
- for (x=0;x<WIDTH;x++) {
- if(!baud) vpoke(VSG,vad(x+COL,y+ROW),*bf++);
- else {
- displ(wnd,x,y,*bf&255,(*bf>>8)&255);
- bf++;
- }
- }
- }
- }
-
- #endif
-
- /* (de)Accent the line where SELECT points */
-
- void pascal acline (WINDOW *wnd,int set) {
-
- int x,ch;
- int at;
- char al,ah;
-
- if (!verify_wnd(&wnd)) return;
- for(x=1-(BTYPE==6);x<WIDTH-(1-(BTYPE==6));x++) {
- if(BTYPE!=6) {
- ch=dget(wnd,x,SELECT) & 255;
- displ(wnd,x,SELECT,ch,set);
- }
- else {
- ch=dget(wnd,x,SELECT);
- at=(ch>>8)&255; /* Invert attribute */
- al=(at>>4)&255;
- ah=(at<<4)&255;
- at=al+ah;
- displ(wnd,x,SELECT,ch&255,at&255);
-
- }
- }
- }
-
- /* Linked List functions */
-
- /* Add a window to the end of the list */
-
- static void pascal add_list (WINDOW *wnd) {
-
- if(listtail) {
- PREV=listtail;
- listtail->_nx=wnd;
- }
- listtail=wnd;
- if (!listhead)
- listhead=wnd;
- }
-
- /* Add a window to the beginning of the list */
-
- static void pascal beg_list(WINDOW *wnd) {
-
- if(listhead) {
- NEXT=listhead;
- listhead->_pv=wnd;
- }
- listhead=wnd;
- if(!listtail) listtail=wnd;
- }
-
- /* Remove a window from the list */
-
- static void pascal remove_list (WINDOW *wnd) {
-
- if(NEXT) NEXT->_pv=PREV;
- if(PREV) PREV->_nx=NEXT;
- if (listhead==wnd) listhead=NEXT;
- if (listtail==wnd) listtail=PREV;
- NEXT=PREV=NULL;
- }
-
- /* Insert w1 after w2 */
-
- static void pascal insert_list (WINDOW *w1,WINDOW *w2) {
-
- w1->_pv=w2;
- w1->_nx=w2->_nx;
- w2->_nx=w1;
- if (w1->_nx==NULL) listtail=w1;
- else w1->_nx->_pv=w1;
- }
-
- #ifndef FASTWINDOWS
-
- /* Verify the presence of a window in the list */
-
- static int pascal verify_wnd (WINDOW **w1) {
-
- WINDOW *wnd;
-
- wnd=listhead;
- if(*w1==NULL) *w1=listtail;
- else {
- while(wnd !=NULL) {
- if(*w1==wnd) break;
- wnd=NEXT;
- }
- }
- return wnd != NULL;
- }
-
- #endif
-
-
- /* Error/misc messages */
-
- void pascal error_message (char *s) {
-
- clear_message();
- ewnd=establish_window(50,(maxy-3),3,max(10,strlen(s)+2));
- set_colors(ewnd,ALL,RED,YELLOW,BRIGHT);
- set_colors(ewnd,TITLE,RED,YELLOW,BRIGHT|128);
- set_title(ewnd," ERROR! ");
- display_window(ewnd);
- wprintf(ewnd,s);
- }
-
- void pascal any_message (char *s) {
-
- clear_message();
- ewnd=establish_window(65,(maxy-4),3,max(9,strlen(s)+2));
- set_border(ewnd,2);
- set_colors(ewnd,ALL,AQUA,BLACK,DIM);
- set_title(ewnd," NOTE: ");
- display_window(ewnd);
- wprintf(ewnd,s);
- }
-
- void pascal _anymsg (char *t,char *s) {
-
- clear_message();
- ewnd=establish_window(65,(maxy-4),3,max(strlen(s),strlen(t))+2);
- set_border(ewnd,2);
- set_colors(ewnd,ALL,AQUA,BLACK,DIM);
- set_title(ewnd,t);
- display_window(ewnd);
- wprintf(ewnd,s);
- }
-
- void pascal clear_message() {
-
- if (ewnd) delete_window(ewnd);
- ewnd=NULL;
- }
-