Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-04 - decus/20-0135/comp/mided1.lst
There are no other files named mided1.lst in the archive.
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE    1
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		00040	OPTIONS(/l/e); COMMENT DISPLAY EDITOR.

SIM013  W LINE    40     EXTERNAL SWITCH ALREADY SPECIFIED, IGNORED 

		00080	See VISTA.MAN for explanations on the routines called by this program,
		00120	taken from the class mvista;
		00160	COMMENT Copyright (c) Swedish National Defense Research Institute;
		00200	COMMENT%IF CALLMAC;
		00240	EXTERNAL PROCEDURE vtmcur, vtsynk, vtisng;
		00280	COMMENT%IFEND CALLMAC;
		00320	EXTERNAL PROCEDURE outche, tshift, pgcopy;
		00360	EXTERNAL INTEGER PROCEDURE iondx, vdlno;
		00400	EXTERNAL TEXT PROCEDURE conc, front, storbokstav, litenbokstav,
		00440	compress, rest, inline, frontstrip, scanto, from, upto, maketext;
		00480	EXTERNAL CHARACTER PROCEDURE findtrigger, fetchar, getch;
		00520	EXTERNAL INTEGER PROCEDURE search, scanint, sscan, checkint;
		00560	EXTERNAL REF (infile) PROCEDURE findinfile;
		00600	EXTERNAL REF (outfile) PROCEDURE findoutfile;
		00640	EXTERNAL INTEGER PROCEDURE trmop, gettab;
		00680	EXTERNAL BOOLEAN PROCEDURE puttext, numbered, dotypeout;
		00720	EXTERNAL PROCEDURE depchar, outstring, forceout, echo;
		00760	EXTERNAL PROCEDURE outchr, abort, exit;
		00800	EXTERNAL BOOLEAN PROCEDURE meny;
		00840	EXTERNAL CLASS termty;
		00880	
		00920	COMMENT%IF CALLMAC;
		00960	EXTERNAL CLASS mmista;
		01000	mmista CLASS mided1;

SIM052  W LINE  1000     ILLEGAL SWITCH SETTING 

		01040	COMMENT%IFNOT CALLMAC
		01080	EXTERNAL CLASS mvista;
		01120	COMMENT%IFNOT CALLMAC
		01160	mvista CLASS vided1;
		01200	COMMENT%IFEND CALLMAC;
		 1201
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE    2
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

B1		01240	BEGIN
		01280	
		01320	CLASS qregister(qwidth, qheight, qname);
		01360	INTEGER qwidth, qheight; TEXT qname;
B2		01400	BEGIN
		01440	  COMMENT qregister is a class containing segments
		01480	  of text which the user has stored away for
		01520	  insertion in other places in his text. A qregister
		01560	  is a square of text, with a width
		01600	  (characters/line) and height (number of lines).
		01640	
		01680	  Qregister is a separately compiled class, since
		01720	  the class should be available outside the body of
		01760	  VIDED1 and VIDED2 in the preamble of the VIDED
		01800	  program, so that a user can retain qregister
		01840	  contents between successive editings of different
		01880	  or the same text;
		01920	
		01960	  TEXT ARRAY lines[0:qheight-1];
		02000	  REF (qregister) next_qregister;
E2		02040	END;
		02080	
		02120	INTEGER last_line_number; ! When creating line-numbered files,
		02160	  number of last line which has been output to the output file;
		02200	INTEGER line_number; ! temporary line number value;
		02240	INTEGER largest_line_number; ! Largest line number yet created;
		02280	INTEGER increment; ! between new line-numbered lines;
		02300	BOOLEAN videdp; ! count lines in VIDEDP fashion;
		02320	BOOLEAN numbered_infile; ! input file had line numbers;
		02360	BOOLEAN backuping; ! Auto-backup in progress;
		02400	BOOLEAN merrygoround; ! Either auto-backup or moving to earlier page;
		02440	BOOLEAN swedish, tmpoutfile;
		02480	REF (infile) editin; ! Input file to be edited;
		02520	REF (outfile) editout; ! Output file from editing;
		02560	INTEGER showdefault; ! how many lines to show on screen;
		02600	INTEGER pageheight; ! plus height = number of lines kept in core;
		02660	INTEGER warningheight; ! before page-end-warning;
		02680	INTEGER leftmargin, rightmargin; ! used when justifying
		02720	  paragraphs;
		02760	BOOLEAN pageheader; ! Put header and number on new pages;
		02800	TEXT command; ! Text of user &command during editing;
		02840	TEXT belowcommand; ! Screen text below user &command;
		02880	INTEGER keys; ! Max dimension of the arrays below;
		02920	COMMENT the arrays below contain handling of switches in
		02960	the initial command to VIDED giving file names etc:
		03000	For a description of these arrays, see the large comment
		03040	in the beginning of the file SCAN.SIM;
		03080	TEXT ARRAY arg, key, ini(1:27); ! User switch.ini and file creation
		03120	commands;
		03160	CHARACTER dot; ! this character in pos 1 of line stops &JU, &FI;
		03200	
		03240	mvistax CLASS vided1x;
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE   2-1
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

B3		03280	BEGIN
		03320	  INTEGER sub_page_number; ! too large pages divided into;
		03360	  INTEGER ARRAY screen_length[0:height-1]; ! when overwriting
		03400	  part of the screen with corrected text, this array keeps the old
		03440	  line lengthes to know how much has to be overwritten;
		03480	TEXT ARRAY top_of_page[0:pageheight]; ! lines which have rolled
		03520	  out on top of the screen but have not yet been output;
		03560	  INTEGER top_size; ! Number of lines in "top_of_page";
		03600	  INTEGER top_fill; ! Number of lines currently in "top_of_page";
		03640	INTEGER ttytab; ! Value of monitor TRMOP .TTY TAB settings,
		03680	  governs the handling of <HT> characters at terminal output;
		03720	  INTEGER pagenumber; ! Count of input page number;
		03760	INTEGER debugslow; ! When this variable is nonzero, the program can
		03800	  be artificially slowed down to create the kind of bugs which only
		03840	  occur with a heavily loaded computer;
		03880	  INTEGER out_pagenumber; ! Count of output page number;
		03920	  INTEGER first_text_pos;! 8 for numbered, 0 for other files;
		03960	  INTEGER pbottom; ! Unwanted size of blank area in &nPS command;
		04000	  CHARACTER control_f, control_d, control_v, control_u, control_w;
		04040	  ! What is input when the terminal user pushes CONTROL plus
		04080	  one of the letters f, d, v, u or w;
		04120	  BOOLEAN ARRAY tab_position[0:width]; ! tabs set by user;
		04160	  INTEGER margin_width; ! rightmargin-leftmargin;
		04200	  INTEGER cover_length; ! cover old text at end of line;
		04240	BOOLEAN first_input_line; ! true when only one line has been input
		04280	  from the input text file;
		04320	  BOOLEAN nooutput; ! During &_ monitor command;
		04360	BOOLEAN long_line_warned; ! user has been warned about too long
		04400	  input lines;
		04440	  BOOLEAN addff; ! Add <form feed> before next output line;
		04480	  BOOLEAN inhibit_ff; ! form feed has been copied;
		04520	  BOOLEAN after_addff; ! Outputting second line of a page;
		04560	  BOOLEAN endpage; ! Last line of a page has been read from file;
		04600	BOOLEAN verybadscreen; ! Terminal screen must be restored from the
		04640	  computer;
		04680	  BOOLEAN printing; ! New input lines to be printed on terminal;
		04720	  BOOLEAN emptyscroll; ! Scroll in blank lines at bottom of screen;
		04760	  BOOLEAN psearch; ! TRUE during &nPS command execution;
		04800	  BOOLEAN pfound; ! TRUE when large blank bottom found during &nPS;
		04840	  BOOLEAN command_done; ! VIDED command correctly done;
		04880	        REF (qregister) qregisters; ! See description of &Q editor
		04920	          command;
		04960	TEXT editin_image_strip; ! Stripped text of last line from the input
		05000	  text file;
		05040	  TEXT other_editin_image; ! Extra image to be used sometimes;
		05080	  TEXT line_model; ! Extra line, often blank, for use sometimes;
		05120	  TEXT editout_image; ! Image of output text file;
		05160	  TEXT header; ! Header at top of each page;
		05200	  TEXT sub_header; ! Subheader = line below header;
		05240	  TEXT page_word; ! Contains the word "PAGE";
		05280	  TEXT sid_word; ! Contains the word "SID", swedish for "PAGE";
		05320	  TEXT sixdigits; ! Used to produce line number text segments;
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE   2-2
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		05360	  TEXT page_end_marker; ! Funny text warning user of end-of-page;
		05400	  TEXT output_line; ! Line to be output to output text file;
		05440	  TEXT first_scroll_line; ! Top-of-page-line to be scrolled out;
		05480	COMMENT REF-variables below used to get faster execution by using
		05520	the CALL procedure instead of ordinary PROCEDURE invokings;
		05560	  REF (one_more_line_please) p_one_more_line_please;
		05600	  REF (scroll) p_scroll;
		05640	  REF (editin_true_inimage) p_editin_true_inimage;
		05680	  REF (true_write) p_true_write;
		05720	  REF (write) p_write;
		05760	  REF (editin_inimage) p_editin_inimage;
		05800	  REF (lower_line) lower_lines;
		 5801
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE    3
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		05840	  PROCEDURE blankterminal;
B4		05880	  BEGIN IF addaltmode AND NOT homesingle
		05920	    THEN outchr(terminalout,altmode,1);
		05960	    outchr(terminalout,home,1);
		06000	    IF addaltmode AND NOT clearsingle
		06040	    THEN outchr(terminalout,altmode,1);
		06080	    outchr(terminalout,erasescreen,1);
		06120	    outchr(terminalout,delayer,10);
