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
|
{
This file is part of the ffff
Copyright (c) 1998 by Berczi Gabor
Help menu entries
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
procedure TIDEApp.HelpContents;
var FileID: word;
Ctx : THelpCtx;
var Found: boolean;
begin
CheckHelpSystem;
Found:=HelpFacility^.TopicSearch('Table of contents',FileID,Ctx);
if Found then
Help(FileID,Ctx,false)
else
HelpIndex('');
end;
procedure TIDEApp.HelpHelpIndex;
begin
HelpIndex('');
end;
procedure TIDEApp.HelpTopicSearch;
var FileID: word;
Ctx : THelpCtx;
var Found: boolean;
var
EditorWindow : PSourceWindow;
S : string;
begin
EditorWindow:=FirstEditorWindow;
If assigned(EditorWindow) then
S:=LowerCaseStr(EditorWindow^.Editor^.GetCurrentWord)
else
S:='';
CheckHelpSystem;
Found:=false;
if S<>'' then
Found:=HelpFacility^.TopicSearch(S,FileID,Ctx);
if Found then
Help(FileID,Ctx,false)
else
HelpIndex('');
end;
procedure TIDEApp.HelpPrevTopic;
begin
if HelpWindow=nil then HelpContents else
with HelpWindow^ do
if GetState(sfVisible) then Message(HelpWindow^.HelpView,evCommand,cmPrevTopic,nil)
else begin HelpWindow^.Show; HelpWindow^.MakeFirst; end;
end;
procedure TIDEApp.HelpUsingHelp;
begin
Help(0,hcUsingHelp,false);
end;
type
PHelpFileListBox = ^THelpFileListBox;
THelpFileListBox = object(TListBox)
function GetText(Item: sw_Integer; MaxLen: sw_Integer): String; virtual;
end;
PHelpFilesDialog = ^THelpFilesDialog;
THelpFilesDialog = object(TCenterDialog)
constructor Init;
procedure HandleEvent(var Event: TEvent); virtual;
destructor Done; virtual;
private
LB: PHelpFileListBox;
C : PUnsortedStringCollection;
end;
function THelpFileListBox.GetText(Item: sw_Integer; MaxLen: sw_Integer): String;
var S: string;
P: integer;
begin
S:=inherited GetText(Item,MaxLen);
P:=Pos('|',S);
if P>0 then S:=copy(S,P+1,255)+' - '+copy(S,1,P-1);
GetText:=copy(S,1,MaxLen);
end;
constructor THelpFilesDialog.Init;
var R,R2: TRect;
SB: PScrollBar;
I: integer;
begin
R.Assign(0,0,round(ScreenWidth*5/8),ScreenHeight-10);
inherited Init(R, dialog_helpfiles);
New(C, Init(20,10));
GetExtent(R); R.Grow(-2,-2); Inc(R.A.Y); R.B.X:=R.B.X-13;
R2.Copy(R); R2.Move(1,0); R2.A.X:=R2.B.X-1;
New(SB, Init(R2)); Insert(SB);
New(LB, Init(R, 1, SB));
for I:=0 to HelpFiles^.Count-1 do
begin
C^.Insert(NewStr(HelpFiles^.At(I)^));
end;
LB^.NewList(C);
Insert(LB);
R2.Copy(R); Dec(R2.A.Y); R2.B.Y:=R2.A.Y+1;
Insert(New(PLabel, Init(R2, label_helpfiles_helpfiles, LB)));
GetExtent(R); R.Grow(-2,-2); Inc(R.A.Y); R.A.X:=R.B.X-13+1; R.B.Y:=R.A.Y+2;
Insert(New(PButton, Init(R, button_OK, cmOK, bfDefault)));
R.Move(0,2);
Insert(New(PButton, Init(R, button_New, cmAddItem, bfNormal)));
R.Move(0,2);
Insert(New(PButton, Init(R, button_Delete, cmDeleteItem, bfNormal)));
R.Move(0,2);
Insert(New(PButton, Init(R, button_Cancel, cmCancel, bfNormal)));
LB^.Select;
end;
procedure THelpFilesDialog.HandleEvent(var Event: TEvent);
function StoreHtmlIndexFile(const FileName: string; LS: PFPHTMLFileLinkScanner;var Re: Word; SilentFails: Boolean): Boolean;
var
BS: PBufStream;
begin
if ExistsFile(FileName) then
if ConfirmBox(FormatStrStr(msg_filealreadyexistsoverwrite,FileName),nil,true)<>cmYes then
Re:=cmCancel;
if Re<>cmCancel then
begin
PushStatus(FormatStrStr(msg_storinghtmlindexinfile,FileName));
New(BS, Init(FileName, stCreate, 4096));
if Assigned(BS)=false then
begin
if not SilentFails then
begin
ErrorBox(FormatStrStr(msg_cantcreatefile,FileName),nil);
end;
Re:=cmCancel;
end
else
begin
LS^.StoreDocuments(BS^);
if BS^.Status<>stOK then
begin
if not SilentFails then
begin
ErrorBox(FormatStrInt(msg_errorstoringindexdata,BS^.Status),nil);
end;
Re:=cmCancel;
end;
Dispose(BS, Done);
end;
PopStatus;
end;
StoreHtmlIndexFile := Re <> cmCancel;
end;
var I: integer;
D: PFileDialog;
FileName: string;
Re: word;
S: string;
LS: PFPHTMLFileLinkScanner;
begin
case Event.What of
evKeyDown :
case Event.KeyCode of
kbIns :
begin
Message(@Self,evCommand,cmAddItem,nil);
ClearEvent(Event);
end;
kbDel :
begin
Message(@Self,evCommand,cmDeleteItem,nil);
ClearEvent(Event);
end;
end;
evCommand :
case Event.Command of
cmAddItem :
begin
S:='';
New(D, Init(HelpFileExts,
dialog_installhelpfile,
label_installhelpfile_filename,
fdOpenButton,hidOpenHelpFile));
Re:=Desktop^.ExecView(D);
if Re<>cmCancel then
begin
D^.GetFileName(FileName);
if UpcaseStr(ExtOf(FileName))=UpcaseStr(HTMLIndexExt) then
begin
S:='HTML Index';
end
else
if UpcaseStr(copy(ExtOf(FileName),1,length(HTMLExt)))=UpcaseStr(HTMLExt) then
begin
Re:=ConfirmBox(msg_createkeywordindexforhelpfile,nil,true);
if Re<>cmCancel then
if Re=cmNo then
Re:=InputBox(dialog_topictitle,label_topictitle_title,S,40)
else
begin
ShowMessage(msg_pleasewaitwhilecreatingindex);
S:='HTML Index';
PushStatus(FormatStrStr(msg_buildingindexfile,FileName));
New(LS, Init(DirOf(FileName)));
LS^.ProcessDocument(FileName,[soSubDocsOnly]);
if LS^.GetDocumentCount=0 then
begin
ErrorBox(FormatStrStr(msg_filedoesnotcontainanylinks,FileName),nil);
Re:=cmCancel;
end
else
begin
FileName:=DirAndNameOf(FileName)+HTMLIndexExt;
if not StoreHtmlIndexFile(FileName, LS, Re, True) then
begin
Re:=ConfirmBox(FormatStrStr('Could not create "%s", try creating it in local dir?', FileName),nil,true);
FileName := GetCurDir + NameAndExtOf(FileName);
if Re = cmYes then
begin
StoreHtmlIndexFile(FileName, LS, Re, False);
end;
end
end;
Dispose(LS, Done);
PopStatus;
HideMessage;
end;
end;
end;
if Re<>cmCancel then
begin
if S<>'' then FileName:=FileName+'|'+S;
LB^.List^.Insert(NewStr(FileName));
LB^.SetRange(LB^.List^.Count);
ReDraw;
end;
Dispose(D, Done);
ClearEvent(Event);
end;
cmDeleteItem :
if LB^.Range>0 then
begin
LB^.List^.AtFree(LB^.Focused);
LB^.SetRange(LB^.List^.Count);
ReDraw;
ClearEvent(Event);
end;
cmOK :
begin
HelpFiles^.FreeAll;
for I:=0 to LB^.List^.Count-1 do
HelpFiles^.Insert(NewStr(C^.At(I)^));
end;
end;
end;
inherited HandleEvent(Event);
end;
destructor THelpFilesDialog.Done;
begin
if C<>nil then
begin
C^.FreeAll;
Dispose(C, Done);
end;
inherited Done;
end;
procedure TIDEApp.HelpFiles;
var
PHFD : PHelpFilesDialog;
begin
New(PHFD, Init);
if Desktop^.ExecView(PHFD)=cmOK then
begin
DoneHelpSystem;
Message(Application,evBroadcast,cmHelpFilesChanged,nil);
InitHelpSystem;
end;
if assigned(PHFD) then
Dispose(PHFD, Done);
end;
procedure TIDEApp.About;
begin
ExecuteDialog(New(PFPAboutDialog, Init), nil);
end;
|