Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-04 - decus/20-0135/vided1.sim
There is 1 other file named vided1.sim in the archive. Click here to see a list.
00010	OPTIONS(/l/e); COMMENT DISPLAY EDITOR.
00020	  See VISTA.MAN for explanations on the routines called by this
00030	  program, taken from the class mvista;
00040	EXTERNAL TEXT PROCEDURE conc, front, storbokstav, upcase,
00050	compress, rest, inline, frontstrip, scanto, from, upto;
00060	EXTERNAL CHARACTER PROCEDURE findtrigger, fetchar, getch;
00070	EXTERNAL INTEGER PROCEDURE search, scanint, scan, checkint;
00080	EXTERNAL REF (infile) PROCEDURE findinfile;
00090	EXTERNAL REF (outfile) PROCEDURE findoutfile;
00100	EXTERNAL INTEGER PROCEDURE trmop, gettab;
00110	EXTERNAL BOOLEAN PROCEDURE puttext, numbered, dotypeout;
00120	EXTERNAL PROCEDURE depchar, outstring, forceout, echo;
00130	EXTERNAL PROCEDURE outchr, abort, exit;
00140	EXTERNAL CLASS mvista, qregister=vided0;
00150	
00160	mvista CLASS vided1(pageheader,increment,editout,editin,
00170	command, belowcommand, arg, numbered_infile,pageheight,
00180	left_margin, right_margin, qregisters);
00190	
00200	INTEGER increment; ! between new line-numbered lines;
00210	INTEGER pageheight; ! 1) before page-end-warning line, 2)
00220	  plus height = number of lines kept in core;
00230	INTEGER left_margin, right_margin; ! used when justifying
00240	  paragraphs;
00250	BOOLEAN numbered_infile; ! input file had line numbers;
00260	BOOLEAN pageheader; ! Put header and number on new pages;
00270	REF (infile) editin; ! Input file to be edited;
00280	REF (outfile) editout; ! Output file from editing;
00290	TEXT command; ! Text of user &command during editing;
00300	TEXT belowcommand; ! Screen text below user &command;
00310	TEXT ARRAY arg; ! User switch.ini and file creation commands;
00320	REF (qregister) qregisters; ! See description of &Q editor
00330	  command;
00340	BEGIN INTEGER ARRAY screen_length[0:height-1]; ! when overwriting
00350	  part of the screen with corrected text, this array keeps the old
00360	  line lengthes to know how much has to be overwritten;
00370	TEXT ARRAY top_of_page[0:pageheight]; ! lines which have rolled
00380	  out on top of the screen but have not yet been output;
00390	INTEGER top_size; ! Number of lines in "top_of_page";
00400	INTEGER top_fill; ! Number of lines currently in "top_of_page";
00410	INTEGER ttytab; ! Value of monitor TRMOP .TTY TAB settings,
00420	  governs the handling of <HT> characters at terminal output;
00430	INTEGER pagenumber; ! Count of input page number;
00440	INTEGER debugslow; ! When this variable is nonzero, the program can
00450	  be artificially slowed down to create the kind of bugs which only
00460	  occur with a heavily loaded computer;
00470	INTEGER out_pagenumber; ! Count of output page number;
00480	INTEGER last_line_number; ! When creating line-numbered files,
00490	  number of last line which has been output to the output file;
00500	INTEGER largest_line_number; ! Largest line number yet created;
00510	INTEGER first_text_pos;! 8 for numbered, 0 for other files;
00520	CHARACTER control_f, control_d, control_v, control_u, control_w;
00530	  ! What is input when the terminal user pushes CONTROL plus
00540	  one of the letters f, d, v, u or w;
00550	BOOLEAN ARRAY tab_position[0:width]; ! tabs set by user;
00560	INTEGER margin_width; ! right_margin-left_margin;
00570	INTEGER cover_length; ! cover old text at end of line;
00580	BOOLEAN first_input_line; ! true when only one line has been input
00590	  from the input text file;
00600	BOOLEAN long_line_warned; ! user has been warned about too long
00610	  input lines;
00620	BOOLEAN addff; ! Add <form feed> before next output line;
00630	BOOLEAN after_addff; ! Outputting second line of a page;
00640	BOOLEAN endpage; ! Last line of a page has been read from file;
00650	BOOLEAN verybadscreen; ! Terminal screen must be restored from the
00660	  computer;
00670	BOOLEAN printing; ! New input lines to be printed on terminal;
00680	BOOLEAN emptyscroll; ! Scroll in blank lines at bottom of screen;
00690	TEXT editin_image_strip; ! Stripped text of last line from the input
00700	  text file;
00710	TEXT other_editin_image; ! Extra image to be used sometimes;
00720	TEXT line_model; ! Extra line, often blank, for use sometimes;
00730	TEXT editout_image; ! Image of output text file;
00740	TEXT header; ! Header at top of each page;
00750	TEXT sub_header; ! Subheader = line below header;
00760	TEXT page_word; ! Contains the word "PAGE";
00770	TEXT sid_word; ! Contains the word "SID", swedish for "PAGE";
00780	TEXT sixdigits; ! Used to produce line number text segments;
00790	TEXT page_end_marker; ! Funny text warning user of end-of-page;
00800	TEXT output_line; ! Line to be output to output text file;
00810	TEXT first_scroll_line; ! Top-of-page-line to be scrolled out;
00820	COMMENT REF-variables below used to get faster execution by using
00830	the CALL procedure instead of ordinary PROCEDURE invokings;
00840	REF (one_more_line_please) p_one_more_line_please;
00850	REF (scroll) p_scroll;
00860	REF (editin_true_inimage) p_editin_true_inimage;
00870	REF (true_write) p_true_write;
00880	REF (write) p_write;
00890	REF (editin_inimage) p_editin_inimage;
00900	REF (lower_line) lower_lines;
     
