perm filename EAUX1A.2[EAL,HE]2 blob sn#701190 filedate 1983-03-24 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00007 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	{$NOMAIN	Editor Auxilliary routines }
C00023 00003	{ Externally defined routines from elsewhere: }
C00024 00004	(* aux routines: GetAChar, out1Line, clearLine, eUppercase, eEqStrng, eResLookup, eIdLookup *)
C00029 00005	(* aux routines: makeNVar, makeUVar, varLookup *)
C00034 00006	(* cursorStack routines: pushStmnt, pushNode *)
C00036 00007	(* bannerLine, borderLines, & adjustDisplay *)
C00040 ENDMK
C⊗;
{$NOMAIN	Editor Auxilliary routines }

const

	(* Constants from EDIT *)
      	maxLines = 28;		(* smaller on the 11 than on the 10 *)
      	maxPPLines = 18;
      	maxBpts = 25;
      	maxTBpts = 20;	(* max could be exceeded by huge case stmnt *)
	listinglength = 2000;	(* Length of Listingarray *)

(* Random type declarations for OMSI/SAIL compatibility *)

type

  byte = 0..255;	(* doesn't really belong here, but... *)
  ascii = char; 
  atext = text;

{ Define all the pointer types here }

strngp = ↑strng;
statementp = ↑statement;
varidefp = ↑varidef;
nodep = ↑node;
identp = ↑ident;
tokenp = ↑token;
reswordp = ↑resword;
pdbp = ↑pdb;
envheaderp = ↑envheader;
enventryp = ↑enventry;
environp = ↑environment;
cmoncbp = ↑cmoncb;
linerecp = ↑linerec;
cursorpp = ↑cursorp;	{Ron's style, not mine}

(* This one is used whenever a pointer is needed for which the 	*)
(* definition is missing from this file; naturally, all 	*)
(* pointers use the same space 					*)

dump = ↑integer;

(* datatype definitions *)

datatypes = (pconstype, varitype, svaltype, vectype, rottype, transtype,
	     frametype, eventtype, strngtype, labeltype, proctype, arraytype,
	     reftype, valtype, cmontype, nulltype, undeftype,
	     dimensiontype, mactype, macargtype, freevartype);

scalar = real;

cstring = packed array [1..10] of ascii;
c4str = packed array [1..4] of ascii;
c5str = packed array [1..5] of ascii;
c20str = packed array [1..20] of ascii;
linestr = packed array [1..130] of ascii;

strng = record
	  next: strngp;
	  ch: cstring;
	end;


(* statement definitions *)

stmntypes = (progtype, blocktype, coblocktype, endtype, coendtype,
		fortype, iftype, whiletype, untiltype, casetype,
		calltype, returntype,
		printtype, prompttype, pausetype, aborttype, assigntype,
		signaltype, waittype, enabletype, disabletype, cmtype,
		affixtype, unfixtype,
		movetype, operatetype, opentype, closetype, centertype,
		stoptype, retrytype,
		requiretype, definetype, macrotype, commenttype, dimdeftype,
		setbasetype, wristtype, tovaltype, declaretype, emptytype);
		(* more??? *)

statement = packed record
		next, last: statementp; (* ↑ to lexical tokens? *)
		stlab: varidefp;
		exprs: nodep;	(* any expressions used by this statement *)
		nlines: integer;
		bpt: boolean;
		case stype: stmntypes of

    progtype:	    (pcode: statementp; errors: integer);
    blocktype,
    declaretype,
    endtype,
    coendtype:	    (bcode, bparent: statementp; blkid: identp;
			level, numvars: 0..255; variables: varidefp);
		end;

(* auxiliary definitions: variable, etc. *)

varidef = packed record
	    next,dnext: varidefp;
	    name: identp;
	    level: 0..255;	(* environment level *)
	    offset: 0..255;	(* environment offset *)
	    dtype: varidefp;	(* to hold the dimension info *)
	    tbits: 0..15;  (* special type bits: array = 1, proc = 2, ref = 4 & ? *)
	    dbits: 0..15;	(* for use by debugger/interpreter *)
	    case vtype: datatypes of
  arraytype:  (a: nodep);
  proctype:   (p: nodep);
  labeltype,
  cmontype:   (s: statementp);
  mactype:    (mdef: statementp);
  macargtype: (marg: tokenp);
  pconstype:  (c: nodep);
  dimensiontype: (dim: nodep);
	  end;

(* definition of the ubiquitous NODE record *)

nodetypes = (exprnode, leafnode, listnode, clistnode, colistnode, forvalnode,
		deprnode, viaptnode, apprnode, destnode, durnode,
		sfacnode, wobblenode, swtnode, nullingnode, wristnode, cwnode,
		arrivalnode, departingnode,
		ffnode, forcenode, stiffnode, gathernode, cmonnode, errornode,
		calcnode, arraydefnode, bnddefnode, bndvalnode,
		waitlistnode, procdefnode, tlistnode, dimnode, commentnode);

exprtypes =  (	svalop,					(* scalar operators *)
		sltop, sleop, seqop, sgeop, sgtop, sneop,	(* relations *)
		notop, orop, xorop, andop, eqvop,		(* logical *)
		saddop, ssubop, smulop, sdivop, snegop, sabsop, (* scalar ops *)
		sexpop, maxop, minop, intop, idivop, modop,
		sqrtop, logop, expop, timeop,			(* functions *)
		sinop, cosop, tanop, asinop, acosop, atan2op,	(* trig *)
		vdotop, vmagnop, tmagnop,
		vecop,					(* vector operators *)
		vmakeop, unitvop, vaddop, vsubop, crossvop, vnegop,
		svmulop, vsmulop, vsdivop, tvmulop, wrtop,
		tposop, taxisop,
		transop,				(* trans operators *)
		tmakeop, torientop, ttmulop, tvaddop, tvsubop, tinvrtop,
		vsaxwrop, constrop, ftofop, deproachop, fmakeop, vmkfrcop,
		ioop,					(* i/o operators *)
		queryop, inscalarop,
		specop,					(* special operators *)
		arefop, callop, grinchop, macroop, vmop, adcop, dacop,
		badop,
		addop, subop, negop, mulop, divop, absop); (* for parsing *)

leaftypes = pconstype..strngtype;

reltypes = sltop..sgtop;
forcetypes = (force,absforce,torque,abstorque,angvelocity);

node = record
	next: nodep;
	case ntype: nodetypes of
    exprnode:	(op: exprtypes; arg1, arg2, arg3: nodep; elength: integer);
    leafnode:	(case ltype: leaftypes of
	varitype:  (vari: varidefp; vid: identp);
	pconstype: (cname: varidefp; pcval: nodep);
	svaltype:  (s: scalar; wid: integer);
	vectype:   (v: dump);
	transtype: (t: dump);
	strngtype: (length: integer; str: strngp) ); (* also used by commentnodes *)
    procdefnode:(ptype: datatypes; level: 0..255;
		    pname, paramlist: varidefp; body: statementp);
    listnode:	(lval: nodep);
	end;

(* records for parser: ident, token, resword *)

ident = record
	    next: identp;
	    length: integer;
	    name: strngp;
	    predefined: varidefp;
	  end;


tokentypes = (reswdtype, identtype, constype, comnttype, delimtype, labeldeftype,
		macpartype);

constypes = svaltype..strngtype;

reswdtypes = (stmnttype, filtype, clsetype, decltype, optype, edittype);

filtypes = (abouttype,alongtype,attype,bytype,defertype,dotype,elsetype,
		errmodestype,fromtype,handtype,intype,nonrigidlytype,rigidlytype,
		sourcefiletype,steptype,thentype,totype,untltype,viatype,
		withtype,worldtype,zeroedtype,oftype,wheretype,nowaittype,
		ontype,offtype,ppsizetype,collecttype,alltype,lextype);

clsetypes = (approachtype,arrivaltype,departuretype,departingtype,durationtype,
		errortype,forcetype,forceframetype,forcewristtype,gathertype,
		nildeproachtype,nonullingtype,nullingtype,stiffnesstype,
		torquetype,velocitytype,wobbletype,
		cwtype,ccwtype,stopwaittimetype,angularvelocitytype,
		fxtype,fytype,fztype,mxtype,mytype,mztype,
		t1type,t2type,t3type,t4type,t5type,t6type,tbltype);

edittypes = (getcmd,savecmd,insertcmd,renamecmd,startcmd,gocmd,proceedcmd,
		stepcmd,sstepcmd,nstepcmd,gstepcmd,executecmd,setcmd,tracecmd,
		breakcmd,unbreakcmd,tbreakcmd,definecmd,markcmd,unmarkcmd,
		popcmd);

token = record
	  next: tokenp;
	  case ttype: tokentypes of
constype:   (cons: nodep);
comnttype:  (len: integer; str: strngp);
delimtype:  (ch: ascii);
reswdtype:  (case rtype: reswdtypes of
	stmnttype: (stmnt: stmntypes);
	filtype:   (filler: filtypes);
	clsetype:  (clause: clsetypes);
	decltype:  (decl: datatypes);
	optype:	   (op: exprtypes);
	edittype:  (ed: edittypes) );
identtype:  (id: identp);
labeldeftype: (lab: varidefp);
macpartype: (mpar: varidefp);
	end;


resword = record
	  next: reswordp;
	  length: integer;
	  name: strngp;
	  case rtype: reswdtypes of
	stmnttype:  (stmnt: stmntypes);
	filtype:    (filler: filtypes);
	clsetype:   (clause: clsetypes);
	decltype:   (decl: datatypes);
	optype:	    (op: exprtypes);
	edittype:  (ed: edittypes);
	  end;

(* process descriptor blocks & environment record definitions *)

queuetypes = (nullqueue,nowrunning,runqueue,inputqueue,eventqueue,sleepqueue,
		forcewait,devicewait,joinwait,proccall);

pdb = packed record
	nextpdb,next: pdbp;	(* for list of all/active pdb's *)
	level: 0..255;		(* lexical level *)
	mode: 0..255;		(* expression/statement/sub-statement *)
	priority: 0..255;
	status: queuetypes;	(* what are we doing *)
	env: envheaderp;
	spc: statementp;	(* current statement *)
	epc: nodep;		(* current expression (if any) *)
	sp: nodep;		(* intermediate value stack *)
	cm: cmoncbp;		(* if we're a cmon point to our definition *)
	mech: dump;		(* current device being used *)
	linenum: integer;	(* used by editor/debugger *)
	 case procp: boolean of	(* true if we're a procedure *)
true:  (opdb: pdbp;		(* pdb to restore when procedure exits *)
	pdef: nodep);		(* procedure definition node *)
false: (evt: dump;		(* event to signal when process goes away *)
	sdef: statementp);	(* first statement where process was defined *)
      end;


envheader = packed record
	      parent: envheaderp;
	      env: array [0..4] of environp;
	      varcnt: 0..255;		(* # of variables in use ??? *)
		case procp: boolean of  (* true if we're a procedure *)
	true: (proc: nodep);
	false:(block: statementp);
	    end;


enventry = record
	    case etype: datatypes of
  svaltype:  (s: scalar);
  vectype:   (v: dump);
  transtype: (t: dump);
  frametype: (f: dump);
  eventtype: (evt: dump);
  strngtype: (length: integer; str: strngp);
  cmontype:  (c: cmoncbp);
  proctype:  (p: nodep; penv: envheaderp);
  reftype:   (r: enventryp);
  arraytype: (a: envheaderp; bnds: nodep);
	   end;


environment = record
		next: environp;
		vals: array [0..9] of enventryp;
	      end;


cmoncb = record
	   running, enabled: boolean;		(* cmon's status *)
	   cmon: statementp;
	   pdb: pdbp;
	   evt: dump;
	   fbits: integer;			(* bits for force sensing *)
	   oldcmon: cmoncbp;			(* for debugger *)
	 end;

(* print related records: *)

cursorp = record
	  cline,ind: integer;
	  case stmntp: boolean of
  true:    (st: statementp);
  false:   (nd: nodep);
	 end;

linerec = record
	next: linerecp;
	start,length: integer
       end;

listingarray = packed array [0..listinglength] of ascii;

(* Global variables *)

var 
	(* From ALMAIN *)
    b:boolean;		
    ch:ascii;
    ltime: real;

	(* From PARSE *)
    reswords: array [0..26] of reswordp;
    idents: array [0..26] of identp;
    macrostack: array [1..10] of tokenp;
    curmacstack: array [1..10] of varidefp;
    macrodepth: integer;
    curchar, maxchar, curline: integer;
    curBlock,newDeclarations: statementp;
    curProc: varidefp;
    pnode: nodep;
    nodim, distancedim, timedim, angledim,
      forcedim, torquedim, veldim, angveldim: varidefp;
    fvstiffdim, mvstiffdim: nodep;
(*  filedepth: integer;
    curpage: integer;
    sysVars,unVars: varidefp;
    errcount: integer;
    outerBlock: statementp;
    curVariable: varidefp;
    curMotion: statementp;
    endOk,coendOk: integer;
    moveLevel: integer;
    curErrhandler, curCmon: statementp;	*)
    d1: array[1..13] of dump;
    endOfLine, backup, expandmacros, flushcomments, dimCheck: boolean;
(*  semiseen, shownline: boolean;
    eofError: boolean;
    inMove,inCoblock: boolean;	*)
    d2,d3,d4,d5,d6: boolean;
    curtoken: token;
    file1,file2,file3,file4,file5: atext;
    line: linestr;

	(* From INTERP *)
(*  curInt, activeInts, readQueue, allPdbs: pdbp;
    curEnv, sysEnv: envheaderp;
    clkQueue: nodep;
    allEvents: dump;
    STLevel: integer;		
    etime: integer;		
    curtime: integer; 		
    stime: integer;		
    msg: dump;			
    inputp: integer;		
    debugLevel: integer;	*)
    d10: array[1..15] of integer;
    tSingleThreadMode: boolean;
    resched, running, escapeI, singleThreadMode: boolean;
    msgp: boolean;		(* flag set if any messages pending *)
    inputReady: boolean;
    inputLine: array [1..20] of ascii;

	(* From EDIT *)
    lines: array [1..maxLines] of linerecp; 
    ppLines: array [1..maxPPLines] of linerecp;	
    marks: array [1..20] of integer;
    cursorStack: array [1..15] of cursorp;
    bpts: array [1..maxBpts] of statementp;
    tbpts: array [1..maxTBpts] of statementp;
    debugPdbs: array [0..10] of pdbp;
    screenheight,dispHeight: integer;
    ppBufp,oppBufp,ppOffset,ppSize,nmarks: integer;
    lbufp,cursor,ocur,cursorLine,fieldnum,lineNum,findLine,pcLine: integer;
    firstDline,topDline,botDline,firstLine,lastLine: integer;
    freeLines,oldLines: linerecp;
    findStmnt: statementp;
    nbpts,ntbpts: integer;
    eCurInt: pdbp;
    dProg: statementp;	
    smartTerminal: boolean; 
    setUp,setExpr,setCursor,dontPrint,outFilep,newVarOk,collect: boolean;
    backUp: boolean;			
    eSingleThreadMode: boolean;	
    listing: packed array [0..listinglength] of ascii;
    lbuf: array [1..160] of ascii;
    ppBuf: array [1..100] of ascii;
    outFile: atext;
    curToken: token;			

	(* Various device & variable pointers *)
    speedfactor: enventryp;
    barm: dump;

	(* Various constant pointers *)
    xhat,yhat,zhat,nilvect: dump;
    niltrans: dump;
    bpark, ypark, gpark, rpark: dump;		(* arm park positions *)

{ Externally defined routines from elsewhere: }

	(* From ALLOC *)
function newVaridef: varidefp;					external;
function newStatement: statementp;				external;

	(* From DISP *)
procedure outLine(line,col,start,length: integer); 		external;
function getChar: ascii; 					external;

(* aux routines: GetAChar, out1Line, clearLine, eUppercase, eEqStrng, eResLookup, eIdLookup *)

function getAChar: ascii; external;
function getAChar;
 var ch: ascii; i: integer;
 begin
 repeat ch := getChar until ch <> chr(12B);	(* skip over any <lf>'s *)
 i := ord(ch);
 if i < 40B then 				(* or undo ASCII control key *)
   if ((i < 10B) or (15B < i)) and (i <> 30B) then ch := chr(i+100B);
 getAChar := ch;
 end;

procedure out1Line(line,start,length: integer); external;	(* Also in EPUT *)
procedure out1Line;
 begin
 if length > 79 then length := 79;	(* only display first 79 chars *)
 outLine(line,1,start,length);
 end;

procedure clearLine(i: integer); external;
procedure clearLine;				(* copy in ppGlitch *)
 var ch: ascii;
 begin
 ch := listing[1];
 listing[1] := ' ';
 outLine(i,1,1,1);
 listing[1] := ch;
 end;

function upperCase(c: ascii): ascii; external;
function upperCase;
 begin
 if (c < chr(141B)) or (chr(172B) < c) then upperCase := c
  else upperCase := chr(ord(c) - 40B);		(* c - 'a' + 'A' *)
 end;

function eqStrng(s1: strngp; s2,len: integer): boolean; external;
function eqStrng;
 var i,j: integer; b: boolean;
 begin
 b := true;
 i := 0;
 j := 1;
 repeat
  if upperCase(s1↑.ch[j]) <> upperCase(listing[s2+i]) then b := false
   else
    begin
    i := i + 1;
    if j < 10 then j := j + 1
     else begin j := 1; s1 := s1↑.next end;
    end
 until (i >= len) or not b;
 eqStrng := b;
 end;

function hash(ch: ascii): integer; external;
function hash;
 var i: integer;
 begin			(* this will only work for ascii *)
 i := ord(ch);
 if ('A' <= ch) and (ch <= 'Z') then i := i - ord('A') + 1
  else if (chr(141B) <= ch) and (ch <= chr(172B)) then i := i - 141B + 1
  else i := 0;
 hash := i;
 end;

function resLookup(str,len: integer): reswordp; external;
function resLookup;
 var res: reswordp; b: boolean;
 begin
 res := reswords[hash(listing[str])];	(* look in right bucket *)
 b := true;
 while (res <> nil) and b do
  if res↑.length = len then
    if eqStrng(res↑.name,str,len) then b := false
     else res := res↑.next
   else res := res↑.next;
 resLookup := res;
 end;

function idLookup(str,len: integer): identp; external;
function idLookup;
 var id: identp; b: boolean;
 begin
 id := idents[hash(listing[str])];	(* look in right bucket *)
 b := true;
 while (id <> nil) and b do
  if id↑.length = len then
    if eqStrng(id↑.name,str,len) then b := false
     else id := id↑.next
   else id := id↑.next;
 idLookup := id;
 end;

(* aux routines: makeNVar, makeUVar, varLookup *)

function makeNVar(vartype: datatypes; vid: identp): varidefp; external;
function makeNVar;
 var v,vo: varidefp; b: boolean;
 begin
 if curBlock = nil then v := nil else v := curBlock↑.variables;
 vo := nil;
 b := true;
 while (v <> nil) and b do	(* look through var list for free var *)
  if v↑.vtype = freevartype then b := false
   else begin vo := v; v := v↑.next end;
 if v = nil then
   begin
   v := newVaridef;
   with v↑ do
    begin
    next := nil;
    if curBlock = nil then level := 0
     else
      begin
      level := curBlock↑.level;
      with curBlock↑ do numvars := numvars + 1;
      end;
    if vo <> nil then
      begin
      offset := vo↑.offset + 1;
      vo↑.next := v;		(* add var to current block's list of vars *)
      end
     else
      begin
      offset := 0;
      if curBlock <> nil then curBlock↑.variables := v;
       (* *** ??? else ??? *** *)
      end;
    end;
   end;
 with v↑ do
  begin
  vtype := vartype;
  dtype := nil;
  name := vid;
  dnext := nil;
  tbits := 0;
  dbits := 0;
  if vartype = labeltype then s := nil;
  end;
 makeNVar := v;
 end;

function makeUVar(vartype: datatypes; vid: identp): varidefp; external;
function makeUVar;
 var v: varidefp; sp,oldCurBlock: statementp; i: integer; b: boolean;
 begin
 oldCurBlock := curBlock;
 curBlock := cursorStack[2].st;		(* assume outermost block *)
 i := cursor;			(* unless in body of an enclosing procedure *)
 while i > 2 do
  begin
  with cursorStack[i] do
   if not stmntp then 
     if nd↑.ntype = procdefnode then
       if nd↑.body↑.stype = blocktype then
	 begin					(* found one *)
	 curBlock := nd↑.body;
	 b := not(sParse and (i >= sCursor)); (* special case for stmnt parsing *)
	 i := 0
	 end;
  i := i - 1;
  end;
 v := makeNVar(vartype,vid);
 sp := newStatement;	(* add a new declaration statement to start of block *)
 with sp↑ do
  begin
  stype := declaretype; variables := v; numvars := 1;
  next := curBlock↑.bcode;
  if b then
    if newDeclarations = nil then last := curBlock
     else begin last := newDeclarations; newDeclarations↑.next := sp end
   else begin last := curBlock; curBlock↑.bcode := sp end;
  nlines := 1;
  end;
 if b then newDeclarations := sp;
(* fix the display up later - hopefully the variable will be defined by then *)
 curBlock := oldCurBlock;
 makeUVar := v;
 end;

function varLookup(id: identp): varidefp; external;
function varLookup;
 var v: varidefp; i: integer; b: boolean;
 begin
 i := cursor;
 b := true;
 while (i > 1) and b do
  begin
  v := nil;
  with cursorStack[i] do
   if stmntp then begin if st↑.stype = blocktype then v := st↑.variables end
    else if nd↑.ntype = procdefnode then v := nd↑.paramlist;
  while (v <> nil) and b do
   if v↑.name = id then b := false else v := v↑.next;
  i := i - 1;
  end;
 if b then v := id↑.predefined;	(* maybe it's a predefined variable? *)
 varLookup := v;
 end;

(* cursorStack routines: pushStmnt, pushNode *)

procedure pushStmnt(s: statementp; indent: integer); external;
procedure pushStmnt;
 begin
 cursor := cursor + 1;
 with cursorStack[cursor] do
  begin
  cline := curLine + 1;
  if cursor = 1 then ind := indent
   else ind := cursorStack[cursor-1].ind + indent;
  stmntp := true;
  st := s;
  end;
 if (s↑.stlab = nil) or (cursorLine <> curLine + 1) then fieldNum := 1
  else fieldNum := 0;
 if s↑.stype = blocktype then curBlock := s;
 end;

procedure pushNode(n: nodep); external;
procedure pushNode;
 begin
 cursor := cursor + 1;
 with cursorStack[cursor] do
  begin
  cline := curLine + 1;
  if cursor = 1 then ind := 0
   else ind := cursorStack[cursor-1].ind;
  stmntp := false;
  nd := n;
  end;
 fieldNum := 1;
 end;

(* bannerLine, borderLines, & adjustDisplay *)

procedure bannerLine(ch: ascii; l: integer); external;
procedure bannerLine;
 var i: integer; h: packed array [1..27] of ascii; 
     t: real; hr,min: integer;

 procedure digitize(n,i:integer; zfill:boolean);
  var ch: char;
  begin
  listing[i] := chr((n mod 10) + ord('0')); 
  n := n DIV 10;
  ch := chr((n mod 10) + ord('0')); 	(* 2nd char *)
  if (n > 0) or zfill then listing[i-1] := ch;
  n := n DIV 10;
  if n > 0 then listing[i-2] := chr((n mod 10) + ord('0'));
  end;

 begin
 for i := 151 to 190 do listing[i] := ch;
 h := ' Cursor at Line     of     ';
 if l = 0 then		(* Top line *)
   begin		
   for i := 11 to 20 do listing[145+i] := h[i];	(* Clear end of line *)
   digitize(topDline+firstDline-1,164,false);	(* Put in line# at top of scrn *)
   for i:=171 to 190 do listing[i] := ' ';	(* Clear last part of line *)
   if collect then listing[172] := 'C';		(* Flag if Collect is on *)
   if eSingleThreadMode then       		(* Flag if nowait mode *)
     begin
     listing[175] := 'N'; listing[176] := 'W';
     end;
   t := time;     				(* Find out what time it is *)
   hr := trunc(t);
   min := trunc((t-hr)*60);
   digitize(hr,187,false);			(* Put time into buffer *)
   listing[188] := ':';
   digitize(min,190,true);
   end
  else			(* Bottom line *)
   begin		
   for i := 1 to 27 do listing[155+i] := h[i];
   digitize(cursorline,174,false);		(* Put in line# cursor is at *)
   digitize(dprog↑.nlines,181,false);		(* and total lines in program *)
   end;
 outLine(l,1,151,40);
 end;

procedure borderLines; external;
procedure borderLines;
 var ch: ascii; i: integer;
 begin
 if not fParse then
   begin
   if topDline + firstDline = 2 then ch := '*' else ch := '.';
   bannerLine(ch,0);
   if topDline + firstDline + dispHeight - 2 >= dprog↑.nlines then ch := '*'
    else ch := '.';
   if botDline < dispHeight then bannerLine(ch,botDline+1)
    else bannerLine(ch,dispHeight+1);
   end;
 end;

procedure adjustDisplay; external;
procedure adjustDisplay;
 begin
 if (cursorLine < topDline + firstDline - 1) or
    (cursorLine > topDline + firstDline + dispHeight - 2) then
   lineNum := cursorLine - dispHeight div 2;		(* off screen *)
 end;