home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / ECO30603.ZIP / ECO30603.LZH / ECOLIBII / ECO_FILE.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-03-03  |  49.6 KB  |  1,428 lines

  1. (*
  2.          ┌────────────────[ File Information Report ]────────────────┐
  3.          │                                                           │
  4.          │   Sourcefile for The Fast Commander, V3.51 and higher.    │
  5.          │   All material is protected and licensed.                 │
  6.          │   (C) Copyright 1992 by EUROCON PANATIONAL CORPORATION.   │
  7.          │   Written exclusively by Floor Naaijkens for              │
  8.          │   UltiHouse Software / The ECO Group All Rights Reserved. │
  9.          │   See various documentory files for further information   │
  10.          │   on how to handle these files.                           │
  11.          │                                                           │
  12.          │   Filename:      ECO_FILE.PAS                             │
  13.          │   Version:       3.51                                     │
  14.          │   Last change:   March 3rd MCMXCIII 11:16                 │
  15.          │   Dependencies:  CRT, DOS, ECO_LIB                        │
  16.          │                                                           │
  17.          └───────────────────────────────────────────────────────────┘
  18. *)
  19.  
  20.  
  21. {$A-,B-,D-,E-,F-,I-,L-,N-,O-,R-,S-,V-}
  22. unit eco_file;
  23.  
  24. interface
  25.  
  26. uses
  27.   dos, crt, eco_lib
  28.  
  29.   ;
  30.  
  31.  
  32. type
  33.   readwrite = (readfile, writefile, readconfig, writeconfig);
  34.   str6 = string[6];
  35.   str12 = string[12];
  36.  
  37.   searchrecord = record
  38.    {fill   : array[1..21] of byte; we don't need that!}
  39.     attr   :       byte;
  40.     time   :    longint;
  41.     size   :    longint;
  42.     name   : string[12];
  43.     tagged :    boolean;
  44.   end;
  45.  
  46.  
  47.   filtagar    = array[0..511] of boolean;
  48.   {filtagar   = array[0..63] of byte;         bits are booleans! }
  49.   far         = array[0..511] of searchrecord;
  50.   filtagarptr = ^filtagar;
  51.   farptr      = ^far;
  52.  
  53.  
  54.  
  55.   filespanelobj = object { data must not be altered directly }
  56.     showpath,
  57.     fullwide                  : boolean;
  58.     x1, y1, x2, y2,
  59.     boxtype,
  60.     panel_f, panel_b,
  61.     header_f, header_b        :    byte;
  62.     footer_f, footer_b        :    byte;
  63.     showscan                  : boolean;
  64.     x3, y3, x4, y4,
  65.     popup_f, popup_b,
  66.     tagcsr_f, tagcsr_b,
  67.     tagnocsr_f, tagnocsr_b,
  68.     scrollbar_f, scrollbar_b,
  69.     curactbar_f, curactbar_b  :    byte;
  70.  
  71.     {==================================}
  72.     filarray                  :    ^far;
  73.     filenumber,
  74.     tagnum, filoff, pc,
  75.     filescursor               :    word;
  76.     wild                      : filestr;
  77.     scnlen,
  78.     oldfil, oldoff,
  79.     scan                      :    byte;
  80.     newfiloff                 : boolean;
  81.     tagbytes                  : longint;
  82.     sum                       : longint;
  83.  
  84.     sort                      :    byte; { sort:           1 name             }
  85.                                          {                 2 ext              }
  86.     show_r_o                  : boolean; {                 3 date & time      }
  87.     show_hid                  : boolean; {                 4 size             }
  88.     show_sys                  : boolean; { condition sort: 5 name             }
  89.     show_arc                  : boolean; {                 6 ext              }
  90.     show_vol                  : boolean; {                 7 date & time      }
  91.     show_non                  : boolean; {                 8 size             }
  92.     show_dir                  : boolean; { condition: if less than maxforsort }
  93.     maxforsort                :    byte; { entries found then sort else skip. }
  94.  
  95.     {==================================}
  96.     procedure init;
  97.     procedure done;
  98.     procedure draw;
  99.     procedure readfiles(_doscurpath: pathstr);
  100.     procedure startsorting;
  101.     function  walk_files_(
  102.       returnkeys: pointer; nroffileskeys: byte;
  103.       var pl: boolean; var retkey: word
  104.     ): string;
  105.     function  __tm2ststr(hour, minute: word): str6;
  106.     function  __xfrstr(sourc: string; xfrin, xfrout: char): string;
  107.     function  chnam(s: searchrecord; plain, bar: boolean): string;
  108.     function  anytagged(var nr: word): boolean;
  109.     procedure retagfiles(option: readwrite; files: filtagarptr);
  110.     procedure getoptions(
  111.       var
  112.         filesfullwide , filesshowpath        : boolean;
  113.       var
  114.         bt,
  115.         filesx1, filesy1, filesx2, filesy2,
  116.         filespanel_f, filespanel_b,
  117.         filesheader_f, filesheader_b         :    byte;
  118.         filesfooter_f, filesfooter_b         :    byte;
  119.       var
  120.         filesshowscan                       : boolean;
  121.       var
  122.         filesx3, filesy3, filesx4, filesy4,
  123.         filespopup_f, filespopup_b,
  124.         filestagnocsr_f, filestagnocsr_b,
  125.         filestagcsr_f, filestagcsr_b,
  126.         filesscrollbar_f, filesscrollbar_b,
  127.         filescuractbar_f, filescuractbar_b   :    byte
  128.     );
  129.     procedure setoptions(
  130.       filesfullwide , filesshowpath        : boolean;
  131.       bt,
  132.       filesx1, filesy1, filesx2, filesy2,
  133.       filespanel_f, filespanel_b,
  134.       filesheader_f, filesheader_b         :    byte;
  135.       filesfooter_f, filesfooter_b         :    byte;
  136.       filesshowscan                        : boolean;
  137.       filesx3, filesy3, filesx4, filesy4,
  138.       filespopup_f, filespopup_b,
  139.       filestagnocsr_f, filestagnocsr_b,
  140.       filestagcsr_f, filestagcsr_b,
  141.       filesscrollbar_f, filesscrollbar_b,
  142.       filescuractbar_f, filescuractbar_b   :    byte
  143.     );
  144.   end; { filespanelobj }
  145.  
  146.  
  147.  
  148. const
  149.   _c_v               =          $2f16;
  150.   shellfile : string = 'C:\SHELL.ECO';
  151.  
  152.  
  153. var
  154.   hours, mins, secs,
  155.   tics, year, month,
  156.   day                 :        word;
  157.   plain               :     boolean;
  158.   atri                :   searchrec;
  159.  
  160.  
  161.  
  162.  
  163. implementation
  164.  
  165.  
  166.  
  167.   procedure smallbeep;
  168.   begin
  169.   end;
  170.  
  171.  
  172.  
  173.   {$F+}
  174.   function det(d1, d2: searchrecord): byte;
  175.   begin
  176.     if (
  177.       (d1.attr and volumeid)>0) and not((d2.attr and volumeid)>0
  178.     ) then det := 1 else if not(
  179.       (d1.attr and volumeid)>0) and ((d2.attr and volumeid)>0
  180.     ) then det := 0 else if (
  181.       (d1.attr and directory)>0) and not((d2.attr and directory)>0
  182.     ) then det := 1 else if not(
  183.       (d1.attr and directory)>0) and ((d2.attr and directory)>0
  184.     ) then det := 0 else if (
  185.       (d1.attr and directory)>0) and ((d2.attr and directory)>0
  186.     ) then if (d1.name < d2.name) then det := 1 else det := 0 else det := 2;
  187.   end; { det }
  188.  
  189.  
  190.  
  191.   function sortfactorname(var data1, data2): boolean;
  192.   var dd: byte;
  193.   begin
  194.     dd := det(searchrecord(data1),searchrecord(data2));
  195.     if dd = 0 then sortfactorname := false else
  196.     if dd = 1 then sortfactorname := true else
  197.     sortfactorname := (searchrecord(data1).name < searchrecord(data2).name);
  198.   end; { sortfactorname }
  199.  
  200.  
  201.  
  202.  
  203.   function sortfactorext(var data1, data2): boolean;
  204.   var
  205.     st1, st2: string[3];
  206.     in1, in2: integer;
  207.     dd      : byte;
  208.  
  209.   begin
  210.     dd := det(searchrecord(data1),searchrecord(data2));
  211.     if dd = 0 then sortfactorext := false else
  212.     if dd = 1 then sortfactorext := true else begin { by extension }
  213.       in1 := pos('.', searchrecord(data1).name);
  214.       if in1<>0 then
  215.         st1 := __juststr(copy(searchrecord(data1).name, in1+1, 3),
  216.           ' ', 3, _left_just_str) else st1 := '   ';
  217.       in2 := pos('.', searchrecord(data2).name);
  218.       if in2<>0 then
  219.         st2 := __juststr(copy(searchrecord(data2).name, in2+1, 3),
  220.           ' ', 3, _left_just_str) else st2 := '   ';
  221.       if (st1='   ') and (st2<>'   ') then sortfactorext := true else
  222.         if (st1<>'   ') and (st2='   ') then sortfactorext := false else
  223.       if (st1<>'   ') and (st2<>'   ') and (st1<>st2)
  224.       then sortfactorext := st1<st2
  225.       else sortfactorext := { now by name, ext did not give result }
  226.          (searchrecord(data1).name < searchrecord(data2).name);
  227.     end;
  228.   end; { sortfactorext }
  229.  
  230.  
  231.  
  232.  
  233.  
  234.   function sortfactortime(var data1, data2): boolean;
  235.   var
  236.     dt1, dt2: datetime;
  237.     li1, li2: longint;
  238.     dd      : byte;
  239.  
  240.   begin
  241.     dd := det(searchrecord(data1),searchrecord(data2));
  242.     if dd = 0 then sortfactortime := false else
  243.     if dd = 1 then sortfactortime := true else begin { by date and time }
  244.       unpacktime(searchrecord(data1).time, dt1);
  245.       unpacktime(searchrecord(data2).time, dt2);
  246.       li1 := __dt2jlutl(dt1.year, dt1.month, dt1.day);
  247.       li2 := __dt2jlutl(dt2.year, dt2.month, dt2.day);
  248.       if li1<>li2 then sortfactortime := { by date & time } li1<li2
  249.       else begin
  250.               li1 := dt1.hour*10000 + dt1.min*100 + dt1.sec;
  251.               li2 := dt2.hour*10000 + dt2.min*100 + dt2.sec;
  252.               sortfactortime := li1<li2
  253.            end;
  254.     end;
  255.   end; { sortfactortime }
  256.  
  257.  
  258.  
  259.  
  260.   function sortfactorsize(var data1, data2): boolean;
  261.   var dd: byte;
  262.   begin
  263.     dd := det(searchrecord(data1),searchrecord(data2));
  264.     if dd = 0 then sortfactorsize := false else
  265.     if dd = 1 then sortfactorsize := true else
  266.     sortfactorsize := (searchrecord(data1).size < searchrecord(data2).size);
  267.   end; { sortfactorsize }
  268.   {$F-}
  269.  
  270.  
  271.  
  272.  
  273.   procedure filespanelobj.init;
  274.   begin
  275.     newfiloff := false; tagbytes := 0; sum := 0; filenumber := 0;
  276.     tagnum := 0; filoff := 0; pc := 3; sort := 1;
  277.     boxtype := bt_single;
  278.     show_r_o := true; show_hid := true; show_sys := true;
  279.     show_arc := true; show_vol := true; show_non := true;
  280.     show_dir := true; maxforsort := 100; new(filarray);
  281.     getdir(0, _doscurpath); wild := '*.*';
  282.   end;
  283.  
  284.  
  285.  
  286.  
  287.   procedure filespanelobj.done;
  288.   begin
  289.     if filarray<>nil then dispose(filarray);
  290.     filenumber := 0; filoff := 0; filescursor := 0;
  291.   end;
  292.  
  293.  
  294.  
  295.  
  296.   procedure filespanelobj.setoptions(
  297.     filesfullwide , filesshowpath        : boolean;
  298.     bt,
  299.     filesx1, filesy1, filesx2, filesy2,
  300.     filespanel_f, filespanel_b,
  301.     filesheader_f, filesheader_b         :    byte;
  302.     filesfooter_f, filesfooter_b         :    byte;
  303.     filesshowscan                        : boolean;
  304.     filesx3, filesy3, filesx4, filesy4,
  305.     filespopup_f, filespopup_b,
  306.     filestagnocsr_f, filestagnocsr_b,
  307.     filestagcsr_f, filestagcsr_b,
  308.     filesscrollbar_f, filesscrollbar_b,
  309.     filescuractbar_f, filescuractbar_b   :    byte
  310.   );
  311.  
  312.   begin
  313.     fullwide := filesfullwide; showpath := filesshowpath;
  314.     boxtype := bt;
  315.     x1 := filesx1; y1 := filesy1; x2 := filesx2; y2 := filesy2;
  316.     panel_f := filespanel_f; panel_b := filespanel_b;
  317.     header_f := filesheader_f; header_b := filesheader_b;
  318.     footer_f := filesfooter_f; footer_b := filesfooter_b;
  319.     showscan := filesshowscan;
  320.     x3 := filesx3; y3 := filesy3; x4 := filesx4; y4 := filesy4;
  321.     popup_f := filespopup_f; popup_b := filespopup_b;
  322.     tagnocsr_f := filestagnocsr_f; tagnocsr_b := filestagnocsr_b;
  323.     tagcsr_f := filestagcsr_f; tagcsr_b := filestagcsr_b;
  324.     scrollbar_f := filesscrollbar_f; scrollbar_b := filesscrollbar_b;
  325.     curactbar_f := filescuractbar_f; curactbar_b := filescuractbar_b;
  326.   end;
  327.  
  328.  
  329.  
  330.   procedure filespanelobj.getoptions(
  331.     var
  332.       filesfullwide , filesshowpath        : boolean;
  333.     var
  334.       bt,
  335.       filesx1, filesy1, filesx2, filesy2,
  336.       filespanel_f, filespanel_b,
  337.       filesheader_f, filesheader_b         :    byte;
  338.       filesfooter_f, filesfooter_b         :    byte;
  339.     var
  340.       filesshowscan                       : boolean;
  341.     var
  342.       filesx3, filesy3, filesx4, filesy4,
  343.       filespopup_f, filespopup_b,
  344.       filestagnocsr_f, filestagnocsr_b,
  345.       filestagcsr_f, filestagcsr_b,
  346.       filesscrollbar_f, filesscrollbar_b,
  347.       filescuractbar_f, filescuractbar_b   :    byte
  348.   );
  349.  
  350.   begin
  351.     filesfullwide := fullwide; filesshowpath := showpath;
  352.     bt := boxtype;
  353.     filesx1 := x1; filesy1 := y1; filesx2 := x2; filesy2 := y2;
  354.     filespanel_f := panel_f; filespanel_b := panel_b;
  355.     filesheader_f := header_f; filesheader_b := header_b;
  356.     filesfooter_f := footer_f; filesfooter_b := footer_b;
  357.     filesshowscan := showscan;
  358.     filesx3 := x3; filesy3 := y3; filesx4 := x4; filesy4 := y4;
  359.     filespopup_f := popup_f; filespopup_b := popup_b;
  360.     filestagnocsr_f := tagnocsr_f; filestagnocsr_b := tagnocsr_b;
  361.     filestagcsr_f := tagcsr_f; filestagcsr_b := tagcsr_b;
  362.     filesscrollbar_f := scrollbar_f; filesscrollbar_b := scrollbar_b;
  363.     filescuractbar_f := curactbar_f; filescuractbar_b := curactbar_b;
  364.   end;
  365.  
  366.  
  367.  
  368.   procedure filespanelobj.draw;
  369.   const
  370.     onlyshow : word = $0000;
  371.  
  372.   var
  373.     dkey :   word;
  374.     ds   : string;
  375.  
  376.   begin
  377.     newfiloff := true;
  378.     ds := walk_files_(@onlyshow, 1, showscan, dkey);
  379.   end;
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.   procedure filespanelobj.readfiles(_doscurpath: pathstr);
  387.   type
  388.     filterenum = (r_o, hid, sys, vol, dir, arc, bit6, bit7);
  389.     fs = set of filterenum;
  390.  
  391.   var
  392.     filter: fs;
  393.  
  394.   begin
  395.     filenumber := 0; tagbytes := 0; sum := 0; tagnum := 0;
  396.     filter := []; { construct filter }
  397.     if show_r_o then filter := filter + [r_o];
  398.     if show_hid then filter := filter + [hid];
  399.     if show_sys then filter := filter + [sys];
  400.     if show_vol then filter := filter + [vol];
  401.     if show_dir then filter := filter + [dir];
  402.     if show_arc then filter := filter + [arc];
  403.     if _doscurpath[length(_doscurpath)] = '\' then findfirst('\*.*', anyfile, atri) else
  404.       findfirst(_doscurpath + '\*.*', anyfile, atri);
  405.     findfirst('*.*', anyfile, atri);
  406.  
  407.     while doserror = 0 do begin
  408.       if (atri.name<>'.') and (fs(atri.attr) <= filter) and
  409.          (show_non or (atri.attr<>0)) then begin
  410.         with filarray^[filenumber] do begin
  411.          {fill := atri.fill;}
  412.           attr := atri.attr;
  413.           time := atri.time;
  414.           size := atri.size;
  415.           name := atri.name; { need upper? }
  416.           tagged :=   false; {gets through...}
  417.           inc(sum, atri.size);
  418.         end; inc(filenumber);
  419.       end; findnext(atri)
  420.     end; dec(filenumber);
  421.   end; { readfiles }
  422.  
  423.  
  424.  
  425.  
  426.   procedure filespanelobj.startsorting;
  427.   begin
  428.     if sort<>0 then case sort of
  429.       1: __qsortsrt(
  430.         @filarray^, filenumber+1, sizeof(searchrecord), @sortfactorname
  431.       );
  432.       2: __qsortsrt(
  433.         @filarray^, filenumber+1, sizeof(searchrecord), @sortfactorext
  434.       );
  435.       3: __qsortsrt(
  436.         @filarray^, filenumber+1, sizeof(searchrecord), @sortfactortime
  437.       );
  438.       4: __qsortsrt(
  439.         @filarray^, filenumber+1, sizeof(searchrecord), @sortfactorsize
  440.       );
  441.       5: if filenumber<maxforsort then
  442.          __qsortsrt(
  443.            @filarray^, filenumber+1, sizeof(searchrecord), @sortfactorname
  444.          );
  445.       6: if filenumber<maxforsort then
  446.          __qsortsrt(
  447.            @filarray^, filenumber+1, sizeof(searchrecord), @sortfactorext
  448.          );
  449.       7: if filenumber<maxforsort then
  450.          __qsortsrt(
  451.            @filarray^, filenumber+1, sizeof(searchrecord), @sortfactortime
  452.          );
  453.       8: if filenumber<maxforsort then
  454.          __qsortsrt(
  455.            @filarray^, filenumber+1, sizeof(searchrecord), @sortfactorsize
  456.          );
  457.       else ; { no sorting }
  458.     end; { case }
  459.   end; { startsorting }
  460.  
  461.  
  462.  
  463.  
  464.   function filespanelobj.__tm2ststr(hour, minute: word): str6;
  465.   var st: string;
  466.   begin
  467.     st := __juststr(__num(hour), ' ', 2, _right_just_str) + ':' +
  468.           __juststr(__num(minute), '0', 2, _right_just_str);
  469.     __tm2ststr := st;
  470.   end; { __tm2ststr }
  471.  
  472.  
  473.  
  474.   function filespanelobj.__xfrstr(sourc: string; xfrin, xfrout: char): string;
  475.   var i: byte;
  476.   begin
  477.     for i := 1 to length(sourc) do if sourc[i]=xfrin then sourc[i] := xfrout;
  478.     __xfrstr := sourc;
  479.   end; { __xfrstr }
  480.  
  481.  
  482.  
  483.  
  484.   function filespanelobj.chnam(s: searchrecord; plain,bar: boolean): string;
  485.   var
  486.     siz: string[9];
  487.     st: string;
  488.     t : datetime;
  489.  
  490.   begin
  491.     if ((s.attr and directory)>0) and (copy(s.name, 1, 1)<>'.') and
  492.         (pos('.', s.name)<>0) then
  493.       st:=__juststr(copy(s.name,1, pos('.', s.name)-1),' ',9,_left_just_str) +
  494.         __juststr(copy(s.name,pos('.', s.name)+1, 3),' ',3,_left_just_str) else
  495.       if ((s.attr and directory)>0) or (pos('.', s.name)=0) then
  496.         st := __juststr(s.name, ' ', 12, _left_just_str) else
  497.         if ((s.attr and directory)>0) then
  498.           st := __juststr(s.name, ' ', 12, _left_just_str) else
  499.           if ((s.attr and volumeid)>0) then
  500.             st := __juststr(copy(s.name, 1, pos('.', s.name)-1) +
  501.                             copy(s.name, pos('.', s.name)+1, 3), ' ', 12,
  502.                             _left_just_str) else
  503.             if not bar then st := __juststr(copy(s.name, 1, pos('.',s.name)-1),
  504.               ' ',8,_left_just_str)+' '+__juststr(copy(s.name,pos('.', s.name)+
  505.               1, 3), ' ', 3,_left_just_str) else
  506.               st := __juststr(__cvtstr(s.name, _to_lowcase_str), ' ', 12,
  507.                 _left_just_str);
  508.     if ((s.attr and directory)>0) then begin
  509.       { keuze voor . notatie of niet, maar dan ook in tree }
  510.       st := __juststr(__cvtstr(st, _to_upcase_str + _rem_white_str),
  511.         ' ', 12, _left_just_str
  512.       );
  513.     end else st := __cvtstr(st, _to_lowcase_str);
  514.     if not bar then begin
  515.       if ((s.attr and readonly)>0) then st[1] := upcase(st[1]);
  516.       if ((s.attr and sysfile )>0) then st[2] := upcase(st[2]);
  517.       if ((s.attr and hidden  )>0) then st[9] := '▒';
  518.     end;
  519.  
  520.     if not(plain) then begin
  521.       unpacktime(s.time, t);
  522.       if ((s.attr and directory)>0) and (s.name='..') then
  523.         siz := chr(16)+'UP--DIR'+chr(17) else
  524.       if ((s.attr and directory)>0) and (s.name<>'..') then
  525.         siz := chr(16)+'SUB-DIR'+chr(17) else
  526.       if ((s.attr and volumeid)>0) then
  527.         siz := chr(16)+'VOLUMID'+chr(17) else
  528.       if s.size=0 then siz := chr(16)+'NULFILE'+chr(17) else
  529.         if s.size<99999999 then
  530.           siz := __juststr(__pntstr(s.size), ' ', 9, _right_just_str) else
  531.             siz := __juststr(__num(s.size), ' ', 9, _right_just_str);
  532.       st := st + '│' + siz + '│' +
  533.       __juststr(
  534.         __dt2ststr(t.year, t.month, t.day, _euro_dt_str), ' ', 8, _left_just_str
  535.       ) + '│ ' +
  536.       __tm2ststr(t.hour, t.min);
  537.     end; chnam := st;
  538.   end; { chnam }
  539.  
  540.  
  541.  
  542.  
  543.  
  544.   function filespanelobj.anytagged(var nr: word): boolean;
  545.   var
  546.     i,n : word;
  547.  
  548.   begin
  549.     n := 0; sum := 0;
  550.     for i := 0 to filenumber do begin
  551.       inc(sum, filarray^[i].size);
  552.       if filarray^[i].tagged then inc(n)
  553.     end; nr := n; anytagged := (n>0)
  554.   end;
  555.  
  556.  
  557.  
  558.  
  559.  
  560.   procedure filespanelobj.retagfiles(option: readwrite; files: filtagarptr);
  561.   var
  562.     f : file of boolean;
  563.     i :            word;
  564.  
  565.   begin
  566.     i := 0;
  567.     case option of
  568.       writefile : begin
  569.         assign(f, shellfile); rewrite(f);
  570.         for i := 0 to filenumber do write(f, filarray^[i].tagged);
  571.         close(f);
  572.       end;
  573.  
  574.       readfile : begin
  575.         i := 0; assign(f, shellfile); reset(f);
  576.         while not(eof(f) or (i>511)) do begin
  577.            read(f, files^[i]); filarray^[i].tagged := files^[i]; inc(i)
  578.         end;
  579.         close(f);
  580.       end;
  581.  
  582.       writeconfig : begin
  583.         for i := 0 to 511 do files^[i] := false;
  584.         for i := 0 to filenumber do files^[i] := filarray^[i].tagged;
  585.       end;
  586.  
  587.       readconfig : begin
  588.         for i := 0 to 511 do filarray^[i].tagged := false;
  589.         for i := 0 to filenumber do filarray^[i].tagged := files^[i];
  590.       end;
  591.     end; { option }
  592.   end;
  593.  
  594.  
  595.  
  596.  
  597.  
  598.   {@}
  599.   function filespanelobj.walk_files_(
  600.     returnkeys: pointer; nroffileskeys: byte;
  601.     var pl: boolean; var retkey: word
  602.   ): string;
  603.  
  604.   type
  605.     arr = array[1..128] of word;
  606.     ar  = ^arr;
  607.  
  608.   var
  609.     i, j, page, dd,
  610.     key            :       word;
  611.     retkeypressed  :    boolean;
  612.     statusbits     :    longint;
  613.     statusflags    : _keystatus;
  614.  
  615.  
  616.  
  617.     {sub}procedure filesscreen(
  618.       x1, y1, x2, y2, bx,
  619.       fg, bg, head_f, head_b,
  620.       tagnocsr_f, tagnocsr_b: byte;
  621.       first: word; pl: boolean;
  622.       filesonly: boolean;
  623.       _doscurpath: string);
  624.  
  625.     var
  626.       i, xoff: word;
  627.  
  628.     begin
  629.       {_hidemouse := false; if __hidemou(true)=_ok_mou then ;}
  630.       if pl then begin
  631.         if not(filesonly) then begin
  632.           __clrscn(x1, y1, x2, y2, fg, bg, ' ');
  633.           __boxscn(x1, y1, x2, y2, bx, fg, bg);
  634.           if bx = bt_double then __write(
  635.             x1, y2-2, panel_f, panel_b, '╟'+__rep(x2-x1-1, '─')+'╢'
  636.           ) else __write(x1, y2-2, fg, bg, '├' + __rep(x2-x1-1, '─') +'┤');
  637.           if bx = bt_double then __write(x1+13, y1, fg, bg,  '╤') else
  638.             __write(x1+13, y1, fg, bg,  '┬');
  639.           __write(x1+13, y2-2, fg, bg, '┴');
  640.           if fullwide then begin
  641.             if bx = bt_double then __write(x1+26, y1, fg, bg, '╤') else
  642.               __write(x1+26, y1, fg, bg, '┬');
  643.             __vert(x1+26, y1+1, fg, bg, __rep(y2-y1-3, '│'));
  644.             __write(x1+26, y2-2, fg, bg, '┴');
  645.           end;
  646.  
  647.           __vert(x1+13, y1+1, fg, bg, __rep(y2-y1-3, '│'));
  648.           __write(x1+5, y1+1, head_f, head_b,  'Name');
  649.           __write(x1+18, y1+1, head_f, head_b, 'Name');
  650.           if fullwide then __write(x1+31, y1+1, head_f, head_b, 'Name');
  651.  
  652.           __betwscn(x1, x2, y1, bg, fg, ' ' + 
  653.             __slashfil(
  654.               __packfil(
  655.                 __cvtstr(
  656.                   __xlatestr(__backrem(_doscurpath), '.', ' '),
  657.                   _rem_white_str
  658.                 ),
  659.                 x2-x1-1-2
  660.               )
  661.             ) +
  662.             ' '
  663.           );
  664.  
  665.         end;
  666.         { display all those files in filarray }
  667.         i := 0; xoff := 0;
  668.         while ((i < pc*(y2-y1-1-2-1)) and (i<=filenumber)) do begin
  669.           if not filarray^[i+first].tagged then
  670.             __write(x1+1+xoff, i+y1+2-((xoff div 13)*(y2-y1-1-2-1)),
  671.               fg, bg, chnam(filarray^[i+first], pl, false)) else
  672.             __write(x1+1+xoff, i+y1+2-((xoff div 13)*(y2-y1-1-2-1)),
  673.               tagnocsr_f,tagnocsr_b,chnam(filarray^[i+first],pl, false));
  674.           inc(i);
  675.           if (i >= (y2-y1-1-2-1)) and (i <= 2*(y2-y1-1-2-1)-1) then xoff := 13
  676.             else if (i >= 2*(y2-y1-1-2-1)) and fullwide then xoff := 26;
  677.         end;
  678.       end else begin { attibutes are wanted }
  679.         if not(filesonly) then begin
  680.           __clrscn(x1,y1,x2,y2,fg,bg, ' ');
  681.           __boxscn(x1, y1, x2, y2, bx, fg, bg);
  682.           if bx = bt_double then
  683.             __write(x1+00, y2-2, fg, bg, '╟' + __rep(x2-x1-1, '─')+'╢') else
  684.             __write(x1+00, y2-2, fg, bg, '├' + __rep(x2-x1-1, '─')+'┤');
  685.           if bx = bt_double then
  686.             __write(x1+13, y1,   fg, bg, '╤') else
  687.             __write(x1+13, y1,   fg, bg, '┬');
  688.           __write(x1+13, y2-2, fg, bg, '┴');
  689.           if bx = bt_double then
  690.             __write(x1+23, y1-0, fg, bg, '╤') else
  691.             __write(x1+23, y1-0, fg, bg, '┬');
  692.           __write(x1+23, y2-2, fg, bg, '┴');
  693.           __vert(x1+13, y1+1, fg, bg, __rep(y2-y1-3, '│'));
  694.           __vert(x1+23, y1+1, fg, bg, __rep(y2-y1-3, '│'));
  695.  
  696.           __betwscn(x1, x2, y1, bg, fg, ' ' + 
  697.             __slashfil(
  698.               __packfil(
  699.                 __cvtstr(
  700.                   __xlatestr(__backrem(_doscurpath), '.', ' '),
  701.                   _rem_white_str
  702.                 ),
  703.                 x2-x1-1-2
  704.               )
  705.             ) +
  706.             ' '
  707.           );
  708.  
  709.           __write(x1+05, y1+1, head_f, head_b, 'Name');
  710.           __write(x1+17, y1+1, head_f, head_b, 'Size');
  711.           if fullwide then begin
  712.             if bx = bt_double then
  713.               __write(x1+32, y1,   fg, bg, '╤') else
  714.               __write(x1+32, y1,   fg, bg, '┬');
  715.             __write(x1+32, y2-2, fg, bg, '┴');
  716.             __vert(x1+32, y1+1, fg, bg, __rep(y2-y1-3, '│'));
  717.             __write(x1+26, y1+1, head_f, head_b, 'Date');
  718.             __write(x1+34, y1+1, head_f, head_b, 'Time');
  719.           end;
  720.  
  721.         end; i := 0;
  722.         while (i < (y2-y1-1-2-1)) and (i<=filenumber) do begin
  723.           if not filarray^[i+first].tagged then
  724.             __write(x1+1,y1+2+i,fg,bg,
  725.               copy(chnam(filarray^[i+first], pl, false), 1, scnlen)) else
  726.             __write(x1+1,y1+2+i,tagnocsr_f,tagnocsr_b,
  727.               copy(chnam(filarray^[i+first], pl, false), 1, scnlen));
  728.           inc(i);
  729.         end;
  730.       end;
  731.       {_hidemouse := __equipmou=_ok_mou; if __hidemou(false)=_ok_mou then ;}
  732.     end; { filesscreen }
  733.  
  734.  
  735.  
  736.  
  737.     {sub}procedure tagbar(aa,fg,bg: word);
  738.     begin
  739.       if pl then __attrib(
  740.         x1+1+13*(aa div page),       y1+1+01+(aa mod page),
  741.         x1+1+13*(aa div page) + 11,  y1+1+01+(aa mod page),
  742.         fg, bg
  743.       ) else __attrib(x1+1, y1+2+aa, x2-1, y1+2+aa, fg, bg);
  744.     end; { tagbar }
  745.  
  746.  
  747.  
  748.     procedure oldtags(
  749.       var a1, b1: byte; fg, bg, tag_f, tag_b: byte; removeoldtag: boolean
  750.     );
  751.     begin
  752.       if removeoldtag then begin
  753.         if filarray^[a1+b1].tagged then tagbar(a1, tag_f, tag_b) else
  754.           tagbar(a1, fg, bg)
  755.       end;
  756.       a1 := filescursor; b1 := filoff;
  757.     end;
  758.  
  759.  
  760.  
  761.  
  762.     {sub}procedure last1;
  763.     begin
  764.       if filoff <= filenumber - page then newfiloff := true;
  765.       if filenumber >= page then filoff := filenumber - page + 1 else
  766.         filoff := 0;
  767.       if filenumber < page then filescursor := filenumber else
  768.         filescursor := page - 1
  769.     end; { last1 }
  770.  
  771.  
  772.     {sub}procedure last3;
  773.     begin
  774.       if filoff <= filenumber - pc * page then newfiloff := true;
  775.       if filenumber >= pc * page then begin
  776.         filoff := filenumber - pc * page + 1;
  777.         filescursor := pc * page - 1
  778.       end else filescursor := filenumber;
  779.     end; { last3 }
  780.  
  781.  
  782.     {sub}procedure swaptag(var item: searchrecord);
  783.     begin
  784.       if not(
  785.         ((item.attr and directory)>0) or ((item.attr and volumeid)>0)
  786.       ) then begin
  787.         item.tagged := not item.tagged;
  788.         if item.tagged then begin
  789.           inc(tagnum); inc(tagbytes, item.size)
  790.         end else begin
  791.           dec(tagnum); dec(tagbytes, item.size)
  792.         end;
  793.       end;
  794.     end;
  795.  
  796.  
  797.     {sub}procedure swaptagged;
  798.     var i: word;
  799.     begin
  800.       for i := 0 to filenumber do swaptag(filarray^[i]); newfiloff := true;
  801.     end;
  802.  
  803.  
  804.  
  805.  
  806.     {sub}procedure tagfiles(tag: boolean);
  807.     var
  808.       errorcode    :     word;
  809.       fieldctrl2   : _editctrl;
  810.       sstt         :   string;
  811.       nam1, nam2   :  namestr;
  812.       ext1, ext2   :   extstr;
  813.       j,i          :  integer;
  814.       check,
  815.       anymatch, ok :  boolean;
  816.       tmpscn       : _scnimageptr;
  817.  
  818.     begin
  819.       tagbar(filescursor, curactbar_f, curactbar_b);
  820.       new(tmpscn); __savscn(tmpscn); anymatch := false;
  821.       __bandwin(true, 33, 9, 48, 10, popup_f, popup_b, sh_default, 2);
  822.       if tag then sstt := ' Select ' else sstt := ' Unselect ';
  823.       __betwscn(34, 48, 8, popup_f, popup_b, sstt);
  824.       __betwscn(34, 48, 9, popup_f, popup_b, ' Match: ');
  825.       fillchar(fieldctrl2, sizeof(fieldctrl2), 0);
  826.       with fieldctrl2 do begin
  827.         _viewx1   := 35;
  828.         _viewx2   := 47;
  829.         _viewy1   := 10;
  830.         _vscnfore := popup_f;
  831.         _vscnback := popup_b;
  832.         _vscncols := 12;
  833.         {_editmode := _leftjust_edt + _to_upcase_str + _mergemask_edt;
  834.         _mask     := '';
  835.         }
  836.       end;
  837.       
  838.       if __editline(wild, fieldctrl2) then begin
  839.         __resscn(tmpscn);
  840.         newfiloff := true;
  841.         for i := 0 to filenumber do begin
  842.           if (
  843.             (tag and not(filarray^[i].tagged)) or
  844.             (not(tag) and filarray^[i].tagged)
  845.           ) and not (
  846.             ((filarray^[i].attr and directory) >0) or
  847.             ((filarray^[i].attr and volumeid)  >0)
  848.           ) then begin
  849.             ok := true; __parsefil(wild, nam1, ext1);
  850.             __parsefil(filarray^[i].name, nam2, ext2);
  851.             nam1 := __up(nam1); nam2 := __up(nam2);
  852.             ext1 := __up(ext1); ext2 := __up(ext2);
  853.             j := 1;
  854.             while (j <= length(nam1)) and ok do begin
  855.               if nam1[j] = '*' then j := 9 else
  856.                 if not(nam1[j] in ['?', nam2[j]]) then ok := false;
  857.               inc(j);
  858.             end; { while1 }
  859.             if (
  860.               ok and (j = length(nam1)+1) and (length(nam2)>length(nam1)) 
  861.             ) then ok := false; 
  862.             { if j <> length(nam1)+1 then mismatch or a * found }
  863.  
  864.             j := 1;
  865.             while (j <= length(ext1)) and ok do begin
  866.               if ext1[j] = '*' then j := 4 else
  867.                 if not(ext1[j] in ['?', ext2[j]]) then ok := false;
  868.               inc(j);
  869.             end; { while2 }
  870.             if (
  871.               ok and (j=length(ext1)+1) and (length(ext2) > length(ext1))
  872.             ) then ok := false;
  873.             { if j <> length(ext1)+1 then mismatch or a * found }
  874.  
  875.             if not(filarray^[i].tagged) and tag and ok then begin
  876.               filarray^[i].tagged := true;
  877.               inc(tagnum); inc(tagbytes, filarray^[i].size)
  878.             end;
  879.             if filarray^[i].tagged and not(tag) and ok then begin
  880.               filarray^[i].tagged := false;
  881.               dec(tagnum); dec(tagbytes, filarray^[i].size)
  882.             end;
  883.             anymatch := anymatch or ok;
  884.           end; { something may happen }
  885.         end; { while, check all the files }
  886.  
  887.         if not anymatch then begin
  888.           __savscn(tmpscn);
  889.           __bandwin(true, 24, 8, 57, 11, popup_f, popup_b, sh_default, 2);
  890.           if anytagged(dd) then
  891.             __betwscn(26, 55, 09, popup_f, popup_b,
  892.               'No extra matches found with:') else
  893.             __betwscn(26, 55, 09, popup_f, popup_b,
  894.               'No match found using filter:');
  895.           __betwscn(26, 55, 10, popup_f, popup_b, wild);
  896.           if tag then sstt := ' Select ' else sstt := ' Unselect ';
  897.           __betwscn(26, 55, 08, popup_f, popup_b, sstt);
  898.           delay(3000); __resscn(tmpscn);
  899.         end;
  900.  
  901.       end; { user not escaped }
  902.       __resscn(tmpscn); dispose(tmpscn);
  903.     end; { tagfiles }
  904.  
  905.  
  906.  
  907.  
  908.  
  909.     function __kpntstr(l: longint; b: byte): string;
  910.     begin
  911.       if b=3 then __kpntstr := __pntstr(l) else
  912.         if ((l div 1024) div 1024) > 0 then
  913.           __kpntstr := __num((l div 1024) div 1024) + 'M' else
  914.             __kpntstr := __num(__max(l, 1024) div 1024) + 'K';
  915.     end;
  916.  
  917.  
  918.  
  919.   begin
  920.     retkeypressed := false; page := y2 - y1 - 1 - 2 - 1;
  921.     if fullwide then pc := 3 else pc := 2;
  922.     scnlen := x2-x1-1;
  923.  
  924.     if word((ar(returnkeys))^[1]) = $0000 then begin
  925.       filesscreen(x1, y1, x2, y2, boxtype,
  926.         panel_f, panel_b, header_f, header_b,
  927.         tagnocsr_f, tagnocsr_b, 0, pl, false, _doscurpath);
  928.       if pl then __write(x1+1,y2-1,footer_f,footer_b, copy(
  929.         __xfrstr(chnam(filarray^[filoff+filescursor], false, true), '│', ' '),
  930.           1, scnlen)
  931.       );
  932.       { !!! checken voor klok }
  933.       __betwscn(x1, x2, y1, panel_f, panel_b, ' ' + 
  934.         __slashfil(
  935.           __packfil(
  936.             __cvtstr(
  937.               __xlatestr(__backrem(_doscurpath), '.', ' '),
  938.               _rem_white_str
  939.             ),
  940.             x2-x1-1-2
  941.           )
  942.         ) +
  943.         ' '
  944.       );
  945.       tagbar(filescursor, curactbar_f, curactbar_b); exit
  946.       { just getting a nice picture and leave }
  947.     end;
  948.  
  949.     __betwscn(x1, x2, y1, panel_b, panel_f, ' ' + 
  950.       __slashfil(
  951.         __packfil(
  952.           __cvtstr(
  953.             __xlatestr(__backrem(_doscurpath), '.', ' '),
  954.             _rem_white_str
  955.           ),
  956.           x2-x1-1-2
  957.         )
  958.       ) +
  959.       ' '
  960.     );
  961.  
  962.     repeat
  963.       if newfiloff then begin
  964.         newfiloff := false;
  965.         filesscreen(x1, y1, x2, y2, boxtype,
  966.           panel_f, panel_b, header_f, header_b,
  967.           tagnocsr_f, tagnocsr_b, filoff, pl, false, _doscurpath
  968.         );
  969.       end;
  970.  
  971.       if pl then begin { more rows, no attrs }
  972.  
  973.         if fullwide then pc := 3 else pc := 2;
  974.         if anytagged(dd) then __write(x1+1,y2-1, footer_f, footer_b,
  975.           __juststr(copy(
  976.           'F ' + __num(filenumber)+' ('+ __kpntstr(sum,pc)      + ')' + '  ' +
  977.           'T ' + __num(tagnum) +' ('+ __kpntstr(tagbytes,pc) + ')',1,x2-x1-1),
  978.           ' ', x2-x1-1, _left_just_str)
  979.         ) else __write(x1+1,y2-1, footer_f, footer_b, copy(
  980.           __xfrstr(chnam(filarray^[filoff+filescursor], false, true), '│',' '),
  981.             1, scnlen)
  982.         );
  983.  
  984.  
  985.         oldtags(oldfil, oldoff, panel_f, panel_b, tagnocsr_f, tagnocsr_b,true);
  986.         if filarray^[filoff+filescursor].tagged then
  987.           tagbar(filescursor, tagcsr_f, tagcsr_b) else
  988.           tagbar(filescursor, scrollbar_f, scrollbar_b);
  989.  
  990.         if retkey=$0000 then key := __retkey else key := retkey;
  991.         statusbits := __statkey(statusflags); retkey := $0000;
  992.         oldtags(oldfil,oldoff, panel_f, panel_b, tagnocsr_f, tagnocsr_b,false);
  993.  
  994.  
  995.         case key of
  996.  
  997.           _up, _padup: begin
  998.             if statusflags._scrollstate then begin
  999.               if statusflags._capsstate then begin
  1000.                 if (y1>1) then begin
  1001.                   __copyscn(x1,y1,x2,y2,x1,y1-1);
  1002.                   {__partscn(scn4, x1, y2, x2, y2, true);}
  1003.                   dec(y1); dec(y2);
  1004.                 end else smallbeep;
  1005.               end else begin
  1006.                 if y2 > y1+6 then begin
  1007.                   dec(y2); newfiloff := true; dec(page);
  1008.                   filoff := 0; filescursor := 0;
  1009.                   {__partscn(scn4,x1,y2+1,x2,y2+2, true);}
  1010.                 end else smallbeep;
  1011.               end;
  1012.             end else begin
  1013.               if filescursor>0 then dec(filescursor) else
  1014.               if filoff>0 then begin
  1015.   {              if not filarray^[oldoff+oldfil].tagged then
  1016.                   __attrib(x1+1, y1+2+1, x1+12, y1+2+1, panel_f, panel_b) else
  1017.                   __attrib(x1+1, y1+2+1, x1+12, y1+2+1, tagnocsr_f, tagnocsr_b);
  1018.    }
  1019.                 dec(filoff); inc(oldfil);
  1020.                 __flushkey;
  1021.                 if fullwide then begin
  1022.                                     { y1+2 since last must scroll off        }
  1023.                   __copyscn(x1+27, y1+2, x1+38, y2-1-3, x1+27, y1+3);
  1024.                                     { get last of 2nd column as first of 3rd }
  1025.                   __copyscn(x1+14, y2-1-2, x1+25, y2-1-2, x1+27, y1+2);
  1026.                 end;
  1027.                                     { y1+2 since last one must scroll off    }
  1028.                 __copyscn(x1+14, y1+2, x1+25, y2-1-3, x1+14,  y1+3);
  1029.                                     { get last of 1st column as first of 2nd }
  1030.                 __copyscn(x1+01, y2-1-2, x1+12, y2-1-2, x1+14, y1+2);
  1031.                                     { y1+3 since first must scroll off       }
  1032.                 __copyscn(x1+01, y1+2, x1+12, y2-1-3, x1+1, y1+3);
  1033.                                     { write new filename as last item on scn }
  1034.                 __write(x1+01, y1+2, panel_f, panel_b,
  1035.                   chnam(filarray^[filoff], pl, false)
  1036.                 );
  1037.               end;
  1038.             end; { status }
  1039.           end;
  1040.  
  1041.  
  1042.           _down, _paddown, _c_v, _ins, _padins: begin
  1043.             case key of
  1044.               _ins, _padins, _c_v: begin
  1045.                 swaptag(filarray^[filoff+filescursor]);
  1046.                 if filarray^[filoff+filescursor].tagged then
  1047.                   tagbar(filescursor, tagnocsr_f, tagnocsr_b) else
  1048.                   tagbar(filescursor, panel_f, panel_b);
  1049.               end; else ;
  1050.             end;
  1051.             if statusflags._scrollstate then begin
  1052.               if statusflags._capsstate then begin
  1053.                 if (y2<_currows-2) then begin
  1054.                   __copyscn(x1,y1,x2,y2,x1,y1+1);
  1055.                   {__partscn(scn4, x1, y1, x2, y1, true);}
  1056.                   inc(y1); inc(y2);
  1057.                 end else smallbeep;
  1058.               end else begin
  1059.                 if y2 < _currows - 2 then begin
  1060.                   inc(y2); newfiloff := true; inc(page);
  1061.                   filoff := 0; filescursor := 0;
  1062.                 end{ else smallbeep;}
  1063.               end;
  1064.             end else begin
  1065.               if (filescursor < pc*page-1) and
  1066.                  (filescursor < filenumber) then inc(filescursor) else
  1067.               if filoff+pc*page <= filenumber then begin
  1068.   {
  1069.                 if not filarray^[oldoff+oldfil].tagged then
  1070.                   __attrib(x1+27-(3-pc)*13, y1+2+1,
  1071.                            x1+38-(3-pc)*13, y1+2+1, panel_f, panel_b) else
  1072.                   __attrib(x1+27-(3-pc)*13, y1+2+1,
  1073.                            x1+38-(3-pc)*13, y1+2+1, tagnocsr_f, tagnocsr_b);
  1074.   }
  1075.                 __flushkey; inc(filoff); dec(oldfil);
  1076.                                     { y1+3 since first must scroll off       }
  1077.                 __copyscn(x1+01, y1+3, x1+12, y2-1-2, x1+1, y1+2);
  1078.                                     { get first of 2nd column as last of 1st }
  1079.                 __copyscn(x1+14, y1+2, x1+25, y1+2, x1+1, y2-1-2);
  1080.                                     { y1+3 since first must scroll off       }
  1081.                 __copyscn(x1+14, y1+3, x1+25, y2-1-2, x1+14,  y1+2);
  1082.                                     { get first of 3nd column as last of 2nd }
  1083.                 if fullwide then begin
  1084.                   __copyscn(x1+27, y1+2, x1+38, y1+2, x1+14, y2-1-2);
  1085.                                     { y1+3 since first must scroll off       }
  1086.                   __copyscn(x1+27, y1+3, x1+38, y2-1-2, x1+27, y1+2);
  1087.                                     { write new filename as last item on scn }
  1088.                 end;
  1089.                 if fullwide then __write(x1+27, y2-1-2, panel_f, panel_b,
  1090.                   chnam(filarray^[filoff + 3*page-1], pl, false)) else
  1091.                     __write(x1+14, y2-1-2, panel_f, panel_b,
  1092.                       chnam(filarray^[filoff + 2*page-1], pl, false));
  1093.               end;
  1094.             end; { status }
  1095.           end;
  1096.  
  1097.  
  1098.           _left, _padleft: begin
  1099.             if statusflags._scrollstate then begin
  1100.               if statusflags._capsstate then begin
  1101.                 if (x1>1) then begin
  1102.                   __copyscn(x1,y1,x2,y2,x1-1,y1);
  1103.                   {__partscn(scn4, x2, y1, x2, y2, true);}
  1104.                   dec(x1); dec(x2);
  1105.                 end{ else smallbeep;}
  1106.               end else begin
  1107.                 if not fullwide then begin
  1108.                   fullwide := true; {smallbeep;}
  1109.                   if x1 > 13 then dec(x1, 13) else begin
  1110.                     x1 := 1; x2 := 40
  1111.                   end;
  1112.                   pc := 3; newfiloff := true; filoff := 0; filescursor := 0;
  1113.                   scnlen := x2-x1-1;
  1114.                 end else smallbeep;
  1115.               end;
  1116.             end else begin
  1117.               if (filescursor div page) > 0 then
  1118.               dec(filescursor, page) else begin
  1119.                 if filoff<page then begin
  1120.                   if filescursor>0 then newfiloff := true;
  1121.                   filoff := 0; filescursor := 0;
  1122.                 end else begin
  1123.                   __flushkey; dec(filoff,page); inc(oldfil, page);
  1124.                 if not filarray^[oldoff+oldfil].tagged then
  1125.                   __attrib(x1+1,  y1+2+(filescursor mod page),
  1126.                     x1+12, y1+2+(filescursor mod page), panel_f, panel_b) else
  1127.                   __attrib(x1+1,  y1+2+(filescursor mod page),
  1128.                            x1+12, y1+2+(filescursor mod page),
  1129.                     tagnocsr_f, tagnocsr_b
  1130.                   );
  1131.                   if fullwide then
  1132.                     __copyscn(x1+14, y1+2, x1+25, y2-1-2, x1+27, y1+2);
  1133.                   __copyscn(x1+01, y1+2, x1+12, y2-1-2, x1+14, y1+2);
  1134.                   for i := 0 to page-1 do
  1135.                     if not filarray^[filoff].tagged then
  1136.                       __write(x1+1, y1+2+i, panel_f, panel_b,
  1137.                         chnam(filarray^[i + filoff], pl, false)) else
  1138.                       __write(x1+1, y1+2+i, tagnocsr_f, tagnocsr_b,
  1139.                         chnam(filarray^[i + filoff], pl, false));
  1140.                 end;
  1141.               end;
  1142.             end;
  1143.           end;
  1144.  
  1145.  
  1146.           _right, _padright: begin
  1147.             if statusflags._scrollstate then begin
  1148.               if statusflags._capsstate then begin
  1149.                 if (x2<_curcolumns) then begin
  1150.                   __copyscn(x1,y1,x2,y2,x1+1,y1);
  1151.                   {__partscn(scn4, x1, y1, x1, y2, true);}
  1152.                   inc(x1); inc(x2);
  1153.                 end else smallbeep;
  1154.               end else begin
  1155.                 if fullwide then begin
  1156.                   {__partscn(scn4,x1,y1,x1+13,y2,true);}
  1157.                   fullwide := false; {smallbeep;} inc(x1, 13);
  1158.                   pc := 2; newfiloff := true; filoff := 0; filescursor := 0;
  1159.                   scnlen := x2-x1-1;
  1160.                 end else smallbeep;
  1161.               end;
  1162.             end else begin
  1163.               if (filescursor div page) < pc-1 then
  1164.               inc(filescursor, page) else begin
  1165.                 if filoff + (pc+1)*page < filenumber then begin
  1166.                   inc(filoff, page); __flushkey; dec(oldfil, page);
  1167.                   if not filarray^[oldoff+oldfil].tagged then
  1168.                     __attrib(x1+27-(3-pc)*13, y1+2+(filescursor mod page),
  1169.                       x1+38-(3-pc)*13, y1+2+(filescursor mod page),
  1170.                       panel_f, panel_b
  1171.                     ) else __attrib(x1+27-(3-pc)*13,
  1172.                       y1+2+(filescursor mod page),
  1173.                       x1+38-(3-pc)*13, y1+2+(filescursor mod page),
  1174.                       tagnocsr_f, tagnocsr_b
  1175.                     );
  1176.                   __copyscn(x1+14, y1+2, x1+25, y2-1-2, x1+1, y1+2);
  1177.                   if fullwide then
  1178.                     __copyscn(x1+27, y1+2, x1+38, y2-1-2, x1+14, y1+2);
  1179.                   i := 0;
  1180.                   while (
  1181.                     (i<page) and (i+filoff+(pc-1)*page<filenumber)
  1182.                   ) do begin
  1183.                     if not filarray^[i + filoff + (pc-1)*page].tagged then
  1184.                       __write(x1+27-(3-pc)*13, y1+1+1+i, panel_f, panel_b,
  1185.                         chnam(filarray^[i + filoff + (pc-1)*page],pl,false)
  1186.                       ) else __write(
  1187.                         x1+27-(3-pc)*13, y1+1+1+i, tagnocsr_f, tagnocsr_b,
  1188.                         chnam(filarray^[i + filoff + (pc-1)*page], pl, false)
  1189.                       );
  1190.                     inc(i);
  1191.                   end;
  1192.                 end else last3;
  1193.               end;
  1194.               if filoff + filescursor > filenumber then
  1195.                  filescursor := filenumber - filoff;
  1196.             end;
  1197.           end;
  1198.  
  1199.  
  1200.           _home, _padhome: begin
  1201.             if filoff>0 then newfiloff := true; filoff := 0; filescursor := 0
  1202.           end;
  1203.  
  1204.           _end, _padend: last3;
  1205.  
  1206.           _pgdn, _padpgdn: begin
  1207.             newfiloff := true;
  1208. {@}         if (
  1209.               (filoff < filenumber - pc * 2 * page) and
  1210.               (filenumber > pc * 2 * page)
  1211.             ) then begin
  1212.               inc(filoff, pc * page); filescursor := pc * page - 1;
  1213.             end else last3;
  1214.           end;
  1215.  
  1216.           _pgup, _padpgup: begin
  1217.             newfiloff := true;
  1218.             if (filoff >= pc*page) then dec(filoff, pc*page) else
  1219.               filoff := 0;
  1220.             filescursor := 0;
  1221.           end;
  1222.  
  1223.           _minus, _padminus: tagfiles(false);
  1224.           _plus, _padplus: tagfiles(true);
  1225.           _padstar: swaptagged;
  1226.  
  1227.           else retkeypressed := true;
  1228.           {
  1229.             for i := 5 to nroffileskeys do retkeypressed := retkeypressed or
  1230.               (key = __keyword(_keys((ar(returnkeys))^[i])));
  1231.           end;
  1232.           }
  1233.         end; { case }
  1234.  
  1235.       end else begin
  1236.  
  1237.         if fullwide then pc := 3 else pc := 2;
  1238.         __write(x1+1,y2-1,footer_f, footer_b, __juststr(
  1239.           'F ' + __num(filenumber) + ' (' + __kpntstr(sum,pc)   + ')' + '  ' +
  1240.           'T ' + __num(tagnum)     + ' (' + __kpntstr(tagbytes,pc) + ')',
  1241.           ' ', x2-x1-1, _left_just_str)
  1242.         );
  1243.         if filarray^[filoff+filescursor].tagged then
  1244.           tagbar(filescursor, tagcsr_f, tagcsr_b) else
  1245.           tagbar(filescursor, scrollbar_f, scrollbar_b);
  1246.  
  1247.         key := __retkey; statusbits := __statkey(statusflags);
  1248.  
  1249.         if filarray^[filoff+filescursor].tagged then
  1250.           tagbar(filescursor, tagnocsr_f, tagnocsr_b) else
  1251.           tagbar(filescursor, panel_f, panel_b);
  1252.  
  1253.  
  1254.         case key of
  1255.  
  1256.           _up, _padup: begin
  1257.             if statusflags._scrollstate then begin
  1258.               if statusflags._capsstate then begin
  1259.                 if (y1>1) then begin
  1260.                   __copyscn(x1,y1,x2,y2,x1,y1-1);
  1261.                   {__partscn(scn4, x1, y2, x2, y2, true);}
  1262.                   dec(y1); dec(y2);
  1263.                 end else smallbeep;
  1264.               end else begin
  1265.                 if y2 > 7 then begin
  1266.                   dec(y2); newfiloff := true; dec(page);
  1267.                   filoff := 0; filescursor := 0;
  1268.                   {if y2<_currows-2 then
  1269.                     __write(x1, y2+1, panel_f, panel_b, __rep(x2-x1+1, ' '));}
  1270.                   {__partscn(scn4,x1,y2+1,x2,y2+2,true);}
  1271.                 end else smallbeep;
  1272.               end;
  1273.             end else begin
  1274.               if filescursor>0 then dec(filescursor) else
  1275.                 if filoff>0 then begin
  1276.                   dec(filoff);
  1277.                   __copyscn(x1+1, y1+2, x2-1, y2-1-2-1, x1+1, y1+3);
  1278.                   __write(x1+1, y1+2, panel_f, panel_b, copy(
  1279.                     chnam(filarray^[filoff],pl,false), 1, scnlen));
  1280.               end;
  1281.             end; { status }
  1282.           end;
  1283.  
  1284.           _down, _paddown, _c_v, _ins, _padins: begin
  1285.             case key of
  1286.               _ins, _padins, _c_v: begin
  1287.                 swaptag(filarray^[filoff+filescursor]);
  1288.                 if filarray^[filoff+filescursor].tagged then
  1289.                   tagbar(filescursor, tagnocsr_f, tagnocsr_b) else
  1290.                   tagbar(filescursor, panel_f, panel_b);
  1291.               end; else ;
  1292.             end;
  1293.             if statusflags._scrollstate then begin
  1294.               if statusflags._capsstate then begin
  1295.                 if (y2<_currows-2) then begin
  1296.                   __copyscn(x1,y1,x2,y2,x1,y1+1);
  1297.                   {__partscn(scn4, x1, y1, x2, y1, true);}
  1298.                   inc(y1); inc(y2);
  1299.                 end else smallbeep;
  1300.               end else begin
  1301.                 if y2 < _currows - 2 then begin
  1302.                   inc(y2); newfiloff := true; inc(page);
  1303.                   filoff := 0; filescursor := 0;
  1304.                 end else smallbeep;
  1305.               end;
  1306.             end else begin
  1307.               if (filescursor < page-1) and (filescursor<filenumber) then
  1308.                 inc(filescursor) else
  1309.                 if filoff < (filenumber-page+1) then begin
  1310.                   inc(filoff);
  1311.                   __copyscn(x1+1, y1+3, x2-1, y2-1-2, x1+1, y1+2);
  1312.                   __write(x1+1, y2-1-2, panel_f, panel_b, copy(
  1313.                     chnam(filarray^[filoff + page -1], pl, false), 1, scnlen));
  1314.                 end;
  1315.             end; { status }
  1316.           end;
  1317.  
  1318.           _left, _padleft: begin
  1319.             if statusflags._scrollstate and (x1>13) then begin
  1320.               if statusflags._capsstate then begin
  1321.                 if (x1>1) then begin
  1322.                   __copyscn(x1,y1,x2,y2,x1-1,y1);
  1323.                   {__partscn(scn4, x2, y1, x2, y2, true);}
  1324.                   dec(x1); dec(x2);
  1325.                 end else smallbeep;
  1326.               end else begin
  1327.                 if not fullwide then begin
  1328.                   fullwide := true; {smallbeep;} dec(x1, 13);
  1329.                   pc := 3; newfiloff := true; filoff := 0; filescursor := 0;
  1330.                   scnlen := x2-x1-1;
  1331.                 end else smallbeep;
  1332.               end;
  1333.             end;
  1334.           end;
  1335.  
  1336.           _right, _padright: begin
  1337.             if statusflags._scrollstate then begin
  1338.               if statusflags._capsstate then begin
  1339.                 if (x2<_curcolumns) then begin
  1340.                   __copyscn(x1,y1,x2,y2,x1+1,y1);
  1341.                   {__partscn(scn4, x1, y1, x1, y2, true);}
  1342.                   inc(x1); inc(x2);
  1343.                 end else smallbeep;
  1344.               end else begin
  1345.                 if fullwide then begin
  1346.                   {__partscn(scn4,x1,y1,x1+13,y2,true);}
  1347.                   fullwide := false; smallbeep; inc(x1, 13);
  1348.                   pc := 2; newfiloff := true; filoff := 0; filescursor := 0;
  1349.                   scnlen := x2-x1-1;
  1350.                 end else smallbeep;
  1351.               end;
  1352.             end;
  1353.           end;
  1354.  
  1355.           _pgdn, _padpgdn: begin
  1356. {@}           if (
  1357.                 (filoff < (filenumber - 2 * page)) and (filenumber > 2 * page)
  1358.               ) then begin
  1359.               inc(filoff, page); newfiloff := true;
  1360.             end else last1;
  1361.            end;
  1362.  
  1363.           _pgup, _padpgup: begin
  1364.             newfiloff := true;
  1365.             if filoff >= page then dec(filoff,page) else filoff := 0;
  1366.           end;
  1367.  
  1368.           _end, _padend: last1;
  1369.  
  1370.           _home, _padhome: begin
  1371.             if filoff>0 then newfiloff := true; filoff := 0; filescursor := 0;
  1372.           end;
  1373.  
  1374.           _padminus: tagfiles(false);
  1375.           _padplus:  tagfiles(true);
  1376.           _padstar:  swaptagged;
  1377.  
  1378.           else retkeypressed := true;
  1379.           {
  1380.             for i := 5 to nroffileskeys do retkeypressed := retkeypressed or
  1381.               (key = __keyword(_keys((ar(returnkeys))^[i])));
  1382.           end;
  1383.           }
  1384.         end; { case }
  1385.  
  1386.       end; { pl or not pl }
  1387.  
  1388.       if key = ar(returnkeys)^[1] then begin
  1389.         readfiles(_doscurpath); startsorting; newfiloff := true;
  1390.         retkeypressed := false;
  1391.       end;
  1392.  
  1393.       if key = ar(returnkeys)^[2] then begin
  1394.         retkeypressed := true; { confirmation }
  1395.       end;
  1396.  
  1397.       if key = ar(returnkeys)^[3] then begin
  1398.         newfiloff := true; pl := not pl; filoff := 0; filescursor := 0;
  1399.         retkeypressed := false;
  1400.       end;
  1401.  
  1402.     until retkeypressed;
  1403.  
  1404.     __betwscn(x1, x2, y1, panel_b, panel_f, ' ' + 
  1405.       __slashfil(
  1406.         __packfil(
  1407.           __cvtstr(
  1408.             __xlatestr(__backrem(_doscurpath), '.', ' '),
  1409.             _rem_white_str
  1410.           ),
  1411.           x2-x1-1-2
  1412.         )
  1413.       ) +
  1414.       ' '
  1415.     );
  1416.  
  1417.     retkey := key; tagbar(filescursor, curactbar_f, curactbar_b);
  1418.     if key = ar(returnkeys)^[2] then
  1419.       walk_files_ := filarray^[filoff + filescursor].name else
  1420.         walk_files_ := #0;
  1421.   end; { walk_files_ }
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427. end. { unit }
  1428.