! ZEROECCE: Dummy file for non-fans of VECCE
! containing the CONNECT EDFILE routine used by the compilers,
! and a dummy routines for the editor itself.

%include "inc:util.imp" {for STOI, PAM, CONNECT etc}

%constinteger MAXNAME=127
%recordformat EDFILE(%integer start1,lim1, {part 1}
                              start2,lim2, {part2}
                              lim, {VMLIM}
                              lbeg,fp,change,flag,
                              line  {line number of current pos},
                              diff  {diff between LINE and ROW},
                %byteinteger  top  {top row of sub_window},
                              win  {floating top},
                              bot  {bottom row +1 of sub_window},
                              min  {minimum window size},
                              row  {last row position},
                              col  {last col position},
             %string(maxname) name)

%external%routine CONNECT EDFILE(%record(edfile)%name f)
! Utilises special extension to CONNECT FILE which allows additional
! space to be allocated fore and aft
%constinteger BIZARRE=128
%integer gap
  %on %event 2,3,9 %start
    select output(0)
    printstring(event_message);  newline
    f_flag = 1
    %return
  %finish
  heapput(f_start1) %if f_start1 # 0;  !VM previously allocated
  f_start1 = 0;  f_lim1 = 0
  gap = f_flag>>1
  f_start2 = gap;  f_lim2 = gap;  !extra space fore and aft
  f_change = 0;  f_line = 0
  connect file(f_name,BIZARRE,f_start2,f_lim2)
  f_start1 = f_start2-gap;  f_lim1 = f_start1;  !VM start
  f_lim2 = f_lim2+f_start2;                     !length => limit
  f_lim = f_lim2+gap;                           !VM limit
  f_lim2 = f_lim2-1 %while f_lim2 > f_start2 %and byteinteger(f_lim2-1) # nl
  f_flag = 0
%END

%externalroutine SET PARAMETERS(%string(maxname)%name in,sec,out,
                                %string(255) parm)
%end

%externalroutine EDI(%record(edfile)%name main,sec,
                     %string(255) message)
  printstring(message); newline
%end

%external%routine DISCONNECT EDFILE(%record(edfile)%name out)
%end

%endoffile