E4		06160	  END;
		06200	
		06240	  TEXT PROCEDURE make_five_digits(i);
		06280	  INTEGER i;
B5		06320	  BEGIN COMMENT prepars text in line-number-field of output line;
		06360	    sixdigits.putint(i+100000);
		06400	    make_five_digits:- sixdigits.sub(2,5);
		06440	    IF i > largest_line_number THEN largest_line_number:= i;
E5		06480	  END;
		06520	
		06560	  INTEGER PROCEDURE checksum;
B6		06600	  BEGIN COMMENT makes a checksum of what is shown on the screen;
		06640	    INTEGER i, sum;
		06680	    FOR i:=1 STEP 1 UNTIL height DO
B7		06720	    BEGIN
		06760	      sum:= sum + i * rank(fetchar(screen[i-1],i+13));
E7		06800	    END;
		06840	    checksum:= sum;
E6		06880	  END;
		 6881
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE    4
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		06920	  TEXT PROCEDURE warning(message, line2);
		06960	  VALUE message, line2; TEXT message, line2;
B8		07000	  BEGIN INTEGER hpos, vpos, sl0;
		07040	    hpos:= q_horizontalpos; vpos:= q_verticalpos;
		07080	    dotypeout(terminalout); home_the_cursor; specialtext;
		07120	    INSPECT terminalin DO INSPECT terminalout DO
B9		07160	    BEGIN command_done:= TRUE; ! since one warning is enough;
		07200	      IF message.length >= widthm1-14 THEN message:-
		07240	      message.sub(1,widthm1-15); IF line2.length >= widthm1 THEN
		07280	      line2:- line2.sub(1,widthm1);
		07320	      outtext("?VIDED - ");
		07360	      outtext(message); outtext("   ");
		07400	      sl0:= image.pos-1;  breakoutimage; outimage;
		07440	      outtext(IF line2 == NOTEXT THEN
		07480	      "To continue push RETURN. " ELSE line2); breakoutimage;
		07520	      inimage; storbokstav(terminalin.image.sub(1,10));
		07560	      warning:- terminalin.image;
E9		07600	    END;
		07640	    normaltext;
		07680	    IF q_display_output THEN
B10		07720	    BEGIN
		07760	      home_the_cursor; outtext(screen[0].sub(1,sl0));
		07800	      move_the_cursor_to(0,1); outtext(screen[1].sub(1,
		07840	      IF line2 == NOTEXT THEN 39 ELSE line2.length));
E10		07880	    END;
		07920	    move_the_cursor_to(hpos,vpos);
E8		07960	  END;
		 7961
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE    5
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		08000	  REF (qregister) PROCEDURE find_qregister(qname);
		08040	  TEXT qname;
B11		08080	  BEGIN COMMENT find the latest qregister with a given name;
		08120	    COMMENT See description of the "Q" VIDED command;
		08160	    REF (qregister) scanner;
		08200	    storbokstav(qname);
		08240	    scanner:- qregisters;
		08280	    WHILE scanner =/= NONE DO
B12		08320	    BEGIN IF scanner.qname EQ qname THEN GOTO out;
		08360	      scanner:- scanner.next_qregister;
E12		08400	    END;
		08440	    out: find_qregister:- scanner;
E11		08480	  END;
		08520	
		08560	  TEXT PROCEDURE pop_line;
		08600	  COMMENT get a line from stack of lines pushed below screen;
		08640	  INSPECT lower_lines WHEN lower_line DO
B13		08680	  BEGIN pop_line:- linetext; lower_lines:- next_lower_line;
E13		08720	  END;
		 8721
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE    6
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		08722	INTEGER PROCEDURE videdpcount;
B14		08724	BEGIN INTEGER line, count; CHARACTER two; TEXT t;
		08726	  FOR line:= -heightm1 step 1 until top_fill DO
B15		08727	  BEGIN
		08728	    t:- IF line <= 0 THEN screen(-line) ELSE top_of_page(line);
		08731	    IF fetchar(t,1) NE '.' THEN count:= count+2
B16		08732	    ELSE BEGIN
		08734	      two:= fetchar(t,2);
		08736	      IF two NE '&' AND two NE '_' AND two NE '+' THEN
B17		08737	      BEGIN
		08738	        count:= count +
		08741	        (IF two = 'u' OR two = 'U' OR two = 'L' or two = 'l' THEN
		08742	        1 ELSE 2);
E17		08744	      END;
E16		08746	    END;
E15		08748	  END;
		08750	  videdpcount:= count//2+1;
E14		08752	END;
		 8753
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE    7
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		08760	  CLASS lower_line(linetext);
		08800	  TEXT linetext;
B18		08840	  BEGIN COMMENT Text of line which has been pushed below the screen;
		08880	    REF (lower_line) next_lower_line;
		08920	    next_lower_line:- lower_lines;
		08960	    lower_lines:- THIS lower_line;
E18		09000	  END;
		09040	
		09080	  PROCEDURE push_line(l); NAME l; TEXT l;
B19		09120	  BEGIN COMMENT push a line to stack of lines below screen;
		09160	    IF upto(l,46) = page_end_marker THEN GOTO out;
		09200	    IF lower_lines =/= NONE THEN NEW lower_line(l) ELSE
		09240	    IF NOT (editin.endfile OR endpage)
		09280	    THEN NEW lower_line(l) ELSE
B20		09320	    BEGIN
		09360	      IF increment <= 0 THEN
B21		09400	      BEGIN
		09440	        IF l.strip =/= NOTEXT THEN NEW lower_line(l);
E21		09480	      END ELSE IF from(l,6).strip =/= NOTEXT
		09520	      THEN NEW lower_line(l);
E20		09560	    END;
		09600	    out: l:- blanks(width);
E19		09640	  END;
		 9641
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE    8
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		09680	  PROCEDURE get_register(reg); REF (qregister) reg;
		09720	  COMMENT action of the &G VIDED command. Find a qregister, puts its
		09760	  contents on top of square on screen equal to the qregister size;
		09800	  INSPECT reg DO
B22		09840	  BEGIN
		09880	    INTEGER i, orghpos, hpos, vpos, coverlength, putlength;
		09920	    INTEGER maxwidth, maxheight, boxwidth, boxheight;
		09960	    TEXT coverpart;
		10000	    orghpos:= q_horizontalpos;
		10040	    IF increment > 0 THEN
B23		10080	    BEGIN COMMENT do not restore line numbers;
		10120	      IF qwidth = width-8 AND q_horizontalpos = 0 THEN
		10160	      move_the_cursor_to(8,q_verticalpos);
E23		10200	    END;
		10240	    hpos:= q_horizontalpos; vpos:= q_verticalpos;
		10280	    maxwidth:= width-hpos;
		10320	    maxheight:= height-vpos;
		10360	    boxwidth:= IF maxwidth < qwidth THEN maxwidth ELSE qwidth;
		10400	    boxheight:= (IF maxheight < qheight THEN maxheight ELSE
		10440	    qheight)-1;
		10480	    FOR i:= 0 STEP 1 UNTIL boxheight DO
