Trailing-Edge
-
PDP-10 Archives
-
decuslib20-04
-
decus/20-0135/sources/vided.sim
There is 1 other file named vided.sim in the archive. Click here to see a list.
00010 OPTIONS(/l); COMMENT DISPLAY EDITOR. See
00020 VISTA.MAN for explanations on the routines used in this program;
00030 COMMENT The Author and the Swedish National Defense Research
00040 Institute take no responsibility for errors in this program or other
00050 files connected with it;
00060 BEGIN
00070
00080 COMMENT COMMENT%IF VIDTIM marks additions to output everything
00090 input from the user terminal onto a log file;
00100 COMMENT COMMENT%IF FQC marks additions to enable the use of
00110 FQC for frequency counting on VIDED;
00120 COMMENT COMMENT%IF DEBUGTERMINAL marks additions to allow separate
00130 debug and editing terminals;
00140 COMMENT COMMENT%IF DEBUGSLOW marks additions to create artificial
00150 slowness to debug behaviour on a heavily loaded machine;
00160
00170 COMMENT all the external procedures below are described in the
00180 DECsystem-10 SIMULA Language Handbook part 3;
00190 EXTERNAL TEXT PROCEDURE tmpin, conc, front, storbokstav, upcase,
00200 compress, rest, filspc, inline, frontstrip, scanto, from, upto,
00210 today, tmpnam;
00220 EXTERNAL CHARACTER PROCEDURE findtrigger, fetchar;
00230 EXTERNAL INTEGER PROCEDURE search, scanint, rename;
00240 EXTERNAL INTEGER PROCEDURE scan;
00250 EXTERNAL REF (infile) PROCEDURE findinfile;
00260 EXTERNAL REF (outfile) PROCEDURE findoutfile;
00270 EXTERNAL CHARACTER PROCEDURE getch;
00280 EXTERNAL INTEGER PROCEDURE trmop, gettab, checkint;
00290 EXTERNAL BOOLEAN PROCEDURE puttext, numbered, tmpout, rescan,
00300 dotypeout;
00310 EXTERNAL PROCEDURE depchar, outstring, forceout, echo, abort, exit,
00320 outchr;
00330 COMMENT%IF debugslow
00340 EXTERNAL PROCEDURE sleep;
00350 COMMENT%IFEND debugslow;
00360 EXTERNAL CLASS mvista, qregister=vided0;
00370 EXTERNAL CLASS vided1, vided2;
00380 COMMENT%IF debugterminal - when debugging with a separate debug
00390 REF (infile) newsysin; ! terminal for SIMDDT i/o and another;
00400 COMMENT%IF debugterminal terminal for the VIDED editing
00410 REF(outfile) newsysout;
00420 COMMENT%IFEND debugterminal;
00430 COMMENT%IF VIDTIM
00440 REF (outfile) vidtim; ! File for log of input from terminal;
00450 COMMENT%IFEND VIDTIM;
00460
00470 REF (infile) editin; ! Input text file to be edited;
00480 REF (outfile) editout; ! Output file after editing;
00490 REF (qregister) q_qregisters; ! See &Q and &G VIDED commands;
00500 INTEGER terminaltype; ! Number of user terminal type;
00510 INTEGER absterminaltype; ! Absolute value of this number;
00520 INTEGER height; ! Number of lines on the screen;
00530 INTEGER width; ! Number of characters in a line on the screen;
00540 INTEGER pageheight; ! Number of lines in a page;
00550 INTEGER bad_line_count; ! Count of bad lines;
00560 INTEGER leftmargin; ! Initial value for left margin;
00570 INTEGER rightmargin; ! Initial value for right margin;
00580 INTEGER increment; ! Increment for line numbered files, 0 for
00590 nonnumbered files;
00600 COMMENT%IF debugterminal
00610 BOOLEAN debug; ! Debugging with separate terminal for SIMDDT;
00620 COMMENT%IFEND debugterminal;
00630 BOOLEAN numbered_infile; ! Input file was line-numbered;
00640 BOOLEAN tmpoutfile; ! Output file has temporary file name;
00650 BOOLEAN pageheader; ! Put headers and page numbers on top of each
00660 page;
00670 BOOLEAN synka; ! Synchronization needed of cursor;
00680 COMMENT the arrays below contain handling of switches in
00690 the initial command to VIDED giving file names etc:
00700 For a description of these arrays, see the large comment
00710 in the beginning of the file SCAN.SIM;
00720 TEXT ARRAY key, arg, ini, default[1:13];
00730 TEXT command; ! Command given by the user when starting VIDED;
00740 TEXT belowcommand; ! 1) Messages to and from the TMP:EDS file, which
00750 remembers which file to edit between edit sessions,
00760 2) The text below a VIDED command on the screen, to be restored when
00770 the command is ready;
00780 TEXT infilename;
00790 TEXT outfilename;
00800 TEXT inprotect; ! Protection code on input file;
00810 TEXT indevice; ! Device of input file;
00820 TEXT inspec; ! Input file specification;
00830 TEXT temparg; ! Temporary text;
00840 BOOLEAN otherppn; ! Input file from other PPN than your own;
00850 CHARACTER dot; ! % for .GNO files, otherwise a dot;
00860
00870 PROCEDURE overwritewarning(t); TEXT t;
00880 BEGIN
00890 outtext("%VIDED - You are overwriting a file: ");
00900 outtext(temparg);
00910 outtext(". To continue push RETURN."); outimage; inimage;
00920 END;
00930
00940 BOOLEAN PROCEDURE helptype(heightm1,helpprint);
00950 INTEGER heightm1; BOOLEAN helpprint;
00960 COMMENT Action of &H VIDED command requesting the printing of a help
00970 text;
00980 BEGIN REF (infile) helpfile;
00990 INTEGER count; BOOLEAN limitfound; TEXT helpborder;
01000 helpborder:- copy("VIDED EDITING COMMANDS");
01010 COMMENT Switch these two for higher efficiency if VIDED.HLP
01020 is in the HLP: area;
01030 helpfile:- findinfile("VIDED.HLP[106,346]");
01040 IF helpfile == NONE THEN helpfile:- findinfile("HLP:VIDED.HLP");
01050 INSPECT helpfile DO
01060 BEGIN
01070 open(blanks(80)); inimage;
01080 WHILE NOT helpfile.endfile DO
01090 BEGIN
01100 COMMENT Different part of help file printed depending
01110 on when this procedure is called;
01120 IF NOT limitfound THEN
01130 BEGIN
01140 limitfound:= search(image,helpborder) <= 60;
01150 IF limitfound THEN helpprint:= NOT helpprint;
01160 END;
01170 IF helpprint THEN
01180 BEGIN
01190 sysout.image:= image; sysout.outimage;
01200 count:= count+1;
01210 IF count = heightm1 THEN
01220 BEGIN sysout.outtext("To continue push RETURN.");
01230 sysout.breakoutimage;
01240 sysin.inimage; count:= 0;
01250 outchr(sysout,char(13),1); !carriage return;
01260 outchr(sysout,' ',25); outchr(sysout,char(13),1);
01270 END;
01280 END;
01290 inimage;
01300 END;
01310 helptype:= TRUE;
01320 close;
01330 END;
01340 END;
01350
01360 topstart: !z_t(18); COMMENT Start of execution here;
01370 COMMENT%IF VIDTIM
01380 vidtim:- new outfile("VIDTIM *");
01390 COMMENT%IF VIDTIM
01400 !vidtim vidtim.open(notext);
01410 COMMENT%IFEND VIDTIM;
01420
01430 dot:= '.';
01440 outtext("[VIDED DISPLAY TERMINAL EDITOR VERSION 2A IS HERE]");
01450 outimage;
01460 key[1]:-copy("/DEFAULT:");
01470 key[2]:-copy("/T:");
01480 key[3]:-copy("=");
01490 key[4]:- copy("/DEBUG");
01500 key[5]:- copy("/H");
01510 key[6]:- copy("/N");
01520 key[7]:- copy("/-N");
01530 key[8]:- copy("/MP:");
01540 key[9]:- copy("/ML:");
01550 key[10]:- copy("/MR:");
01560 key[11]:- copy("/P");
01570 key[12]:- copy("/-P");
01580 key[13]:- copy("/L:");
01590
01600 INSPECT findinfile("SWITCH.INI") DO
01610 BEGIN COMMENT The SWITCH.INI file may contain personal default
01620 settings, e.g. telling VIDED what kind of terminal you are using;
01630 open(blanks(130));
01640 WHILE NOT endfile DO
01650 BEGIN
01660 inimage;
01670 storbokstav(image);
01680 IF image.sub(1,5) = "VIDED" THEN
01690 BEGIN
01700 IF scan(from(image,7),13,ini,key,1) NE 0 THEN
01710 BEGIN outtext("? Multiple keywords"
01720 " in SWITCH.INI:");
01730 outtext(image.strip);
01740 outimage;
01750 END;
01760 END;
01770 END;
01780 close;
01790 END;
01800 start:
01810 IF rescan THEN
01820 INSPECT sysin DO
01830 BEGIN COMMENT Reread line invoking VIDED;
01840 inimage;
01850 IF scanto(image,'-').length < image.length THEN
01860 BEGIN
01870 command:- rest(image);
01880 IF scan(command,13,arg,key,1) NE 0 THEN
01890 GOTO multiple ELSE GOTO gotparameters;
01900 END;
01910 END;
01920
01930 COMMENT Scan and interpret switches in input command;
01940 restart: WHILE scan(inline("*",sysin),13,arg,key,1) NE 0 DO
01950 BEGIN
01960 multiple: outtext("? Multiple keywords:");
01970 outtext(sysin.image.strip);
01980 outtext("please try again.");
01990 outimage;
02000 END;
02010
02020 gotparameters:
02030 IF arg[1] = "?" OR arg[5] =/= NOTEXT THEN
02040 BEGIN COMMENT type help text to the user;
02050 echo(sysin,2); ! no echo;
02060 IF NOT helptype(15,TRUE) THEN
02070 BEGIN outtext("Cannot find VIDED.HLP"); outimage;
02080 END;
02090 echo(sysin,4); ! echo again;
02100 GOTO start;
02110 END;
02120 BEGIN INTEGER i;
02130 COMMENT Use default settings from the SWITCH.INI file;
02140 FOR i:= 1 STEP 1 UNTIL 12 DO
02150 BEGIN IF arg[i] == NOTEXT THEN arg[i]:- ini[i];
02160 END;
02170 END;
02180
02190 COMMENT If the user gave no input file name, look for
02200 previously used file name in TMP:EDS;
02210 IF arg[1] = " " THEN
02220 BEGIN
02230 belowcommand:- tmpin("EDS",FALSE);
02240 belowcommand:- scanto(belowcommand,char(13)).strip;
02250 belowcommand:- scanto(belowcommand,char(10)).strip;
02260 scanto(belowcommand,' '); arg[1]:- rest(belowcommand);
02270 END;
02280
02290 editin:- findinfile(arg[1]);
02300 IF editin =/= NONE THEN
02310 BEGIN
02320 IF arg[3] =/= NOTEXT THEN
02330 overwritewarning(arg[1]) ELSE
02340 BEGIN
02350 arg[3]:- arg[1];
02360 tmpoutfile:= TRUE;
02370 END;
02380 END ELSE IF arg[3] == NOTEXT THEN arg[3]:- copy("NUL:NUL");
02390 IF arg[1] NE arg[3] THEN editin:- findinfile(arg[3]);
02400 IF editin == NONE THEN
02410 BEGIN outtext("?CANNOT FIND INPUT FILE: "); outtext(arg[3]);
02420 outimage; GOTO start;
02430 END;
02440
02450 editin.open(blanks(IF width < 140 THEN 140 ELSE width));
02460
02470 COMMENT find and interpret input file specification;
02480 inspec:- filspc(editin,8R121101 000001);
02490 scanto(inspec,':');
02500 indevice:- inspec.sub(1,inspec.pos-1);
02510 scanto(inspec,'['); IF inspec.more THEN
02520 BEGIN otherppn:= TRUE;
02530 END;
02540 inspec.setpos(1); scanto(inspec,'<');
02550 inprotect:- from(inspec,inspec.pos-1);
02560
02570 IF tmpoutfile THEN
02580 BEGIN COMMENT Use temporary name on the output file;
02590 IF otherppn THEN
02600 BEGIN COMMENT Input file not on the user PPN, put output file
02610 there;
02620 temparg:- arg[1];
02630 temparg.setpos(1); scanto(temparg,'[');
02640 IF temparg.more THEN
02650 BEGIN temparg.setpos(temparg.pos-1);
02660 scanto(temparg,']'):= NOTEXT;
02670 temparg.sub(temparg.pos-3,2):= "[,";
02680 END ELSE temparg:- conc(temparg,"[,]");
02690 arg[1]:- temparg;
02700 tmpoutfile:= FALSE;
02710 IF findinfile(temparg) =/= NONE THEN
02720 overwritewarning(temparg);
02730 END ELSE
02740 BEGIN
02750 arg[1]:- tmpnam("VID");
02760 IF findinfile(tmpnam("PIP")) =/= NONE THEN
02770 BEGIN outtext("?VIDED - You must delete the file """);
02780 outtext(tmpnam("PIP")); outtext(""" first.");
02790 outimage; outimage;
02800 GOTO stopedit;
02810 END;
02820 END;
02830 END;
02840
02850 COMMENT Read first line to check for line numbers;
02860 editin.inimage;
02870 numbered_infile:= numbered;
02880 IF arg[6] =/= NOTEXT THEN
02890 BEGIN
02900 increment:= scanint(arg[5]);
02910 IF increment > 1100000 THEN increment:= 0;
02920 END;
02930 IF numbered_infile AND increment = 0 THEN increment:= 10;
02940 IF arg[7] =/= NOTEXT THEN increment:= 0;
02950
02960 temparg:- arg[1];
02970 IF tmpoutfile THEN
02980 BEGIN COMMENT Create name of backup file;
02990 inspec.setpos(1); scanto(inspec,'.');
03000 IF inspec.more THEN
03010 BEGIN IF fetchar(inspec,inspec.pos) = 'Q' OR inspec.getchar = 'q'
03020 THEN
03030 BEGIN outtext("?VIDED - Cannot handle input file with '.Q': ");
03040 outtext(inspec); outimage;
03050 GOTO start;
03060 END;
03070 END;
03080
03090 IF fetchar(inprotect,2) > '2' THEN
03100 BEGIN outtext("?VIDED - Cannot overwrite file: ");
03110 outtext(inspec); outimage; exit(0); GOTO start;
03120 END;
03130
03140 COMMENT Set protection of temporary output file;
03150 temparg.setpos(1);
03160 IF scanto(temparg, '<').length >= temparg.length THEN
03170 BEGIN COMMENT no protection given by the user;
03180 temparg:- conc(temparg,"<077>");
03190 END;
03200
03210 COMMENT Set device for temporary output file;
03220 temparg.setpos(1); IF scanto(temparg,
03230 ':').length >= temparg.length THEN
03240 BEGIN COMMENT no device given by the user;
03250 temparg:- conc(indevice,temparg);
03260 END;
03270 END;
03280
03290 COMMENT Numbered outfile?;
03300 IF increment > 0 THEN temparg:- conc(temparg,"/NUMBERED");
03310
03320 editout:- findoutfile(temparg);
03330 arg[1]:- temparg;
03340 IF editout == NONE THEN
03350 BEGIN outtext("?VIDED - CANNOT OPEN OUTPUT FILE: "); outtext(arg[1]);
03360 outimage; exit(0);
03370 GOTO start;
03380 END;
03390
03400 COMMENT Find user given or default parameters;
03410 terminaltype:= scanint(arg[2]);
03420 COMMENT%IF debugterminal
03430 debug:= arg[4] =/= NOTEXT;
03440 COMMENT%IFEND debugterminal;
03450
03460 IF arg[8] =/= NOTEXT THEN pageheight:= scanint(arg[8]) ELSE
03470 pageheight:= 56;
03480 IF arg[9] =/= NOTEXT THEN leftmargin:= scanint(arg[9]) ELSE
03490 leftmargin:= IF increment = 0 THEN 5 ELSE 13;
03500 IF arg[10] =/= NOTEXT THEN rightmargin:= scanint(arg[10]) ELSE
03510 rightmargin:= IF increment = 0 THEN 68 ELSE 76;
03520 IF increment > 0 AND leftmargin < 8 THEN leftmargin:= 8;