home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / AMETHYST / TABS.C < prev    next >
C/C++ Source or Header  |  2000-06-30  |  9KB  |  307 lines

  1. /* Tabs.C extra mince commands to set and clear tab stops at irregular
  2.    intervals. Contributed to AUG by Mark of the Unicorn 07/20/81 */
  3.  
  4. /* BINDINGS.C - Set up the key bindings for Mince
  5.  
  6. The seller of this software hereby disclaims any and all
  7. guarantees and warranties, both express and implied.  No
  8. liability of any form shall be assumed by the seller, nor shall
  9. direct, consequential, or other damages be assumed by the seller.
  10. Any user of this software uses it at his or her own risk.
  11.  
  12. Due to the ill-defined nature of "fitness for purpose" or similar
  13. types of guarantees for this type of product, no fitness for any
  14. purpose whatsoever is claimed or implied.
  15.  
  16. The physical medium upon which the software is supplied is
  17. guaranteed for one year against any physical defect.  If it
  18. should fail, return it to the seller, and a new physical medium
  19. with a copy of the purchased software shall be sent.
  20.  
  21. The seller reserve the right to make changes, additions, and
  22. improvements to the software at any time; no guarantee is made
  23. that future versions of the software will be compatible with any
  24. other version.
  25.  
  26. The parts of this disclaimer are severable and fault found in any
  27. one part does not invalidate any other parts.
  28.  
  29.     Copyright (c) 1981 by Mark of the Unicorn
  30.     Created for Version 2.3  10/4/80  JTL
  31.     Updated to version three  1/7/81  JTL
  32.  
  33.     This file contains the function table initializers and mode set up
  34. functions */
  35.  
  36. #include "mince.gbl"
  37.  
  38. finit1()            /* initialize the control and self insert key bindings */
  39. {
  40.     int cnt;
  41.     int MInsert(), MSetMrk(), MBegLin(), MPrevChar();
  42.     int MNotImpl(), MDelChar(), MEndLin(), MNextChar();
  43.     int MAbort(), MDelLin(), NewDsp(), MNewLin();
  44.     int MNextLin(), MOpenLin(), MPrevLin(), MQuote();
  45.     int MRSearch(), MSearch(), MSwapChar(), MArg();
  46.     int MNextPage(), MDelRgn(), MCtrlX(), MYank();
  47.     int MMeta(), MDelIndent(), MRDelChar(), MIndent();
  48. /*    int MTab(); */
  49.  
  50.     for (cnt=0; cnt<128; ++cnt) functs[cnt] = &MInsert;
  51.     TKbChk();
  52.  */
  53.     functs[1] = &MBegLin;        /* C-A */
  54.     functs[2] = &MPrevChar;        /* C-B */
  55.     functs[3] = &MNotImpl;        /* C-C */
  56.     functs[4] = &MDelChar;        /* C-D */
  57.     functs[5] = &MEndLin;        /* C-E */
  58.     functs[6] = &MNextChar;        /* C-F */
  59.     functs[7] = &MAbort;        /* C-G */
  60.     functs[8] = &MRDelChar;        /* C-H */
  61. /*    functs[9] = &MTab;            /* C-I */ */
  62.     functs[10] = &MIndent;        /* C-J */
  63.     functs[11] = &MDelLin;        /* C-K */
  64.     functs[12] = &NewDsp;        /* C-L */
  65.     functs[13] = &MNewLin;        /* C-M */
  66.     functs[14] = &MNextLin;        /* C-N */
  67.     functs[15] = &MOpenLin;        /* C-O */
  68.     functs[16] = &MPrevLin;        /* C-P */
  69.     functs[17] = &MQuote;        /* C-Q */
  70.     functs[18] = &MRSearch;        /* C-R */
  71.     functs[19] = &MSearch;        /* C-S */
  72.     functs[20] = &MSwapChar;        /* C-T */
  73.     functs[21] = &MArg;            /* C-U */
  74.     functs[22] = &MNextPage;        /* C-V */
  75.     functs[23] = &MDelRgn;        /* C-W */
  76.     functs[24] = &MCtrlX;        /* C-X */
  77.     functs[25] = &MYank;        /* C-Y */
  78.     functs[26] = &MNotImpl;        /* C-Z */
  79.     functs[ESC] = &MMeta;        /* ESC */
  80.     functs[28] = &MDelIndent;    /* C-\ */
  81.     functs[29] = &MNotImpl;        /* C-] */
  82.     functs[30] = &MNotImpl;        /* C-^ */
  83.     functs[31] = &MNotImpl;        /* C-_ */
  84.     functs[DEL] = &MRDelChar;    /* DEL */
  85.     }
  86.  
  87. finit2()            /* set up the Meta key bindings */
  88. {
  89.     int cnt;
  90.     int MNotImpl(), MAbort(), MDelELin(), MQryRplc();
  91.     int MMakeDel(), MToStart(), MToEnd(), MBSent();
  92.     int BWord(), MCapWord(), MDelWord(), MFSent();
  93.     int FWord(), MMrkPara(), MDelSent(), MLowWord();
  94.     int MFillPara(), MReplace(), MCntrLine(), MUpWord();
  95.     int MPrevPage(), MCopyRgn(), MBPara(), MDelWhite();
  96.     int MFPara(), MRDelWord(), MSetMrk(), MSwapWord();
  97. /**/ int MScrnSiz();
  98.  
  99.     for (cnt=128; cnt<256; ++cnt) functs[cnt] = &MNotImpl;
  100.     TKbChk();
  101.     functs[128+7] = &MAbort;                    /* M-C-G */
  102.     functs[128+8] = &MRDelWord;                /* M-C-H */
  103.     functs[128+11] = &MDelELin;                /* M-C-K */
  104.     functs[128+18] = &MQryRplc;                /* M-C-R */
  105. /**/ functs[128+19] = &MScrnSiz;                /* M-C-S */
  106.     functs[128+23] = &MMakeDel;                /* M-C-W */
  107.     functs[128+'<'] = &MToStart;                /* M-< */
  108.     functs[128+'>'] = &MToEnd;                /* M-> */
  109.     functs[128+' '] = &MSetMrk;                /* M-  */
  110.     functs[128+'A']=functs[128+'a'] = &MBSent;    /* M-A */
  111.     functs[128+'B']=functs[128+'b'] = &BWord;    /* M-B */
  112.     functs[128+'C']=functs[128+'c'] = &MCapWord;    /* M-C */
  113.     functs[128+'D']=functs[128+'d'] = &MDelWord;    /* M-D */
  114.     functs[128+'E']=functs[128+'e'] = &MFSent;    /* M-E */
  115.     functs[128+'F']=functs[128+'f'] = &FWord;    /* M-F */
  116.     functs[128+'H']=functs[128+'h'] = &MMrkPara;    /* M-H */
  117.     functs[128+'K']=functs[128+'k'] = &MDelSent;    /* M-K */
  118.     functs[128+'L']=functs[128+'l'] = &MLowWord;    /* M-L */
  119.     functs[128+'Q']=functs[128+'q'] = &MFillPara;/* M-Q */
  120.     functs[128+'R']=functs[128+'r'] = &MReplace;    /* M-R */
  121.     functs[128+'S']=functs[128+'s'] = &MCntrLine;/* M-S */
  122.     functs[128+'T']=functs[128+'t'] = &MSwapWord;/* M-T */
  123.     functs[128+'U']=functs[128+'u'] = &MUpWord;    /* M-U */
  124.     functs[128+'V']=functs[128+'v'] = &MPrevPage;/* M-V */
  125.     functs[128+'W']=functs[128+'w'] = &MCopyRgn;    /* M-W */
  126.     functs[128+'['] = &MBPara;                /* M-[ */
  127.     functs[128+'\\'] = &MDelWhite;            /* M-\ */
  128.     functs[128+']'] = &MFPara;                /* M-] */
  129.     functs[128+DEL] = &MRDelWord;                /* M-DEL */
  130.     }
  131.  
  132. finit3()            /* set up the Control-X key bindings */
  133. {
  134.     int cnt;
  135.     int MNotImpl(), MLstBuffs(), MExit(), MFindFile();
  136.     int MAbort(), MSetTabs(), MDelMode(), MFileRead();
  137.     int MFileSave(), MFileWrite(), MSwapMrk(), MSetIndent();
  138.     int MPrintPos(), MSwitchTo(), MKillBuff(), MSetFill();
  139.     int MAddMode(), MOneWind(), MTwoWind(), MSwpWind();
  140.     int MNxtOthrWind(), MPrvOthrWind(), MGrowWind();
  141. /*    int MSetTab(), MClrTab(), MTabEvery(); */
  142. #ifdef UNIX
  143.     int MUnix();
  144. #endif
  145.  
  146.     for (cnt=256; cnt<384; ++cnt) functs[cnt] = &MNotImpl;
  147.     TKbChk();
  148.     functs[256+2] = &MLstBuffs;                /* C-X C-B */
  149.     functs[256+3] = &MExit;                    /* C-X C-C */
  150.     functs[256+6] = &MFindFile;                /* C-X C-F */
  151.     functs[256+7] = &MAbort;                    /* C-X C-G */
  152. /*    functs[256+9] = &MTabEvery;                /* C-X Tab */ */
  153.     functs[256+13] = &MDelMode;                /* C-X C-M */
  154.     functs[256+18] = &MFileRead;                /* C-X C-R */
  155.     functs[256+19] = &MFileSave;                /* C-X C-S */
  156.     functs[256+22] = &MNxtOthrWind;            /* C-X C-V */
  157.     functs[256+23] = &MFileWrite;                /* C-X C-W */
  158.     functs[256+24] = &MSwapMrk;                /* C-X C-X */
  159.     functs[256+26] = &MPrvOthrWind;            /* C-X C-Z */
  160.     functs[256+'.'] = &MSetIndent;            /* C-X . */
  161. #ifdef UNIX
  162.     functs[256+'!'] = &MUnix;                /* C-X ! */
  163. #endif
  164.     functs[256+'='] = &MPrintPos;                /* C-X = */
  165.     functs[256+'1'] = &MOneWind;                /* C-X 1 */
  166.     functs[256+'2'] = &MTwoWind;                /* C-X 2 */
  167.     functs[256+'B']=functs[256+'b'] = &MSwitchTo;/* C-X B */
  168. /*    functs[256+'C']=functs[256+'c'] = &MClrTab;  /* C-X C */    
  169.     functs[256+'K']=functs[256+'k'] = &MKillBuff;/* C-X K */
  170.     functs[256+'F']=functs[256+'f'] = &MSetFill;    /* C-X F */
  171.     functs[256+'M']=functs[256+'m'] = &MAddMode;    /* C-X M */
  172.     functs[256+'O']=functs[256+'o'] = &MSwpWind;    /* C-X O */
  173. /*    functs[256+'S']=functs[256+'s'] = &MSetTab;    /* C-X S */ */
  174.     functs[256+'^'] = &MGrowWind;                /* C-X ^ */
  175.     }
  176.  
  177. SetModes()            /* Set the modes according to the bmodes array */
  178. {
  179.     int cnt;
  180.     int MFillChk();
  181. /*    int MInsert(), MOverwrite(), MPBegLine();
  182.     int MPBChar(), MPEndLine(), MPFChar(), MPBackSpace();
  183.     int MPNextLine(), MPPrevLine(), MTrimWhite(), MPTab(); */
  184. #ifdef LARGE
  185.     int MNewLin(), MCIndent(), MSInsert();
  186. #endif
  187.  
  188.     *mode='\0';
  189.     finit1();                    /* Set up the key bindings */
  190.     finit2();
  191.     finit3();
  192.     for (cnt=MAXMODES-1; cnt>=0; --cnt) {
  193.         switch (buffs[cbuff].bmodes[cnt]) {
  194.  
  195. #ifdef LARGE
  196.         case 'c':
  197.             functs[13] = &MCIndent;
  198.             strcat(&mode,"C ");
  199.             break;
  200.         case 's':
  201.             Rebind(&MInsert,&MSInsert);
  202.             strcat(&mode,"Save ");
  203.             break;
  204. #endif
  205.         case 'f':
  206.             functs[' '] = &MFillChk;
  207.             strcat(&mode,"Fill ");
  208.             break;
  209. /*        case 'p':
  210.             Rebind(&MInsert,&MOverwrite);
  211.             functs[1] = &MPBegLine;
  212.             functs[2] = &MPBChar;
  213.             functs[5] = &MPEndLine;
  214.             functs[6] = &MPFChar;
  215.             functs[8] = &MPBackSpace;
  216.             functs[9] = &MPTab;
  217.             functs[14] = &MPNextLine;
  218.             functs[16] = &MPPrevLine;
  219.             functs[256+'\\'] = &MTrimWhite;
  220.             strcat(&mode,"Page ");
  221.             break; */
  222.             }
  223.         }
  224.     if (!*mode) strcpy(&mode,"Normal ");
  225.     mode[strlen(mode)-1]='\0';
  226.     ModeLine();
  227.     }
  228.  
  229. UInit()            /* Do User Code Initialization */
  230.     /* This function is called once at the very beginning. it may be used
  231.     to do any initialization required for user code */
  232. {
  233.     for (cnt=9; cnt>=0; --cnt) spare[cnt]=0;
  234.     for (cnt=tabincr; cnt<80; cnt+=tabincr) spare[cnt>>3]|=1<<(cnt&7);
  235.     }
  236.  
  237. /*
  238. MTab()                /* Insert spaces to the next tab stop */
  239. {
  240.     for (cnt=BGetCol(); cnt<80 && (++cnt, !(spare[cnt>>3]&(1<<(cnt&7))));
  241.         BInsert(' '));
  242.     BInsert(' ');
  243.     }
  244.  
  245. MSetTab()                /* Set a tab stop */
  246. {
  247.     if (!argp) arg=BGetCol();
  248.     if (arg>79) arg=79;
  249.     spare[arg>>3] |= 1<<(arg&7);
  250.     arg=0;
  251.     return;
  252.     }
  253.  
  254. MClrTab()                /* Clear a tab stop */
  255. {
  256.     if (!argp) arg=BGetCol();
  257.     if (arg>79) arg=79;
  258.     spare[arg>>3] &= !(1<<(arg&7));
  259.     arg=0;
  260.     return;
  261.     }
  262.  
  263. MTabEvery()            /* Set a tab stop every arg characters */
  264. {
  265.     if (arg>79) arg=79;
  266.     for (cnt=9; cnt>=0; --cnt) spare[cnt]=0;
  267.     if (!argp) return;
  268.     for (cnt=arg; cnt<80; cnt+=arg) spare[cnt>>3]|=1<<(cnt&7);
  269.     arg=0;
  270.     }
  271.  
  272. */
  273. /* ---------------------------------------------------------------------- */
  274.  
  275. MScrnSiz()
  276. {
  277.     char *ssc;
  278.     int ssi;
  279.     
  280.     switch (arg) {
  281.     
  282.     case 18:
  283.     case 20:
  284.     case 22:
  285.     case 24:
  286.     case 26:
  287.     case 28:
  288.     case 30:
  289.     case 36:
  290.     case 40:
  291.     case 48:
  292.         break;
  293.     default:
  294.         Error("Invalid Scrn Size");
  295.         arg=0;
  296.         return;
  297.         }
  298.     MOneWind();
  299.     terminal.nrows=arg;
  300.     divide=TMaxRow()-2; 
  301.     prefrow=arg/2;
  302.     arg=0;
  303.     NewDsp();
  304.     }
  305.  
  306. /* END OF TABS.C - set up key bindings */
  307.