00910	TEXT PROCEDURE make_five_digits(i);
00920	INTEGER i;
00930	BEGIN COMMENT prepars text in line-number-field of output line;
00940	  sixdigits.putint(i+100000);
00950	  make_five_digits:- sixdigits.sub(2,5);
00960	  IF i > largest_line_number THEN largest_line_number:= i;
00970	END;
     
00980	CLASS lower_line(linetext);
00990	TEXT linetext;
01000	BEGIN COMMENT Text of line which has been pushed below the screen;
01010	  REF (lower_line) next_lower_line;
01020	  next_lower_line:- lower_lines;
01030	  lower_lines:- THIS lower_line;
01040	END;
     
01050	REF (qregister) PROCEDURE find_qregister(qname);
01060	TEXT qname;
01070	BEGIN COMMENT find the latest qregister with a given name;
01080	  COMMENT See description of the "Q" VIDED command;
01090	  REF (qregister) scanner;
01100	  scanner:- qregisters;
01110	  WHILE scanner =/= NONE DO
01120	  BEGIN IF scanner.qname EQ qname THEN GOTO out;
01130	    scanner:- scanner.next_qregister;
01140	  END;
01150	  out: find_qregister:- scanner;
01160	END;
     
01170	TEXT PROCEDURE pop_line;
01180	COMMENT get a line from stack of lines pushed below screen;
01190	INSPECT lower_lines WHEN lower_line DO
01200	BEGIN pop_line:- linetext; lower_lines:- next_lower_line;
01210	END;
     
01220	PROCEDURE push_line(l); NAME l; TEXT l;
01230	BEGIN COMMENT push a line to stack of lines below screen;
01240	  IF upto(l,46) = page_end_marker THEN GOTO out;
01250	  IF lower_lines =/= NONE THEN NEW lower_line(l) ELSE
01260	  IF NOT (editin.endfile OR endpage)
01270	  THEN NEW lower_line(l) ELSE
01280	  BEGIN
01290	    IF increment <= 0 THEN
01300	    BEGIN
01310	      IF l.strip =/= NOTEXT THEN NEW lower_line(l);
01320	    END ELSE IF from(l,6).strip =/= NOTEXT
01330	    THEN NEW lower_line(l);
01340	  END;
01350	  out: l:- blanks(width);
01360	END;
     
01370	PROCEDURE get_register(qname); TEXT qname;
01380	COMMENT action of the &G VIDED command. Find a qregister,
01390	puts its contents on top of square on screen equal to the
01400	qregister size;
01410	INSPECT find_qregister(storbokstav(qname)) DO
01420	BEGIN
01430	  INTEGER i, hpos, vpos;
01440	  INTEGER maxwidth, maxheight, boxwidth, boxheight;
01450	  IF increment > 0 THEN
01460	  BEGIN COMMENT do not restore line numbers;
01470	    IF qwidth = width-8 AND q_horizontalpos = 0 THEN
01480	    move_the_cursor_to(8,q_verticalpos);
01490	  END;
01500	  hpos:= q_horizontalpos; vpos:= q_verticalpos;
01510	  maxwidth:= width-hpos;
01520	  maxheight:= height-vpos;
01530	  boxwidth:= IF maxwidth < qwidth THEN maxwidth ELSE qwidth;
01540	  boxheight:= IF maxheight < qheight THEN maxheight ELSE
01550	  qheight;
01560	  FOR i:= 1 STEP 1 UNTIL boxheight DO
01570	  BEGIN
01580	    move_the_cursor_to(hpos,vpos+i-1);
01590	    outtext(lines[i-1].sub(1,boxwidth));
01600	  END;
01610	  move_the_cursor_to(hpos,vpos);
01620	END;
     