B24		10520	    BEGIN
		10560	      move_the_cursor_to(hpos,vpos+i);
		10600	      coverpart:- lines(i).sub(1,boxwidth);
		10640	      putlength:= coverpart.strip.length;
		10680	      coverlength:= screen(q_verticalpos).sub(hpos+1,boxwidth)
		10720	      .strip.length;
		10760	      IF line_erasable AND (terminaltype NE i200 OR hpos = 0)
		10800	      AND boxwidth + hpos >= width THEN
B25		10840	      BEGIN outstring(terminalout,eraseeol);
		10880	        IF putlength < coverlength THEN screen(q_verticalpos).
		10920	        sub(hpos+1+putlength,coverlength-putlength):= NOTEXT;
E25		10960	      END ELSE IF putlength < coverlength
		11000	      THEN putlength:= coverlength;
		11040	      outtext(coverpart.sub(1,putlength));
E24		11080	    END;
		11120	    move_the_cursor_to(orghpos,vpos);
		11160	    command_done:= TRUE;
E22		11200	  END;
		11201
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE    9
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		11240	  PROCEDURE put_register(qname,box_width, box_height);
		11280	  TEXT qname; INTEGER box_width, box_height;
B26		11320	  BEGIN COMMENT action of the &Q VIDED command;
		11360	    INTEGER hpos, vpos, maxwidth, maxheight, i;
		11400	    IF box_width= 0 THEN
B27		11440	    BEGIN
		11480	      hpos:= IF q_horizontalpos=0 AND increment > 0
		11520	      THEN 8 ELSE q_horizontalpos;
		11560	      box_width:= width;
E27		11600	    END ELSE hpos:= q_horizontalpos;
		11640	    IF box_height = 0 THEN box_height:= height;
		11680	    storbokstav(qname);
		11720	    vpos:= q_verticalpos;
		11760	    maxheight:= height-vpos; maxwidth:= width-hpos;
		11800	    IF box_width > maxwidth THEN box_width:= maxwidth;
		11840	    IF box_height > maxheight THEN box_height:= maxheight;
		11880	    INSPECT NEW qregister(box_width, box_height, qname) DO
B28		11920	    BEGIN
		11960	      next_qregister:- qregisters; qregisters:- THIS qregister;
		12000	      FOR i:= 1 STEP 1 UNTIL box_height DO
		12040	      lines(i-1):- copy(screen[vpos+i-1].sub(hpos+1,box_width));
		12080	      command_done:= TRUE;
E28		12120	    END;
E26		12160	  END;
		12161
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE   10
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		12200	  PROCEDURE restore_the_whole_screen;
		12240	  restore_screen(q_verticalpos, 998);
		12280	
		12320	  PROCEDURE restore_screen(startline, showlines);
		12360	  INTEGER startline, showlines;
		12400	  COMMENT: If the picture of the screen has been destroyed, then a
		12440	  call to this procedure will make the picture on the screen equal to
		12480	  the internal picture in the program. Used by the &R VIDED command;
		12520	  COMMENT negative showlines gives no initial blanking;
		12560	  IF q_display_output THEN
B29		12600	  BEGIN TEXT strippedline; INTEGER first, last;
		12640	    BOOLEAN donotblank;
		12680	    IF showlines < 0 THEN
B30		12720	    BEGIN showlines:= -showlines; donotblank:= TRUE;
E30		12760	    END;
		12800	    IF showlines >= height THEN showlines:= showlines*3;
		12840	    last:= showlines//3; first:= startline-showlines+last+1;
		12880	    last:= last+startline;
		12920	    IF last > heightm1 THEN last:= heightm1;
		12960	    IF first < 0 THEN first:= 0;
		13000	    IF last-first+1 < showlines THEN
B31		13040	    BEGIN
		13080	      last:= first+showlines-1;
		13120	      IF last > heightm1 THEN last:= heightm1;
E31		13160	    END;
		13200	    INSPECT terminalout DO
B32		13240	    BEGIN
		13280	      INTEGER h, v, hold, vold, vp;
		13320	      badscreen:= verybadscreen:= FALSE; ! We are making it good again;
		13360	      hold:= q_horizontalpos; vold:= q_verticalpos;
		13400	      home_the_cursor;
B33		13440	      BEGIN ! Blank the screen;
		13480	        IF NOT donotblank THEN blankterminal;
E33		13520	      END;
		13560	      IF terminaltype = cdc71310s THEN home_the_cursor;
		13600	      q_horizontalpos:= q_verticalpos:= 0;
		13640	      FOR vp:= 0 STEP 1 UNTIL heightm1 DO
		13680	      FOR v:= startline+vp,startline-vp-1 DO
B34		13720	      BEGIN
		13760	        IF v >= first THEN
B35		13800	        BEGIN
		13840	          IF v <= last THEN
B36		13880	          BEGIN
		13920	            strippedline:- screen[v];
		13960	            IF NOT donotblank OR line_erasable THEN
		14000	            strippedline:- strippedline.strip;
		14040	            IF donotblank OR strippedline =/= NOTEXT THEN
B37		14080	            BEGIN
		14120	              move_the_cursor_to(0,v);
		14160	              IF line_erasable THEN outstring(terminalout,eraseeol);
		14200	              outstring(terminalout,strippedline);
		14240	              outchr(terminalout,carriagereturn,1);
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE  10-1
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

E37		14280	            END;
E36		14320	          END;
E35		14360	        END;
E34		14400	      END;
		14440	      forceout(terminalout); dotypeout(terminalout);
		14480	      synchronize(hold,vold);
E32		14520	    END;
E29		14560	  END;
		14561
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE   11
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		14600	  PROCEDURE save_lengthes;
		14640	COMMENT Save the lengthes of non-blank lines on the screen to know
		14680	how much must later be restored;
B38		14720	  BEGIN INTEGER i;
		14760	    FOR i:= 0 STEP 1 UNTIL heightm1 DO
		14800	    screen_length[i]:= screen[i].strip.length;
E38		14840	  END;
		14841
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE   12
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		14880	  PROCEDURE exchange_lines(l1,l2);
		14920	  INTEGER l1, l2;
B39		14960	  BEGIN TEXT firstline;
		15000	    firstline:- screen(l1);
		15040	    screen(l1):- screen(l2);
		15080	    screen(l2):- firstline;
E39		15120	  END;
		15121
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE   13
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		15160	  CLASS one_more_line_please;
		15200	  COMMENT Get a line from the input file;
B40		15240	  BEGIN INTEGER new_length;
		15280	    detachloop: detach;
		15320	    !z_t(8); call(p_editin_inimage);
		15360	    IF printing THEN
B41		15400	    BEGIN
		15440	      new_length:= editin_image_strip.length;
		15480	      IF line_erasable THEN
		15520	      outstring(terminalout,eraseeol)
		15560	      ELSE IF new_length < cover_length
		15600	      THEN new_length:= cover_length;
		15640	      outtext(editin.image.sub(1,new_length));
		15680	      move_the_cursor_to(0,q_verticalpos);
E41		15720	    END ELSE screen(q_verticalpos):= editin_image_strip;
		15760	    !z_t(-8);
		15800	    GOTO detachloop;
E40		15840	  END;
		15841
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE   14
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		15880	  PROCEDURE shift(frompos, topos, steps);
		15920	  INTEGER frompos, topos, steps;
		15960	COMMENT shift part of the screen downwards, e.g. to get space for
		16000	new lines created by &L or &J VIDED commands;
B42		16040	  BEGIN INTEGER i;
		16080	    steps:= steps-1;
		16120	    IF frompos > topos THEN
B43		16160	    BEGIN
		16200	      FOR i:= 0 STEP 1 UNTIL steps DO
		16240	      exchange_lines(topos+i,frompos+i);
E43		16280	    END ELSE
B44		16320	    BEGIN
		16360	      FOR i:= steps STEP -1 UNTIL 0 DO
		16400	      exchange_lines(topos+i,frompos+i);
E44		16440	    END;
E42		16480	  END of shift;
		16481
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE   15
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		16520	  PROCEDURE restore_lines(first,last);
		16560	  INTEGER first, last;
		16600	COMMENT make the terminal screen contents equal to the internal
		16640	screen contents for lines [first,last] of the screen;
		16680	  IF q_display_output THEN
