-
Notifications
You must be signed in to change notification settings - Fork 0
/
SEUI.PAS
338 lines (294 loc) · 10.2 KB
/
SEUI.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
{
$Id: SEUI.PAS 1.0 2003/01/15 21:13:49 tony Exp tony $
$Log: SEUI.PAS $
Revision 1.0 2003/01/15 21:13:49 tony
Initial revision
2015-03-03 adg Move Hints into the private section of this unit
since there is no code that needs to manipulate
it directly. The only exposed type is the TSysEdit
System Configuration System Configuration Editor
Version 1.0
Written by Antony Gordon
Copyright 2003 AGE Software
----------------------------------
This file is part of System Configuration Editor.
System Configuration Editor is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
System Configuration Editor 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. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with System Configuration Editor. If not, see <http://www.gnu.org/licenses/>.
----------------------------------
Filename: SEUI.PAS
Contains Turbo Vision routines
}
unit SEUI;
interface
uses Strings, ColorSel, App, Editors, StdDlg, Dialogs, Memory, MsgBox,
Objects, Menus, Drivers, Views;
type
TSysEdit = object(TApplication)
AboutBox : PDialog;
constructor Init;
procedure InitStatusLine; virtual;
procedure InitMenuBar; virtual;
procedure HandleEvent(var Event : TEvent); virtual;
procedure About;
procedure ColorSelDialog;
procedure OutOfMemory; virtual;
end;
implementation
uses Dos, SeConst;
type
PHintStatusLine = ^THintStatusLine;
THintStatusLine = object(TStatusLine)
function Hint (AHelpCtx : Word) : String; virtual;
end;
var
ClipWindow : PEditWindow; (* Create clipboard window *)
Editor : TSysEdit;
function THintStatusLine.Hint(AHelpCtx : Word) : String;
begin
case AHelpCtx of
hcNew : Hint := 'Create a new file in a new edit window';
hcOpen : Hint := 'Locate and open a file in an edit window';
hcSave : Hint := 'Save the file in the active edit window';
hcPrint : Hint := 'Print the contents of the active edit window';
hcDosShell : Hint := 'Temporarily exit to DOS';
hcExit : Hint := 'Exit SysEdit';
hcUndo : Hint := 'Undo the previous editor operation';
hcCut : Hint := 'Removes the current selection and copies it to the clipboard';
hcCopy : Hint := 'Copies the current selection to the clipboard';
hcPaste : Hint := 'Insert items you have copied or cut into the selected area';
hcClear : Hint := 'Deletes the selected text';
hcFind : Hint := 'Search for text';
hcReplace : Hint := 'Search for text and replace it with new text';
hcSearchAgain : Hint := 'Repeat the last find or replace command';
hcOptionsVideo : Hint := 'Switch between hi res and low res mode';
hcTile : Hint := 'Arrange windows on desktop by tiling';
hcCascade : Hint := 'Arrange windows on desktop by cascading';
hcCloseAll : Hint := 'Close all windows on the desktop';
hcResize : Hint := 'Change the size of the active window';
hcZoom : Hint := 'Enlarge or restore the size of the active window';
hcNext : Hint := 'Make the next window active';
hcPrev : Hint := 'Make the previous window active';
hcClose : Hint := 'Close the active window';
hcAbout : Hint := 'Show version and copyright information';
hcClipShow : Hint := 'Show contents of the clipboard';
hcColors : Hint := 'Customize editor colors';
hcFileMenu : Hint := 'File management commands (Open, Save, etc)';
hcEditMenu : Hint := 'Cut-and-paste editing commands';
hcSearchMenu : Hint := 'Text search commands';
hcOptionsMenu : Hint := 'Set defaults for editor';
hcWindowMenu : Hint := 'Open and arrange windows';
hcHelpMenu : Hint := 'Get online help';
hcAboutDlg : Hint := 'Welcome to System Config Editor. Press Enter to close this dialog box';
hcColorDlg : Hint := 'Use cursor keys to select an editor group and customize its colors';
else
Hint := '';
end;
end;
function OpenEditor(theFile: FNameStr; Visible: Boolean): PEditWindow;
(*
The OpenEditor is used by the event handler to actually open files. It can
generate a new editor window, or create an editor window for an existing file
*)
var
P: PWindow;
R: TRect;
begin
DeskTop^.GetExtent(R);
P := New(PEditWindow, Init(R, theFile, WinNum));
if not Visible then P^.Hide;
{ P^.Palette := wpGrayWindow; }
OpenEditor := PEditWindow(Application^.InsertWindow(P));
inc(WinNum);
end;
procedure Open(FName, Path : String);
var
P : PathStr;
begin
P := FSearch(FName, Path);
If Length(P) <> 0 then OpenEditor(FExpand(P), true);
end;
procedure OpenConfigFiles;
var
D : String[3];
R : Registers;
begin
Open('WIN.INI', GetEnv('PATH'));
Open('SYSTEM.INI', GetEnv('PATH'));
Open('PROTOCOL.INI', GetEnv('PATH'));
Open('AUTOEXEC.NT', GetEnv('PATH'));
Open('CONFIG.NT', GetEnv('PATH'));
r.ah := $19;
msdos(r);
D := chr((65+r.al))+':\';
Open('AUTOEXEC.BAT', D);
Open('CONFIG.SYS', D);
Open('FDCONFIG.SYS', D);
end; (* OpenConfigFiles *)
(*
Turbo Vision Code begins here for the user interface
*)
constructor TSysEdit.Init;
(*
Application initialization, sets up the heapsize and the clipboard
*)
var
i : byte;
cmdSet : TCommandSet;
begin
cmdSet := [cmOpen, cmSave, cmSaveAs, cmCut, cmCopy, cmPaste, cmClear,
cmUndo, cmPrint, cmFind, cmReplace, cmSearchAgain];
MaxHeapSize := HeapSize;
inherited Init;
if Mono then SetScreenMode(smMono);
if BW then SetScreenMode(smBW80);
EditorFlags := EditorFlags or efBackupFiles;
DisableCommands(cmdSet);
EditorDialog := StdEditorDialog;
ClipWindow := OpenEditor('', False);
dec(WinNum);
if ClipWindow <> nil then
begin
Clipboard := ClipWindow^.Editor;
Clipboard^.CanUndo := False;
end;
OpenConfigFiles;
Cascade;
end;
procedure TSysEdit.ColorSelDialog;
var
R : TRect;
D : PDialog;
begin
D := New(PColorDialog, Init('',
ColorGroup('Desktop', DesktopColorItems(nil),
ColorGroup('Menus', MenuColorItems(nil),
ColorGroup('Editor/Windows', WindowColorItems(wpBlueWindow, nil),
ColorGroup('Dialog Boxes', DialogColorItems(dpGrayDialog, nil),
nil))))));
D^.HelpCtx := hcColorDlg;
if ExecuteDialog(D, Application^.GetPalette) <> cmCancel then
begin
DoneMemory;
ReDraw;
end;
end;
procedure TSysEdit.InitStatusLine;
var R : TRect;
begin
GetExtent(R); (* get application boundaries *)
R.A.Y := R.B.Y - 1; (* set top to one above bottom *)
StatusLine := New(PHintStatusLine, Init(R,
NewStatusDef(0, 999,
NewStatusKey('', kbF1, cmHelp,
NewStatusKey('~F2~ Save', kbF2, cmSave,
NewStatusKey('~Alt+F3~ Close', kbAltF3, cmClose,
StdStatusKeys(nil)))),
NewStatusDef(1000, $FFFF,
NewStatusKey('', kbF1, cmHelp,
nil), nil))));
end;
procedure TSysEdit.InitMenuBar;
var R : TRect;
begin
GetExtent(R);
R.B.Y := R.A.Y + 1;
MenuBar := New(PMenuBar, Init(R, NewMenu(
NewSubMenu('~F~ile', hcFileMenu, NewMenu(
NewItem('~S~ave','F2', kbF2, cmSave, hcSave,
NewItem('~P~rint', 'Ctrl+PrtScr', kbCtrlPrtSc, cmPrint, hcPrint,
NewItem('~D~OS Shell', '', kbNoKey, cmDosShell, hcDosShell,
NewItem('E~x~it','Alt+X', kbAltX, cmQuit, hcExit,
nil))))),
NewSubMenu('~E~dit', hcEditMenu, NewMenu(
StdEditMenuItems(
NewLine(
NewItem('~S~how clipboard', '', kbNoKey, cmClipShow, hcClipShow,
nil)))),
NewSubMenu('~S~earch', hcSearchMenu, NewMenu(
NewItem('~F~ind...', '', kbNoKey, cmFind, hcFind,
NewItem('~R~eplace...', '', kbNoKey, cmReplace, hcReplace,
NewItem('~S~earch again', '', kbNoKey, cmSearchAgain, hcSearchAgain,
nil)))),
NewSubMenu('~O~ptions', hcOptionsMenu, NewMenu(
NewItem('~T~oggle video', '', kbNoKey, cmOptionsVideo, hcOptionsVideo,
NewItem('~C~olors...', '', kbNoKey, cmColors, hcColors,
nil))),
NewSubMenu('~W~indow', hcWindowMenu, NewMenu(
StdWindowMenuItems(nil)),
NewSubMenu('~H~elp', hcHelpMenu, NewMenu(
NewItem('~A~bout...', '', kbNoKey, cmAbout, hcAbout, nil)),
nil)))))))));
end;
procedure TSysEdit.About;
{
Draws about box
}
var
S : String;
R : TRect;
begin
R.Assign(0, 0, 55, 12);
AboutBox := New(PDialog, Init(R, 'About System Config Editor'));
with AboutBox^ do begin
Options := Options or ofCentered;
HelpCtx := hcAboutDlg;
R.Assign(1,4,54,5);
FormatStr(S, #3+sBanner, VERSION);
Insert(New(PStaticText, Init(R, S)));
R.Assign(1, 6, 54, 7);
Insert(New(PStaticText, Init(R, #3+Copyright)));
R.Assign(23, 8, 32, 10);
Insert(New(PButton, Init(R, '~C~lose', cmOK, bfDefault)));
end;
ExecuteDialog(AboutBox, nil);
end;
procedure TSysEdit.HandleEvent;
(*
Event handler code
*)
procedure ChangeDir;
begin
ExecuteDialog(New(PChDirDialog, Init(cdNormal, 0)), nil);
end;
procedure ChangeVideo;
begin
SetScreenMode(ScreenMode xor smFont8x8);
end;
procedure ShowClip;
begin
ClipWindow^.Select;
ClipWindow^.Show;
end;
{ Main portion of event handler }
begin
inherited HandleEvent(Event);
if Event.What = evCommand then
case Event.Command of
cmOptionsVideo : ChangeVideo;
cmColors : ColorSelDialog;
cmClipShow : ShowClip;
cmChangeDir : ChangeDir;
cmAbout : About;
else
exit;
end;
ClearEvent(Event);
end;
procedure TSysEdit.OutOfMemory;
begin
MessageBox('Not enough memory for this operation.',
nil, mfError + mfOkButton);
end;
{$IFDEF Debug}
begin
writeln('Loading user interface module...');
{$ENDIF}
end.