01630	PROCEDURE put_register(qname,box_width, box_height);
01640	TEXT qname; INTEGER box_width, box_height;
01650	BEGIN COMMENT action of the &Q VIDED command;
01660	  INTEGER hpos, vpos, maxwidth, maxheight, i;
01670	  IF box_width= 0 THEN
01680	  BEGIN
01690	    IF q_horizontalpos=0 AND increment > 0
01700	    THEN move_the_cursor_to(8,q_verticalpos);
01710	    box_width:= width;
01720	  END;
01730	  IF box_height = 0 THEN box_height:= height;
01740	  storbokstav(qname); hpos:= q_horizontalpos;
01750	  vpos:= q_verticalpos;
01760	  maxheight:= height-vpos; maxwidth:= width-hpos;
01770	  IF box_width > maxwidth THEN box_width:= maxwidth;
01780	  IF box_height > maxheight THEN box_height:= maxheight;
01790	  INSPECT NEW qregister(box_width, box_height, qname) DO
01800	  BEGIN
01810	    next_qregister:- qregisters; qregisters:- THIS qregister;
01820	    FOR i:= 1 STEP 1 UNTIL box_height DO
01830	    lines(i-1):- copy(screen[vpos+i-1].sub(hpos+1,box_width));
01840	  END;
01850	END;
     
01860	PROCEDURE restore_the_whole_screen;
01870	
01880	restore_screen(q_verticalpos);
01890	
01900	PROCEDURE restore_screen(startline);
01910	INTEGER startline;
01920	COMMENT: If the picture of the screen has been destroyed, then a
01930	call to this procedure will make the picture on the screen equal to
01940	the internal picture in the program. Used by the &R VIDED command;
01950	IF q_display_output THEN
01960	BEGIN TEXT strippedline;
01970	  INSPECT terminalout DO
01980	  BEGIN
01990	    INTEGER h, v, hold, vold, vp;
02000	    verybadscreen:= FALSE; ! We are making it good again;
02010	    hold:= q_horizontalpos; vold:= q_verticalpos;
02020	    home_the_cursor; ! Blank the screen;
02030	    IF addaltmode THEN outchr(terminalout,altmode,1);
02040	    outchr(terminalout,erasescreen ,1);
02050	    IF terminaltype = cdc71310s THEN home_the_cursor;
02060	    q_horizontalpos:= q_verticalpos:= 0;
02070	    FOR vp:= 0 STEP 1 UNTIL heightm1 DO
02080	    FOR v:= startline+vp,startline-vp-1 DO
02090	    BEGIN
02100	      IF v >= 0 THEN
02110	      BEGIN
02120	        IF v <= heightm1 THEN
02130	        BEGIN
02140	          strippedline:- screen[v].strip;
02150	          IF strippedline =/= NOTEXT THEN
02160	          BEGIN
02170	            IF allow_cr THEN
02180	            outchr(terminalout,carriagereturn,1)
02190	            ELSE home_the_cursor;
02200	            move_the_cursor_to(0,v);
02210	            outstring(terminalout,strippedline);
02220	          END;
02230	        END;
02240	      END;
02250	    END;
02260	    forceout(terminalout); dotypeout(terminalout);
02270	    synchronize(hold,vold);
02280	  END;
02290	END;
     
02300	PROCEDURE save_lengthes;
02310	COMMENT Save the lengthes of non-blank lines on the screen to know
02320	how much must later be restored;
02330	BEGIN INTEGER i;
02340	  FOR i:= 0 STEP 1 UNTIL heightm1 DO
02350	  screen_length[i]:= screen[i].strip.length;
02360	END;
     
02370	PROCEDURE exchange_lines(l1,l2);
02380	INTEGER l1, l2;
02390	BEGIN TEXT firstline;
02400	  firstline:- screen(l1);
02410	  screen(l1):- screen(l2);
02420	  screen(l2):- firstline;
02430	END;
     
