-
Notifications
You must be signed in to change notification settings - Fork 4
/
frmConsoleUnit.pas
732 lines (666 loc) · 22.6 KB
/
frmConsoleUnit.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
unit frmConsoleUnit;
interface
uses
Forms, Windows, Messages, Dialogs, SysUtils, Classes, Controls, ComCtrls, StdCtrls, Menus, ShellAPI, ExtCtrls, AlignEdit,
CoolTrayIcon, ImgList;
type
TfrmTARConsole = class(TForm)
txtConsole: TAlignEdit;
mnuMain: TPopupMenu;
mnuExit: TMenuItem;
mnuBorder6: TMenuItem;
mnuSelectAll: TMenuItem;
mnuClear: TMenuItem;
mnuBorder4: TMenuItem;
mnuReread: TMenuItem;
mnuUndo: TMenuItem;
mnuSettings: TMenuItem;
mnuEditor: TMenuItem;
mnuBorder2: TMenuItem;
mnuShowConsole: TMenuItem;
mnuHideConsole: TMenuItem;
mnuAbout: TMenuItem;
mnuBorder7: TMenuItem;
mnuHelp: TMenuItem;
mnuToggleET: TMenuItem;
mnuCut: TMenuItem;
mnuCopy: TMenuItem;
mnuPaste: TMenuItem;
mnuBorder3: TMenuItem;
mnuNewAlias: TMenuItem;
mnuBorder5: TMenuItem;
mnuDelString: TMenuItem;
trayIcon: TCoolTrayIcon;
mnuOpenFolder: TMenuItem;
trayIcons: TImageList;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure txtConsoleKeyPress(Sender: TObject; var Key: Char);
procedure mnuExitClick(Sender: TObject);
procedure mnuSelectAllClick(Sender: TObject);
procedure mnuClearClick(Sender: TObject);
procedure txtConsoleKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure txtConsoleKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure mnuRereadClick(Sender: TObject);
procedure mnuUndoClick(Sender: TObject);
procedure txtConsoleMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure mnuSettingsClick(Sender: TObject);
procedure mnuEditorClick(Sender: TObject);
procedure mnuHideConsoleClick(Sender: TObject);
procedure mnuShowConsoleClick(Sender: TObject);
procedure AppDeActivate(Sender: TObject);
procedure AppActivate(Sender: TObject);
procedure mnuAboutClick(Sender: TObject);
procedure mnuHelpClick(Sender: TObject);
procedure mnuToggleETClick(Sender: TObject);
procedure mnuCutClick(Sender: TObject);
procedure mnuCopyClick(Sender: TObject);
procedure mnuPasteClick(Sender: TObject);
procedure mnuNewAliasClick(Sender: TObject);
procedure mnuDelStringClick(Sender: TObject);
procedure trayIconDblClick(Sender: TObject);
procedure trayIconMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure FormHide(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure mnuOpenFolderClick(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure FormDestroy(Sender: TObject);
procedure mnuMainPopup(Sender: TObject);
private
procedure WMHotkey(var Msg: TWMHotkey); message WM_HOTKEY;
procedure WMCopyData(var Msg: TMessage); message WM_COPYDATA;
procedure WMNCHitTest(var Msg: TWMNCHitTest); message WM_NCHITTEST;
procedure WMOnMove(var Msg: TWMMove ); message WM_MOVE;
procedure WMDialogKey(var Msg: TCMDialogKey); message CM_DIALOGKEY;
procedure WMMouseWheel(var Msg: TMessage); message WM_MOUSEWHEEL;
public
procedure EasyTypeTimer(Sender: TObject);
procedure AutoHideTimer(Sender: TObject);
procedure AutoRereadTimer(Sender: TObject);
procedure BallonTimer(Sender: TObject);
procedure WndProc(var Message: TMessage); override;
end;
var
frmTARConsole: TfrmTARConsole;
IsShift: boolean; // Çàæàò ëè Shift
Unded: boolean; // Ôëàã îòìåíû
Tabbed: boolean; // Ôëàã ïåðåáîðà ïî TAB'ó
tmrAutoReread: TTimer; // Àâòîïåðå÷èòûâàíèå êîíôèãà
tmrAutoHide: TTimer; // Àâòîñêðûòèå ïðîãðàììû
tmrEasyType: TTimer; // Ðàáîòà àâòîäîïîëíåíèÿ
CanUnload: boolean; // Èä¸ò ëè óæå âûãðóçêà ïðîãðàììû
MainMenuEvent: integer; // Îòêóäà âûçûâàåòñÿ ãëàâíîå ìåíþ
implementation
{$R *.dfm}
uses Static, ForAll, Configs, frmSettingsUnit, frmAboutUnit, Plugins, frmTypeDownDropUnit, Settings, frmHintUnit;
// Êîëåñèêî ìûøè
procedure TfrmTARConsole.WMMouseWheel(var Msg: TMessage);
begin
if (Msg.WParam<0) xor (Options.History.InvertScroll) then
HistoryDown
else
HistoryUp;
inherited;
end;
// Ïåðåòàñêèâàíèå ôîðìû.
procedure TfrmTARConsole.WMNcHitTest(var Msg: TWMNcHitTest);
var
ScrPoint: TPoint;
begin
if (GetKeyState(VK_CONTROL) and $8000)=0 then exit;
with Msg do begin
ScrPoint.x:=XPos;
ScrPoint.y:=YPos;
Result:=HTCAPTION;
end;
end;
// Çàïóñêàåòñÿ ïðè íàæàòèè çàáèòîãî ñèñòåìíîãî õîòêåÿ
procedure TfrmTARConsole.WMHotkey(var Msg: TWMHotkey);
begin
if Msg.HotKey=HotKeyId then begin
if Options.Show.TriggerShow then
if frmTARConsole.Visible then
frmTARConsole.Hide
else
ShowCon
else
ShowCon;
end;
end;
// Ëîâèì çàïóñê ïðîèçâîëüíîé ñòðîêè
procedure TfrmTARConsole.WMCopyData(var Msg: TMessage);
var
txtString: string;
begin
SetLength(txtString, PCopyDataStruct(Msg.LParam)^.cbData);
Move(PCopyDataStruct(Msg.LParam)^.lpData^, txtString[1], Length(txtString));
IsParseMessage:=True;
ParseConsole(Trim(txtString));
end;
// Ïðèëèïàíèå êîíñîëè ê êðàÿì ýêðàíà.
procedure TfrmTARConsole.WMOnMove(var Msg: TWMMove);
const
hitPix=7;
begin
Inherited;
if(txtConsole.Top=-txtConsole.Height) then begin
if (frmTARConsole.Top<Screen.WorkAreaRect.Top+hitPix) and (frmTARConsole.Top>Screen.WorkAreaRect.Top-hitPix) then frmTARConsole.Top:=Screen.WorkAreaRect.Top;
if (frmTARConsole.Top>Screen.WorkAreaRect.Bottom-frmTARConsole.Height-hitPix) and (frmTARConsole.Top<Screen.WorkAreaRect.Bottom-frmTARConsole.Height+hitPix) then frmTARConsole.Top:=Screen.WorkAreaRect.Bottom-frmTARConsole.Height;
if (frmTARConsole.Left<Screen.WorkAreaRect.Left+hitPix) and (frmTARConsole.Left>Screen.WorkAreaRect.Left-hitPix) then frmTARConsole.Left:=Screen.WorkAreaRect.Left;
if (frmTARConsole.Left>Screen.WorkAreaRect.Right-frmTARConsole.Width-hitPix) and (frmTARConsole.Left<Screen.WorkAreaRect.Right-frmTARConsole.Width+hitPix) then frmTARConsole.Left:=Screen.WorkAreaRect.Right-frmTARConsole.Width;
if (frmTARConsole.Top<hitPix) and (frmTARConsole.Top>-hitPix) then frmTARConsole.Top:=0;
if (frmTARConsole.Top>Screen.Height-frmTARConsole.Height-hitPix) and (frmTARConsole.Top<Screen.Height-frmTARConsole.Height+hitPix) then frmTARConsole.Top:=Screen.Height-frmTARConsole.Height;
if (frmTARConsole.Left<hitPix) and (frmTARConsole.Left>-hitPix) then frmTARConsole.Left:=0;
if (frmTARConsole.Left>Screen.Width-frmTARConsole.Width-hitPix) and (frmTARConsole.Left<Screen.Width-frmTARConsole.Width+hitPix) then frmTARConsole.Left:=Screen.Width-frmTARConsole.Width;
end;
end;
// Äåàêòèâèçàöèÿ êîíñîëè
procedure TfrmTARConsole.AppDeActivate(Sender: TObject);
begin
if frmTARConsole.Visible then begin
tmrAutoHide.Enabled:=False;
tmrAutoHide.Enabled:=Options.Show.AutoHide;
end;
end;
// Àêòèâèçàöèÿ êîíñîëè
procedure TfrmTARConsole.AppActivate(Sender: TObject);
begin
tmrAutoHide.Enabled:=False;
end; // AppActivate
// Ïðîöåññ èíèöèàëèçàöèè ïðè ñîçäàíèè ôîðìû
procedure TfrmTARConsole.FormCreate(Sender: TObject);
begin
// Èíèöèàëèçàöèÿ òàéìåðîâ
tmrEasyType:=TTimer.Create(frmTARConsole);
tmrEasyType.Enabled:=False;
tmrEasyType.Interval:=1;
tmrEasyType.OnTimer:=EasyTypeTimer;
tmrAutoHide:=TTimer.Create(frmTARConsole);
tmrAutoHide.Enabled:=False;
tmrAutoHide.OnTimer:=AutoHideTimer;
tmrAutoReread:=TTimer.Create(frmTARConsole);
tmrAutoReread.Enabled:=False;
tmrAutoReread.OnTimer:=AutoRereadTimer;
tmrHide:=TTimer.Create(frmTARConsole);
tmrHide.Enabled:=False;
tmrHide.OnTimer:=frmTARConsole.BallonTimer;
Options.ReadSettings;
// Ïîäñêàçêà â òðåå
setTrayIcon;
trayIcon.Hint:=Program_Name+' '+Program_Version;
MainMenuEvent:=0;
// Ìîæíî âûãðóæàòü
CanUnload:=true;
end;
// Óáèðàåì êíîïêó íà òàñêáàðå ïðè ïîêàçå ôîðìû
procedure TfrmTARConsole.FormShow(Sender: TObject);
begin
ShowWindow(Application.Handle, SW_HIDE);
if frmTARConsole.Visible and frmTARConsole.Enabled and frmTARConsole.txtConsole.Visible and frmTARConsole.txtConsole.Enabled then txtConsole.SetFocus;
end;
procedure TfrmTARConsole.FormClose(Sender: TObject; var Action: TCloseAction);
begin
end;
// Íàæàòèå êëàâèøè â êîíñîëè
procedure TfrmTARConsole.txtConsoleKeyPress(Sender: TObject; var Key: Char);
var
ConText: string;
begin
tmrAutoHide.Enabled:=False;
// Íàæàò TAB - àâòîäîïîëíåíèå
if Key=Char(VK_TAB) then begin
Key:=#0;
Tabbed:=True;
if Options.EasyType.EasyType=1 then
ET_Console(txtConsole.Text, txtConsole.SelStart, txtConsole.SelLength);
if Options.EasyType.EasyType=2 then begin
if ShortText='' then ShortText:=txtConsole.Text;
ET_Console(txtConsole.Text, Length(ShortText), Length(txtConsole.Text)-Length(ShortText));
end;
end
else begin
ConText:=txtConsole.Text;
ShortText:='';
ET_Num:=0;
if Key=Char(VK_RETURN) then begin
Key:=#0;
if ConText<>'' then begin
ParseConsole(ConText);
end;
end
else begin
if (not Unded) and Options.Undo.UseUndo then
AddUndo(txtConsole.Text, txtConsole.SelStart, txtConsole.SelLength);
Unded:=FALSE;
if Options.EasyType.AdvancedSpace and (txtConsole.SelLength<>0) then begin
if Key=Char(VK_SPACE) then begin
if not IsShift then begin
txtConsole.SelStart:=txtConsole.SelStart+txtConsole.SelLength;
txtConsole.SelLength:=0;
end;
if Options.EasyType.EasyType=1 then tmrEasyType.Enabled:=True;
end;
end;
if (Key='\') and PB_Flag then begin // Åñëè íàæàò ñëåø ïðè àâòîäîïîëíåíèè
if SetBrowse then Key:=#0;
PB_Flag:=False;
end
else if (Key=Char(VK_BACK)) then begin
if Options.EasyType.AdvancedBackspace and (Options.EasyType.EasyType=1) and not IsShift then begin
CoolBackSpace;
if txtConsole.Text<>txtConsole.SelText then tmrEasyType.Enabled:=True;
end;
end
else if (Key=#127) then begin
Key:=#0;
CtrlBackSpace;
end
else if (Key<>'"') then
if Options.EasyType.EasyType=1 then
tmrEasyType.Enabled:=True;
end;
if(txtConsole.Text = '') then ViewHint('');
end;
end;
// Âûõîä èç êîíñîëè (ìåíþ)
procedure TfrmTARConsole.mnuExitClick(Sender: TObject);
begin
frmTARConsole.Hide;
frmTARConsole.Close;
end;
// Âûäåëèòü âåñü òåêñò (ìåíþ)
procedure TfrmTARConsole.mnuSelectAllClick(Sender: TObject);
begin
txtConsole.SelectAll;
end;
// Î÷èñòèòü êîíñîëü (ìåíþ)
procedure TfrmTARConsole.mnuClearClick(Sender: TObject);
begin
txtConsole.Clear;
end;
// Çàæàòèå êëàâèøè â êîíñîëè
procedure TfrmTARConsole.txtConsoleKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if Options.Font.LockEnglish then SetKeyboardLayout('00000409');
if Shift = [ssShift]+[ssCtrl]+[ssAlt] then begin
txtConsole.Top:=-txtConsole.Height;
end;
if Key = VK_SHIFT then IsShift:=True;
// Êíîïêà ââåðõ - èñòîðèÿ âïåðåä
if Key = VK_UP then begin
Key:=0;
if Options.History.InvertScroll then HistoryDown else HistoryUp;
end;
// Êíîïêà âíèç - èñòîðèÿ íàçàä
if Key = VK_DOWN then begin
Key:=0;
if Shift = [ssCtrl] then begin
if ((frmHint<>nil) and frmHint.Visible) then
ViewHint('')
else
ViewHint(txtConsole.Text)
end
else if Shift = [ssAlt] then
DropDown(txtConsole.Text, txtConsole.SelStart, txtConsole.SelLength)
else
if Options.History.InvertScroll then HistoryUp else HistoryDown;
end;
end;
// Îòæàòèå êëàâèøè â êîíñîëè
procedure TfrmTARConsole.txtConsoleKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if Options.Font.LockEnglish then SetKeyboardLayout('00000409');
if Key = VK_SHIFT then IsShift:=False;
txtConsole.Top:=0;
Options.Show.ConsoleX:=frmTARConsole.Left;
Options.Show.ConsoleY:=frmTARConsole.Top;
if(txtConsole.Text = '') then ViewHint('');
end;
// Ïåðå÷èòàòü êîíôèãè (ìåíþ)
procedure TfrmTARConsole.mnuRereadClick(Sender: TObject);
begin
Options.ReadSettings;
ApplySettings;
ReadConfig(Program_Config);
ReadHistory(Program_History);
Options.SystemAliases.ReadSystemAliases;
end;
// Èíèöèàëèçàöèè îòìåíû íà îäèí øàã (ìåíþ)
procedure TfrmTARConsole.mnuUndoClick(Sender: TObject);
begin
if ((UndoMax>0) and (Options.Undo.UseUndo)) then begin
txtConsole.Text:=Undo[UndoMax-1];
txtConsole.SelStart:=UndoCur[UndoMax-1];
txtConsole.SelLength:=UndoCurLength[UndoMax-1];
Dec(UndoMax);
SetLength(Undo, UndoMax);
SetLength(UndoCur, UndoMax);
SetLength(UndoCurLength, UndoMax);
end;
end;
// Ìåíþ â êîíñîëè. Ïîêàçûâàþòñÿ ìåíþõè, îòíîñÿùèåñÿ ê ïîëþ ðåäàêòèðîâàíèÿ.
procedure TfrmTARConsole.txtConsoleMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Options.Font.LockEnglish then SetKeyboardLayout('00000409');
if (Button=mbRight) then MainMenuEvent:=0;
end;
// Âûçîâ íàñòðîåê
procedure TfrmTARConsole.mnuSettingsClick(Sender: TObject);
begin
CreateSettingsForm;
frmSettings.Show;
AttachThreadInput(GetWindowThreadProcessId(GetForegroundWindow, nil), GetWindowThreadProcessId(frmSettings.Handle, nil), True);
SetForegroundWindow(frmSettings.Handle);
frmSettings.BringToFront;
frmTARConsole.Hide;
end;
// Âûçîâ íàñòðîåê, ñðàçó ðåäàêòèðîâàíèå êîíôèãà
procedure TfrmTARConsole.mnuEditorClick(Sender: TObject);
var
strCon: string;
i: integer;
begin
strCon:=Trim(txtConsole.Text);
NumEditor:=0;
if strCon<>'' then begin
i:=0;
while i<ConfigStr.Count do begin
if strCon=GetName('alias', ConfigStr.Strings[i]) then begin
NumEditor:=i;
Break;
end;
Inc(i);
end;
end;
IsEditor:=True;
CreateSettingsForm;
frmSettings.Show;
AttachThreadInput(GetWindowThreadProcessId(GetForegroundWindow, nil), GetWindowThreadProcessId(frmSettings.Handle, nil), True);
SetForegroundWindow(frmSettings.Handle);
frmSettings.BringToFront;
frmTARConsole.Hide;
end;
// Àâòîäîïîëíåíèå ñðàáàòûâàåò ïî òàéìåðó
procedure TfrmTARConsole.EasyTypeTimer(Sender: TObject);
begin
tmrEasyType.Enabled:=False;
if Options.EasyType.EasyType=1 then
ET_Console(txtConsole.Text, txtConsole.SelStart, txtConsole.SelLength);
if Options.EasyType.EasyType=2 then
ET_Console(txtConsole.Text, Length(ShortText), Length(txtConsole.Text)-Length(ShortText));
end;
// Ïîêàçûâàåò áàëóí òèïñ â òðåå è ñêðûâàåò åãî ÷åðåç íåêîòîðîå âðåìÿ
procedure TfrmTARConsole.BallonTimer(Sender: TObject);
begin
tmrHide.Enabled:=False;
trayIcon.HideBalloonHint;
end;
// Ñêðûòü êîíñîëü (èç ìåíþ)
procedure TfrmTARConsole.mnuHideConsoleClick(Sender: TObject);
begin
frmTARConsole.Hide;
end;
// Ïîêàçàòü êîíñîëü èç ìåíþ
procedure TfrmTARConsole.mnuShowConsoleClick(Sender: TObject);
begin
ShowCon;
end;
// Àâòîñêðûòèå êîíñîëè ïî òàéìåðó
procedure TfrmTARConsole.AutoHideTimer(Sender: TObject);
begin
frmTARConsole.Hide;
tmrAutoHide.Enabled:=False;
end;
// Ïåðå÷èòûâàíèå êîíôèãà ïî òàéìåðó
procedure TfrmTARConsole.AutoRereadTimer(Sender: TObject);
begin
ReadConfig(Program_Config);
Options.SystemAliases.ReadSystemAliases;
end;
// Âûçîâ îêíà Î ïðîãðàììå...
procedure TfrmTARConsole.mnuAboutClick(Sender: TObject);
begin
CreateAboutForm;
frmAbout.Show;
frmTARConsole.Hide;
end;
// Âûçîâ ïîìîùè
procedure TfrmTARConsole.mnuHelpClick(Sender: TObject);
begin
HideCon;
if FileExists(GetMyPath+'Lang\'+Options.Language.Language+'.chm') then
RunShell(GetMyPath+'Lang\'+Options.Language.Language+'.chm')
else
RunShell(GetMyPath+'Lang\English.chm');
end;
// Ïåðåêëþ÷åíèå ðåæèìà EasyType
procedure TfrmTARConsole.mnuToggleETClick(Sender: TObject);
begin
mnuToggleET.Checked:=not mnuToggleET.Checked;
frmTARConsole.BorderWidth:=0;
if mnuToggleET.Checked then begin
Options.EasyType.EasyType:=1;
frmTARConsole.txtConsole.Font.Color:=Options.Color[1].Text;
frmTARConsole.txtConsole.Color:=Options.Color[1].Console;
frmTARConsole.color:=Options.Color[1].Border;
end
else begin
Options.EasyType.EasyType:=0;
frmTARConsole.txtConsole.Font.Color:=Options.Color[2].Text;
frmTARConsole.txtConsole.Color:=Options.Color[2].Console;
frmTARConsole.color:=Options.Color[2].Border;
end;
frmTARConsole.BorderWidth:=Options.Show.BorderSize;
end;
// Âûðåçàåò â áóôåð îáìåíà
procedure TfrmTARConsole.mnuCutClick(Sender: TObject);
begin
if (not Unded) and Options.Undo.UseUndo then
AddUndo(txtConsole.Text, txtConsole.SelStart, txtConsole.SelLength);
txtConsole.CutToClipboard;
end;
// Êîïèðóåò â áóôåð îáìåíà
procedure TfrmTARConsole.mnuCopyClick(Sender: TObject);
begin
txtConsole.CopyToClipboard;
end;
// Âñòàâëÿåò èç áóôåðà îáìåíà
procedure TfrmTARConsole.mnuPasteClick(Sender: TObject);
begin
if (not Unded) and Options.Undo.UseUndo then
AddUndo(txtConsole.Text, txtConsole.SelStart, txtConsole.SelLength);
txtConsole.PasteFromClipboard;
end;
// Ñðàçó ñîçäàåì íîâûé àëèàñ
procedure TfrmTARConsole.mnuNewAliasClick(Sender: TObject);
begin
if txtConsole.Text<>'' then
AddToProgram('--add='+txtConsole.Text)
else
AddToProgram('--add=!@#$%^&*()');
end;
// Óäàëåíèå ñòðîêè ïðÿìî èç êîíñîëè
procedure TfrmTARConsole.mnuDelStringClick(Sender: TObject);
var
strCon: string;
i: integer;
begin
strCon:=Trim(txtConsole.Text);
if strCon<>'' then begin
i:=0;
while i<ConfigStr.Count do begin
if strCon=GetName('alias', ConfigStr.Strings[i]) then begin
ConfigStr.Delete(i);
SaveConfig(Program_Config);
txtConsole.Clear;
end;
Inc(i);
end;
i:=0;
while i<HistoryStr.Count do begin
if strCon=HistoryStr.Strings[i] then begin
HistoryStr.Delete(i);
SaveHistory(Program_History);
ReadHistory(Program_History);
// Ïåðåìåùåíèå óêàçàòåëÿ â ñîñåäíþþ ïîçèöèþ
if HistoryStr.Count>0 then begin
HisViewPos:=i;
if HisViewPos=0 then HisViewPos:=1;
HistoryUp;
end
else
txtConsole.Clear;
end;
Inc(i);
end;
end;
end;
// Îáðàáîòêà êëàâèøè TAB
procedure TfrmTARConsole.WMDialogKey(var Msg: TCMDialogKey);
begin
if Msg.Charcode<>VK_TAB then inherited;
end;
// Ïîêàçûâàòü êîíñîëü ïðè äâîéíîì ùåë÷êå
procedure TfrmTARConsole.trayIconDblClick(Sender: TObject);
begin
Showcon;
end;
// Ìåíþ â òðåå. Óáèðàþòñÿ ìåíþõè, îòíîñÿùèåñÿ ê ïîëþ ðåäàêòèðîâàíèÿ.
procedure TfrmTARConsole.trayIconMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if (Button=mbRight) then MainMenuEvent:=1;
end;
// Ëîâèì ñîîáùåíèå îêíó
procedure TfrmTARConsole.WndProc;
var
Buf: array[Byte] of Char;
begin
if Message.Msg=WM_SendFileNameToOpen then begin
GlobalGetAtomName(Message.LParam, Buf, 255);
AddToProgram(Buf);
end
else
inherited WndProc(Message);
end;
// Ïðè ñêðûòèè ôîðìû óáðàòü ïîäñêàçêó
procedure TfrmTARConsole.FormHide(Sender: TObject);
begin
ViewHint('');
if frmTypeDropDown<>nil then frmTypeDropDown.Close;
end;
// Óäàëèòü äðîïäàóííóþ ôîðìó
procedure TfrmTARConsole.FormActivate(Sender: TObject);
begin
if frmTypeDropDown<>nil then frmTypeDropDown.Close;
end;
// Îòêðûâàåò ïàïêó ñ ýòèì àëèàñîì
procedure TfrmTARConsole.mnuOpenFolderClick(Sender: TObject);
var
strCon: string;
i: integer;
begin
strCon:=Trim(txtConsole.Text);
HideCon;
if strCon<>'' then begin
for i:=0 to ConfigStr.Count-1 do begin
if (GetProgName(strCon)=GetName('alias', ConfigStr.Strings[i])) or (not Options.EasyType.CaseSensitivity and (AnsiLowerCase(GetProgName(strCon))=AnsiLowerCase(GetName('alias', ConfigStr.Strings[i])))) then begin
{if GetName('dir', ConfigStr.Strings[i])<>'' then
ExecFolder(GetName('dir', ConfigStr.Strings[i]))
else} if GetProgPath(GetName('action', ConfigStr.Strings[i]))<>'' then
ExecFolder(GetProgPath(GetName('action', ConfigStr.Strings[i])));
end;
end;
for i:=0 to Options.SystemAliases.Name.Count-1 do begin
if (GetProgName(strCon)=Options.SystemAliases.Name.Strings[i]) or (not Options.EasyType.CaseSensitivity and (AnsiLowerCase(GetProgName(strCon))=AnsiLowerCase(Options.SystemAliases.Name.Strings[i]))) then begin
{if GetSysName('path', i)<>'' then
ExecFolder(GetSysName('path', i))
else }if GetProgPath(Options.SystemAliases.Action.Strings[i])<>'' then
ExecFolder(GetProgPath(Options.SystemAliases.Action.Strings[i]));
end;
end;
end;
end;
// Çàêðûòèå ôîðìû
procedure TfrmTARConsole.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
FormDestroy(Sender);
end;
// Óíè÷òîæåíèå ôîðìû
procedure TfrmTARConsole.FormDestroy(Sender: TObject);
begin
if CanUnload then begin
CanUnload:=false;
ViewHint('');
if frmTypeDropDown<>nil then begin
frmTypeDropDown.Free;
frmTypeDropDown:=nil;
end;
if frmHint<>nil then begin
frmHint.Free;
frmHint:=nil;
end;
if frmAbout<>nil then begin
frmAbout.Free;
frmAbout:=nil;
end;
if frmSettings<>nil then begin
frmSettings.Free;
frmSettings:=nil;
end;
UnBindHotKey(HotKeyId, frmTARConsole.Handle);
trayIcon.Enabled:=False;
// Ñîõðàíÿåò ïðè âûõîäå âñå íàñòðîéêè
Options.SaveSettings;
Options.Free;
SaveConfig(Program_Config);
SaveHistory(Program_History);
SavePlugins(Program_Plugin);
UnloadPlugins;
tmpAliasStr.Free;
ConfigStr.Free;
HistoryStr.Free;
end;
end;
// Ïîêàç ãëàâíîãî ìåíþ ïðîãðàììû
procedure TfrmTARConsole.mnuMainPopup(Sender: TObject);
begin
if MainMenuEvent=0 then begin
mnuShowConsole.Visible:=False;
mnuHideConsole.Visible:=True;
mnuBorder2.Visible:=True;
mnuCut.Visible:=True;
mnuCopy.Visible:=True;
mnuPaste.Visible:=True;
mnuBorder3.Visible:=True;
mnuClear.Visible:=True;
mnuSelectAll.Visible:=True;
mnuUndo.Visible:=Options.Undo.UseUndo;
mnuBorder4.Visible:=True;
mnuNewAlias.Visible:=True;
mnuDelString.Visible:=True;
mnuOpenFolder.Visible:=True;
mnuBorder5.Visible:=True;
mnuToggleET.Visible:=True;
end;
if MainMenuEvent=1 then begin
mnuShowConsole.Visible:=True;
mnuHideConsole.Visible:=False;
mnuBorder2.Visible:=False;
mnuCut.Visible:=False;
mnuCopy.Visible:=False;
mnuPaste.Visible:=False;
mnuBorder3.Visible:=False;
mnuClear.Visible:=False;
mnuSelectAll.Visible:=False;
mnuUndo.Visible:=False;
mnuBorder4.Visible:=False;
mnuNewAlias.Visible:=False;
mnuDelString.Visible:=False;
mnuOpenFolder.Visible:=False;
mnuBorder5.Visible:=False;
mnuToggleET.Visible:=False;
end;
MainMenuEvent:=0;
end;
end.