--- sbbs/uifc/uifc.c 2018/04/24 16:37:52 1.1.1.1 +++ sbbs/uifc/uifc.c 2018/04/24 16:37:53 1.1.1.2 @@ -1,14 +1,22 @@ #line 1 "UIFC.C" +/* Developed 1990-1997 by Rob Swindell; PO Box 501, Yorba Linda, CA 92885 */ + #include "UIFC.h" +#include +#if defined(__OS2__) -#if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__) -#define MALLOC farmalloc -#define FREE farfree -#else -#define MALLOC malloc -#define FREE free +#define INCL_BASE +#include + +void mswait(int msec) +{ +DosSleep(msec ? msec : 1); +} + +#elif defined(__FLAT__) + #define mswait(x) delay(x) #endif /* Bottom line elements */ @@ -17,38 +25,105 @@ #define BL_GET (1<<2) /* Get key */ #define BL_PUT (1<<3) /* Put key */ +#define HELP 1 -char hclr,lclr,bclr,cclr,scrn_len,savnum=0 +char hclr,lclr,bclr,cclr,scrn_len,savnum=0,show_free_mem=0 + ,helpdatfile[256]="" + ,helpixbfile[256]="" + ,*helpfile=0,*helpbuf=0 ,blk_scrn[MAX_BFLN],savdepth=0,changes=0,uifc_status=0; win_t sav[MAX_BUFS]; -uint cursor; +uint cursor,helpline=0,max_opts=MAX_OPTS; extern int daylight=0; +extern long timezone=0; void bottomline(int line); +#ifdef __FLAT__ +int inkey(int mode) +{ + int c; + +if(mode) + return(kbhit()); +c=getch(); +if(!c) + c=(getch()<<8); +return(c); +} +#else +int inkey(int mode) +{ +if(mode) + return(bioskey(1)); +while(!bioskey(1)); +return(bioskey(0)); +} +#endif + +uint mousecursor=0x28; + void uifcini() { int i; struct text_info txtinfo; +#ifndef __FLAT__ + union REGS r; +#endif + +putenv("TZ=UCT0"); /* Fix for Watcom C++ EDT default */ gettextinfo(&txtinfo); -if(txtinfo.currmode==7) /* returns 0607h on hercules - incorrect */ - cursor=0x0b0c; -else - cursor=getcursortype(); -scrn_len=lclini(5<<8)-1; -lputc(FF); + +scrn_len=txtinfo.screenheight; +scrn_len--; +clrscr(); if(scrn_len>50) { - lputs("\7UIFC: Can't operate in video modes beyond 80x50\r\n"); + cputs("\7UIFC: Can't operate in video modes beyond 80x50\r\n"); exit(1); } -setcursortype(NO_CURSOR); -if(txtinfo.currmode==2 || txtinfo.currmode==7) { + +if(txtinfo.screenwidth<80) { + cputs("\7UIFC: Can't operate in video modes less than 80x25\r\n"); + exit(1); } + +#ifndef __FLAT__ + +r.w.ax=0x0000; /* reset mouse and get driver status */ +INT_86(0x33,&r,&r); + +if(r.w.ax==0xffff) { /* mouse driver installed */ + uifc_status|=UIFC_MOUSE; + + + r.w.ax=0x0020; /* enable mouse driver */ + INT_86(0x33,&r,&r); + + r.w.ax=0x000a; /* set text pointer type */ + r.w.bx=0x0000; /* software cursor */ + r.w.cx=0x77ff; + r.w.dx=mousecursor<<8; + INT_86(0x33,&r,&r); + + r.w.ax=0x0013; /* set double speed threshold */ + r.w.dx=32; /* double speed threshold */ + INT_86(0x33,&r,&r); + + r.w.ax=0x0001; /* show mouse pointer */ + INT_86(0x33,&r,&r); } + +#endif + + +if(!(uifc_status&UIFC_COLOR) + && (uifc_status&UIFC_MONO + || txtinfo.currmode==MONO || txtinfo.currmode==BW80)) { bclr=BLACK; hclr=WHITE; lclr=LIGHTGRAY; cclr=LIGHTGRAY; } else { + textmode(C80); bclr=BLUE; hclr=YELLOW; lclr=WHITE; @@ -56,19 +131,68 @@ else { for(i=0;i<8000;i+=2) { blk_scrn[i]='°'; blk_scrn[i+1]=cclr|(bclr<<4); } + +cursor=_NOCURSOR; +_setcursortype(cursor); + +} + +void hidemouse(void) +{ +#ifndef __FLAT__ + union REGS r; + +if(uifc_status&UIFC_MOUSE) { + r.w.ax=0x0002; /* hide mouse pointer */ + INT_86(0x33,&r,&r); } +#endif +} + +void showmouse(void) +{ +#ifndef __FLAT__ + union REGS r; + +if(uifc_status&UIFC_MOUSE) { + r.w.ax=0x0001; /* show mouse pointer */ + INT_86(0x33,&r,&r); } +#endif +} + + +void uifcbail(void) +{ + +hidemouse(); +_setcursortype(_NORMALCURSOR); +textattr(LIGHTGRAY); +clrscr(); +} + +int uscrn(char *str) +{ + +textattr(bclr|(cclr<<4)); +gotoxy(1,1); +clreol(); +gotoxy(3,1); +cputs(str); +if(!puttext(1,2,80,scrn_len,blk_scrn)) + return(-1); +gotoxy(1,scrn_len+1); +clreol(); +return(0); } -void uscrn(char *str) +void scroll_text(int x1, int y1, int x2, int y2, int down) { -lclatr(bclr|(cclr<<4)); -lclxy(1,1); -lputc(CLREOL); -lclxy(3,1); -lputs(str); -lclini(scrn_len); -puttext(1,2,80,scrn_len,blk_scrn); -lclxy(1,scrn_len+1); -lputc(CLREOL); + uchar buf[MAX_BFLN]; + +gettext(x1,y1,x2,y2,buf); +if(down) + puttext(x1,y1+1,x2,y2,buf); +else + puttext(x1,y1,x2,y2-1,buf+(((x2-x1)+1)*2)); } /**************************************************************************/ @@ -80,34 +204,52 @@ lputc(CLREOL); /* option is an array of char arrays, first element of last char array */ /* must be NULL. */ /**************************************************************************/ -int ulist(int mode, char left, char top, char width, int *cur - , char *title, char option[][MAX_OPLN]) +int ulist(int mode, char left, int top, char width, int *cur, int *bar + , char *title, char **option) { - char line[160],height,y,shade[160],win[MAX_BFLN],*ptr,a,b,c,longopt - ,search[MAX_OPLN]; + uchar line[256],shade[256],win[MAX_BFLN],*ptr,a,b,c,longopt + ,search[MAX_OPLN],bline=0; + int height,y; int i,j,opts=0,s=0; /* s=search index into options */ - union REGS reg; + +#ifndef __FLAT__ + union REGS reg,r; + +hidemouse(); + +r.w.ax=0x0006; /* Get button release info */ +r.w.bx=0x0000; /* Left button */ +INT_86(0x33,&r,&r); /* Clears any buffered mouse clicks */ + +r.w.ax=0x0006; /* Get button release info */ +r.w.bx=0x0001; /* Right button */ +INT_86(0x33,&r,&r); /* Clears any buffered mouse clicks */ + +#endif if(mode&WIN_SAV && savnum>=MAX_BUFS-1) - lputc(7); + putch(7); i=0; -if(mode&WIN_INS) i|=BL_INS; -if(mode&WIN_DEL) i|=BL_DEL; -if(mode&WIN_GET) i|=BL_GET; -if(mode&WIN_PUT) i|=BL_PUT; -bottomline(i); -while(optsscrn_len-3) height=(scrn_len-3)-top; -if(!width) { +if(!width || widthwidth) - width=j; } + width=j; } } if(width>(SCRN_RIGHT+1)-SCRN_LEFT) width=(SCRN_RIGHT+1)-SCRN_LEFT; if(mode&WIN_L2R) @@ -120,42 +262,44 @@ else if(mode&WIN_BOT) top=scrn_len-height-3-top; if(mode&WIN_SAV && savdepth==savnum) { if((sav[savnum].buf=(char *)MALLOC((width+3)*(height+2)*2))==NULL) { - lprintf("UIFC: error allocating %u bytes.",(width+3)*(height+2)*2); + cprintf("UIFC: error allocating %u bytes.",(width+3)*(height+2)*2); return(-1); } - gettext(SCRN_LEFT+left,SCRN_TOP+top,SCRN_LEFT+left+width+2 - ,SCRN_TOP+top+height+1,sav[savnum].buf); + gettext(SCRN_LEFT+left,SCRN_TOP+top,SCRN_LEFT+left+width+1 + ,SCRN_TOP+top+height,sav[savnum].buf); sav[savnum].left=SCRN_LEFT+left; sav[savnum].top=SCRN_TOP+top; - sav[savnum].right=SCRN_LEFT+left+width+2; - sav[savnum].bot=SCRN_TOP+top+height+1; + sav[savnum].right=SCRN_LEFT+left+width+1; + sav[savnum].bot=SCRN_TOP+top+height; savdepth++; } else if(mode&WIN_SAV && (sav[savnum].left!=SCRN_LEFT+left || sav[savnum].top!=SCRN_TOP+top - || sav[savnum].right!=SCRN_LEFT+left+width+2 - || sav[savnum].bot!=SCRN_TOP+top+height+1)) { /* dimensions have changed */ + || sav[savnum].right!=SCRN_LEFT+left+width+1 + || sav[savnum].bot!=SCRN_TOP+top+height)) { /* dimensions have changed */ puttext(sav[savnum].left,sav[savnum].top,sav[savnum].right,sav[savnum].bot ,sav[savnum].buf); /* put original window back */ FREE(sav[savnum].buf); if((sav[savnum].buf=(char *)MALLOC((width+3)*(height+2)*2))==NULL) { - lprintf("UIFC: error allocating %u bytes.",(width+3)*(height+2)*2); + cprintf("UIFC: error allocating %u bytes.",(width+3)*(height+2)*2); return(-1); } - gettext(SCRN_LEFT+left,SCRN_TOP+top,SCRN_LEFT+left+width+2 - ,SCRN_TOP+top+height+1,sav[savnum].buf); /* save again */ + gettext(SCRN_LEFT+left,SCRN_TOP+top,SCRN_LEFT+left+width+1 + ,SCRN_TOP+top+height,sav[savnum].buf); /* save again */ sav[savnum].left=SCRN_LEFT+left; sav[savnum].top=SCRN_TOP+top; - sav[savnum].right=SCRN_LEFT+left+width+2; - sav[savnum].bot=SCRN_TOP+top+height+1; } + sav[savnum].right=SCRN_LEFT+left+width+1; + sav[savnum].bot=SCRN_TOP+top+height; } -/*** -lclxy(58,1); /* print available memory after allocating */ -lclatr(bclr|(cclr<<4)); -#if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__) -lprintf("%10ld bytes free",farcoreleft()); -#else -lprintf("%10u bytes free",coreleft()); + +#ifndef __OS2__ +if(show_free_mem) { + #if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__) + uprintf(58,1,bclr|(cclr<<4),"%10ld bytes free",farcoreleft()); + #else + uprintf(58,1,bclr|(cclr<<4),"%10u bytes free",coreleft()); + #endif + } #endif -***/ + if(mode&WIN_ORG) { /* Clear around menu */ if(top) @@ -171,7 +315,24 @@ if(mode&WIN_ORG) { /* Clear around menu ptr=win; *(ptr++)='É'; *(ptr++)=hclr|(bclr<<4); -for(i=0;i=opts) - (*cur)=opts-1; -if((*cur)>height-5) - (*cur)=height-5; + (*cur)=opts-1; /* returned after scrolled */ + +if(!bar) { + if((*cur)>height-5) + (*cur)=height-5; + i=0; } +else { + if((*bar)>=opts) + (*bar)=opts-1; + if((*bar)>height-5) + (*bar)=height-5; + if((*cur)==opts-1) + (*bar)=height-5; + if((*bar)<0) + (*bar)=0; + if((*cur)<(*bar)) + (*cur)=(*bar); + i=(*cur)-(*bar); +// + if(i+(height-5)>=opts) { + i=opts-(height-4); + (*cur)=i+(*bar); + } + } if((*cur)<0) (*cur)=0; -i=0; + +j=0; +if(i<0) i=0; longopt=0; -while(iheight && (*cur)!=opts-1) { - lclxy(SCRN_LEFT+left+1,SCRN_TOP+top+height-2); - lclatr(lclr|(bclr<<4)); - lputc(31); /* put down arrow */ - lclatr(hclr|(bclr<<4)); } +if(bar) + y=top+3+(*bar); +else + y=top+3+(*cur); +if(opts+4>height && ((!bar && (*cur)!=opts-1) + || (bar && ((*cur)-(*bar))+(height-4)=SCRN_LEFT+left + && r.w.cx/8<=SCRN_LEFT+left+width + && r.w.dx/8>=SCRN_TOP+top+2 + && r.w.dx/8<=(SCRN_TOP+top+height)-3) { + + hidemouse(); + gettext(SCRN_LEFT+3+left,SCRN_TOP+y + ,SCRN_LEFT+left+width-2,SCRN_TOP+y,line); + for(i=1;i=SCRN_LEFT+left + && r.w.cx/8<=SCRN_LEFT+left+width + && r.w.dx/8>=SCRN_TOP+top+2 + && r.w.dx/8<=(SCRN_TOP+top+height)-3) { + + (*cur)=(r.w.dx/8)-(SCRN_TOP+top+2); + if(bar) + (*bar)=(*cur); + y=top+3+((r.w.dx/8)-(SCRN_TOP+top+2)); + + if(!opts || (mode&WIN_XTR && (*cur)==opts-1)) + continue; + + if(mode&WIN_ACT) { + hidemouse(); + gettext(SCRN_LEFT+left,SCRN_TOP+top,SCRN_LEFT + +left+width-1,SCRN_TOP+top+height-1,win); + for(i=1;i<(width*height*2);i+=2) + win[i]=lclr|(cclr<<4); + j=(((y-top)*width)*2)+7+((width-4)*2); + for(i=(((y-top)*width)*2)+7;i=SCRN_LEFT+left+3 + && r.w.cx/8<=SCRN_LEFT+left+5 + && r.w.dx/8==(SCRN_TOP+top)-1) /* Clicked help icon */ + help(); + else + goto hitesc; } + + r.w.ax=0x0006; /* Get button release information */ + r.w.bx=0x0001; /* right button */ + INT_86(0x33,&r,&r); + + if(r.w.bx) { /* Right button down, same as ESC */ +hitesc: + if(mode&WIN_ESC || (mode&WIN_CHE && changes) + && !(mode&WIN_SAV)) { + hidemouse(); + gettext(SCRN_LEFT+left,SCRN_TOP+top,SCRN_LEFT + +left+width-1,SCRN_TOP+top+height-1,win); + for(i=1;i<(width*height*2);i+=2) + win[i]=lclr|(cclr<<4); + puttext(SCRN_LEFT+left,SCRN_TOP+top,SCRN_LEFT + +left+width-1,SCRN_TOP+top+height-1,win); + showmouse(); } + else if(mode&WIN_SAV) { + hidemouse(); + puttext(sav[savnum].left,sav[savnum].top + ,sav[savnum].right,sav[savnum].bot + ,sav[savnum].buf); + showmouse(); + FREE(sav[savnum].buf); + savdepth--; } + return(-1); } + } +#endif + + if(inkey(1)) { + i=inkey(0); if(!(i&0xff)) { s=0; switch(i>>8) { @@ -275,21 +585,26 @@ while(1) { if(!opts) break; if(opts+4>height) { - lclxy(SCRN_LEFT+left+1,SCRN_TOP+top+3); - lclatr(lclr|(bclr<<4)); - lputc(' '); /* Delete the up arrow */ - lclxy(SCRN_LEFT+left+1,SCRN_TOP+top+height-2); - lputc(31); /* put the down arrow */ - lclxy(SCRN_LEFT+left+3,SCRN_TOP+top+3); - lclatr(bclr|(LIGHTGRAY<<4)); - lprintf("%-*.*s",width-4,width-4,option[0]); - lclatr(lclr|(bclr<<4)); - for(i=1;iheight) { - lclxy(SCRN_LEFT+left+1,SCRN_TOP+top+3); /* like end */ - lclatr(lclr|(bclr<<4)); - lputc(30); /* put the up arrow */ - lclxy(SCRN_LEFT+left+1,SCRN_TOP+top+height-2); - lputc(' '); /* delete the down arrow */ - for(i=(opts+4)-height,j=0;i(opts-1)) + (*cur)=(opts-1); + + hidemouse(); + gettext(SCRN_LEFT+3+left,SCRN_TOP+y + ,SCRN_LEFT+left+width-2,SCRN_TOP+y,line); + for(i=1;iheight) { /* Scroll mode */ - lclxy(SCRN_LEFT+left+1,SCRN_TOP+top+3); - lclatr(lclr|(bclr<<4)); - lputc(30); /* put the up arrow */ - lclxy(SCRN_LEFT+left+1,SCRN_TOP+top+height-2); - lputc(' '); /* delete the down arrow */ - for(i=(opts+4)-height,j=0;iheight) { /* like home */ - lclxy(SCRN_LEFT+left+1,SCRN_TOP+top+3); - lclatr(lclr|(bclr<<4)); - lputc(' '); /* Delete the up arrow */ - lclxy(SCRN_LEFT+left+1,SCRN_TOP+top+height-2); - lputc(31); /* put the down arrow */ - lclxy(SCRN_LEFT+left+3,SCRN_TOP+top+3); - lclatr(bclr|(LIGHTGRAY<<4)); - lprintf("%-*.*s",width-4,width-4,option[0]); - lclatr(lclr|(bclr<<4)); - for(i=1;i=longopt) { b=0; @@ -517,36 +913,42 @@ while(1) { else s++; if(y+(j-(*cur))+2>height+top) { (*cur)=j; - lclxy(SCRN_LEFT+left+1,SCRN_TOP+top+3); - lclatr(lclr|(bclr<<4)); - lputc(30); /* put the up arrow */ + gotoxy(SCRN_LEFT+left+1,SCRN_TOP+top+3); + textattr(lclr|(bclr<<4)); + putch(30); /* put the up arrow */ if((*cur)==opts-1) { - lclxy(SCRN_LEFT+left+1,SCRN_TOP+top+height-2); - lputc(' '); } /* delete the down arrow */ - for(i=((*cur)+5)-height,j=0;i<(*cur)+1;i++,j++) { - if(i==(*cur)) lclatr(bclr|(LIGHTGRAY<<4)); - lclxy(SCRN_LEFT+left+3,SCRN_TOP+top+3+j); - lprintf("%-*.*s",width-4,width-4,option[i]); } + gotoxy(SCRN_LEFT+left+1,SCRN_TOP+top+height-2); + putch(' '); } /* delete the down arrow */ + for(i=((*cur)+5)-height,j=0;i<(*cur)+1;i++,j++) + uprintf(SCRN_LEFT+left+3,SCRN_TOP+top+3+j + ,i==(*cur) ? bclr|(LIGHTGRAY<<4) + : lclr|(bclr<<4) + ,"%-*.*s",width-4,width-4,option[i]); y=top+height-2; + if(bar) + (*bar)=height-5; break; } if(y-((*cur)-j)j) + (*bar)-=(*cur)-j; + else + (*bar)+=j-(*cur); } + (*cur)=j; gettext(SCRN_LEFT+3+left,SCRN_TOP+y ,SCRN_LEFT+left+width-2,SCRN_TOP+y,line); for(i=1;iSCRN_RIGHT) { /* prompt+max is too large */ - width=max+6; - for(lines=1,i=0,j=0;iwidth) - width=j+6; - j=0; } - height=3+lines; } -if(mode&WIN_MID) { +if(!plen) + slen=4; +else + slen=6; +width=plen+slen+max; +if(mode&WIN_T2B) top=(scrn_len/2)-(height/2)-2; - left=36-(width/2); } -else if(mode&WIN_L2R) +if(mode&WIN_L2R) left=36-(width/2); if(mode&WIN_SAV) gettext(SCRN_LEFT+left,SCRN_TOP+top,SCRN_LEFT+left+width+1 ,SCRN_TOP+top+height,save_buf); -lclxy(SCRN_LEFT+left,SCRN_TOP+top); -lclatr(hclr|(bclr<<4)); -lputc('É'); -for(c=1;c=SP) - lputc(prompt[i]); - i++; } - lclatr(hclr|(bclr<<4)); - i++; /* skip LF */ - lclxy(SCRN_LEFT+left+width,SCRN_TOP+top+1+j); - lputc('º'); - j++; - lclxy(SCRN_LEFT+left,SCRN_TOP+SCRN_TOP+top+1+j); - lputc('º'); } } -else { - lprintf(" %s: %*s ",prompt,max,""); - lclatr(hclr|(bclr<<4)); - lputc('º'); } -lclxy(SCRN_LEFT+left,SCRN_TOP+top+2+lines); -lputc('È'); -for(c=1;c=60) { - lclxy(55,1); - lclatr(bclr|(cclr<<4)); - lputs(timestr(&now)); + uprintf(55,1,bclr|(cclr<<4),timestr(&now)); savetime=now; } } @@ -759,94 +1156,145 @@ if(difftime(now,savetime)>=60) { /* Different modes - K_* macros. ESC aborts input. */ /* Cursor should be at END of where string prompt will be placed. */ /****************************************************************************/ -int getstr(char *outstr, int max, int mode) +int getstr(char *outstr, int max, long mode) { - char str[256],ch,ins=0,buf[256],y; - int i,j,k; /* i=offset, j=length */ + uchar str[256],ch,ins=0,buf[256],y; + int i,j,k,f=0; /* i=offset, j=length */ +#ifndef __FLAT__ + union REGS r; +#endif -setcursortype(cursor); +cursor=_NORMALCURSOR; +_setcursortype(cursor); +y=wherey(); if(mode&K_EDIT) { /*** truncsp(outstr); ***/ - lclatr(bclr|(LIGHTGRAY<<4)); - lputs(outstr); - lclatr(lclr|(bclr<<4)); + outstr[max]=0; + textattr(bclr|(LIGHTGRAY<<4)); + cputs(outstr); + textattr(lclr|(bclr<<4)); strcpy(str,outstr); i=j=strlen(str); - while((k=bioskey(1))==0); - y=lclwy(); - lclxy(lclwx()-i,y); - if(!isprint(k&0xff) && k!=0x5300) - lputs(outstr); + while(inkey(1)==0) { +#ifndef __FLAT__ + if(uifc_status&UIFC_MOUSE) { + r.w.ax=0x0006; /* Get button release information */ + r.w.bx=0x0000; /* Left button */ + INT_86(0x33,&r,&r); + if(r.w.bx) { /* Left button release same as CR */ + cursor=_NOCURSOR; + _setcursortype(cursor); + return(i); } + r.w.ax=0x0006; /* Get button release information */ + r.w.bx=0x0001; /* Right button */ + INT_86(0x33,&r,&r); + if(r.w.bx) { /* Right button release same as ESC */ + cursor=_NOCURSOR; + _setcursortype(cursor); + return(-1); } } +#endif + mswait(0); + } + f=inkey(0); + gotoxy(wherex()-i,y); + if(!isprint(f&0xff) && f!=0x5300) + cputs(outstr); else { - lprintf("%*s",i,""); - lclxy(lclwx()-i,y); + cprintf("%*s",i,""); + gotoxy(wherex()-i,y); i=j=0; } } else i=j=0; + + while(1) { + + if(i>j) j=i; - if(bioskey(1)) { - k=bioskey(0); +#ifndef __FLAT__ + if(uifc_status&UIFC_MOUSE) { + r.w.ax=0x0006; /* Get button release information */ + r.w.bx=0x0000; /* Left button */ + INT_86(0x33,&r,&r); + if(r.w.bx) /* Left button release same as CR */ + break; + r.w.ax=0x0006; /* Get button release information */ + r.w.bx=0x0001; /* Right button */ + INT_86(0x33,&r,&r); + if(r.w.bx) { /* Right button release same as ESC */ + cursor=_NOCURSOR; + _setcursortype(cursor); + return(-1); } } +#endif + if(f || inkey(1)) { + if(f) k=f; /* First key */ + else k=inkey(0); + f=0; ch=k&0xff; if(!ch) { switch(k>>8) { + case 0x3b: /* F1 Help */ + #if HELP + help(); + #endif + continue; case 0x4b: /* left arrow */ if(i) { - lclxy(lclwx()-1,lclwy()); + gotoxy(wherex()-1,y); i--; } continue; case 0x4d: /* right arrow */ if(i=SP && i=SP || (ch==1 && mode&K_MSG)) && ii;k--) str[k]=str[k-1]; } - lputc(ch); - str[i++]=ch; } } } + putch(ch); + str[i++]=ch; } } + else + mswait(0); + } str[j]=0; if(mode&K_EDIT) { truncsp(str); @@ -892,59 +1341,88 @@ else { if(j) changes=1; } strcpy(outstr,str); -setcursortype(NO_CURSOR); +cursor=_NOCURSOR; +_setcursortype(cursor); return(j); } +#if defined(SCFG) /****************************************************************************/ /* Performs printf() through local assembly routines */ /* Called from everywhere */ /****************************************************************************/ -int lprintf(char *fmat, ...) { - char sbuf[256]; +int lprintf(char *fmat, ...) +{ + va_list argptr; + char sbuf[512]; int chcount; -chcount=vsprintf(sbuf,fmat,_va_ptr); -lputs(sbuf); +va_start(argptr,fmat); +chcount=vsprintf(sbuf,fmat,argptr); +va_end(argptr); +cputs(sbuf); return(chcount); } +#endif + +/****************************************************************************/ +/* Performs printf() through puttext() routine */ +/****************************************************************************/ +int uprintf(char x, char y, char attr, char *fmat, ...) +{ + va_list argptr; + char str[256],buf[512]; + int i,j; + +va_start(argptr,fmat); +vsprintf(str,fmat,argptr); +va_end(argptr); +for(i=j=0;str[i];i++) { + buf[j++]=str[i]; + buf[j++]=attr; } +puttext(x,y,x+(i-1),y,buf); +return(i); +} + + /****************************************************************************/ /* display bottom line of screen in inverse */ /****************************************************************************/ void bottomline(int line) { - -lclxy(4,scrn_len+1); -lclatr(bclr|(cclr<<4)); -lputs("F1 "); -lclatr(BLACK|(cclr<<4)); -lputs("Help "); + int i=4; +uprintf(i,scrn_len+1,bclr|(cclr<<4),"F1 "); +i+=3; +uprintf(i,scrn_len+1,BLACK|(cclr<<4),"Help "); +i+=6; if(line&BL_GET) { - lclatr(bclr|(cclr<<4)); - lputs("F5 "); - lclatr(BLACK|(cclr<<4)); - lputs("Get Item "); } + uprintf(i,scrn_len+1,bclr|(cclr<<4),"F5 "); + i+=3; + uprintf(i,scrn_len+1,BLACK|(cclr<<4),"Get Item "); + i+=10; } if(line&BL_PUT) { - lclatr(bclr|(cclr<<4)); - lputs("F6 "); - lclatr(BLACK|(cclr<<4)); - lputs("Put Item "); } + uprintf(i,scrn_len+1,bclr|(cclr<<4),"F6 "); + i+=3; + uprintf(i,scrn_len+1,BLACK|(cclr<<4),"Put Item "); + i+=10; } if(line&BL_INS) { - lclatr(bclr|(cclr<<4)); - lputs("INS "); - lclatr(BLACK|(cclr<<4)); - lputs("Add Item "); } + uprintf(i,scrn_len+1,bclr|(cclr<<4),"INS "); + i+=4; + uprintf(i,scrn_len+1,BLACK|(cclr<<4),"Add Item "); + i+=10; } if(line&BL_DEL) { - lclatr(bclr|(cclr<<4)); - lputs("DEL "); - lclatr(BLACK|(cclr<<4)); - lputs("Delete Item "); } -lclatr(bclr|(cclr<<4)); -lputs("ESC "); -lclatr(BLACK|(cclr<<4)); -lputs("Exit"); -lputc(CLREOL); + uprintf(i,scrn_len+1,bclr|(cclr<<4),"DEL "); + i+=4; + uprintf(i,scrn_len+1,BLACK|(cclr<<4),"Delete Item "); + i+=13; } +uprintf(i,scrn_len+1,bclr|(cclr<<4),"ESC "); +i+=4; +uprintf(i,scrn_len+1,BLACK|(cclr<<4),"Exit"); +i+=4; +gotoxy(i,scrn_len+1); +textattr(BLACK|(cclr<<4)); +clreol(); } @@ -1031,3 +1509,228 @@ sprintf(str,"%s %s %02d %4d %02d:%02d %s ,hour,gm->tm_min,mer); return(str); } + +/****************************************************************************/ +/* Truncates white-space chars off end of 'str' and terminates at first tab */ +/****************************************************************************/ +void truncsp(char *str) +{ + char c,tmp[256]; + +tmp[0]=TAB; +tmp[1]=0; +str[strcspn(str,tmp)]=0; +c=strlen(str); +while(c && (uchar)str[c-1]<=SP) c--; +str[c]=0; +} + +void upop(char *str) +{ + static char sav[26*3*2]; + char buf[26*3*2]; + int i,j,k; + +hidemouse(); +if(!str) { + puttext(28,12,53,14,sav); + showmouse(); + return; } +gettext(28,12,53,14,sav); +memset(buf,SP,25*3*2); +for(i=1;i<26*3*2;i+=2) + buf[i]=(hclr|(bclr<<4)); +buf[0]='Ú'; +for(i=2;i<25*2;i+=2) + buf[i]='Ä'; +buf[i]='¿'; i+=2; +buf[i]='³'; i+=2; +i+=2; +k=strlen(str); +i+=(((23-k)/2)*2); +for(j=0;j