-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
TextEditForm.pas
73 lines (59 loc) · 1.6 KB
/
TextEditForm.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
unit TextEditForm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,
InflatablesList_Manager;
type
TfTextEditForm = class(TForm)
meText: TMemo;
procedure meTextKeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
fILManager: TILManager;
public
{ Public declarations }
procedure Initialize(ILManager: TILManager);
procedure Finalize;
procedure ShowTextEditor(const Title: String; var Text: String; ProportionalFont: Boolean);
end;
var
fTextEditForm: TfTextEditForm;
implementation
{$R *.dfm}
procedure TfTextEditForm.Initialize(ILManager: TILManager);
begin
fILManager := ILManager;
end;
//------------------------------------------------------------------------------
procedure TfTextEditForm.Finalize;
begin
// nothing to do here
end;
//------------------------------------------------------------------------------
procedure TfTextEditForm.ShowTextEditor(const Title: String; var Text: String; ProportionalFont: Boolean);
begin
Caption := Title;
If ProportionalFont then
meText.Font.Name := 'Tahoma'
else
meText.Font.Name := 'Courier New';
meText.Text := Text;
// set cursor at the end of text
If Length(meText.Text) > 0 then
meText.SelStart := Length(meText.Text);
ShowModal;
Text := meText.Text;
end;
//==============================================================================
procedure TfTextEditForm.meTextKeyPress(Sender: TObject; var Key: Char);
begin
case Key of
^A: begin
meText.SelectAll;
Key := #0;
end;
#27: Close; // escape
end;
end;
end.