perm filename EMAIN.2[EAL,HE]1 blob
sn#674812 filedate 1982-09-27 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00003 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 {$NOMAIN Editor: main program part (edit routine) }
C00005 00003 (* edit: Main routine *)
C00016 ENDMK
C⊗;
{$NOMAIN Editor: main program part (edit routine) }
%include emain.hdr;
{ Externally defined routines from elsewhere: }
(* From the EMAINn modules *)
procedure eEditInit; external;
procedure eDo1Cmd (ch: ascii; iCh: integer;
var done, minus, okp: boolean;
oldline, oldcline, arg: integer); external;
procedure eDo2Cmd (ch: ascii; iCh: integer; var okp: boolean;
arg: integer); external;
procedure eDoECmd (var okp: boolean); external;
procedure eDoStmnt; external;
procedure eGetCommand (ch: ascii); external;
procedure eDoOtherCmd; external;
(* From PP *)
procedure ppLine; external;
procedure ppOutNow; external;
procedure ppChar(ch: ascii); external;
procedure pp5(ch: c5str; length: integer); external;
procedure pp10(ch: cstring; length: integer); external;
procedure pp10L(ch: cstring; length: integer); external;
procedure pp20(ch: c20str; length: integer); external;
procedure pp20L(ch: c20str; length: integer); external;
procedure ppInt(i: integer); external;
procedure ppReal(r: real); external;
procedure ppStrng(length: integer; s: strngp); external;
(* From DISP *)
procedure resetScreen; external;
procedure echo(on: boolean); external;
function getChar: ascii; external;
(* edit: Main routine *)
procedure edit; external;
procedure edit;
var done,minus,okp: boolean;
ch: ascii;
arg,oldcline,oldline,oc,ol,iCh: integer;
function getCChar: ascii;
var ch: ascii; iCh: integer;
begin
repeat ch := getChar until ord(ch) <> 12B; (* read in next char *)
if (ord(ch) = 177B) then
ch := chr(10B); (* convert DEL to <bs> *)
iCh := ord(ch);
if (iCh < 40B) and (iCh <> 15B) then
begin (* ASCII cntl char *)
ppChar('↑');
iCh := iCh + 100B;
end;
ppChar(chr(iCh)); (* echo it to page printer *)
ppOutNow;
getCChar := ch;
end;
begin (* edit *)
eEditInit; (* Initialize stuff *)
oldcline := 1;
oldline := 1;
done := false;
repeat
okp := true;
oc := cursorLine; (* remember where we were *)
ol := lineNum;
ch := getCChar;
iCh := ord(ch);
minus := false;
if (iCh = 34B) or (iCh = 33B) then (* ↑\ or ALT *)
begin (* get repeat count *)
ch := getCChar;
if (ch = '+') or (ch = '-') then
begin
minus := ch = '-';
ch := getCChar;
end;
arg := 0;
while ('0' <= ch) and (ch <= '9') do
begin
arg := 10*arg + (ord(ch) - ord('0')); (* get next digit *)
ch := getCChar;
end;
iCh := ord(ch);
end
else arg := 1;
if minus then arg := -arg;
if (iCh <= 40B) or (ch in ['↑','<','>','[','?','@','!']) then
if (iCh=11B) or (ch=' ') or (ch='!') (* 'I', ' ', '!' handled separately *)
then eDo2Cmd(ch, iCh, okp, arg)
else eDo1Cmd(ch, iCh, done, minus, okp, oldline, oldcline, arg)
else
begin
eGetCommand (ch); (* read in text of user's command *)
with eCurToken do
if (ttype = reswdtype) and (rtype <> optype) then
if rtype = edittype then (* editor/debugger command *)
eDoECmd(okp) (* Go do it! *)
else
eDoOtherCmd (* Some other kind of stmnt *)
else
eDoStmnt
end;
if abs(cursorLine-oc) > 4 then
begin
oldcline := oc; (* remember for "O" command *)
oldline := ol;
end;
if okp then
begin
pp5(' OK ',4);
ppOutNow;
end;
if PPbufp > 60 then ppLine;
until done;
echo(true); (* turn echoing back on *)
resetScreen; (* restore world for main *)
writeln;
end (* edit *);