B45		16720	  BEGIN
		16760	    INTEGER i, maxlength;
		16800	    maxlength:= 1000;
		16840	    FOR i:= first STEP 1 UNTIL last DO
B46		16880	    BEGIN
		16920	      IF maxlength < width THEN outchr(terminalout,linefeed,1)
		16960	      ELSE synchronize(0,i);
		17000	      maxlength:= screen(i).strip.length;
		17040	      IF line_erasable THEN
		17080	      outstring(terminalout,eraseeol)
		17120	      ELSE IF maxlength < screen_length(i) THEN
		17160	      maxlength:= screen_length(i);
		17200	      outstring(terminalout,screen(i).sub(1,maxlength));
		17240	      outchr(terminalout,carriagereturn,1);
E46		17280	    END;
		17320	    home_the_cursor;
E45		17360	  END;
		17361
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE   16
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		17400	  CLASS editin_true_inimage;
		17440	  COMMENT input a line from the input text file;
B47		17480	  BEGIN TEXT part; INTEGER current_line_number;
		17520	    detachloop: detach;
		17560	    INSPECT editin DO
B48		17600	    BEGIN
		17640	      IF first_input_line THEN first_input_line:= FALSE
		17680	      ELSE inimage;
		17720	      IF endfile THEN image.sub(1,2):= NOTEXT;
		17760	      part:- scanto(image,tab);
		17800	      IF image.more THEN
B49		17840	      BEGIN COMMENT there was a tab;
		17880	        IF other_editin_image == NOTEXT THEN
		17920	        other_editin_image:- blanks(image.length) ELSE
B50		17960	        BEGIN other_editin_image:= NOTEXT;
		18000	          other_editin_image.setpos(1);
E50		18040	        END;
		18080	        IF numbered_infile THEN
B51		18120	        BEGIN IF increment = 0 THEN
B52		18160	          BEGIN IF part.length = 5 THEN
B53		18200	            BEGIN COMMENT remove line number; COMMENT Code only
		18240	              executed when removing line numbers from a file;
		18280	              IF vdlno(part) >= 0 THEN GOTO after_put;
E53		18320	            END of part.length = 5;
E52		18360	          END of increment = 0;
E51		18400	        END;
		18440	        loop:
		18480	        puttext(other_editin_image,part);
		18520	        other_editin_image.setpos
		18560	        (other_editin_image.pos+8
		18600	        -mod(other_editin_image.pos-1,8));
		18640	        after_put:
		18680	        IF image.more THEN
B54		18720	        BEGIN
		18760	          part:- scanto(image,tab);
		18800	          IF NOT image.more THEN part:- part.strip;
		18840	          GOTO loop;
E54		18880	        END;
		18920	        part:- image; image:- other_editin_image;
		18960	        other_editin_image:- part;
E49		19000	      END;
		19040	      image.setpos(1);
E48		19080	    END;
		19120	    GOTO detachloop;
E47		19160	  END;
		19161
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE   17
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		19200	  CLASS true_write;
B55		19240	  BEGIN COMMENT Output of a line to the output text file;
		19280	    detachloop: detach;
		19320	    IF NOT backuping AND upto(output_line,46) = page_end_marker THEN
B56		19360	    BEGIN output_line:= NOTEXT; GOTO fastout;
E56		19400	    END;
		19440	    output_line:- output_line.strip;
		19480	    IF after_addff THEN
B57		19520	    BEGIN after_addff:= FALSE;
		19560	      IF pageheader THEN
		19600	      sub_header:- IF addff THEN NOTEXT ELSE
		19640	      copy(IF increment <= 0 THEN output_line ELSE
		19680	      from(output_line,9));
E57		19720	    END;
		19760	    IF increment NE 0 THEN
B58		19800	    BEGIN
		19840	      IF addff THEN
B59		19880	      BEGIN
		19920	        IF pageheader THEN header:= from(output_line,9);
		19960	        after_addff:= TRUE;
B60		20000	        IF inhibit_ff THEN inhibit_ff:= FALSE ELSE BEGIN
		20040	          editout.image.setpos(6); editout.outchar(carriagereturn);
		20080	          editout.outchar(formfeed);
		20120	          editout.breakoutimage;
E60		20160	        END;
		20200	        addff:= FALSE;
		20240	        out_pagenumber:= out_pagenumber+1;
E59		20280	      END;
		20320	      line_number:= vdlno(output_line);
		20360	      IF line_number >= 0 THEN
B61		20400	      BEGIN
		20440	        last_line_number:= line_number;
		20480	        IF output_line.length = 5 THEN GOTO goodnumbered;
		20520	        IF output_line.length >= 8 THEN
B62		20560	        BEGIN IF output_line.sub(6,3) = "   " THEN
		20600	          GOTO goodnumbered;
E62		20640	        END;
E61		20680	      END;
		20720	      IF output_line.length > 8 THEN
B63		20760	      BEGIN
		20800	        IF output_line.sub(1,8) = "        " THEN
		20840	        output_line:- output_line.sub(9,output_line.length-8);
E63		20880	      END;
		20920	      COMMENT the line had no correct line number;
		20960	      last_line_number:= last_line_number+increment;
		21000	      editout.outtext(make_five_digits(last_line_number));
		21040	      editout.outchar(tab); editout.outtext(output_line);
		21080	      IF FALSE THEN goodnumbered:
B64		21120	      BEGIN
		21160	        editout.outtext(output_line.sub(1,5));
		21200	        editout.outchar(tab);
		21240	        IF output_line.length >= 8 THEN
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE  17-1
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		21280	        editout.outtext(from(output_line,9));
E64		21320	      END;
		21360	      editout.outimage; output_line:= NOTEXT;
E58		21400	    END ELSE
B65		21440	    BEGIN COMMENT the output file should NOT
		21480	      be line numbered;
B66		21520	      IF addff THEN BEGIN
		21560	        IF inhibit_ff THEN editout.image:- output_line
B67		21600	        ELSE BEGIN
		21640	          editout.outchar(formfeed); editout.outtext(output_line);
E67		21680	        END;
		21720	        IF pageheader THEN header:= output_line; after_addff:= TRUE;
		21760	        editout.outimage; output_line:= NOTEXT;
		21800	        out_pagenumber:= out_pagenumber+1; addff:= FALSE;
B68		21840	        IF inhibit_ff THEN BEGIN
		21880	          inhibit_ff:= FALSE; editout.image:- editout_image;
E68		21920	        END;
E66		21960	      END ELSE
B69		22000	      BEGIN
		22040	        editout.image:- output_line;
		22080	        editout.outimage;
		22120	        editout.image:- editout_image;
E69		22160	      END;
E65		22200	    END;
		22240	    fastout:
		22280	    GOTO detachloop;
E55		22320	  END;
		22321
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE   18
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		22360	  CLASS write;
B70		22400	  BEGIN
		22440	    TEXT exchanger;
		22480	    detachloop: detach;
		22520	    IF upto(first_scroll_line,46) = page_end_marker THEN
B71		22560	    BEGIN first_scroll_line:= NOTEXT;
		22600	      GOTO detachloop;
E71		22640	    END;
		22680	    IF top_fill = top_size THEN empty_top_of_page;
		22720	    IF NOT nooutput THEN
B72		22760	    BEGIN
		22800	      top_fill:= top_fill+1;
		22840	      exchanger:- top_of_page[top_fill];
		22880	      top_of_page[top_fill]:- first_scroll_line;
		22920	      first_scroll_line:- exchanger;
E72		22960	    END ELSE first_scroll_line:= NOTEXT;
		23000	    GOTO detachloop;
E70		23040	  END of CLASS write;
		23041
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE   19
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		23080	  PROCEDURE empty_top_of_page;
		23120	COMMENT move lines which previously have been scrolled out
		23160	above the top of the screen from an internal buffer
		23200	"top_of_page" to the output text file;
B73		23240	  BEGIN
		23280	    INTEGER top_bottom;
		23320	    sub_page_number:= sub_page_number+1;
		23360	    FOR top_bottom:= 0 STEP 1 UNTIL top_fill DO
B74		23400	    BEGIN
		23440	      output_line:- top_of_page[top_bottom]; call(p_true_write);
E74		23480	    END;
		23520	    top_fill:= -1;
