home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Guide
/
c-cplusplus-interactive-guide.iso
/
c_ref
/
csource3
/
115_01
/
config1.c
< prev
next >
Wrap
Text File
|
1979-12-31
|
15KB
|
739 lines
/* Screen editor: configuration program
*
* Source: config1.c
* Version: June 4, 1981.
*/
/* Values of control keys go here */
int up; /* value of cursor up key */
int down; /* cursor down key */
int left; /* cursor left key */
int right; /* cursor right key */
int ins; /* enter insert mode key */
int del; /* delete character key */
int esc; /* leave current mode key */
int abt; /* undo editing key */
int altup; /* alternate up key */
int altdn; /* alternate down key */
int delline; /* delete line key */
int govid; /* enter video mode key */
/* Video screen and printer characteristics go here */
int scrnl; /* number of rows on screen */
int scrnw; /* # of columns on screen */
int haseol; /* has erase to end of line */
int hasel; /* has erase line */
int hassup; /* has hardware scroll up */
int hassdn; /* has hardware scroll down */
int lwidth; /* width of list device */
/* Define array which contains the code that the
* user gives to do special screen functions.
*/
#define BYTEMAX 1000 /* size of byte array */
char bytes[BYTEMAX];
int bytec; /* index of next free entry */
/* Define indices into bytes[] which point at start
* of code for each special screen function.
*/
int gotoind; /* index to gotoxy code */
int eolind; /* erase to end of line */
int elind; /* erase line */
int supind; /* scroll up */
int sdnind; /* scroll down */
/* Define return codes */
#define YES 1 /* all ok */
#define NO 2 /* try again */
#define EXIT 3 /* stop the program */
/* Define special characters */
#define CR 13 /* carriage return */
#define LF 10 /* line feed */
#define TAB 9 /* tab */
/* define output file index */
int output;
/* This program has 5 parts.
*
* Part 1 asks which keys do which special functions.
* Part 2 asks which special functions the screen has.
* Part 3 asks what code sequences must be output
* to the screen to do the functions in part 2.
* Part 4 creates the file ed1.ccc from the answers to
* Part 1.
* Part 5 creates the file ed6.ccc from the answers to
* Parts 2 and 3.
*/
main()
{
/* initialize byte count */
bytec=0;
/* sign on and give general information */
signon();
/* get keyboard information */
while (part1()==NO) {
;
}
/* get screen features */
while (part2()==NO) {
;
}
/* get control sequences for screen features */
while (part3()==NO) {
;
}
/* make sure we want to continue */
blank();
plc("You are now ready to create files ");
pc("ed1.ccc and ed6.ccc.");
plc("Do you want to proceed ?");
if (yesno()==NO) {
return;
}
/* write keyboard info to file ed1.ccc */
if (part4()!=YES) {
return;
}
/* write control sequences for screen features
* to file ed6.ccc
*/
part5();
/* sign off and tell about compiling */
signoff();
}
/* sign on and tell how to abort */
signon()
{
plc("Welcome to the configuration program for the ");
pc("screen editor.");
plc("Hit control-c to exit this program early.");
plc("Hit control-p to send output to the printer.");
}
/* part 1. find out what keys will be used for
* special functions.
*/
part1()
{
blank();
plc("This section deals with your keyboard.");
plc("For each function key, enter the DECIMAL ");
pc("value of the ascii ");
plc("code that you want to assign to that function key.");
plc("Hit carriage return to indicate the default value.");
blank();
plc("up key:");
indent();
pc("This key usually moves the cursor up. In insert mode");
indent();
pc("this key inserts a line above the current line.");
indent();
pc("The default is line feed (10).");
up=getval(10);
plc("down key:");
indent();
pc("This key usually moves the cursor down. In insert mode");
indent();
pc("this key inserts a line below the current line.");
indent();
pc("The default is carriage return (13).");
down=getval(13);
plc("alternate up key:");
indent();
pc("This key usually inserts a line above the current line.");
indent();
pc("In insert mode it just moves the cursor up");
indent();
pc("The default is control-u (21).");
altup=getval(21);
plc("alternate down key:");
indent();
pc("This key usually inserts a line below the current line.");
indent();
pc("In insert mode it just moves the cursor down");
indent();
pc("The default is control-d (4).");
altdn=getval(4);
plc("left key:");
indent();
pc("This key moves the cursor left ");
pc("in all edit modes.");
indent();
pc("The default is back space (8).");
left=getval(8);
plc("right key:");
indent();
pc("This key moves the cursor right ");
pc("in all edit modes.");
indent();
pc("The default is control-r (18).");
right=getval(18);
plc("insert key:");
indent();
pc("This key enters insert mode.");
indent();
pc("The default is control-n (14).");
ins=getval(14);
plc("video key:");
indent();
pc("This key enters video mode.");
indent();
pc("The default is control-v (22).");
govid=getval(22);
plc("exit current mode key:");
indent();
pc("This key exits the current mode.");
indent();
pc("The default is esc (27).");
esc=getval(27);
plc("delete character key:");
indent();
pc("This key deletes the character to the left ");
pc("of the cursor.");
indent();
pc("The default is del (127).");
del=getval(127);
plc("delete line key:");
indent();
pc("This key deletes the line on which the cursor rests.");
indent();
pc("The default is control-z (26).");
delline=getval(26);
plc("abort key:");
indent();
pc("This key undoes the editing done on a line.");
indent();
pc("The default is control-x (24).");
abt=getval(24);
/* recap what the user has typed.
* ask if everything is all right.
*/
plc("The values of the keyboard keys are:");
plc("up: ");
putdec(up,3);
plc("down: ");
putdec(down,3);
plc("alternate up: ");
putdec(altup,3);
plc("alt down: ");
putdec(altdn,3);
plc("left: ");
putdec(left,3);
plc("right: ");
putdec(right,3);
plc("insert move: ");
putdec(ins,3);
plc("video mode: ");
putdec(govid,3);
plc("exit mode: ");
putdec(esc,3);
plc("delete char: ");
putdec(del,3);
plc("delete line: ");
putdec(delline,3);
plc("abort: ");
putdec(abt,3);
blank();
plc("are all values correct ?");
return(yesno());
}
/* get features of the video screen */
part2()
{
blank();
plc("This section deals with the video screen.");
plc("The screen MUST have a cursor positioning function,");
plc("but no other special screen functions are required.");
blank();
plc("screen length:");
indent();
pc("How many rows does your screen have ?");
indent();
pc("The default is 16.");
scrnl=getval(16);
blank();
plc("screen width:");
indent();
pc("How many columns does your screen have ?");
indent();
pc("The default is 64.");
scrnw=getval(64);
blank();
plc("printer width:");
indent();
pc("How many columns does your printer have ?");
indent();
pc("The default is 132.");
lwidth=getval(132);
blank();
plc("erase line:");
indent();
pc("Does your screen have a function which erases ");
indent();
pc("the line on which the cursor rests ?");
hasel=yesno();
plc("erase to end of line:");
indent();
pc("Does your screen have a function which erases ");
indent();
pc("from the cursor to the end of the line ?");
haseol=yesno();
plc("hardware scroll up: (line feed)");
indent();
pc("Does your screen have a function that scrolls the");
indent();
pc("screen up when the cursor is on the bottom line ?");
hassup=yesno();
plc("hardware scroll down:");
indent();
pc("Does your screen have a function which scrolls the");
indent();
pc("screen down when the cursor is on the top line ?");
hassdn=yesno();
blank();
plc("You have answered as follows: ");
plc("screen length: ");
putdec(scrnl,1);
plc("screen width: ");
putdec(scrnw,1);
plc("printer width: ");
putdec(lwidth,1);
plc("erase line ? ");
putyesno(hasel);
plc("erase to end of line ? ");
putyesno(haseol);
plc("hardware scroll up ?