02440	BOOLEAN PROCEDURE five_digits(t); TEXT t;
02450	COMMENT check if a given text contains five digits;
02460	BEGIN
02470	  IF t.length > 4 THEN
02480	  BEGIN
02490	    t.setpos(1);
02500	    IF digit(t.getchar) THEN
02510	    BEGIN IF digit(t.getchar) THEN
02520	      BEGIN IF digit(t.getchar) THEN
02530	        BEGIN IF digit(t.getchar) THEN
02540	          five_digits:= digit(t.getchar);
02550	        END;
02560	      END;
02570	    END;
02580	  END;
02590	END;
     
02600	CLASS one_more_line_please;
02610	COMMENT Get a line from the input file;
02620	BEGIN INTEGER new_length;
02630	  detachloop: detach;
02640	  !z_t(8); call(p_editin_inimage);
02650	  IF printing THEN
02660	  BEGIN
02670	    new_length:= editin_image_strip.length;
02680	    IF new_length > cover_length THEN cover_length:=
02690	    new_length;
02700	    outtext(editin.image.sub(1,cover_length));
02710	    move_the_cursor_to(0,q_verticalpos);
02720	  END ELSE screen(q_verticalpos):= editin_image_strip;
02730	  !z_t(-8);
02740	  GOTO detachloop;
02750	END;
     
02760	PROCEDURE shift(frompos, topos, steps);
02770	INTEGER frompos, topos, steps;
02780	COMMENT shift part of the screen downwards, e.g. to get space for
02790	new lines created by &L or &J VIDED commands;
02800	BEGIN INTEGER i;
02810	  steps:= steps-1;
02820	  IF frompos > topos THEN
02830	  BEGIN
02840	    FOR i:= 0 STEP 1 UNTIL steps DO
02850	    exchange_lines(topos+i,frompos+i);
02860	  END ELSE
02870	  BEGIN
02880	    FOR i:= steps STEP -1 UNTIL 0 DO
02890	    exchange_lines(topos+i,frompos+i);
02900	  END;
02910	END of shift;
     
02920	PROCEDURE restore_lines(first,last);
02930	INTEGER first, last;
02940	COMMENT make the terminal screen contents equal to the internal
02950	screen contents for lines [first,last] of the screen;
02960	IF q_display_output THEN
02970	BEGIN
02980	  INTEGER i, maxlength;
02990	  maxlength:= 1000;
03000	  FOR i:= first STEP 1 UNTIL last DO
03010	  BEGIN
03020	    IF maxlength < width THEN outchr(terminalout,linefeed,1)
03030	    ELSE synchronize(0,i);
03040	    maxlength:= screen(i).strip.length;
03050	    IF maxlength < screen_length(i) THEN
03060	    maxlength:= screen_length(i);
03070	    outstring(terminalout,screen(i).sub(1,maxlength));
03080	    outchr(terminalout,carriagereturn,1);
03090	  END;
03100	  home_the_cursor;
03110	END;
     
03120	CLASS editin_true_inimage;
03130	COMMENT input a line from the input text file;
03140	BEGIN TEXT part;
03150	  detachloop: detach;
03160	  INSPECT editin DO
03170	  BEGIN
03180	    IF first_input_line THEN first_input_line:= FALSE
03190	    ELSE inimage;
03200	    part:- scanto(image,tab);
03210	    IF image.more THEN
03220	    INSPECT editin DO
03230	    BEGIN COMMENT there was a tab;
03240	      IF other_editin_image == NOTEXT THEN
03250	      other_editin_image:- blanks(image.length) ELSE
03260	      BEGIN other_editin_image:= NOTEXT;
03270	        other_editin_image.setpos(1);
03280	      END;
03290	      IF numbered_infile THEN
03300	      BEGIN IF increment = 0 THEN
03310	        BEGIN IF part.length = 5 THEN
03320	          BEGIN COMMENT remove line number;
03330	            IF five_digits(part) THEN GOTO after_put;
03340	          END;
03350	        END;
03360	      END;
03370	      loop:
03380	      puttext(other_editin_image,part);
03390	      other_editin_image.setpos
03400	      (other_editin_image.pos+8
03410	      -mod(other_editin_image.pos-1,8));
03420	      after_put:
03430	      IF image.more THEN
03440	      BEGIN
03450	        part:- scanto(image,tab);
03460	        IF NOT image.more THEN part:- part.strip;
03470	        GOTO loop;
03480	      END;
03490	      part:- image; image:- other_editin_image;
03500	      other_editin_image:- part;
03510	    END;
03520	    image.setpos(1);
03530	  END;
03540	  GOTO detachloop;
03550	END;
     