E73		23560	  END;
		23561
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE   20
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		23600	  CLASS scroll;
B75		23640	  BEGIN COMMENT scroll screen, top line out, new bottom line in;
		23680	    INTEGER i;
		23720	    detachloop: detach;
		23760	    !z_t(9); first_scroll_line:- screen(0); call(p_write);
		23800	    FOR i:= 1 STEP 1 UNTIL heightm1 DO
		23840	    screen(i-1):- screen(i);
		23880	    screen(heightm1):- first_scroll_line;
		23920	    IF NOT pageheader OR backuping THEN GOTO nomark;
B76		23939	    IF NOT videdp THEN BEGIN
		23949	      IF top_fill+height+1 = warningheight
		23962	      THEN GOTO mark ELSE GOTO nomark;
E76		23972	    END;
		23979	    IF top_fill+height+1 < warningheight THEN GOTO nomark;
		23986	    IF videdpcount = warningheight THEN
B77		24000	    BEGIN
		24040	      mark: IF printing THEN
B78		24080	      BEGIN synchronize(0,q_verticalpos);
		24120	        outtext(page_end_marker);
		24160	        synchronize(0,q_verticalpos);
E78		24200	      END ELSE screen[heightm1]:= page_end_marker;
E77		24240	    END ELSE
		24280	    nomark: IF NOT emptyscroll THEN
B79		24320	    BEGIN cover_length:= 0;
		24360	      call(p_one_more_line_please);
E79		24400	    END;
		24440	    !z_t(-9);
		24480	    GOTO detachloop;
E75		24520	  END;
		24521
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE   21
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		24560	  PROCEDURE addline;
		24600	  COMMENT User has pushed the INSERT LINE key;
B80		24640	  BEGIN
		24680	    push_line(screen[heightm1]);
		24720	    shift(q_verticalpos,q_verticalpos+1,heightm1-q_verticalpos);
		24760	    q_horizontalpos:= 0;
E80		24800	  END;
		24840	
		24880	  PROCEDURE addlines(number, printing, leftjustify, restorebelow);
		24920	  COMMENT Action of &L VIDED command, new lines are inserted
		24960	  and existing lines pushed downwards;
		25000	  INTEGER number; BOOLEAN printing, leftjustify, restorebelow;
B81		25040	  BEGIN INTEGER  sink, vpos, hpos, emptysink, leftm, vpos_number;
		25080	    INTEGER i, addpos; TEXT firstpart, high_line, strip_model;
		25120	    INTEGER high_number, low_bord_number, add_increment;
		25160	    BOOLEAN badnumber;
		25200	    !z_t(10); vpos:= q_verticalpos; hpos:= q_horizontalpos;
		25240	    firstpart:- screen(vpos).sub(1,hpos);
		25280	    IF increment > 0 THEN
B82		25320	    BEGIN
		25360	      leftm:= leftmargin-8;
		25400	      IF vpos > 0 THEN high_line:- screen[vpos-1]
		25440	      ELSE IF top_fill >= 0
		25480	      THEN high_line:- top_of_page[top_fill];
		25520	      low_bord_number:= vdlno(high_line);
		25560	      IF low_bord_number < 0 THEN low_bord_number:= last_line_number;
		25600	      high_number:= vdlno(screen[vpos]);
B83		25640	      IF high_number < 0 THEN BEGIN
		25680	        badnumber:= TRUE;
		25720	        high_number:= low_bord_number+(number+1)*increment;
E83		25760	      END;
		25800	      add_increment:=
		25840	      entier((high_number-low_bord_number)/(number+1));
		25880	      IF add_increment < 1 THEN add_increment:= 1;
E82		25920	    END ELSE leftm:= leftmargin;
		25960	    IF NOT line_erasable THEN
B84		26000	    BEGIN IF printing THEN save_lengthes;
E84		26040	    END;
		26080	    sink:= number; emptysink:= sink+vpos-height;
		26120	    IF emptysink < 0 THEN emptysink:= 0;
		26160	    sink:= sink-emptysink;
		26200	    FOR i:= 1 STEP 1 UNTIL sink DO
		26240	    push_line(screen(height-i));
		26280	    FOR i:= 1 STEP 1 UNTIL emptysink DO
B85		26320	    BEGIN
		26360	      IF increment > 0 THEN
B86		26400	      BEGIN
		26440	        high_number:= high_number-add_increment;
B87		26480	        IF high_number < 1 THEN BEGIN
		26520	          high_number:= 1; badnumber:= TRUE;
E87		26560	        END;
		26600	        line_model.sub(1,5):= make_five_digits(high_number);
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE  21-1
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

E86		26640	      END;
		26680	      push_line(line_model);
E85		26720	    END;
		26760	    line_model.sub(1,5):= NOTEXT;
		26800	    shift(vpos,vpos+sink,height-vpos-sink);
		26840	    IF increment > 0 THEN
B88		26880	    BEGIN
		26920	      FOR i:= 1 STEP 1 UNTIL sink DO
B89		26960	      BEGIN
		27000	        high_number:= high_number-add_increment;
B90		27040	        IF high_number < 1 THEN BEGIN
		27080	          high_number:= 1; badnumber:= TRUE;
E90		27120	        END;
		27160	        screen(vpos+sink-i).sub(1,5):=
		27200	        make_five_digits(high_number);
E89		27240	      END;
E88		27280	    END;
		27320	    screen(vpos).sub(1,firstpart.length):= firstpart;
		27360	    IF increment <= 0 THEN firstpart:= NOTEXT ELSE
B91		27400	    BEGIN
		27440	      vpos_number:= high_number-1;
		27480	      IF vpos_number < 1 THEN vpos_number:= 1;
		27520	      IF firstpart =/= NOTEXT THEN
B92		27560	      BEGIN
		27600	        screen(vpos).sub(1,5):= make_five_digits(vpos_number);
E92		27640	      END;
		27680	      high_number:= vdlno(firstpart);
		27720	      IF high_number < 0 THEN high_number:= largest_line_number;
		27760	      firstpart:= NOTEXT;
		27800	      IF firstpart.length >= 5 THEN firstpart.sub(1,5):=
		27840	      make_five_digits(high_number+1);
E91		27880	    END;
		27920	    IF leftjustify AND firstpart =/= NOTEXT THEN
B93		27960	    BEGIN firstpart:- firstpart.main;
		28000	      IF increment > 0 THEN
		28040	      firstpart:- from(firstpart,9);
		28080	      line_model:= frontstrip(firstpart);
		28120	      strip_model:- line_model.strip;
		28160	      IF strip_model.length <= firstpart.length - leftm THEN
B94		28200	      BEGIN
		28240	        firstpart.sub(1,leftm):= NOTEXT;
		28280	        from(firstpart,leftm+1):= strip_model;
E94		28320	      END;
		28360	      line_model:= NOTEXT;
E93		28400	    END;
		28401
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE   22
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

B95		28440	    IF increment NE 0 THEN BEGIN ! update above line numbers?;
		28480	      i:= vpos-1;
B96		28520	      WHILE vpos_number <= low_bord_number DO BEGIN
		28560	        IF high_line == NOTEXT THEN GOTO stopnumber;
		28600	        vpos_number:= vpos_number-1;
		28640	        IF vpos_number < 1 THEN GOTO stopnumber;
		28680	        firstpart:- make_five_digits(vpos_number);
B97		28720	        IF i >= 0 AND printing THEN BEGIN
		28760	          move_the_cursor_to(0,i);
		28800	          outtext(firstpart);
E97		28840	        END ELSE high_line.sub(1,5):= firstpart;
		28880	        i:= i-1; ! backup one line more;
B98		28920	        IF top_fill+i < -1 THEN BEGIN
		28960	          high_line:- NOTEXT; low_bord_number:= last_line_number;
B99	E98	29000	        END ELSE BEGIN
		29040	          high_line:- IF i >= 0 THEN screen[i] ELSE
		29080	          top_of_page[top_fill+i+1];
		29120	          low_bord_number:= vdlno(high_line);
E99		29160	        END;
		29200	        IF low_bord_number < 0 THEN GOTO stopnumber;
E96		29240	      END;
		29280	      IF badnumber THEN stopnumber:
		29320	      warning("Line numbers may be out of sequence",NOTEXT);
E95		29360	    END of increment NE 0;
		29400	
		29440	    IF printing THEN
B100		29480	    BEGIN
		29520	      IF insertline =/= NOTEXT
		29560	      COMMENT Will insertline be faster?;
		29600	      AND ((sink*insertline.length < 52*(heightm1-vpos-sink))
		29640	      OR NOT restorebelow) THEN
