-
Notifications
You must be signed in to change notification settings - Fork 9
/
DzNotepad.pas
103 lines (78 loc) · 1.97 KB
/
DzNotepad.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
{------------------------------------------------------------------------------
TDzNotepad component
Developed by Rodrigo Depine Dalpiaz (digao dalpiaz)
Non visual component to store TStrings at DFM file
https://github.com/digao-dalpiaz/DzNoteEditor
Please, read the documentation at GitHub link.
------------------------------------------------------------------------------}
unit DzNotepad;
interface
uses System.Classes;
type TDzNotepad = class(TComponent)
private
FAbout: string;
S: TStrings;
procedure SetLines(const Value: TStrings);
function GetCount: Integer;
function GetText: string;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property Text: string read GetText;
property Count: Integer read GetCount;
procedure Add(const A: string);
procedure Sort;
procedure Clear;
function Has(const A: string): Boolean;
function AddIfNotEx(const A: string): Boolean;
published
property About: string read FAbout;
property Lines: TStrings read S write SetLines;
end;
implementation
const STR_VERSION = '1.7';
constructor TDzNotepad.Create(AOwner: TComponent);
begin
inherited;
FAbout := 'Digao Dalpiaz / Version '+STR_VERSION;
S := TStringList.Create;
end;
destructor TDzNotepad.Destroy;
begin
S.Free;
inherited;
end;
procedure TDzNotepad.SetLines(const Value: TStrings);
begin
S.Assign(Value);
end;
function TDzNotepad.GetCount: Integer;
begin
Result := S.Count;
end;
procedure TDzNotepad.Sort;
begin
TStringList(S).Sort;
end;
procedure TDzNotepad.Add(const A: string);
begin
S.Add(A);
end;
function TDzNotepad.GetText: string;
begin
Result := S.Text;
end;
procedure TDzNotepad.Clear;
begin
S.Clear;
end;
function TDzNotepad.Has(const A: string): Boolean;
begin
Result := ( S.IndexOf(A) <> (-1) );
end;
function TDzNotepad.AddIfNotEx(const A: string): Boolean;
begin
Result := not Has(A);
if Result then Add(A);
end;
end.