03560	CLASS true_write;
03570	BEGIN COMMENT Output of a line to the output text file;
03580	  detachloop: detach;
03590	  IF upto(output_line,46) = page_end_marker THEN
03600	  BEGIN output_line:= NOTEXT; GOTO fastout;
03610	  END;
03620	  output_line:- output_line.strip;
03630	  IF after_addff THEN
03640	  BEGIN after_addff:= FALSE;
03650	    sub_header:- IF addff THEN NOTEXT ELSE
03660	    copy(IF increment <= 0 THEN output_line ELSE
03670	    from(output_line,6));
03680	  END;
03690	  IF increment NE 0 THEN
03700	  BEGIN
03710	    IF addff THEN
03720	    BEGIN
03730	      header:= from(output_line,6); after_addff:= TRUE;
03740	      editout.image.setpos(6); editout.outchar(carriagereturn);
03750	      editout.outchar(formfeed);
03760	      editout.breakoutimage; addff:= FALSE;
03770	      out_pagenumber:= out_pagenumber+1;
03780	    END;
03790	    IF five_digits(output_line) THEN
03800	    BEGIN
03810	      last_line_number:= output_line.sub(1,5).getint;
03820	      IF output_line.length = 5 THEN GOTO goodnumbered;
03830	      IF output_line.length >= 8 THEN
03840	      BEGIN IF output_line.sub(6,3) = "   " THEN
03850	        GOTO goodnumbered;
03860	      END;
03870	    END;
03880	    IF output_line.length > 8 THEN
03890	    BEGIN
03900	      IF output_line.sub(1,8) = "        " THEN
03910	      output_line:- output_line.sub(9,output_line.length-8);
03920	    END;
03930	    COMMENT the line had no correct line number;
03940	    last_line_number:= last_line_number+1;
03950	    editout.outtext(make_five_digits(last_line_number));
03960	    editout.outchar(tab); editout.outtext(output_line);
03970	    IF FALSE THEN goodnumbered:
03980	    BEGIN
03990	      editout.outtext(output_line.sub(1,5));
04000	      editout.outchar(tab);
04010	      IF output_line.length >= 8 THEN
04020	      editout.outtext(from(output_line,9));
04030	    END;
04040	    editout.outimage; output_line:= NOTEXT;
04050	  END ELSE
04060	    BEGIN COMMENT the output file should NOT
04070	      be line numbered;
04080	    IF addff THEN
04090	    BEGIN editout.outchar(formfeed);
04100	      editout.outtext(output_line);
04110	      header:= output_line; after_addff:= TRUE;
04120	      editout.outimage; output_line:= NOTEXT; addff:= FALSE;
04130	      out_pagenumber:= out_pagenumber+1;
04140	    END ELSE
04150	    BEGIN
04160	      editout.image:- output_line;
04170	      editout.outimage;
04180	      editout.image:- editout_image;
04190	    END;
04200	  END;
04210	  fastout:
04220	  GOTO detachloop;
04230	END;
     
04240	CLASS write;
04250	BEGIN
04260	  TEXT exchanger;
04270	  detachloop: detach;
04280	  IF upto(first_scroll_line,46) = page_end_marker THEN
04290	  BEGIN first_scroll_line:= NOTEXT;
04300	    GOTO detachloop;
04310	  END;
04320	  IF top_fill = top_size THEN empty_top_of_page;
04330	  BEGIN
04340	    top_fill:= top_fill+1;
04350	    exchanger:- top_of_page[top_fill];
04360	    top_of_page[top_fill]:- first_scroll_line;
04370	    first_scroll_line:- exchanger;
04380	  END;
04390	  GOTO detachloop;
04400	END of CLASS write;
     
04410	PROCEDURE empty_top_of_page;
04420	COMMENT move lines which previously have been scrolled out
04430	above the top of the screen from an internal buffer
04440	"top_of_page" to the output text file;
04450	BEGIN
04460	  INTEGER top_bottom;
04470	  FOR top_bottom:= 0 STEP 1 UNTIL top_fill DO
04480	  BEGIN
04490	    output_line:- top_of_page[top_bottom]; call(p_true_write);
04500	  END;
04510	  top_fill:= -1;
04520	END;
     
04530	CLASS scroll;
04540	BEGIN COMMENT scroll screen, top line out, new bottom line in;
04550	  INTEGER i;
04560	  detachloop: detach;
04570	  !z_t(9); first_scroll_line:- screen(0); call(p_write);
04580	  FOR i:= 1 STEP 1 UNTIL heightm1 DO
04590	  screen(i-1):- screen(i);
04600	  screen(heightm1):- first_scroll_line;
04610	  IF top_fill + height + 1 = pageheight AND pageheader THEN
04620	  BEGIN
04630	    IF printing THEN
04640	    BEGIN outtext(page_end_marker);
04650	      move_the_cursor_to(0,q_verticalpos);
04660	    END ELSE screen[heightm1]:= page_end_marker;
04670	  END ELSE
04680	  IF NOT emptyscroll THEN
04690	  BEGIN cover_length:= 0;
04700	    call(p_one_more_line_please);
04710	  END;
04720	  !z_t(-9);
04730	  GOTO detachloop;
04740	END;
     