B101		29680	      BEGIN
		29720	        IF vpos < heightm1 THEN
B102		29760	        BEGIN move_the_cursor_to(0,vpos);
		29800	          FOR i:= 1 STEP 1 UNTIL sink DO
B103		29840	          BEGIN outstring(terminalout,insertline);
E103		29880	          END;
E102		29920	        END;
		29960	        IF hpos > 0 THEN restore_lines(vpos,vpos);
		30000	        i:= number+vpos;
		30040	        IF increment NE 0 AND vpos < heightm1 THEN
B104		30080	        BEGIN IF i > heightm1 THEN i:= heightm1;
		30120	          restore_lines(vpos,i);
E104		30160	        END ELSE
		30200	        IF i <= heightm1 THEN restore_lines(i,i);
E101		30240	      END ELSE restore_lines(vpos,IF restorebelow THEN heightm1
		30280	      ELSE vpos);
		30320	      move_the_cursor_to(hpos,vpos);
E100		30360	    END;
		30400	    command_done:= TRUE; !z_t(-10);
E81		30440	  END;
		30441
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE   23
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		30480	  TEXT PROCEDURE to_continue;
		30520	COMMENT restore the screen after user has pushed the
		30560	carriage return key;
		30600	  INSPECT terminalin DO INSPECT terminalout DO
B105		30640	  BEGIN
		30680	    outimage;
		30720	    outtext("To continue push RETURN:"); breakoutimage;
		30760	    inimage; to_continue:- copy(terminalin.image.strip);
		30800	    restore_screen(q_verticalpos, 998);
E105		30840	  END;
		30841
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE   24
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		30880	  CLASS editin_inimage;
B106		30920	  BEGIN COMMENT input of one line from the input text file;
		30960	    INTEGER divpos, mindiv;
		31000	    detachloop: detach;
		31040	    IF lower_lines == NONE THEN
B107		31080	    BEGIN
		31120	      IF endpage OR editin.endfile THEN
B108		31160	      BEGIN COMMENT Input a fictitious blank line;
		31200	        editin.image:= NOTEXT;
		31240	        editin_image_strip:- NOTEXT;
E108		31280	      END ELSE
B109		31320	      BEGIN COMMENT there are more lines to be read;
		31360	        call(p_editin_true_inimage);
		31400	        editin_image_strip:- editin.image.strip;
		31440	        IF NOT endpage AND NOT editin.endfile THEN
B110		31480	        BEGIN COMMENT Was this last line of a page?;
		31520	          IF editin_image_strip =/= NOTEXT THEN
B111		31560	          BEGIN
		31600	            IF fetchar(editin_image_strip,
		31640	            editin_image_strip.length) = formfeed THEN
B112		31680	            BEGIN endpage:= TRUE; IF psearch THEN BEGIN
		31720	                IF (IF videdp THEN videdpcount ELSE top_fill +
		31739	                heightm1) + pbottom < warningheight THEN pfound:=
		31769	                TRUE;
E113		31801	              END;
		31840	              editin_image.setpos(editin_image_strip.length);
		31880	              editin_image.putchar(' ');
		31920	              editin_image_strip:- editin_image_strip.sub(1,
		31960	              editin_image_strip.length-1).strip;
E112		32000	            END of formfeed found;
E111		32040	          END of not empty line;
E110		32080	        END of was this last line;
E109		32120	      END of more lines to be read;
E107		32160	    END ELSE
B114		32200	    BEGIN editin.image:= pop_line;
		32240	      editin_image_strip:- editin.image.strip;
E114		32280	    END;
		32320	    IF editin_image_strip.length > width THEN
B115		32360	    BEGIN COMMENT split too long input lines into two lines;
		32400	      IF NOT long_line_warned THEN
		32440	      INSPECT terminalout DO
B116		32480	      BEGIN long_line_warned:= TRUE;
		32520	        breakoutimage;
		32560	        blankterminal;
		32600	        outtext("Input text contains lines longer than");
		32640	        outint(width,3); outtext(" characters."); outimage;
		32680	        outtext(
		32720	        "Such long lines will be split. No further warnings.");
		32760	        outimage;
		32800	        outtext(
		32840	        "Type CONTROL-C to keep the old file! Your text"
		32880	        " may be destroyed!"); outimage;
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE  24-1
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		32920	        to_continue;
E116		32960	      END;
		33000	      mindiv:= editin_image_strip.length-widthm1;
		33040	      FOR divpos:= widthm1 STEP -1 UNTIL mindiv DO
B117		33080	      BEGIN COMMENT split the line at a space character;
		33120	        IF fetchar(editin_image_strip,divpos) = ' '
		33160	        THEN GOTO blankfound;
E117		33200	      END;
		33240	      divpos:= width;
		33280	      blankfound:
		33320	      editin_image_strip.setpos(divpos);
		33360	      NEW lower_line(copy(rest(editin_image_strip)));
		33400	      rest(editin_image_strip):= NOTEXT;
		33440	      editin_image_strip:- front(editin_image_strip);
E115		33480	    END;
		33520	    IF increment > 0 THEN
B118		33560	    BEGIN COMMENT check line number of line numbered file;
		33600	      divpos:= vdlno(editin_image_strip); IF divpos >= 0 THEN
B119		33640	      BEGIN
		33680	        IF largest_line_number < divpos THEN
		33720	        largest_line_number:= divpos;
E119		33760	      END ELSE IF editin_image_strip == NOTEXT THEN
B120		33800	      BEGIN
		33840	        editin_image_strip:- editin.image.sub(1,5);
		33880	        largest_line_number:= largest_line_number+increment;
		33920	        editin_image_strip:= make_five_digits(
		33960	        largest_line_number);
E120		34000	      END;
E118		34040	    END;
		34080	    GOTO detachloop;
E106		34120	  END;
		34121
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE   25
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		34160	  PROCEDURE center_line(left); INTEGER left;
B121		34200	  BEGIN TEXT start, body, newline; INTEGER leftpos; CHARACTER c;
		34240	    IF left < 0 THEN left:= leftmargin;
		34280	    body:- screen[q_verticalpos]; body.setpos(1);
		34320	    IF body.getchar = '.' THEN
B122		34360	    BEGIN
		34400	      c:= body.getchar;
		34440	      WHILE digit(c) AND body.more DO c:= body.getchar;
		34480	      start:- front(body);
		34520	      body:- rest(body);
