{$R+,B-,S+,I-,N-,L-,V-} Unit editor; Interface uses Crt, Dos, Screen, EditDecl, Edit_Err, ExecT, Menu, Dir, Control, Compile; procedure Edit; Implementation {\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\ \\ \\ ANALOGUE EDITOR TOOLBOX Version 2.00A \\ \\ File Name: \\ \\ \\ \\ Editor: \\ \\ Text Buffer Data Structure Utilities \\ \\ \\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\} var heap_min: ^byte; { min size of heap during compilation } procedure CheckData(c: char); { are all the data structures intact ? } var m: mark_type; begin if (ColNo < 1) or (ColNo > PhyScrCols) then begin ErrorMsg(c+' Data Corrupted: ColNo',true); ColNo:=1; end; if (LineNo < ScreenTop) or (LineNo > PhyScrRows) then begin ErrorMsg(c+' Data Corrupted: LineNo',true); LineNo:=1; end; with AboveScreen do begin if (top < TextBufLo) or (top > TextSize) or (top >= BelowScreen.top) then begin ErrorMsg(c+' Data Corrupted: AboveScreen.top',true); top:=TextBufLo; end; if Buf^[TextBufLo] <> CtrlZ then begin ErrorMsg(c+' Data Corrupted: AboveScreen.Buf^[TextBufLo]',true); Buf^[TextBufLo]:=CtrlZ; end; if (top > TextBufLo) and ((Buf^[top] <> LF) or (Buf^[top-1] <> CR)) then begin ErrorMsg(c+' Data Corrupted: AboveScreen.Buf^[top]',true); inc(top); Buf^[top]:=CR; inc(top); Buf^[top]:=LF; end; end; with BelowScreen do begin if (top > TextSize) or (top < TextBufLo) or (top <= AboveScreen.top) then begin ErrorMsg(c+' Data Corrupted: BelowScreen.top',true); top:=TextSize; end; if Buf^[TextSize] <> CtrlZ then begin ErrorMsg(c+' Data Corrupted: BelowScreen.Buf^[TextSize]',true); Buf^[TextSize]:=CtrlZ; end; if (top < TextSize) and ((Buf^[TextSize-1] <> LF) or (Buf^[TextSize-2] <> CR)) then begin ErrorMsg(c+' Data Corrupted: Below.Buf^[TextSize-1]',true); Buf^[TextSize-1]:=LF; Buf^[TextSize-2]:=CR; end; end; for m:=blk_beg to blk_end do with marker[m] do case class of scrn: begin if (cl < 1) or (cl > PhyScrCols) then begin ErrorMsg(c+' Data Corrupted: marker['+chr(ord(m)+48)+'].cl',true); cl:=1; end; if (ln < ScreenTop) or (ln > PhyScrRows) then begin ErrorMsg(c+' Data Corrupted: marker['+chr(ord(m)+48)+'].ln',true); ln:=1; end; end; abv: with AboveScreen do begin if (index < TextBufLo+1) or (index > top) then begin ErrorMsg(c+' Data Corrupted: marker['+chr(ord(m)+48)+'].abv.index',true); index:=TextBufLo+1; end; if (Buf^[index] = LF) then begin ErrorMsg(c+' Data Corrupted: Buf^[marker['+chr(ord(m)+48)+'].abv.index]',true); dec(index); end; end; blw: with BelowScreen do begin if (index < top) or (index > TextSize-1) then begin ErrorMsg(c+' Data Corrupted: marker['+chr(ord(m)+48)+'].blw.index',true); index:=top; end; if (Buf^[index] = LF) then begin ErrorMsg(c+' Data Corrupted: Buf^[marker['+chr(ord(m)+48)+'].blw.index]',true); dec(index); end; end; end; end; procedure Change; { the current file has been changed } begin CompileChangeFlag:=true; WriteChangeFlag:=true; end; procedure Move_to_Screen(var source; line: LineCnt; col: ColCnt; len: ColCnt); begin if len > PhyScrCols-1 then len:=PhyScrCols-1; Move(source,EditScreen[Line,Col],len); end; function LastNonBlankCol(line: LineCnt): ColCnt; { finds the last non-blank column of a line on the screen } var p: ^char; n: ColCnt; begin (* for n:=physcrcols downto 1 do if EditScreen[line,n] <> ' ' then begin lastnonblankcol:=n; exit; end; LastNonBlankCol:=0; (**) p:=ptr(seg(EditScreen[line,PhyScrCols]),ofs(EditScreen[line,PhyScrCols])); inline( { CX:=PhyScrCols; } $B9 />PhyScrCols { MOV CX,PhyScrCols } { ES:DI := p } /$C4 /$7E /
0 }
/$75 /<-11 { JNZ L1 }
{ n:=CX }
/$89 /$4E /