04750	PROCEDURE addlines(number, printing, leftjustify);
04760	COMMENT Action of &L VIDED command, new lines are inserted
04770	and existing lines pushed downwards;
04780	INTEGER number; BOOLEAN printing, leftjustify;
04790	BEGIN INTEGER  sink, vpos, hpos, emptysink;
04800	  INTEGER i, addpos; TEXT firstpart;
04810	  INTEGER high_number, low_bord_number, add_increment;
04820	  TEXT high_line;
04830	  !z_t(10); vpos:= q_verticalpos; hpos:= q_horizontalpos;
04840	  firstpart:- screen(vpos).sub(1,hpos);
04850	  IF increment > 0 THEN
04860	  BEGIN
04870	    IF vpos > 0 THEN high_line:- screen[vpos-1]
04880	    ELSE IF top_fill >= 0
04890	    THEN high_line:- top_of_page[top_fill];
04900	    IF five_digits(high_line) THEN
04910	    low_bord_number:= high_line.sub(1,5).getint
04920	    ELSE low_bord_number:= last_line_number;
04930	    IF five_digits(screen[vpos]) THEN high_number:=
04940	    screen[vpos].sub(1,5).getint ELSE
04950	    high_number:= low_bord_number+(number+1)*increment;
04960	    add_increment:=
04970	    entier((high_number-low_bord_number)/(number+1));
04980	    IF add_increment < 1 THEN add_increment:= 1;
04990	  END;
05000	  IF printing THEN save_lengthes;
05010	  sink:= number; emptysink:= sink+vpos-1-heightm1;
05020	  IF emptysink < 0 THEN emptysink:= 0;
05030	  sink:= sink-emptysink;
05040	  FOR i:= 1 STEP 1 UNTIL sink DO
05050	  push_line(screen(heightm1-i+1));
05060	  FOR i:= 1 STEP 1 UNTIL emptysink DO
05070	  BEGIN
05080	    IF increment > 0 THEN
05090	    BEGIN
05100	      high_number:= high_number-add_increment;
05110	      IF high_number < 1 THEN high_number:= 1;
05120	      line_model.sub(1,5):= make_five_digits(high_number);
05130	    END;
05140	    push_line(line_model);
05150	  END;
05160	  line_model.sub(1,5):= NOTEXT;
05170	  shift(vpos,vpos+sink,heightm1-vpos+1-sink);
05180	  IF increment > 0 THEN
05190	  BEGIN
05200	    FOR i:= 1 STEP 1 UNTIL sink DO
05210	    BEGIN
05220	      high_number:= high_number-add_increment;
05230	      IF high_number < 1 THEN high_number:= 1;
05240	      screen(vpos+sink-i).sub(1,5):=
05250	      make_five_digits(high_number);
05260	    END;
05270	  END;
05280	  screen(vpos).sub(1,firstpart.length):= firstpart;
05290	  IF increment <= 0 THEN firstpart:= NOTEXT ELSE
05300	  BEGIN
05310	    IF firstpart =/= NOTEXT THEN
05320	    BEGIN
05330	      high_number:= high_number-1;
05340	      IF high_number < 1 THEN high_number:= 1;
05350	      screen(vpos).sub(1,5):= make_five_digits(high_number);
05360	    END;
05370	    IF five_digits(firstpart) THEN
05380	    high_number:= firstpart.sub(1,5).getint ELSE
05390	    high_number:= largest_line_number;
05400	    firstpart:= NOTEXT;
05410	    IF firstpart.length >= 5 THEN firstpart.sub(1,5):=
05420	    make_five_digits(high_number+1);
05430	  END;
05440	  IF leftjustify AND firstpart =/= NOTEXT THEN
05450	  BEGIN firstpart:- firstpart.main;
05460	    IF increment > 0 THEN firstpart:- from(firstpart,9);
05470	    line_model:= frontstrip(firstpart);
05480	    high_line:- line_model.strip;
05490	    IF high_line.length <= firstpart.length - left_margin THEN
05500	    BEGIN
05510	      firstpart.sub(1,left_margin):= NOTEXT;
05520	      from(firstpart,left_margin+1):= high_line;
05530	    END;
05540	    line_model:= NOTEXT;
05550	  END;
05560	  IF printing THEN
05570	  BEGIN
05580	    restore_lines(vpos,heightm1);
05590	    move_the_cursor_to(hpos,vpos);
05600	  END;
05610	  !z_t(-10);
05620	END;
     
