-
Notifications
You must be signed in to change notification settings - Fork 0
/
GVFILER.PAS
172 lines (161 loc) · 4.29 KB
/
GVFILER.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
unit gvfiler;
interface
uses Dos,Graph,GVDrive,GVMenus;
const
cmChDrive = $FF03;
cmChDir = $FF04;
cmLoad = $FF05;
type
p2diskfile= ^pdiskfile;
pdiskfile = ^tdiskfile;
tdiskfile = object
dir : dirstr;
name : namestr;
exte : extstr;
fullpath : pathstr;
constructor init;
procedure load(newfile : pathstr); virtual;
destructor done; virtual;
end;
pFiler=^tFiler;
tFiler= object (tscrollmenu)
diskfile : pdiskfile;
exte : extstr;
HomeDir,NewDir : dirstr;
constructor init (AFile :p2diskfile;
APath : pathstr; AName,AExtension : str32; lenght :word);
procedure run ; virtual;
procedure hide; virtual;
procedure handlekeyboard; virtual;
end;
pfileritem=^tfileritem;
tfileritem= object (tmenuitem)
fileinfo : searchrec;
constructor init(newinfo:searchrec; amessage: word);
procedure run; virtual;
end;
implementation
var mess :tmessagebox;
constructor tdiskfile.init;
begin
end;
procedure tdiskfile.load;
begin
end;
destructor tdiskfile.done;
begin
end;
constructor tFiler.init;
begin
tscrollmenu.init(AName,lenght);
diskfile :=AFile^;
exte :=AExtension;
getdir(0,homedir);
NewDir:=APath;
if copy(NewDir,length(NewDir),1)='\' then
delete(NewDir,length(NewDir),1);
end;
procedure tFiler.run;
var
s,s1 : searchrec;
olddir : pathstr;
begin
if window^.hidden then
begin
getsettings;
getdir(0,olddir);
settextstyle(style.font,style.direction,style.charsize);
{$i-}
chdir(newdir);
{$i+}
if ioresult<>0 then
begin
chdir(olddir);
showmessage('Directory not found');
end;
findfirst('*',directory,s);
if s.name='.' then findnext(s);
if s.name<>'..' then
begin
s1.name:='A:\';
put(new(pfileritem,init(s1,cmChDrive)));
s1.name:='B:\';
put(new(pfileritem,init(s1,cmChDrive)));
s1.name:='C:\';
put(new(pfileritem,init(s1,cmChDrive)));
s1.name:='D:\';
put(new(pfileritem,init(s1,cmChDrive)));
end;
while doserror=0 do
begin
put(new(pfileritem,init(s,cmChDir)));
FindNext(s)
end;
findfirst('*.'+exte,anyfile,s);
while doserror=0 do
begin
put(new(pfileritem,init(s,cmLoad)));
FindNext(s);
end;
top:=1;
bottom:=lines;
restoresettings;
end;
tscrollmenu.show;
focus:=nil;
end;
procedure tfiler.hide;
begin
chdir(homedir);
tscrollmenu.hide;
if child <> nil then
begin
dispose(child,done);
child:=nil;
end;
end;
procedure tfiler.handlekeyboard;
var
sel : pfileritem;
begin
if focus<>nil then
begin
sel:=@focus^;
case keycode of
cmChDrive : begin
NewDir:=focus^.name;
hide;
run;
event:=evNothing;
keycode:=0;
end;
cmChDir : begin
NewDir:=fexpand (sel^.fileinfo.name);
hide;
run;
event:=evNothing;
keycode:=0;
end;
cmLoad : begin
mess.init('Loading '+sel^.fileinfo.name);
diskfile^.load (fexpand(sel^.fileinfo.name));
mess.close;
keycode:=cmEsc;
end;
end;
end;
tscrollmenu.handlekeyboard;
end;
constructor tfileritem.init;
begin
fileinfo:=newinfo;
if fileinfo.attr=directory then
tmenuitem.init(fileinfo.name+'\...',amessage)
else
tmenuitem.init(fileinfo.name,amessage);
end;
procedure tfileritem.run;
begin
parent^.focus:=@self;
end;
end.