-
Notifications
You must be signed in to change notification settings - Fork 2
/
FLPANELX.PAS
1722 lines (1617 loc) · 59.2 KB
/
FLPANELX.PAS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{/////////////////////////////////////////////////////////////////////////
//
// Dos Navigator Version 1.51 Copyright (C) 1991-99 RIT Research Labs
//
// This programs is free for commercial and non-commercial use as long as
// the following conditions are aheared to.
//
// Copyright remains RIT Research Labs, and as such any Copyright notices
// in the code are not to be removed. If this package is used in a
// product, RIT Research Labs should be given attribution as the RIT Research
// Labs of the parts of the library used. This can be in the form of a textual
// message at program startup or in documentation (online or textual)
// provided with the package.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. All advertising materials mentioning features or use of this software
// must display the following acknowledgement:
// "Based on Dos Navigator by RIT Research Labs."
//
// THIS SOFTWARE IS PROVIDED BY RIT RESEARCH LABS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// The licence and distribution terms for any publically available
// version or derivative of this code cannot be changed. i.e. this code
// cannot simply be copied and put under another distribution licence
// (including the GNU Public Licence).
//
//////////////////////////////////////////////////////////////////////////}
{$I STDEFINE.INC}
{$I DN.DEF}
UNIT
FLPanelX;
INTERFACE
USES
Advance, Objects, Views, Drivers, Dos, FilesCol, HideView, Drives;
TYPE
PFilePanelRoot = ^TFilePanelRoot;
TFilePanelRoot = object(THideView)
isValid, MSelect, SelectFlag, Loaded, ChangeLocked: Boolean;
InfoView, DirView, DriveLine: PHideView;
Delta, OldDelta, OldPos, DeltaX: Integer;
Files: PFilesCollection;
SortMode: Byte;
DirectoryName, OldDirectory: PathStr;
FileMask: String;
SearchMask: String[12];
ScrollBar: PScrollBar;
DrawDisableLvl, SelNum, LineLength: Integer;
SelectedLen, PackedLen: TSize;
WasActive, PosChanged, CommandEnabling,
QuickSearch, ViewEnabled: Boolean;
TotalInfo, FreeSpace: String[50];
PanelFlags, ShowFlags: Word;
SearchX: Integer;
LastDriveFlags: Word;
Drive: PDrive;
ForceReading: Boolean;
DriveState: Word;
LastCurPos: TPoint;
constructor Init(var Bounds: TRect; ADrive: Integer; AScrBar: PScrollBar);
constructor Load(var S: TStream);
procedure Store(var S: TStream);
destructor Done; virtual;
procedure Awaken; virtual;
procedure ChDirName;
procedure ShowView; virtual;
procedure HideView; virtual;
procedure CommandHandle(var Event: TEvent);
procedure ChangeBounds(var Bounds: TRect); virtual;
function Valid(Command: Word): Boolean; virtual;
procedure GetUserParams(var FName, List: String);
procedure ReadDirectory;
procedure RereadDir;
procedure SetDirName; virtual;
procedure SendLocated;
procedure IncDrawDisabled;
procedure DecDrawDisabled;
procedure ChkNoMem;
end;
{ }
{ WARNING: The following vars are mirrored in FLPANEL.PAS via ABSOLUTEs! }
{ }
CONST
ActivePanel: Pointer = NIL;
CtrlWas: Boolean = False;
DirsToChange: Array [0..9] of PString = (nil,nil,nil,nil,nil,nil,nil,nil,nil,nil);
CurFileActive: PString = nil;
CurFilePassive: PString = nil;
VAR
CurrentDirectory: PathStr;
PShootState: Word;
IMPLEMENTATION
uses
{$IFDEF DEBUG} DEBUG, {$ENDIF}
Messages, DnApp, DnHelp, Startup, Commands, Histries, HistList, FlTools,
FileFind,
{$IFDEF MODEM}
NavyLink,
{$ENDIF}
CmdLine, ArcView, Archiver, UUcode, DiskImg, DiskInfo,
FileCopy, DnUtil
{DNApp, Startup, Memory, FileCopy, Messages, Menus, DiskInfo, Validate,
Dialogs, Commands, HistList, Tree, FBB, RStrings, UUCode, Swe,
ArcView, CmdLine, Histries, Archiver, Gauges, Gauge, FileFind, FlPanel,
NavyLink, DiskImg, FlTools};
procedure TFilePanelRoot.IncDrawDisabled;
begin
Inc(DrawDisableLvl);
end;
procedure TFilePanelRoot.DecDrawDisabled;
begin
Dec(DrawDisableLvl);
ChkNoMem;
end;
procedure TFilePanelRoot.ChkNoMem;
begin
if Drive^.NoMemory and (DrawDisableLvl = 0) then
begin
Application^.OutOfMemory;
Drive^.NoMemory := False;
end;
end;
constructor TFilePanelRoot.Init;
begin
inherited Init(Bounds);
ForceReading := Off;
CommandEnabling := On;
ChangeLocked := Off;
Abort := Off;
HelpCtx := hcFilePanel;
GrowMode := gfGrowHiY + gfGrowHiX;
Options := Options or ofSelectable or ofTopSelect or ofFirstClick;
PanelFlags := PanelDefaults.Show;
EventMask := $FFFF;
ScrollBar := AScrBar; Loaded := Off; OldDelta := -1; PosChanged := Off;
isValid := On;
if (ADrive <= 0) or not ValidDrive(Char(ADrive+64)) then ADrive := 0;
Drive := New(PDrive, Init(ADrive, @Self, -1));
DeltaX := 0;
if Abort then begin IsValid := False; Exit end;
{GetDir(ADrive, DirectoryName);}
{Drive^.Owner := @Self;}
FileMask := x_x; Files := nil;
if PanelDefaults.Sort < 4 then SortMode := PanelDefaults.Sort + 1 else
if PanelDefaults.Sort = 4 then SortMode := 30
else SortMode := 0;
IncDrawDisabled; MSelect := Off;
QuickSearch := Off; ViewEnabled := Off;
if not Abort then ReadDirectory;
isValid := isValid and not Abort; DecDrawDisabled;
end;
constructor TFilePanelRoot.Load;
var I: Integer;
begin
inherited Load(S);
ChangeLocked := Off;
GetPeerViewPtr(S, ScrollBar);
GetPeerViewPtr(S, DirView);
GetPeerViewPtr(S, InfoView);
GetPeerViewPtr(S, DriveLine);
Drive := PDrive(S.Get);
if Drive = nil then New(Drive, Init(0, @Self, -1));
DeltaX := 0;
Drive^.RereadDirectory('');
{Drive^.Owner := @Self;}
if Drive <> nil then DirectoryName := Drive^.GetDir;
S.Read(FileMask[0], 1); S.Read(FileMask[1], Length(FileMask));
S.Read(SortMode, 1);
S.Read(ShowFlags, 2);
Drive^.Flags := ShowFlags;
S.Read(PanelFlags, 2);
S.Read(Delta, 2); OldDelta := -1; PosChanged := Off;
S.Read(ForceReading, 1);
Files := PFilesCollection(S.Get);
if Files <> nil then
for I := 0 to Files^.Count-1 do PFileRec(Files^.At(I))^.Owner := @Drive^.CurDir;
Loaded := On; MSelect := Off; isValid := True; QuickSearch := Off; ViewEnabled := Off;
CommandEnabling := On;
end;
procedure TFilePanelRoot.Awaken;
begin
if (Size.X > 0) and (GetState(sfVisible)) then RereadDir;
if (DriveLine <> nil) then
if (FMSetup.Show and fmsDriveLine <> 0) then
begin
if not DriveLine^.GetState(sfVisible) then DriveLine^.Show;
end else
if DriveLine^.GetState(sfVisible) then DriveLine^.Hide;
end;
procedure TFilePanelRoot.Store;
begin
inherited Store(S);
PutPeerViewPtr(S, ScrollBar);
PutPeerViewPtr(S, DirView);
PutPeerViewPtr(S, InfoView);
PutPeerViewPtr(S, DriveLine);
if (ActivePanel <> @Self) or (Drive^.DriveType <> dtDisk)
or (StartupData.UnLoad and osuPreserveDir <> 0) then S.Put(Drive) else S.Put(nil);
S.Write(FileMask, 1 + Length(FileMask));
S.Write(SortMode, 1);
S.Write(ShowFlags, 2);
S.Write(PanelFlags, 2);
S.Write(Delta, 2);
S.Write(ForceReading, 1);
PFilesCollection(Files)^.Selected := ScrollBar^.Value;
S.Put(Files);
end;
function TFilePanelRoot.Valid;
begin
Valid := isValid;
if (Command = cmClose) then Valid := Drive^.Disposable;
end;
destructor TFilePanelRoot.Done;
var P: PDrive;
begin
if Files <> nil then Dispose(Files, Done);
if Drive <> nil then Dispose(Drive, Done);
inherited Done;
end;
procedure TFilePanelRoot.ShowView;
begin
if InfoView <> nil then InfoView^.ShowView;
if DirView <> nil then DirView^.ShowView;
if (ScrollBar <> nil) and GetState(sfActive+sfSelected) then
ScrollBar^.Show;
if Loaded then RereadDir;
inherited ShowView;
end;
procedure TFilePanelRoot.HideView;
begin
if InfoView <> nil then InfoView^.HideView;
if DirView <> nil then DirView^.HideView;
if (ScrollBar <> nil) then ScrollBar^.Hide;
inherited HideView;
end;
procedure TFilePanelRoot.ChangeBounds;
var R: TRect;
I: Integer;
begin
I := Byte(( Drive^.DriveType = dtFind ) or ( Drive^.DriveType = dtTemp ) or ( Drive^.DriveType = dtArc ));
I := Byte(FMSetup.Show and fmsDivider <> 0) +
Byte(PanelFlags and fmiCurrent <> 0)*(1 + I) +
Byte(PanelFlags and fmiSelected <> 0) +
Byte(PanelFlags and fmiTotals <> 0) +
Byte(PanelFlags and fmiFree <> 0)*Byte(I=0);
Dec(Bounds.B.Y, I);
SetBounds(Bounds);
R := Bounds; R.B.Y := R.A.Y; Dec(R.A.Y);
if DirView <> nil then DirView^.SetBounds(R);
R := Bounds; R.A.Y := R.B.Y; Inc(R.B.Y, I);
if InfoView <> nil then InfoView^.SetBounds(R);
if DriveLine <> nil then
begin
R.A.Y := R.B.Y + Byte(FMSetup.Show and fmsDriveLine = 0);
Inc(R.B.Y);
DriveLine^.SetBounds(R);
if (FMSetup.Show and fmsDriveLine <> 0) then
begin
if not DriveLine^.GetState(sfVisible) then DriveLine^.Show;
end else
if DriveLine^.GetState(sfVisible) then DriveLine^.Hide;
end;
if ScrollBar <> nil then
begin R :=Bounds; R.A.X := R.B.X; Inc(R.B.X); ScrollBar^.SetBounds(R) end
end;
procedure TFilePanelRoot.SendLocated;
var S: String;
R: Integer;
begin
if (Files^.Count = 0) or (Drive^.DriveType = dtArc) or
(State and sfVisible = 0) then Exit;
R := ScrollBar^.Value; if R >= Files^.Count then Exit;
if not ViewEnabled and (Drive^.Flags and psShowLongDesc = 0) then Exit;
S := MakeNormName(PFileRec(Files^.At(R))^.Owner^,
MakeFileName(PFileRec(Files^.At(R))^.Name));
if ViewEnabled or (Drive^.Drivetype < dtArc)
then Message(Owner, evCommand, cmLoadViewFile, @S);
end;
procedure TFilePanelRoot.RereadDir;
var P,PP,CurP: PFileRec;
I, J, Pos: Integer;
FC {,FCC}: PFilesCollection;
NewDir: PathStr;
BB: Boolean;
TF: TFileRec;
WasLoaded, B: Boolean;
{
procedure DoPut(P: PFileRec); far;
begin
if P^.Selected or (P = CurP) then FCC^.Insert(P);
end;
}
begin
Abort := Off; OldDelta := Delta; PosChanged := Off; WasLoaded := Loaded;
if Loaded then begin
LineLength := Drive^.CalcLength(ShowFlags);;
ScrollBar^.SetParams(PFilesCollection(Files)^.Selected, 0, Files^.Count - 1,
(Size.Y-Byte(FMSetup.Show and fmsColumnTitles <> 0)) *
((Size.X+1) div LineLength), 1);
CurrentDirectory := ActiveDir;
Loaded := Off;
if WasActive and (ActiveDir <> DirectoryName) then
begin DirectoryName := ActiveDir; ReadDirectory;
ScrollBar^.SetValue(0); Exit end;
end;
if (Files = nil) or (Files^.Count = 0) then begin OldDelta := -1; Delta := 0 end;
ClrIO; Loaded := Off; ChDirName;
if Abort then begin Dispose(Files, Done); New(Files, Init(10, 10)); Abort := Off; Exit; end;
NewDir := Drive^.GetRealDir;
if Abort then begin Dispose(Files, Done); New(Files, Init(10, 10)); Abort := Off; Exit; end;
if GetState(sfFocused) then CurrentDirectory := DirectoryName;
if Files^.Count = 0 then
begin DirectoryName := NewDir; ReadDirectory; ChDirName; Exit end;
FC := PFilesCollection(Files); Files := nil; IncDrawDisabled;
Pos := ScrollBar^.Value;
if NewDir <> DirectoryName then
begin Pos := 0; DirectoryName := NewDir end;
I := 0; CurP := FC^.At(Pos);
while (I < FC^.Count) do
begin
P := FC^.Items^[I];
if (P <> CurP) and (P <> nil) and not P^.Selected then
begin FC^.Items^[I] := nil; FC^.FreeItem(P) end;
Inc(I);
end;
ReadDirectory;
B := (Drive^.DriveType <> dtTemp) and (Drive^.DriveType <> dtFind);
if (FC^.Count > 0) then
begin
{New(FCC, Init(SelNum+1,10));
FCC^.SortMode := 1;
FC^.ForEach(@DoPut);
FC^.DeleteAll;
Dispose(FC, Done);
FC := FCC;}
SelNum := 0; SelectedLen := 0; PackedLen := 0; BB := Off;
for I := 0 to FC^.Count-1 do
begin
PP := FC^.At(I);
if (PP <> nil) and PP^.Selected or (PP = CurP) then
for J := 0 to Files^.Count - 1 do
begin
P := Files^.Items^[J];
if (P^.Name = PP^.Name) and (WasLoaded or (P^.Owner^ = PP^.Owner^)) then
begin
TF := PP^;
PP^ := P^;
P^ := TF;
PP^.Selected := TF.Selected;
FC^.Items^[I] := P;
Files^.Items^[J] := PP;
if PP^.Name[1] = '.' then PP^.Selected := Off;
if PP^.Selected then
begin
SelectedLen := SelectedLen + PP^.Size;
PackedLen := PackedLen + PP^.PSize;
Inc(SelNum);
end;
Break;
end;
end;
end;
{for I := 0 to Files^.Count-1 do
begin
PP := Files^.At(I);
if FC^.Search(PP, J) then
begin
P := FC^.Items^[J];
PP^.Selected := P^.Selected;
P^ := PP^;
FC^.Items^[J] := PP;
Files^.Items^[I] := P;
end;
end;
for I := 1 to Files^.Count do
begin
P := Files^.At(I-1);
if not BB and (MakeFileName(PFileRec(CurP)^.Name) = MakeFileName(P^.Name)) then
begin BB := On; Pos := I - 1; end;
end;}
if not BB then
begin
for I := 0 to Files^.Count-1 do
begin
P := Files^.At(I);
if (CurP^.Name = P^.Name) and (CurP^.Owner^ = P^.Owner^) then
begin Pos := I; break; end;
end;
end;
end else Pos := 0;
Dispose(FC, Done);
ScrollBar^.SetValue(Pos);
DecDrawDisabled;
DirectoryName := NewDir;
SetDirName;
if GetState(sfFocused) and (Drive^.DriveType = dtDisk) then
GlobalMessage(evCommand, cmRereadInfo, nil);
SendLocated;
end;
procedure TFilePanelRoot.SetDirName;
begin
{ if (ActivePanel = @Self) then
begin Drive^.ChDir(DirectoryName); if TypeOf(Drive^) = TypeOf(TDrive) then CurrentDirectory := DirectoryName; end;}
DrawView;
if InfoView <> nil then InfoView^.DrawView;
if DirView <> nil then DirView^.DrawView;
end;
procedure TFilePanelRoot.ChDirName;
begin
SetDirName;
end;
procedure TFilePanelRoot.ReadDirectory;
var SR: SearchRec;
P: PFileRec;
D: DateTime;
I: Integer;
DrNm: PathStr;
AllFiles: Boolean;
FreeSpc, TotalLen: LongInt;
S: String;
begin
LineLength := Drive^.CalcLength(ShowFlags);
ShowFlags := Drive^.Flags;
Drive^.Owner := @Self;
case Drive^.DriveType of
dtArc: HelpCtx := hcArchives;
dtLink: HelpCtx := hcLinkPanel;
else HelpCtx := hcFilePanel;
end;
DOSError := 0;
PosChanged := Off; Loaded := Off;
Abort := Off; AllFiles := FileMask = x_x; ClrIO; FreeSpc := 0;
FreeSpace := ''; TotalInfo := ''; TotalLen := 0;
if Files <> nil then Dispose(Files, Done);
Files := PFilesCollection(Drive^.GetDirectory(SortMode, PanelFlags, FileMask, FreeSpace, TotalInfo));
if Files = nil then Files := New(PFilesCollection, Init(10,10));
PFilesCollection(Files)^.Owner := @Self;
SelNum := 0; SelectedLen := 0; PackedLen := 0;
PFilesCollection(Files)^.SortMode := SortMode;
if Abort then Exit;
if DriveState and dsInvalid > 0 then Exit ;
if Drive^.DriveType = dtDisk then DirectoryName := Drive^.GetRealDir;
DirectoryName := Drive^.GetDir;
if GetState(sfSelected) then Message(Owner, evCommand, cmChangeTree, @DirectoryName);
ScrollBar^.SetParams(ScrollBar^.Value, 0, Files^.Count - 1, (Size.Y-Byte(FMSetup.Show and fmsColumnTitles <> 0))
* ((Size.X+1) div LineLength), 1);
{Delta := 0;}
if (ActivePanel = @Self) and (Drive^.DriveType = dtDisk)
then CurrentDirectory := DirectoryName
else ChDir(CurrentDirectory);
if Drive^.DriveType = dtDisk then Message(CommandLine, evCommand, cmRereadInfo, nil);
Message(Owner, evCommand, cmRereadInfo, nil);
if DriveLine <> nil then DriveLine^.DrawView;
ChkNoMem;
end;
procedure TFilePanelRoot.GetUserParams;
var PF: PFileRec;
S: String[1];
procedure MakeTempList;
var T: Text;
I: Integer;
begin
Assign(T, List); ClrIO;
Rewrite(T); if Abort then Exit;
for I := 1 to Files^.Count do
begin
PF := Files^.At(I-1);
if (PF^.Selected) or (I-1=ScrollBar^.Value) and (SelNum=0) then
WriteLn(T, MakeFileName(PF^.Name));
end;
Close(T);
end;
begin
FName := ''; List := '';
if not GetState(sfVisible) or (Files = nil) or (Files^.Count = 0) then Exit;
PF := Files^.At(ScrollBar^.Value);
FName := MakeNormName(PF^.Owner^, MakeFileName(PF^.Name));
if GetState(sfSelected) then S := '$' else S := '';
List := SwpDir+'$$$dn$$'+S+'.lst';
MakeTempList;
end;
PROCEDURE TFilePanelRoot.CommandHandle;
var
PF: PFileRec;
CurPos: Integer;
{S: String;}
MPos: TPoint;
LastRDelay: Word;
{I, J: Integer;
PDr: PDrive;}
procedure CE;begin ClearEvent(Event) end;
procedure CED;begin ClearEvent(Event); DrawView end;
procedure Rebound;
var R: TRect;
begin
GetBounds(R);
R.A.Y := 1; R.B.Y := Owner^.Size.Y - 1;
ChangeBounds(R);
Owner^.Redraw;
end;
procedure GotoSingle(Name: String);
var A: Integer;
begin
Name := MakeFileName(UpStrg(Norm12(Name)));
A := 0;
While (A < Files^.Count) and
(MakeFileName(UpStrg(PFileRec(Files^.At(A))^.Name)) <> Name) do Inc(A);
if A >= Files^.Count then A := 0; IncDrawDisabled;
OldDirectory := DirectoryName;
ScrollBar^.SetValue(A);
DecDrawDisabled;
Rebound;
end;
function ChangeUp: Boolean;
var S: String;
begin
if ChangeLocked then Exit;
ChangeUp := Drive^.IsUp;
DeltaX := 0;
if Drive^.IsUp then Drive^.ChangeUp(S) else Exit;
IncDrawDisabled; ReadDirectory; AddToDirectoryHistory(DirectoryName);
if S <> '' then GotoSingle(UpStrg(S));
DecDrawDisabled;
Rebound;
end;
procedure GotoFile(FileName: PathStr);
var Dr: PathStr;
Nm: NameStr;
Xt: ExtStr;
Name: String[12];
A: Integer;
begin
if ChangeLocked then Exit;
FSplit(FileName, Dr, Nm, Xt);
if Copy(Dr, 1, 5) = cLINK_ then Delete(Dr, 1, 5);
if (Dr[Length(Dr)] = '\') and ((Dr[2] <> ':') or (Dr[0] > #3)) then Dec(Dr[0]);
While (Dr[Length(Dr)] = '.') or (Dr[Length(Dr)] = ' ') do Dec(Dr[0]);
if (Dr[2] = ':') and ((Drive^.DriveType <> dtDisk) and (Drive^.DriveType <> dtLink)) then
begin Dispose(Drive, Done); New(Drive, Init(Byte(Upcase(Dr[1]))-64, @Self, -1)); end;
{if (Xt = '..') and ChangeUp then Exit;}
DirectoryName := Dr; IncDrawDisabled; OldDirectory := Dr;
DeltaX := 0;
Drive^.ChDir(DirectoryName); DirectoryName := Drive^.GetDir;
OldDelta := -1; Delta := 0;
ReadDirectory; AddToDirectoryHistory(DirectoryName);
DecDrawDisabled;
if Nm = '' then Name := '.. '
else Name := Nm+Xt;
GotoSingle(Name);
end;
function isSeldir : boolean ;
begin
isSelDir := False ;
if Files^.Count = 0 then Exit;
if CurPos >= Files^.Count then Exit;
isSelDir := PFileRec(Files^.At(CurPos))^.Attr and Directory <> 0;
end;
procedure ViewFile(Command: Word);
var S: String;
P: PFileRec;
begin
if Files^.Count = 0 then Exit;
CE; if CurPos >= Files^.Count then Exit;
P := Files^.At(CurPos);
if P^.Attr and Directory <> 0 then Exit;
asm
mov ax,Command
cmp ax,cmIntEditFile
jnz @@1
mov ax,cmIntFileEdit;
jmp @@0
@@1:
cmp ax,cmIntViewFile
jnz @@2
mov ax,cmIntFileView;
jmp @@0
@@2:
cmp ax,cmEditFile
jnz @@3
mov ax,cmFileEdit;
jmp @@0
@@3:
mov ax,cmFileView;
@@0:
mov Command, ax
end;
Drive^.UseFile(P, Command);
end;
procedure Recount;
var I: Integer;
PF: PFileRec;
begin
SelectedLen := 0; PackedLen := 0; SelNum := 0;
for I := 1 to Files^.Count do
begin
PF := Files^.At(I-1);
if PF^.Selected then
begin
SelectedLen := SelectedLen + PF^.Size;
PackedLen := PackedLen + PF^.PSize;
Inc(SelNum);
end;
end;
DrawView;
if InfoView <> nil then InfoView^.DrawView;
end;
procedure Setup;
var R: record Sort,Show: Integer; S: String; end;
BB: TRect;
begin
R.Sort := SortMode;
if R.Sort = 0 then R.Sort := 5 else
if R.Sort = 30 then R.Sort := 4 else Dec(R.Sort);
R.Show := PanelFlags;
R.S := FileMask;
if ExecResource(dlgPanelSetup, R) <> cmOK then Exit;
if R.Sort = 5 then R.Sort := 0 else
if R.Sort = 4 then R.Sort := 30 else Inc(R.Sort);
if (ActivePanel = @Self) and (Drive^.DriveType = dtDisk)
then CurrentDirectory := DirectoryName;
SortMode := R.Sort;
PanelFlags := R.Show;
FileMask := R.S; RereadDir;
Rebound;
ChDirName;
end;
procedure CountLen;
procedure DoCount(P: PFileRec); far;
begin
if (P^.Attr and Directory <> 0) and (P^.Selected) and (not Abort) then Drive^.GetDirLength(P);
end;
begin
CE; if (PF = nil) or ((PF^.Attr and Directory = 0) and (SelNum = 0)) then Exit;
if PF^.Attr and Directory <> 0 then Drive^.GetDirLength(PF);
if SelNum > 0 then Files^.ForEach(@DoCount); Abort := False;
Recount;
DrawView;
if InfoView <> nil then InfoView^.DrawView;
end;
var WasFull: Boolean;
procedure InsertDrive;
begin
if ChangeLocked then Exit;
if (PDrive(Event.InfoPtr)^.DriveType = dtTemp) and
(Drive^.DriveType = dtTemp) then begin CE; Exit end;
if PDrive(Event.InfoPtr)^.DriveType in [dtDisk, dtLink] then
begin
if Drive <> nil then Dispose(Drive, Done); Drive := nil;
end;
PDrive(Event.InfoPtr)^.Prev := Drive;
Drive := Event.InfoPtr;
if (Drive^.DriveType = dtArc) or (Drive^.DriveType = dtArvid) then Drive^.ChDir(#0);
{if WasFull then Drive^.Flags := Drive^.GetFullFlags else Drive^.Flags := 0;}
Drive^.Owner := @Self;
CE;
DeltaX := 0;
ReadDirectory; AddToDirectoryHistory(DirectoryName);
ScrollBar^.SetValue(0);
Rebound;
end;
procedure EraseGroup;
begin
Drive^.EraseFiles(Event.InfoPtr);
CE;
end;
procedure SelecType(S: Boolean);
procedure Sel(P: PFileRec); far;
begin
if (P^.TType = PF^.TType) and (P^.Name[1] <> '.') then P^.Selected := S;
end;
begin
if (CurPos >= Files^.Count) {or (PanelFlags and fmiHiliteFiles = 0)} then Exit;
PF := Files^.At(CurPos);
Files^.ForEach(@Sel);
Recount; Owner^.Redraw;
end;
procedure SelectExt(S: Boolean; G1, G2: Integer; Invert: Boolean);
var SS: NameStr;
procedure Sel(P: PFileRec); far;
begin
if ((SS = Copy(P^.Name, G1, G2)) xor Invert) and (P^.Name[1] <> '.') then P^.Selected := S;
end;
begin
if (CurPos >= Files^.Count) then Exit;
PF := Files^.At(CurPos);
SS := Copy(PF^.Name, G1, G2);
Files^.ForEach(@Sel);
Recount; Owner^.Redraw;
end;
procedure HandleCommand;
var FC: PCollection;
W: Word;
begin
W := Event.Command; CE; FC := nil;
case W of
cmExtractTo, cmArcTest: begin FC := GetSelection(@Self, Off); if FC = nil then Exit; end;
end;
Drive^.HandleCommand(W, FC);
if FC <> nil then
begin
FC^.DeleteAll;
Dispose(FC, Done);
end;
end;
function ReplaceDrive(C: char): Boolean;
var
PDr: PDrive;
begin
ReplaceDrive := Off;
New(PDr, Init(Byte(C)-64, @Self, -1));
if Abort then
begin Dispose(PDr, Done); Exit; end;
Dispose(Drive, Done);
Drive := PDr;
DeltaX := 0;
{if WasFull then Drive^.Flags := Drive^.GetFullFlags
else Drive^.Flags := 0;}
DirectoryName := Drive^.GetDir;
if GetState(sfActive+sfSelected) then
SetState(sfActive+sfSelected, On);
Rebound;
ReplaceDrive := On;
end;
function MakeFName(Idx: Integer; Mode: Boolean): String;
begin
PF := Files^.At(Idx);
FreeStr := MakeFileName(PF^.Name);
if PosChar('.', FreeStr) = 0 then AddStr(FreeStr, '.');
if (Drive^.DriveType <> dtDisk) then FreeStr := MakeNormName(PF^.Owner^, FreeStr);
if Mode then Insert(' ', FreeStr, 1);
MakeFName := FreeStr;
end;
procedure DoChange(SS: PathStr);
var SR: SearchRec;
S: string;
begin
S := SS;
ClrIO;
FindFirst(SS, $3f xor VolumeID, SR);
if Abort then Exit;
if ((DOSError <> 0) or (SR.Attr and Directory = 0)) and
(Copy(SS,Length(SS)-1,2) <> ':\') then
Exit;
if SS = '' then Exit;
if Drive^.DriveType <> dtDisk then
begin
if not ReplaceDrive(S[1]) then Exit;
end;
SS := MakeNormName(SS,'..'); OldDelta := -1;
GotoFile(SS);
Rebound;
end;
procedure DoExcept(P: PFileRec); far;
begin
if (P <> nil) and (P^.Attr and Directory = 0) then
begin
FreeStr := P^.Name; FreeStr[9] := '.';
if not InFilter(FreeStr, FileMask) then P^.Size := -100;
end;
end;
procedure _GetFName;
var
S: string;
begin
GetUserParams(S, PString(Event.InfoPtr)^);
S := MakeFileName(PF^.Name);
PString(Event.InfoPtr)^ := S + ' ' + PString(Event.InfoPtr)^;
end;
procedure _DoPush(a: Boolean);
var
S: string;
B,C: Boolean;
begin
if not GetState(sfVisible) then Exit;
if a and (Drive^.DriveType<>dtDisk) then PString(Event.InfoPtr)^ := CurrentDirectory
else
begin
S := Drive^.GetRealName;
if (S <> '') and (S <> CurrentDirectory) then PString(Event.InfoPtr)^ := S;
end;
end;
procedure _DoRereadDir;
var
S: string;
I: Integer;
begin
S := PString(Event.InfoPtr)^;
if (S[0] > #3) and (S[Length(S)] = '\') then Dec(S[0]);
I := Length(S);
if (Drive^.DriveType <> dtDisk) or (Copy(PString(Event.InfoPtr)^, 1, I) =
Copy(DirectoryName, 1, I)) then
begin
Drive^.RereadDirectory(S);
RereadDir;
end else
if (Drive^.DriveType = dtDisk) and (S[1] = DirectoryName[1]) then
begin
if PanelFlags and fmiFree <> 0 then
Drive^.GetFreeSpace(FreeSpace);
if InfoView <> nil then InfoView^.DrawView;
end;
end;
procedure _PushName;
var
S: string;
begin
S := Drive^.GetRealName;
if S <> '' then HistoryAdd(Event.InfoByte, S);
end;
procedure _ChangeDrive;
var
S: string;
begin
if ChangeLocked then Exit;
CE;
Abort := Off; OldDelta := -1;
MPos.X := Origin.X + Size.X div 2;
MPos.Y := Origin.Y+1;
Owner^.MakeGlobal(MPos, MPos);
if (DirectoryName[2] = ':') then S[1] := DirectoryName[1]
else if (Drive^.DriveType = dtLink) then S[1] := '+'
else S[1] := CurrentDirectory[1];
S := SelectDrive(MPos.X, MPos.Y, S[1], On);
if S = cTEMP_ then
begin
Event.InfoPtr := New(PTempDrive, Init);
InsertDrive; Exit;
end else
{$IFDEF MODEM}
if Copy(S,1,1) = '+' then
begin
Event.InfoPtr := NewLinkDrive(s[2]);
InsertDrive; Exit;
end else
{$ENDIF}
if S <> '' then
begin
ClrIO;
if Drive^.DriveType <> dtDisk then
begin
if not ReplaceDrive(S[1]) then Exit;
end else
begin
Drive^.ChDir(S);
if Abort then
begin ClrIO; SetDirName; ChDir(CurrentDirectory); Exit; end;
S := Drive^.GetDir;
end;
IncDrawDisabled; DirectoryName := S; ReadDirectory;
AddToDirectoryHistory(DirectoryName);
DecDrawDisabled; SetDirName;
end;
ChDirName;
end;
procedure _ChangeDrv;
var
S: string;
begin
if ChangeLocked then Exit;
S := PString(Event.InfoPtr)^; CE;
if S = cTEMP_ then
begin
Event.InfoPtr := New(PTempDrive, Init);
InsertDrive; Exit;
end
{$IFDEF MODEM}
else if S[1] = '+' then
begin
Event.InfoPtr := NewLinkDrive(S[2]);
InsertDrive; Exit;
end
{$ENDIF};
GetDir(Byte(S[1])-64, S); if Abort then Exit;
DoChange(S);
end;
procedure _DoChangeDirectory;
var
S: string;
begin
S := PString(Event.InfoPtr)^;
CE; UpStr(S);
if Drive^.DriveType <> dtDisk then Exit;
if (S[0] > #3) and (S[Length(S)] = '\') then Dec(S[0]);
{if S = DirectoryName then Exit;}
{S := S + '\..';
DelDoubles('\\', S); GotoFile(S);}
Drive^.ChDir(S);
IncDrawDisabled;
ReadDirectory;
AddToDirectoryHistory(DirectoryName);
ScrollBar^.SetValue(0);
DecDrawDisabled; DrawView;
GlobalMessage(evCommand, cmRereadInfo, nil);
Owner^.Redraw;
end;
procedure _DoDirHistory;
var
S: string;