05630	TEXT PROCEDURE to_continue;
05640	COMMENT restore the screen after user has pushed the
05650	carriage return key;
05660	INSPECT terminalin DO INSPECT terminalout DO
05670	BEGIN
05680	  outimage;
05690	  outtext("To continue push RETURN:"); breakoutimage;
05700	  inimage; to_continue:- copy(terminalin.image.strip);
05710	  restore_screen(q_verticalpos);
05720	END;
     
05730	CLASS editin_inimage;
05740	BEGIN COMMENT input of one line from the input text file;
05750	  INTEGER divpos, mindiv;
05760	  detachloop: detach;
05770	  IF lower_lines == NONE THEN
05780	  BEGIN
05790	    IF NOT endpage AND NOT editin.endfile THEN
05800	    call(p_editin_true_inimage) ELSE
05810	    BEGIN COMMENT Input a fictious blank line;
05820	      editin.image:= NOTEXT;
05830	      IF increment > 0 THEN
05840	      editin.image.sub(1,5):= make_five_digits(
05850	      largest_line_number+increment);
05860	    END;
05870	    editin_image_strip:- editin.image.strip;
05880	    IF editin.endfile THEN
05890	    BEGIN COMMENT Input a fictious blank line;
05900	      editin.image:= NOTEXT; editin_image_strip:- NOTEXT;
05910	    END ELSE
05920	    IF NOT endpage THEN
05930	    BEGIN COMMENT Was this last line of a page?;
05940	      IF editin_image_strip =/= NOTEXT THEN
05950	      BEGIN
05960	        IF fetchar(editin_image_strip,
05970	        editin_image_strip.length) = formfeed THEN
05980	        BEGIN endpage:= TRUE;
05990	          editin_image.setpos(editin_image_strip.length);
06000	          editin_image.putchar(' ');
06010	          editin_image_strip:- editin_image_strip.sub(1,
06020	          editin_image_strip.length-1).strip;
06030	        END;
06040	      END;
06050	    END;
06060	  END ELSE
06070	  BEGIN editin.image:= pop_line;
06080	    editin_image_strip:- editin.image.strip;
06090	  END;
06100	  IF editin_image_strip.length > width THEN
06110	  BEGIN COMMENT split too long input lines into two lines;
06120	    IF NOT long_line_warned THEN
06130	    INSPECT terminalout DO
06140	    BEGIN long_line_warned:= TRUE;
06150	      breakoutimage;
06160	      IF addaltmode THEN outchr(terminalout,altmode,1);
06170	      outchr(terminalout,erasescreen,1);
06180	      outtext("Input text contains lines longer than");
06190	      outint(width,3); outtext(" characters."); outimage;
06200	      outtext(
06210	      "Such long lines will be split. No further warnings.");
06220	      outimage;
06230	      to_continue;
06240	    END;
06250	    mindiv:= editin_image_strip.length-width;
06260	    FOR divpos:= widthm1 STEP -1 UNTIL mindiv DO
06270	    BEGIN COMMENT split the line at a space character;
06280	      IF fetchar(editin_image_strip,divpos) = ' '
06290	      THEN GOTO blankfound;
06300	    END;
06310	    divpos:= width;
06320	    blankfound:
06330	    editin_image_strip.setpos(divpos);
06340	    NEW lower_line(copy(rest(editin_image_strip)));
06350	    rest(editin_image_strip):= NOTEXT;
06360	    editin_image_strip:- front(editin_image_strip);
06370	  END;
06380	  IF increment > 0 THEN
06390	  BEGIN COMMENT check line number of line numbered file;
06400	    IF five_digits(editin_image_strip) THEN
06410	    BEGIN
06420	      divpos:= editin_image_strip.sub(1,5).getint;
06430	      IF largest_line_number < divpos THEN
06440	      largest_line_number:= divpos;
06450	    END;
06460	  END;
06470	  GOTO detachloop;
06480	END;
     