E122		34560	    END;
		34600	    body:- frontstrip(body).strip;
		34640	    leftpos:=
		34680	    (left+(rightmargin-left-body.length)//2+1);
		34720	    IF leftpos + body.length < width AND
		34760	    leftpos > start.length THEN
B123		34800	    BEGIN
		34840	      newline:- line_model; newline.sub(1,start.length):= start;
		34880	      newline.setpos(leftpos);
		34920	      puttext(newline,body);
		34960	      move_the_cursor_to(0,q_verticalpos);
		35000	      outstring(terminalout,newline);
		35040	      outchr(terminalout,carriagereturn,1);
		35080	      move_the_cursor_to(0,q_verticalpos);
		35120	      line_model:- screen[q_verticalpos];
		35160	      line_model:= NOTEXT;
		35200	      screen[q_verticalpos]:- newline;
		35240	      command_done:= TRUE;
E123		35280	    END;
E121		35320	  END;
		35321
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE   26
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		35360	  PROCEDURE case_shift(char); CHARACTER char;
B124		35400	  BEGIN
		35440	    TEXT body; INTEGER hpos;
		35480	    hpos:= q_horizontalpos;
		35520	    body:- from(screen[q_verticalpos],q_horizontalpos+1).strip;
		35560	    IF char = 'U' OR char = 'u' THEN storbokstav(body)
		35600	    ELSE litenbokstav(body);
		35640	    outstring(terminalout,body);
		35680	    q_horizontalpos:= q_horizontalpos+body.length;
		35720	    move_the_cursor_to(hpos,q_verticalpos);
		35760	    command_done:= TRUE;
E124		35800	  END;
		35801
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE   27
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		35840	  PROCEDURE charinsert; ! User has pushed insert char key;
B125		35880	  BEGIN TEXT thisline; INTEGER length;
		35920	    screen[q_verticalpos].setpos(q_horizontalpos+1);
		35960	    tshift(screen[q_verticalpos],-1);
E125		36000	  END;
		36040	
		36080	  PROCEDURE insert(qname,inserted); TEXT qname; BOOLEAN inserted;
B126		36120	  BEGIN COMMENT &I command of VIDED;
		36160	    INTEGER striplength, hpos, vpos, mindiv, divpos;
		36200	    TEXT lastpart, stripline, longline;
		36240	    hpos:= q_horizontalpos; vpos:= q_verticalpos;
		36280	    stripline:- screen(vpos).strip;
		36320	    striplength:= stripline.length;
		36360	    IF striplength + qname.length < width THEN
B127		36400	    BEGIN COMMENT New line not longer than screen width;
		36440	      IF striplength > hpos THEN lastpart:- copy(screen(vpos).
		36480	      sub(hpos+1,striplength-hpos));
		36520	      outtext(qname);
		36560	      IF inserted THEN q_display_output:= FALSE;
		36600	      outtext(lastpart);
B128		36640	      IF inserted THEN BEGIN
		36680	        q_display_output:= TRUE; q_horizontalpos:= hpos+qname.length;
E128		36720	      END ELSE move_the_cursor_to(hpos+qname.length,vpos);
E127		36760	    END ELSE
B129		36800	    BEGIN COMMENT New line has to be split into two lines on
		36840	      the screen, since it is longer than the screen width;
		36880	      longline:- conc(stripline.sub(1,hpos),qname,
		36920	      stripline.sub(hpos+1,striplength-hpos));
		36960	      mindiv:= longline.length-width;
		37000	      FOR divpos:= widthm1 STEP -1 UNTIL mindiv DO
B130		37040	      BEGIN IF fetchar(longline,divpos) = ' '
		37080	        THEN GOTO blankfound;
E130		37120	      END;
		37160	      divpos:= width;
		37200	      blankfound: move_the_cursor_to(0,vpos);
		37240	      outtext(longline.sub(1,divpos));
		37280	      make_blank(width-divpos);
		37320	      IF vpos = heightm1 THEN
B131		37360	      BEGIN
		37400	        move_the_cursor_to(0,vpos);
		37440	        outchr(terminalout,linefeed,1);
		37480	        call(p_scroll);
		37520	        vpos:= vpos-1;
		37560	        move_the_cursor_to(first_text_pos,heightm1);
E131		37600	      END ELSE move_the_cursor_to(first_text_pos,vpos+1);
		37640	      addlines(1,TRUE,FALSE,TRUE);
		37680	      outtext(longline.sub(divpos+1,longline.length-divpos));
		37720	      hpos:= hpos+qname.length;
		37760	      IF hpos < divpos THEN
		37800	      move_the_cursor_to(hpos,vpos) ELSE
		37840	      move_the_cursor_to(hpos-divpos,vpos+1);
E129		37880	    END;
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE  27-1
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		37920	    command_done:= TRUE;
E126		37960	  END of insert;
		37961
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE   28
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		38000	  INTEGER PROCEDURE written_lines;
		38040	COMMENT VIDED strips blank lines from the bottom of the page
		38080	when outputting a page to the output text file. This procedure
		38120	finds how many non-blank lines there are to output;
B132		38160	  BEGIN TEXT check_line; INTEGER i, print_height;
		38200	    IF lower_lines == NONE AND (endpage OR editin.endfile) THEN
B133		38240	    BEGIN
		38280	      FOR print_height:= heightm1 STEP -1 UNTIL 0 DO
B134		38320	      BEGIN
		38360	        check_line:- screen(print_height);
		38400	        IF increment > 0 THEN check_line:- from(check_line,6);
		38440	        IF check_line.strip =/= NOTEXT THEN GOTO out;
E134		38480	      END;
		38520	      print_height:= -1;
		38560	      out:
E133		38600	    END ELSE print_height:= heightm1;
		38640	    written_lines:= print_height;
E132		38680	  END;
		38681
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE   29
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		38720	  PROCEDURE printpage;
B135		38760	  BEGIN COMMENT Output a page to the output text file;
		38800	    INTEGER i, print_height, breakchar;
		38840	    empty_top_of_page;
		38880	    print_height:= written_lines;
		38920	    IF NOT nooutput THEN
		38960	    FOR i:= 0 STEP 1 UNTIL print_height DO
B136		39000	    BEGIN
		39040	      output_line:- screen[i]; call(p_true_write);
E136		39080	    END;
		39120	    COMMENT Output lines which have been pushed below the screen;
		39160	    WHILE NOT lower_lines == NONE DO
B137		39200	    BEGIN output_line:- pop_line;
		39240	      IF NOT nooutput THEN call(p_true_write);
E137		39280	    END;
		39320	
		39360	    COMMENT Output lines which have not yet been read from the
		39400	    input text file;
B138		39440	    IF NOT endpage AND NOT editin.endfile THEN BEGIN
B139		39480	      IF numbered_infile EQV increment = 0 THEN BEGIN
		39520	        GOTO get_a_line;
B140		39560	        WHILE NOT endpage AND NOT editin.endfile DO BEGIN
		39600	          output_line:- editin_image_strip;
		39640	          IF NOT nooutput THEN call(p_true_write);
		39680	          get_a_line:
		39720	          call(p_editin_inimage);
E140		39760	        END;
B141	E139	39800	      END ELSE BEGIN ! no line number conversion;
		39840	        pgcopy(editin,IF nooutput THEN NONE ELSE editout,
		39880	        numbered_infile); last_line_number:= -1;
		39920	        inhibit_ff:= endpage:= NOT editin.endfile;
E141		39960	      END;
E138		40000	    END of output of not yet read input file lines;
E135		40040	  END of procedure printpage;
		40041
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE   30
DSK:MIDED1.SIM	  23-MAR-1979  11:22	

		40080	COMMENT Main body of the CLASS VIDED1: initialization
		40120	of certain variables;
		40160	  allow_cr:= TRUE;
		40200	  sixdigits:- blanks(10).sub(5,6);
		40240	  p_one_more_line_please:- NEW one_more_line_please;
		40280	  p_editin_true_inimage:- NEW editin_true_inimage;
		40320	  p_true_write:- NEW true_write;
		40360	  p_write:- NEW write;
		40400	  p_editin_inimage:- NEW editin_inimage;
		40440	  p_scroll:- NEW scroll;
		40480	  page_end_marker:- copy(
		40520	  "***??? END OF PAGE *** USE &PI COMMAND ***???");
		40560	  IF page_end_marker.length > widthm1 THEN page_end_marker:-
		40600	  page_end_marker.sub(1,widthm1);
E3		40640	END of vided1x;
E1		40680	END of vided1;


SWITCHES CHANGED FROM DEFAULT:

  -A NO CHECK OF ARRAY INDEX
  -D NO SYMBOL TABLE GENERATED FOR DEBUG
   E EXTERNAL CLASS/PROCEDURE
  -Q NO CHECK OF QUALIFICATION

ERRORS DETECTED:
    2 TYPE W MESSAGES
DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE   31
DSK:MIDED1.SIM	  23-MAR-1979  11:22		LINE NUMBER TABLE

 1240	000164	 8280	000637	10840	001446	13920	002126	17120	002556
 1360	000165	 8320	000642	10880	001452	13960	002136	17200	002573
 2000	000173	 8360	000651	10960	001477	14040	002147	17240	002607
 2040	000175	 8400	000654	11040	001506	14120	002157	17280	002614
 2120	000200	 8440	000655	11080	001526	14160	002167	17320	002615
 3160	000211	 8480	000657	11120	001527	14200	002176	17360	002617
 3280	000212	 8560	000660	11160	001537	14240	002202	17400	002622
 3480	000220	 8640	000660	11200	001541	14400	002207	17480	002622
 3560	000226	 8680	000673	11240	001550	14440	002211	17520	002624
 4160	000233	 8720	000701	11400	001550	14480	002220	17560	002625
 5880	000234	 8722	000706	11480	001553	14520	002230	17640	002632
 5960	000246	 8726	000706	11560	001575	14560	002236	17680	002637
 6000	000253	 8728	000721	11600	001600	14600	002241	17720	002641
 6080	000265	 8731	000742	11640	001604	14760	002241	17760	002656
 6120	000272	 8734	000753	11680	001612	14800	002252	17800	002666
 6160	000277	 8736	000760	11720	001615	14840	002270	17880	002673
 6240	000300	 8738	001000	11760	001620	14880	002271	17960	002707
 6360	000300	 8748	001031	11800	001626	15000	002271	18000	002714
 6400	000305	 8750	001032	11840	001633	15040	002300	18080	002720
 6440	000314	 8752	001036	11880	001640	15080	002312	18120	002723
 6480	000322	 8760	001037	11960	001654	15120	002320	18160	002726
 6560	000323	 8800	001037	12000	001663	15160	002321	18280	002732
 6680	000323	 8920	001041	12040	001674	15240	002321	18440	002743
 6760	000335	 8960	001044	12080	001723	15280	002323	18520	002756
 6800	000355	 9000	001046	12120	001725	15320	002324	18640	002772
 6840	000356	 9080	001051	12160	001731	15360	002327	18760	002777
 6880	000360	 9160	001051	12200	001732	15440	002332	18800	003007
 6920	000361	 9200	001066	12240	001732	15480	002335	18840	003021
 7040	000361	 9240	001103	12320	001743	15560	002343	18920	003025
 7080	000366	 9280	001122	12560	001743	15640	002352	18960	003034
 7120	000376	 9360	001123	12680	001750	15680	002373	19040	003037
 7120	000403	 9440	001127	12720	001753	15720	002403	19080	003043
 7160	000410	 9480	001150	12800	001756	15720	002404	19120	003047
 7200	000412	 9600	001175	12840	001764	15800	002415	19160	003050
 7240	000427	 9640	001210	12880	001774	15840	002416	19200	003053
 7320	000442	 9680	001211	12920	001776	15880	002421	19240	003053
 7360	000445	 9800	001211	12960	002004	16080	002421	19280	003055
 7400	000453	 9840	001215	13000	002010	16120	002422	19320	003056
 7440	000464	10000	001217	13080	002015	16200	002425	19360	003077
 7480	000474	10040	001223	13120	002021	16240	002435	19440	003105
 7520	000476	10120	001227	13200	002027	16280	002447	19480	003113
 7560	000511	10240	001256	13240	002034	16360	002450	19520	003115
 7600	000515	10280	001266	13320	002036	16400	002461	19560	003116
 7640	000525	10320	001273	13360	002041	16480	002473	19760	003146
 7680	000527	10360	001300	13400	002050	16520	002474	19840	003152
 7760	000532	10400	001313	13480	002052	16680	002474	19920	003155
 7800	000560	10480	001327	13560	002056	16800	002501	19960	003171
 7920	000621	10560	001342	13600	002064	16840	002503	20000	003173
 7960	000630	10600	001353	13640	002067	16920	002514	20040	003177
 8000	000631	10640	001370	13680	002102	16960	002525	20080	003211
 8200	000631	10680	001376	13760	002117	17000	002535	20120	003216
 8240	000634	10760	001417	13840	002123	17040	002547	20200	003221

DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE  31-1
DSK:MIDED1.SIM	  23-MAR-1979  11:22		LINE NUMBER TABLE

20240	003223	23520	003625	26200	004237	29000	004777	32240	005466
20320	003224	23560	003627	26240	004250	29040	005000	32320	005475
20360	003232	23600	003630	26280	004273	29120	005023	32400	005502
20440	003235	23640	003630	26360	004304	29200	005027	32480	005510
20480	003237	23720	003632	26440	004310	29240	005032	32520	005512
20520	003244	23760	003633	26480	004313	29280	005033	32560	005514
20560	003250	23800	003644	26520	004316	29440	005050	32600	005516
20720	003262	23840	003656	26600	004321	29520	005052	32640	005521
20800	003267	23880	003673	26680	004340	29720	005100	32680	005533
20960	003313	23920	003702	26720	004347	29760	005103	32760	005536
21000	003316	23939	003707	26760	004350	29800	005112	32800	005540
21040	003330	23949	003711	26800	004361	29840	005123	32880	005543
21080	003342	23962	003722	26840	004376	29880	005127	32920	005545
21160	003345	23979	003723	26920	004402	29960	005130	32960	005547
21200	003356	23986	003732	27000	004413	30000	005142	33000	005553
21240	003363	24040	003737	27040	004416	30040	005145	33040	005560
21360	003400	24080	003742	27080	004421	30080	005162	33120	005572
21400	003410	24120	003752	27160	004424	30120	005167	33200	005601
21520	003411	24160	003761	27240	004451	30160	005176	33240	005602
21560	003414	24200	003771	27320	004452	30200	005177	33280	005605
21640	003423	24240	004003	27360	004470	30240	005212	33360	005611
21720	003435	24280	004004	27440	004501	30320	005227	33400	005623
21760	003447	24320	004007	27480	004504	30400	005236	33440	005632
21800	003457	24360	004010	27520	004511	30440	005240	33520	005640
21840	003462	24480	004012	27600	004515	30480	005241	33600	005644
21880	003464	24520	004013	27680	004540	30600	005241	33680	005654
21960	003471	24560	004016	27720	004544	30600	005246	33760	005662
22040	003472	24680	004016	27760	004552	30680	005253	33840	005667
22080	003477	24720	004037	27800	004556	30720	005255	33880	005700
22120	003501	24760	004053	27920	004601	30760	005262	33920	005703
22240	003506	24800	004055	27960	004611	30800	005274	34080	005717
22320	003507	24880	004056	28000	004615	30840	005304	34120	005720
22360	003512	25200	004056	28080	004626	30880	005315	34160	005723
22400	003512	25240	004063	28120	004635	30920	005315	34240	005723
22480	003514	25280	004075	28160	004642	31000	005317	34280	005731
22520	003515	25360	004101	28240	004651	31040	005320	34320	005743
22560	003530	25400	004104	28280	004661	31120	005324	34400	005750
22600	003535	25440	004120	28360	004671	31200	005333	34440	005754
22680	003536	25520	004132	28440	004676	31240	005340	34480	005776
22720	003544	25560	004136	28480	004702	31280	005343	34520	006002
22800	003547	25600	004144	28520	004705	31360	005344	34600	006006
22840	003550	25640	004155	28560	004710	31400	005347	34640	006014
22880	003556	25680	004160	28600	004714	31440	005356	34720	006027
22920	003564	25720	004161	28640	004715	31520	005366	34840	006050
22960	003566	25800	004167	28680	004720	31600	005373	34880	006063
23000	003574	25880	004201	28720	004726	31680	005404	34920	006066
23040	003575	25920	004206	28760	004735	31720	005407	34960	006101
23080	003600	25960	004212	28800	004744	31840	005427	35000	006111
23320	003600	26000	004215	28840	004753	31880	005434	35040	006115
23360	003602	26080	004221	28880	004764	31920	005440	35080	006122
23440	003613	26120	004230	28920	004765	32160	005454	35120	006132
23480	003624	26160	004234	28960	004772	32200	005455	35160	006141

DECsystem-20 SIMULA  %4A(310)               25-JAN-1981  18:36				 PAGE  31-2
DSK:MIDED1.SIM	  23-MAR-1979  11:22		LINE NUMBER TABLE

35200	006145	37920	006670	    0	000000
35240	006154	37960	006672
35320	006155	38000	006673
35360	006156	38200	006673
35480	006156	38280	006710
35520	006161	38360	006722
35560	006176	38400	006731
35600	006214	38440	006742
35640	006220	38480	006747
35680	006224	38520	006750
35720	006232	38560	006751
35760	006242	38600	006752
35800	006244	38640	006755
35840	006245	38680	006757
35920	006245	38720	006760
35960	006256	38840	006760
36000	006266	38880	006762
36080	006267	38920	006765
36240	006267	39040	007000
36280	006274	39080	007011
36320	006304	39160	007012
36360	006307	39200	007016
36440	006316	39240	007022
36520	006337	39280	007026
36560	006346	39440	007027
36600	006352	39480	007040
36640	006361	39520	007047
36680	006363	39560	007050
36720	006372	39600	007061
36760	006405	39640	007064
36880	006406	39680	007070
36960	006446	39760	007073
37000	006453	39800	007074
37040	006465	39840	007075
37120	006473	39880	007111
37160	006474	39920	007113
37200	006477	40040	007121
37240	006506	40160	007122
37280	006525	40160	007124
37320	006534	40200	007125
37400	006540	40240	007135
37440	006547	40280	007140
37480	006554	40320	007143
37520	006557	40360	007146
37560	006560	40400	007151
37600	006570	40440	007154
37640	006602	40480	007157
37680	006615	40560	007163
37720	006637	40640	007175
37760	006644	40680	007200
37800	006656	40680	007202