Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site unmvax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!genrad!panda!talcott!harvard!cmcl2!lanl!unm-la!unmvax!wampler From: wampler@unmvax.UUCP Newsgroups: net.sources Subject: TVX: PD Editor (5 of 7, repost) Message-ID: <966@unmvax.UUCP> Date: Thu, 16-Jan-86 12:30:46 EST Article-I.D.: unmvax.966 Posted: Thu Jan 16 12:30:46 1986 Date-Received: Sat, 18-Jan-86 08:40:50 EST Distribution: net Organization: Univ. of New Mexico, Albuquerque Lines: 1013 #--------CUT---------CUT---------CUT---------CUT--------# ######################################################### # # # This is a shell archive file. To extract files: # # # # 1) Make a directory (like tvx) for the files. # # 2) Write a file, such as "filen.shar", containing # # this archive file into the directory. # # 3) Type "sh file.shar". Do not use csh. # # # ######################################################### # # echo Extracting tvx_ptch.c: sed 's/^X//' >tvx_ptch.c <<\SHAR_EOF X/* --------------------------------- tvx_ptch.c --------------------------- */ X#include "tvx_defs.ic" X X#define EXTERN X#include "tvx_glbl.ic" X X/*======================================================================= X X tvpatch - program to patch tvx with config.tvx file X X first version 6/19/84 X 7/25/84 - fixed to correspond to tvx version, add extra command X 2/14/85 - version to correspond with rest X 5/15/85 - again, batched to correspond X 9/20/85 - fixed for new version of tvx, unix added X X======================================================================= */ X X#ifndef UNIX X char filein[] = "A:TVX.EXE"; X char fileout[]= "A:TEMP1.$$$"; X#else X char filein[80] = "tvx"; X char fileout[80]= "tvx_temp"; X#endif X char config[80]; X X X/* define our general control item structure for general patching */ X X#define BL remark("") X#define RMK remark X#define PR prompt X X char clower(), cupper(); X extern char *malloc(); X extern FILE *fopen(); X FILE *tvxin, *cfgin, *tvxout; X X/* =============================>>> MAIN <<<============================= */ X main() X { X X char ans[80]; X XTOP: X cls(); X RMK("TVX_PTCH - Version 11/12/85"); X BL; XRMK(" This program is used to permanently alter TVX to match the options"); XRMK("selected with the TVX_CNFG program. It will read in the configuration"); XRMK("file you specify (such as CONFIG.TVX), and patch TVX to reflect those"); XRMK("values. Then you won't need to use the '-c' switch when using TVX."); X BL; XRMK("*** You may press CONTROL-C at any time to cancel this installation. ***"); X X do X { X BL; X#ifndef UNIX X PR("On which drive is TVX.EXE located? (A, B, ...): "); X ureply(ans,10); X filein[0] = ans[0]; X#endif X if ( !(tvxin = fopen(filein,FILEREAD))) X { X PR("TVX not found on specified drive, try again: "); X RMK(filein); X#ifdef UNIX X PR("Please enter name of tvx executable file: "); X reply(filein,79); X#endif X continue; X } X fclose(tvxin); X break; X } X while (1); X X#ifndef UNIX X fileout[0] = cupper(ans[0]); X#endif X X do X { X BL; X PR("Enter the name of the configuration file to use: "); X reply(config,79); X if ( !(cfgin = fopen(config,FILEREAD))) X { X RMK("Configuration not found on specified drive, try again."); X continue; X } X X rdcfg(lexsym,LEXVALUES+1); X rdcfg(synofr,20); X rdcfg(synoto,20); X rdcfg(funchar,50); X rdcfg(funcmd,50); X rdcfg(&funkey,1); X rdcfg(&autoin,1); X rdcfg(&ddline,1); X rdcfg(&dscrl,1); X rdcfg(&dxcase,1); X rdcfg(&wraplm,1); X rdcfg(&use_wild,1); X rdcfg(&usebak,1); X logdef = usebak; X#ifdef MSDOS X rdcfg(&usecz,1); X#endif X fclose(cfgin); X break; X } X while (1); X X BL; X RMK("TVX is being modified to match your choices."); X RMK("This may take several minutes."); X BL; X X fpatch(filein); /* patch tvx */ X X cls(); X RMK("Modification completed. TVX is ready to use without the -c now."); X BL; X } X X/* =============================>>> RDCFG <<<============================= */ X rdcfg(toset,cnt) X char *toset; X int cnt; X { /* read cnt vals from cfgin */ X X FAST int i,val; X X for (i = 0 ; i < cnt ; ++i) X { X if ((val = fgetc(cfgin)) == EOF) X { X remark("Invalid configuration file, aborting"); X fclose(cfgin); X exit(999); X } X *toset++ = val; /* replace with new commands */ X } X } X X/* =============================>>> FPATCH <<<============================= */ X fpatch(fn) X char *fn; X { X static int byt; X static int i; X static int didpatch; X static char *begptr; /* patch area pointers */ X X prompt("Patching "); remark(filein); X X#ifndef UNIX X fn[0] = fileout[0]; /* set drive */ X#endif X didpatch = FALSE; X if (!(tvxin = fopen(fn,FILEREAD))) X { X PR("Unable to find file to patch: "); PR(fn); X RMK(". Aborting to operating system."); X exit(999); X } X if (!(tvxout = fopen(fileout,FILEWRITE))) X { X PR("Unable to create new file, aborting: "); X RMK(fileout); X exit(999); X } X X while ((byt = fgetc(tvxin)) != EOF) X { X fputc(byt,tvxout); X if (byt == '#') /* look for first sharp */ X { X for (i = 1 ; i <= 4 ; ++i) X { X if ((byt = fgetc(tvxin)) == EOF) X goto l900; X fputc(byt,tvxout); /* echo */ X if (byt != '#') X goto l800; X } X byt = fgetc(tvxin); /* should be : next */ X fputc(byt,tvxout); X if (byt != ':') X goto l800; X X/* fall thru means found patch area -- code to patch follows */ X X for (begptr = (char *) &addx ; begptr < (char *) &endpatch ; X ++begptr) X { X if ((byt = fgetc(tvxin)) == EOF) /* read byte from file */ X goto l900; X fputc(*begptr,tvxout); /* replace with byte from my area */ X } X didpatch = TRUE; X } Xl800: byt = byt; /* compiler bug */ X } X X Xl900: X fclose(tvxin); X fclose(tvxout); X if (!didpatch) X { X RMK("********* ERROR ********"); X RMK("The file just checked was not a proper version of the program!"); X RMK("Please check that your are using a valid copy of the"); X RMK("program file supplied with this initialization program!"); X RMK("Unable to make patch, aborting"); X exit(999); X } X unlink(fn); X fn[0] = fileout[0]; /* fix the drive */ X if (rename(fileout,fn) != 0) X { X RMK("Unable to rename temporary patch file"); X exit(999); X } X } X X/* =============================>>> OK <<<============================= */ X ok(msg) X char *msg; X { X char rp[11]; X PR(msg); PR(" (y/n) "); X lreply(rp,10); X return (rp[0] == 'y'); X } X X/* ============================>>> RVALID <<<=========================== */ X rvalid(chr,okstr) X char chr,*okstr; X { X /* sees if chr is in okstr */ X X SLOW int i; X SLOW char ch; X X ch = clower(chr); X while (*okstr) X { X if (ch == clower(*okstr++)) X return TRUE; X } X return FALSE; X } X X/* =============================>>> CLS <<<============================= */ X cls() X { X int i; X X for (i = 0 ; i < 25 ; ++i) X BL; X } X X#define EXTENDED /* my own extended lib functions */ X/* #define STANDARD /* the set of standard functions i use */ X#define LOCAL static /* make all local globals, i think */ X X X#ifdef EXTENDED X/*=============================>>> CLOWER <<<================================*/ X char clower(ch) X char ch; X { X return ((ch >='A' && ch<='Z') ? ch + ' ' : ch); X } X X/*=============================>>> CUPPER <<<================================*/ X char cupper(ch) X char ch; X { X return ((ch >= 'a' && ch <= 'z') ? ch - ' ' : ch); X } X X/* =========================>>> LOWER <<<==============================*/ X lower(str) X char str[]; X { X FAST int i; X X for (i=0 ; str[i] ; ++i) X str[i]=clower(str[i]); X X } X X/*=============================>>> PROMPT <<<================================*/ X prompt(msg) X char msg[]; X { X printf("%s",msg); X } X X X/*=============================>>> REMARK <<<================================*/ X remark(msg) X char msg[]; X { X printf("%s\n",msg); X } X X/*=============================>>> UPPER <<<================================*/ X upper(str) X char str[]; X { X static int i; X X for (i=0 ; str[i] ; ++i) X str[i]=cupper(str[i]); X } X X X/*=============================>>> LREPLY <<<================================*/ X lreply(msg,maxc) X char msg[]; X int maxc; X { X reply(msg,maxc); X lower(msg); X } X X/*=============================>>> UREPLY <<<================================*/ X ureply(msg,maxc) X char msg[]; X int maxc; X { X reply(msg,maxc); X upper(msg); X } X X/*=============================>>> REPLY <<<================================*/ X reply(msg,maxc) X char msg[]; X int maxc; X { X#ifdef UNIX X gets(msg); X#else X gets(msg,maxc,stdin); X#endif X } X X/*=============================>>> RDINT <<<================================*/ X rdint(val) X int *val; X { X char chrrep[12]; X reply(chrrep,11); X *val = atoi(chrrep); X } X#endif X/* --------------------------------- tvx_ptch.c --------------------------- */ SHAR_EOF echo Extracting tvx_cfg.c: sed 's/^X//' >tvx_cfg.c <<\SHAR_EOF X/* ------------------------------- tvx_cfg.c ------------------------ */ X#include "tvx_defs.ic" X X#define BL remark("") X X char synofr[20] = /* from table */ X {' ',13,']',000,000,000,000,000,000,000,00,00,00,00,00,00,00,00,00,00}; X char synoto[20] = /* translate to table */ X {'r','d','{',00,000,0,000,00,00,000,00,00,00,00,00,00,00,00,00,00}; X char funkey = 0; /* leading char for function key */ X char funchar[50] = /* code sent by function key */ X { X 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, X 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, X 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, X 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, X 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, X }; X char funcmd[50] = /* equivalent command */ X { X 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, X 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, X 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, X 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, X 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, X }; X X/* define standard command set */ X X char lexsym[LEXVALUES+1] = { E0, 'r', 'l', 'd', 'u', X 4, 21, 8, 'k', 'i', 11, '"', '\'', ',', '.', 'f', 6, 'p', X 'b', 'e', 2, 'v', 'o', '/', 's', 'g', 23, 25, 24, ';', '&', X 'm', ':', '=', 7, 9, '{', 'a', 16, '?', 'h', 20, 'c', 'j', 't', X 'n', 14, 15, 5, 18, '#', '*', '(', ')' }; X X char newlex[LEXVALUES+1] ; X X char autoin, dsplin, scroll, xcases, warplm, wildch, funesc; X char rp[80]; X X FILE *f, *fopen(); X X main() X { X X FAST int i, val; X X cls(); X remark("TVX define a configuration file -- Version 11/12/85"); X BL; X for (;;) X { X prompt("Enter name of file to save configuration in: "); X reply(rp,79); X if ((f = fopen(rp,FILEWRITE)) == 0) X continue; X else X break; X } X X X remark("Standard commands settable by this program:"); X X BL; Xremark("Commands (n => count allowed):"); Xremark("nA Append lines B Buff begin ^B File begin nC Change chrs nD Down"); Xremark("n^D Down column E Buff end nF Find ^F Find-file G Get save buf"); Xremark("^G Unkill nH Half page nI Insert J Jump back nK Kill ch"); Xremark("n^K Kill line nL Left M Mem stat nN Note loc n^N Reset loc"); Xremark("nO Open line nP Page ^P Print screen ^Q Quit nR Right"); Xremark("nS Save lines ^S Read file nT Tidy ^T Abort nU Up"); Xremark("n^U Up column V Verify n^W Write buff nBS Del ch n; Re-Find"); Xremark(" / Delete last = Change last ' Del ln beg \" Del ln end , Ln beg"); Xremark(" . Line end nTAB Word rt n{ Word left n& Rpt agn"); Xremark("? Help * Ins find pat n:p Set param p ^O Op. System"); Xremark("n^E Edit rptbuf ^R Restore rpt n#k Execute rpt n k times"); Xremark("Note: <> repeat, @ command file, and ESCAPE cannot be changed."); X BL; X X for (;;) X { X BL; X prompt("Use standard command definitions? (y/n) "); X lreply(rp,10); X if (*rp == 'y') X { X for (i=0 ; i <= LEXVALUES ; ++i) X fputc(lexsym[i],f); /* write to file */ X goto LEXDONE; X } X else if (*rp == 'n') X break; X } X XCAGAIN: X cls(); X remark("You now must re-define all 47 commands. You may simply enter"); X remark("the key of the command (followed by a RETURN), or the decimal"); X remark("code of the key, followed by a RETURN."); X BL; X/* define new commands */ X for (i=0 ; i <= LEXVALUES ; ++i) X newlex[i] = 0; /* clear */ X set(1,"cursor right (r)"); X set(2,"cursor left (l)"); X set(3,"cursor down (d)"); X set(4,"cursor up (u)"); X set(5,"cursor down in col (^d)"); X set(6,"cursor up in col (^u)"); X set(7,"del prev char (backspace)"); X set(8,"kill character (k)"); X set(9,"enter insert mode (i)"); X set(10,"kill a line (^k)"); X set(11,"delete to end of line (\")"); X set(12,"delete to beginning of line (')"); X set(13,"cursor to beginning of line (,)"); X set(14,"cursor to end of line (.)"); X set(15,"find (f)"); X set(16,"find across buffer (^f)"); X set(17,"scroll screen one page (p)"); X set(18,"beginning of buffer (b)"); X set(19,"end of buffer (e)"); X set(20,"beginning of file (^b)"); X set(21,"verify screen (v)"); X set(22,"open line (o)"); X set(23,"delete last thing (/)"); X set(24,"save line in save buff (s)"); X set(25,"get save buffer (g)"); X set(26,"write buffer (^w)"); X set(27,"save external file in save buffer (^y)"); X set(28,"exit (^x)"); X set(29,"find again (;)"); X set(30,"execute repeat buffer (&)"); X set(31,"memory status line (m)"); X set(32,"set parameter (:)"); X set(33,"delete last thing, enter insert (=)"); X set(34,"get back last killed line (^g)"); X set(35,"word rigth (tab)"); X set(36,"word left ({)"); X set(37,"append line to save buffer (a)"); X set(38,"print screen (^p)"); X set(39,"help (?)"); X set(40,"scroll page half screen (h)"); X set(41,"abort edit session (^t)"); X set(42,"change characters (c)"); X set(43,"jump back (j)"); X set(44,"tidy (fill to margin) (t)"); X set(45,"note position (n)"); X set(46,"return to noted position (^n)"); X set(47,"'push' to operating system (^O)"); X set(48,"Edit repeat buffer (^E)"); X set(49,"Restore repeat buffer (^R)"); X set(50,"Execute repeat buffer k (#)"); X set(51,"Insert last find match (*)"); X X cls(); Xremark("Commands have been defined. You can start over if you made any mistakes."); X remark(""); X prompt("Are they ok? (y/n) "); X lreply(rp,10); X if (*rp == 'n') X goto CAGAIN; X X for (i=0 ; i <= LEXVALUES ; ++i) X { X fputc(newlex[i],f); /* write to file */ X lexsym[i] = newlex[i]; X } X XLEXDONE: X syno(); X funkeys(); X X cls(); X prompt("Use autoindent (n default) (y/n): "); X lreply(rp,10); X if (*rp == 'y') X fputc(1,f); X else X fputc(0,f); X X BL; X prompt("Home display line: (1-66, 16 default): "); X rdint(&val); X if (val > 66 || val <= 0) X fputc(16,f); X else X fputc(val,f); X X BL; X prompt("Scroll window (0 default): "); X rdint(&val); X if (val > 24) X val = 0; X fputc(val,f); X X BL; X prompt("Find case (e=exact,a=any, any default): "); X lreply(rp,10); X if (*rp == 'e') X fputc(1,f); X else X fputc(0,f); X X BL; X X prompt("Auto line wrap width (0 default): "); X rdint(&val); X if (val > 79) X val = 0; X fputc(val,f); X X BL; X prompt("Use wild cards (y default) (y/n)? "); X lreply(rp,10); X if (*rp == 'n') X fputc(0,f); X else X fputc(1,f); X X BL; X prompt("Use BACKUP.LOG file (n default) (y/n)? "); X lreply(rp,10); X if (*rp == 'y') X fputc(1,f); X else X fputc(0,f); X X#ifdef MSDOS X BL; X remark("The editor can recognize Ctrl-z as EOF, or it can ignore ^Z and"); X remark("just use the standard MS-DOS end of file mark."); X prompt("Should the editor recognize Ctrl-Z as EOF? (y/n) "); X lreply(rp,10); X if (*rp == 'y') X fputc(1,f); X else X fputc(0,f); X#endif X X cls(); X remark("Configuration file created."); X fclose(f); X } X X/* ===============================>>> FUNKEYS <<<========================*/ X funkeys() X { X X FAST int j,i,val; X SLOW int fun; X XFAGAIN: X cls(); X remark("You may now define up to 49 function keys to be translated to"); X remark("commands OR letters. This translation will take place before"); X remark("the editor gets the character at any level -- thus the translation"); X remark("will apply equally to command mode and insert mode. The translation"); X remark("assumes each function key generates a 2 character sequence. The"); X remark("first character is an 'escape' character that must be the same for"); X remark("each key. If the 'escape' character is really ESC, then you must"); X remark("also define one function key to have ESC as its translation value."); X remark("When asked for the function key, simply press the key, followed by"); X remark("RETURN. Enter either the character or decimal value of the translation."); X X for (i = 0 ; i < 50 ; ++i) X { X funchar[i] = funcmd[i] = 0; X } X X BL; X prompt("Do you want to define any function keys? (y/n) "); X lreply(rp,10); X if (*rp == 'n') X goto WTFUN; X X BL; X remark("Now, please press ANY function key so the program can identify"); X prompt("the 'function key escape' code (followed by a RETURN): "); X reply(rp,10); X funesc = *rp; /* this should be the escape char */ X if (funesc == 27) X { X BL; X remark("IMPORTANT: You MUST define a function key to send an ESCAPE (decimal 27)."); X remark("If you don't, then you won't be able to end insert mode or repeat loops."); X remark("The program doesn't have logic to make sure you do this, so don't forget!"); X BL; X } X X for (i = 0 ; i < 50 ; ++i) X { XFUNAGAIN: X prompt("Press function key to define (RETURN only to exit): "); X rp[1] = 0; X reply(rp,10); X fun = rp[1]; X if (rp[1] == 0) X break; X for (j = 0 ; j < 50 ; ++j) X { X if (fun == funchar[j]) X { X remark("That's been used already, try again."); X goto FUNAGAIN; X } X } X funchar[i] = fun; X prompt("Now enter the character/command it gets translated to: "); X reply(rp,10); X val = getval(rp); X funcmd[i] = val; X } X X cls(); Xremark("Functions have been defined. You can start over if you made any mistakes."); X remark(""); X prompt("Are they ok? (y/n) "); X lreply(rp,10); X if (*rp == 'n') X goto FAGAIN; X XWTFUN: X for (i = 0 ; i < 50 ; ++i) X { X fputc(funchar[i],f); X } X for (i = 0 ; i < 50 ; ++i) X { X fputc(funcmd[i],f); X } X fputc(funesc,f); X } X X X/* ===============================>>> GETVAL <<<========================*/ X getval(str) X char *str; X { X /* return one byte value */ X X if (*str >= '0' && *str <= '9') X return (atoi(str)); X else X return (*str & 0377); X } X X/* ===============================>>> SET <<<========================*/ X set(indx,msg) X int indx; X char *msg; X { X /* set newlex[indx] to a new value */ X X SLOW int val,i; X XSAGAIN: X prompt("Enter new command for "); prompt(msg); prompt(": "); X reply(rp,10); X val = getval(rp); X X if (val == 0) X { X remark("Invalid value, try again"); X goto SAGAIN; X } X for (i = 1 ; i <= LEXVALUES ; ++i) X { X if (val == newlex[i]) X { X remark("That value has been already used. Try again."); X goto SAGAIN; X } X } X newlex[indx] = val; /* save value */ X X } X X/* ===============================>>> SYNO <<<========================*/ X syno() X { X X FAST int j, i, valfrom, valto, found; X XSAGAIN: X cls(); X remark("You may now define up to 19 synonyms. For example, you might"); X remark("want to define a space to be a synonym for right, or RETURN"); X remark("the same as down. You must use unused values, however. You"); X remark("can't use a existing command as a synonym. You may enter the"); X remark("character followed by a RETURN, or the decimal value of the key."); X X for (i = 0 ; i < 20 ; ++i) X { X synofr[i] = synoto[i] = 0; X } X X for (i = 0 ; i < 19 ; ++i) X { XSYNAGAIN: X BL; X prompt("Enter the new synonym (RETURN when done): "); X reply(rp,10); X valfrom = getval(rp); X if (valfrom == 0) X break; X for (j = 1 ; j <= LEXVALUES ; ++j) X { X if (lexsym[j] == valfrom) X { X remark("That is already a command! Try again."); X goto SYNAGAIN; X } X } X prompt("Enter the equivalent command: "); X reply(rp,10); X valto = getval(rp); X for (j = 1, found = FALSE ; j <= LEXVALUES ; ++j) X { X if (lexsym[j] == valto) X found = TRUE; X } X if (!found) X { X remark("That is not a defined command. Try again."); X goto SYNAGAIN; X } X X synofr[i] = valfrom; X synoto[i] = valto; X } X cls(); X Xremark("Synonyms have been defined. You can start over if you made any mistakes."); X remark(""); X prompt("Are they ok? (y/n) "); X lreply(rp,10); X if (*rp == 'n') X goto SAGAIN; X X for (i = 0 ; i < 20 ; ++i) X fputc(synofr[i],f); X for (i = 0 ; i < 20 ; ++i) X fputc(synoto[i],f); X X } X X/* ===============================>>> CLS <<<========================*/ X cls() X { X FAST int i; X for (i = 0 ; i < 25 ; ++i) X remark(""); X } X X#define EXTENDED /* my own extended lib functions */ X/* #define STANDARD /* the set of standard functions i use */ X#define LOCAL static /* make all local globals, i think */ X X#ifdef EXTENDED X/*=============================>>> CLOWER <<<================================*/ X char clower(ch) X char ch; X { X return ((ch >='A' && ch<='Z') ? ch + ' ' : ch); X } X X/*=============================>>> CUPPER <<<================================*/ X char cupper(ch) X char ch; X { X return ((ch >= 'a' && ch <= 'z') ? ch - ' ' : ch); X } X X/* =========================>>> LOWER <<<==============================*/ X lower(str) X char str[]; X { X FAST int i; X X for (i=0 ; str[i] ; ++i) X str[i]=clower(str[i]); X X } X X/*=============================>>> PROMPT <<<================================*/ X prompt(msg) X char msg[]; X { X printf("%s",msg); X } X X X/*=============================>>> REMARK <<<================================*/ X remark(msg) X char msg[]; X { X printf("%s\n",msg); X } X X/*=============================>>> UPPER <<<================================*/ X upper(str) X char str[]; X { X static int i; X X for (i=0 ; str[i] ; ++i) X str[i]=cupper(str[i]); X } X X X/*=============================>>> LREPLY <<<================================*/ X lreply(msg,maxc) X char msg[]; X int maxc; X { X reply(msg,maxc); X lower(msg); X } X X/*=============================>>> UREPLY <<<================================*/ X ureply(msg,maxc) X char msg[]; X int maxc; X { X reply(msg,maxc); X upper(msg); X } X X/*=============================>>> REPLY <<<================================*/ X reply(msg,maxc) X char msg[]; X int maxc; X { X#ifdef UNIX X gets(msg); X#else X ms_reply(msg,maxc); X#endif X } X X/*=============================>>> RDINT <<<================================*/ X rdint(val) X int *val; X { X char chrrep[12]; X reply(chrrep,11); X *val = atoi(chrrep); X } X#endif X#ifdef MSDOS X/*=============================>>> MS_REPLY <<<================================*/ X ms_reply(msg,maxc) X char msg[]; X int maxc; X { X#define CBS 8 /* Backspace */ X#define CDL1 21 /* ^U */ X#define CDL2 24 /* ^X */ X#define CABORT 3 /* ^C */ X#define CRET 13 /* cr */ X#define BACKSPACE 8 X X static char ch, rp; X static int i; X X X for (i = 0 ; i < maxc ; ) /* i -> next char */ X { X ch = bdos(7,-1) & 0377; /* read the character */ X if (ch == CBS) /* back space */ X { X if (i > 0) /* must be something to delete */ X { X --i; /* wipe out char */ X bdos(2,BACKSPACE); bdos(2,' '); bdos(2,BACKSPACE); X if (msg[i] < ' ') /* double echo ^ chrs */ X { X bdos(2,BACKSPACE); bdos(2,' '); bdos(2,BACKSPACE); X } X } X } X#ifdef USE_WIPE X else if (ch == CDL1 || ch == CDL2) /* wipe whole line */ X { X i = 0; /* set for loop ++ */ X remark("#"); X prompt("Re-enter? "); X } X#endif X else if (ch == CABORT) X { X remark("^C"); X prompt("Exit to operating system - are you sure? (y/n) "); X rp = bdos(7,-1) & 0377; X if (rp == 'y' || rp =='Y') X { X remark("y"); X exit(0); X } X remark("n"); X msg[i] = 0; X prompt("Re-enter? "); prompt(msg); /* re-echo */ X } X else if (ch == CRET) /* ret, so done */ X { X remark(""); X msg[i] = 0; X return; X } X else X { X msg[i++] = ch; X msg[i] = 0; /* always 0 terminate */ X if (ch < ' ') X { X ch += '@'; X bdos(2,'^'); X } X bdos(2,ch); /* echo char */ X } X } /* end for */ X X remark(""); X } X X#endif X/* ------------------------------- tvx_cfg.c ------------------------ */ SHAR_EOF echo ALL DONE! exit 0