
procedure clear_status;
begin
      write(esc,'j',                 { save cursor position }
            esc,'Y',chr(24+32),' ',  { go to start of line 25 }
            esc,'l',                 { erase entire line }
            esc,'k');                { restore cursor position }
end;

procedure set_status( l1,l2,l3,l4,l5,l6,l7 : string10);
    begin
    write(esc,'x1',                 { enable line 25 }
          esc,'j',                  { save cursor position }
          esc,'Y',chr(24+32),' ');  { go to start of line 25 }

    if l1 <> '' then write(HI,l1,LO) else write('          '); write(' ');
    if l2 <> '' then write(HI,l2,LO) else write('          '); write(' ');
    if l3 <> '' then write(HI,l3,LO) else write('          '); write(' ');
    if l4 <> '' then write(HI,l4,LO) else write('          '); write(' ');
    if l5 <> '' then write(HI,l5,LO) else write('          '); write(' ');
    if l6 <> '' then write(HI,l6,LO) else write('          '); write(' ');
    if l7 <> '' then write(HI,l7,LO) else write('          '); write(' ');
    write(esc,'k');                 { restore cursor position }
    end;



procedure w_erase;
{ frame and clear window }
var x,y : integer;
begin
if w_table.x1 <> -1 then
  with w_table do begin
    for y := y1 + 1 to y2 - 1 do begin
        gotoxy(x1,y);
        write(#$BA,'':x2-x1-2,#$BA);
    end;
    gotoxy(x1,y1); write(#$C9);
    for x := 3 to x2-x1 do write(#$CD); write(#$BB);
    gotoxy(x1,y2); write(#$C8);
    for x := 3 to x2-x1 do write(#$CD); write(#$BC);
    gotoxy(x1+1,y1+1);
    currx := x1+1; curry := y1+1;
end;
end;

procedure w_delete;
 { get rid of the sub window:
      restore the screen contents from 'overwrote'
      invalidate window
 }

begin
if w_table.x1 <> -1 then
  with w_table do begin
    move(overwrote,screen,4096);
    write(esc,'k');
    x1 := -1;
  end;
end;

procedure w_make   (nx1,nx2,ny1,ny2 : integer);  { boundrys }
 { make the sub-window:
         save current screen in 'overwrote'
         set defaults in w_table
         save old cursor position
         call w_erase (above)

 }
var x, y : integer;
begin
if w_table.x1 <> -1 then w_delete;
with w_table do begin
  move(screen,overwrote,4096); (* save screen state *)
  x1 := nx1;x2 := nx2;y1 := ny1;y2 := ny2;
  write(esc,'j');  (* save old cursor position  - VT52+ emulator - *)
  w_erase;
end;
end;

procedure w_writeln;
begin
if w_table.x1 <> -1 then
  with w_table do begin
    currx := x1 + 1;
    if curry >= y2-1 then curry := y1+1
    else curry := curry + 1;
  end;
end;

procedure w_write_c(ch : char);
begin
if w_table.x1 <> -1 then
  with w_table do begin
    gotoxy(currx,curry);
    write(ch);
    if currx >= x2-1 then begin
        currx := x1;
        if curry >= y2-1 then
            curry := y1+1
        else curry := curry + 1;
    end
    else currx := currx + 1;
  end;
end;

procedure w_write_s(s : maxstr);
var x : integer;
begin
with w_table do begin
for x := 1 to length(s) do w_write_c(s[x]);
end;
end;

procedure w_gotoxy (x,y : integer);
begin
if w_table.x1 <> -1 then
  with w_table do begin
    currx := x1 + x;
    curry := y1 + y;
    gotoxy(currx,curry);
  end;
end;
    FK1              =  #$F1;     { 