06490	PROCEDURE insert(qname); TEXT qname;
06500	BEGIN COMMENT &I command of VIDED;
06510	  INTEGER striplength, hpos, vpos, mindiv, divpos;
06520	  TEXT lastpart, stripline, longline;
06530	  hpos:= q_horizontalpos; vpos:= q_verticalpos;
06540	  stripline:- screen(vpos).strip;
06550	  striplength:= stripline.length;
06560	  IF striplength + qname.length < width THEN
06570	  BEGIN COMMENT New line not longer than screen width;
06580	    IF striplength > hpos THEN lastpart:- copy(screen(vpos).
06590	    sub(hpos+1,striplength-hpos));
06600	    outtext(qname); outtext(lastpart);
06610	    move_the_cursor_to(hpos+qname.length,vpos);
06620	  END ELSE
06630	  BEGIN COMMENT New line has to be split into two lines on
06640	    the screen, since it is longer than the screen width;
06650	    longline:- conc(stripline.sub(1,hpos),qname,
06660	    stripline.sub(hpos+1,striplength-hpos));
06670	    mindiv:= longline.length-width;
06680	    FOR divpos:= widthm1 STEP -1 UNTIL mindiv DO
06690	    BEGIN IF fetchar(longline,divpos) = ' '
06700	      THEN GOTO blankfound;
06710	    END;
06720	    divpos:= width;
06730	    blankfound: move_the_cursor_to(0,vpos);
06740	    outtext(longline.sub(1,divpos));
06750	    make_blank(width-divpos);
06760	    IF vpos = heightm1 THEN
06770	    BEGIN
06780	      move_the_cursor_to(0,vpos);
06790	      outchr(terminalout,linefeed,1);
06800	      call(p_scroll);
06810	      vpos:= vpos-1;
06820	      move_the_cursor_to(0,heightm1);
06830	    END ELSE move_the_cursor_to(0,vpos+1);
06840	    addlines(1,TRUE,FALSE);
06850	    outtext(longline.sub(divpos+1,longline.length-divpos));
06860	    hpos:= hpos+qname.length;
06870	    IF hpos < divpos THEN
06880	    move_the_cursor_to(hpos,vpos) ELSE
06890	    move_the_cursor_to(hpos-divpos,vpos+1);
06900	  END;
06910	END of insert;
     
06920	INTEGER PROCEDURE written_lines;
06930	COMMENT VIDED strips blank lines from the bottom of the page
06940	when outputting a page to the output text file. This procedure
06950	finds how many non-blank lines there are to output;
06960	BEGIN TEXT check_line; INTEGER i, print_height;
06970	  IF lower_lines == NONE AND (endpage OR editin.endfile) THEN
06980	  BEGIN
06990	    FOR print_height:= heightm1 STEP -1 UNTIL 0 DO
07000	    BEGIN
07010	      check_line:- screen(print_height);
07020	      IF increment > 0 THEN check_line:- from(check_line,6);
07030	      IF check_line.strip =/= NOTEXT THEN GOTO out;
07040	    END;
07050	    print_height:= -1;
07060	    out:
07070	  END ELSE print_height:= heightm1;
07080	  written_lines:= print_height;
07090	END;
     
07100	PROCEDURE printpage;
07110	BEGIN COMMENT Output a page to the output text file;
07120	  INTEGER i, print_height;
07130	  empty_top_of_page;
07140	  print_height:= written_lines;
07150	  FOR i:= 0 STEP 1 UNTIL print_height DO
07160	  BEGIN
07170	    output_line:- screen[i]; call(p_true_write);
07180	  END;
07190	  COMMENT Output lines which have been pushed below the screen;
07200	  WHILE NOT lower_lines == NONE DO
07210	  BEGIN output_line:- pop_line;
07220	    call(p_true_write);
07230	  END;
07240	  COMMENT Output lines which have not yet been read from the
07250	  input text file;
07260	  IF NOT endpage AND NOT editin.endfile THEN GOTO get_a_line;
07270	  WHILE NOT endpage AND NOT editin.endfile DO
07280	  BEGIN
07290	    output_line:- editin_image_strip; call(p_true_write);
07300	    get_a_line:
07310	    call(p_editin_inimage);
07320	  END;
07330	END;
     
07340	COMMENT Main body of the CLASS VIDED1: initialization
07350	of certain variables;
07355	allow_cr:= TRUE;
07360	editout_image:- editout.image;
07370	sixdigits:- blanks(6);
07380	p_one_more_line_please:- NEW one_more_line_please;
07390	p_editin_true_inimage:- NEW editin_true_inimage;
07400	p_true_write:- NEW true_write;
07410	p_write:- NEW write;
07420	p_editin_inimage:- NEW editin_inimage;
07430	p_scroll:- NEW scroll; printing:= TRUE;
07440	page_end_marker:- copy(
07450	"***??? END OF PAGE *** USE &PI COMMAND ***???");
07460	first_text_pos:= IF increment = 0 THEN 0 ELSE 8;
07470	INNER;
07480	END;