#include /* module funkeys9 */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include union REGS inregs,outregs; /***************************************************************************/ funkeys(void) /* function keys */ { char string[30]; int fail=0,key,index,i,k,m=0,n=0,mold=0,nold=0,x,y; if(inlog()||inhist()||insimu()) { clkey(); goto abort; } if(parse[4]!=CR) { key=atoi(&parse[4]); /* key number */ if(key<1||key>48) goto failed; index=key-1; n=comma(2)-comma(1)-1; /* argument length */ if(n>0) { strncpy(string,&parse[comma(1)+1],n); /* command */ string[n]=0; strcpy(&func[0]+20*index,string); } clkey(); goto abort; } clear(); font(1); text(PALEBLUE,100,479,"FUNCTION KEYS"); txnumber(); text(WHITE,0,420,"KEY"); tex(40,420,"UNSHIFTED"); tex(190,420,"SHIFTED"); tex(340,420,"CTRL-"); tex(490,420,"ALT-"); rect(DARKGREY,0,405,25,160); for(i=0;i<=11;i++) { y=400-20*i; text(WHITE,5,y,itoa(i+1,numb,10)); /* sequence */ strncpy(string,&func[0]+20*i,20); string[20]=0; text(PALEBLUE,40,y,string); strncpy(string,&func[0]+20*(i+12),20); text(PALEBLUE,190,y,string); strncpy(string,&func[0]+20*(i+24),20); text(PALEBLUE,340,y,string); strncpy(string,&func[0]+20*(i+36),20); text(PALEBLUE,490,y,string); } loop: clkey(); message(WHITE,"USE CURSOR KEYS TO SELECT"); onmouse(); while(!kbhit()) { odapc(); switch(click()) /* mouse button */ { case 1: /* left click */ x=outregs.x.cx; y=479-outregs.x.dx; m=(x-40)/150; if(m>3) m=0; n=(400-y)/20; if(n>11||n<0) n=0; goto exec; case 3: /* both click */ k=ESC; goto abort; } } k=caps(); if(k>128) cursor: switch(k) { case LEFT: --m; if(m<0) m=3; /* wrap */ break; case RIGHT: ++m; if(m>3) m=0; /* wrap */ break; case UP: --n; if(n==-1) n=11; /* wrap */ break; case DOWN: ++n; if(n==12) n=0; /* wrap */ break; case HOME: n=0; break; case END: n=11; break; default: goto key; } else { key: keyboard[0]=k; if(k<128) prompt(keyboard); goto abort; } exec: x=40+150*(mold); y=400-20*nold; offmouse(); strncpy(string,&func[0]+20*(nold+mold*12),20); string[20]=0; rect(BLACK,x,y,x+140,y-10); text(PALEBLUE,x,y,string); mold=m; nold=n; x=40+150*(m); y=400-20*n; strncpy(string,&func[0]+20*(n+m*12),20); string[20]=0; rect(BLUE,x,y,x+140,y-10); text(WHITE,x,y,string); clkey(); message(LIGHTGREEN,"ENTER DEFINITION (MAX 20 CHARS), OR Esc TO EXIT"); onmouse(); while(!kbhit()) { odapc(); switch(click()) /* mouse button */ { case 1: /* left click */ x=outregs.x.cx; y=479-outregs.x.dx; m=(x-40)/150; if(m>3) m=0; n=(400-y)/20; if(n>11||n<0) n=0; goto exec; case 3: /* both click */ k=ESC; goto abort; } } offmouse(); k=caps(); if(k>128) goto cursor; if(k==ESC) goto abort; if(k==CR) goto abort; keyboard[0]=k; prompt(keyboard); while(console()!=CR); keyboard[20]=0; /* limit to 20 chars */ strcpy(&func[0]+20*(n+12*m),keyboard); /* includes CR */ rect(BLACK,x,y,x+140,y-10); /* erase old value */ text(GREEN,x,y,keyboard); goto loop; failed: clkey(); fail=1; status[12]|=0x01; /* command failed */ abort: savefunc(); /* update hard drive */ refresh=1; return(fail); }