-
Notifications
You must be signed in to change notification settings - Fork 0
/
SE.PAS
522 lines (456 loc) · 14.8 KB
/
SE.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
(*
$Id: se.pas 1.12 2003/01/05 05:56:21 Tony Exp Tony $
$Log: se.pas $
Revision 1.12 2003/01/05 05:56:21 Tony
*** empty log message ***
Revision 1.11 2002/01/18 09:30:49 tony
Fixed code
Revision 1.10 2002/01/08 17:32:20 tony
Release to manufacture
Revision 1.9 2001/09/19 04:45:31 tony
Added support for Win NT configuration file loading
Revision 1.8 2001/09/13 06:13:52 tony
Tweaked code
Revision 1.7 2001/09/04 15:40:44 tony
Fixed menu bar, status bar, cleaned up code
Revision 1.6 2001/08/24 08:36:32 tony
Added help hints and color selection dialog
Revision 1.5 2001/08/17 02:43:51 tony
Cleaned up command line parsing routine
Revision 1.4 2001/08/16 09:45:03 tony
Updated revision code, fixed command line parsing routines, added
usage information.
Revision 1.3 2001/08/15 19:21:55 tony
Updated revision code and fixed /B switch function so that the backup
flag is actually turned off
Revision 1.2 2001/08/14 17:05:33 tony
Added RCSID line to source
Revision 1.1 2001/08/13 15:57:25 tony
Initial revision
System Editor
Version 1.00
Copyright (C) AGE Software
All rights reserved
Purpose: Full screen system editor.
FILENAME: SE.PAS
*)
{$M 8192,8192,655360}
{$X+,S-}
uses Dos, Strings, ColorSel, App, Editors, StdDlg, Dialogs, Memory, MsgBox, Objects, Menus, Drivers, Views;
type
PHintStatusLine = ^THintStatusLine;
THintStatusLine = object(TStatusLine)
function Hint (AHelpCtx : Word) : String; virtual;
end;
TSysEdit = object(TApplication)
AboutBox : PDialog;
constructor Init;
procedure InitStatusLine; virtual;
procedure InitMenuBar; virtual;
procedure HandleEvent(var Event : TEvent); virtual;
procedure About;
procedure ColorSelDialog;
end;
TVersion = record
OSName : PString;
Maj, Min, Rev : longint;
end;
const
RCSID : String = '$Id: se.pas 1.12 2003/01/05 05:56:21 Tony Exp Tony $';
RCSRev : String = '$Revision: 1.12 $';
ID : String = 'FreeDOS SysEdit';
Copyright : String = 'Copyright (C) 2001-2003 AGE Software';
sBanner = '%s - Version %d.%d (Build %04d LeSabre)';
VERSION : TVersion = (OSName:@ID;Maj:1;Min:0;Rev:0112);
cmAbout = 100;
cmClipShow = cmAbout + 1;
cmHelp = cmClipShow + 1;
cmPrint = cmHelp + 1;
cmOptionsVideo = cmPrint + 1;
cmOptionsSave = cmOptionsVideo + 1;
cmOptionsLoad = cmOptionsSave + 1;
cmColors = cmOptionsLoad + 1;
hcPrint = 1000;
hcFind = hcPrint + 1;
hcReplace = hcFind + 1;
hcSearchAgain = hcReplace + 1;
hcOptionsVideo = hcSearchAgain + 1;
hcAbout = hcOptionsVideo + 1;
hcClipShow = hcAbout + 1;
hcColors = hcClipShow + 1;
hcAboutDlg = hcColors + 1;
hcColorDlg = hcAboutDlg + 1;
hcFileMenu = 2000;
hcEditMenu = hcFileMenu + 1;
hcSearchMenu = hcEditMenu + 1;
hcOptionsMenu = hcSearchMenu + 1;
hcWindowMenu = hcOptionsMenu + 1;
hcHelpMenu = hcWindowMenu + 1;
WinNum : byte = 1;
HeapSize = 48 * (1024 div 16); (* 48K buffer *)
var
ClipWindow : PEditWindow; (* Create clipboard window *)
Editor : TSysEdit;
Mono, BW : Boolean;
i : byte;
S : String;
progname : string[8];
P : Pchar;
procedure Usage;
begin
FormatStr(S, sBanner, VERSION);
PrintStr(S);
PrintStr(#9+Copy(RCSRev,2,(Length(RCSRev) - 2)));
PrintStr(#13#10#13#10'Editor for system configuration files'#13#10#13#10);
PrintStr(progname+' [/B] [/BW] [/M] [/?]'#13#10#13#10);
PrintStr(' /B - turns off the auto backup feature'#13#10);
PrintStr(' /BW - show in black and white on a color monitor'#13#10);
PrintStr(' /M - force monochrome mode'#13#10);
PrintStr(' /? - displays this help screen'#13#10);
end;
function GetProgName(S : String) : string;
var
D : DirStr;
N : NameStr;
E : ExtStr;
begin
FSplit(S, D, N, E);
GetProgName := N;
end;
{
This portion of unused code to display OS information
procedure OSInfo(var p : TVersion; var S : String);
var EDC_Product : word;
begin
EDC_Product := is_drdos;
if EDC_Product <> 0 then
begin
case EDC_Product of
$1060 : S := 'DOS Plus';
$1063 : S := 'DR DOS 3.41';
$1064 : S := 'DR DOS 3.42';
$1065 : S := 'DR DOS 5.0';
$1067 : S := 'DR DOS 6.0';
$1070 : S := 'DR DOS PalmDOS';
$1071 : S := 'DR DOS 6.0 March ''93 update';
$1072 : S := 'Novell DOS 7.0';
$1432 : S := 'Concurrent PC-DOS 3.2';
$1441 : S := 'Concurrent DOS 4.1';
$1450 : S := 'Concurrent DOS/XM 5.0 or Concurrent DOS/386 1.1';
$1460 : S := 'Concurrent DOS/XM 6.0 or Concurrent DOS/386 2.0';
$1462 : S := 'Concurrent DOS/XM 6.2 or Concurrent DOS/386 3.0';
$1466 : S := 'DR Multiuser DOS 5.1';
$1467 : S := 'Concurrent DOS 5.1';
else S := 'Unknown DR DOS version';
end;
end;
case GetOEMNumber of
$00 : S :='IBM ';
$01 : S :='Compaq ';
$02 : S :='Microsoft MS-';
$04 : S :='AT&T ';
$05 : S :='ZDS (Zenith Electronics) ';
$06 : S :='HP ';
$07 : S :='ZDS (Groupe Bull) ';
$0D : S :='Packard Bell ';
$16 : S :='DEC ';
$23 : S :='Olivetti ';
$28 : S :='TI ';
$29 : S :='Toshiba ';
$33 : S :='Novell (Windows/386 device IDs only) ';
$34 .. $35 :
S :='MS Multimedia Systems (Windows/386 device IDs only) ';
$4D : S :='HP ';
$5E : S :='Rx';
$66 : S :='PTS-';
$99 : S :='General Software''s Embedded ';
$EE : S :='DR ';
$EF : S :='Novell ';
$FD : S :='Free';
$FF : S :='Microsoft MS-';
else
end;
S:= S +'DOS';
p.Maj := Lo(DosVersion);
p.Min := Hi(DosVersion);
end;
This code block may be removed at a later time
}
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;
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;
begin
MaxHeapSize := HeapSize;
inherited Init;
if Mono then SetScreenMode(smMono);
if BW then SetScreenMode(smBW80);
EditorFlags := EditorFlags or efBackupFiles;
DisableCommands([cmOpen, cmSave, cmSaveAs, cmCut, cmCopy, cmPaste, cmClear,
cmUndo, cmPrint, cmFind, cmReplace, cmSearchAgain]);
EditorDialog := StdEditorDialog;
ClipWindow := OpenEditor('', False);
dec(WinNum);
if ClipWindow <> nil then
begin
Clipboard := ClipWindow^.Editor;
Clipboard^.CanUndo := False;
end;
About;
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;
{ Main execution portion }
begin
(*
Let's make the following assumptions -
1. You can't directly write to video memory
2. We are using a color video adapter
3. We are in color mode
*)
BW := false;
Mono := false;
if Lo(DosVersion) < 3 then begin
PrintStr('System Config Editor requires DOS 3.0 or higher'#13#10);
halt(255);
end;
if paramstr(0) <> '' then progname := GetProgName(paramstr(0));
if paramcount > 0 then
for i := 1 to paramcount do begin
StrPCopy(P, paramstr(i));
StrUpper(P);
inc(P);
case char( P^) of
'B' :
begin
inc (P);
if char(P^) = 'W' then
BW := true
else
EditorFlags := EditorFlags xor efBackupFiles;
end;
'M' : Mono := true;
'?', 'H' :
begin
Usage;
halt;
end;
'I' :
begin
FormatStr(S, sBanner, VERSION);
PrintStr(S);
PrintStr(#9+Copy(RCSRev,2,(Length(RCSRev) - 2))+#13#10);
halt;
end;
else;
end;
end;
Editor.Init;
Editor.Run;
Editor.Done;
end.