• R/O
  • SSH
  • HTTPS

denkzettelcompanion: Commit


Commit MetaInfo

Revision53 (tree)
Zeit2018-12-31 04:01:36
Autordummzeuch

Log Message

added incremental search to category and notes list

Ändern Zusammenfassung

Diff

--- trunk/src/u_dzlazutils.pas (revision 52)
+++ trunk/src/u_dzlazutils.pas (revision 53)
@@ -5,6 +5,7 @@
55 interface
66
77 uses
8+ Windows,
89 SysUtils,
910 Types,
1011 Classes,
@@ -17,12 +18,12 @@
1718 const
1819 TRICOLON = #$E2#$81#$9D; // UTF-8 for #$205D tricolon unicode character
1920
20-procedure EnumDirectories(const _Base: string; _Dirs: TStrings;
21- _Sorted: boolean = True; _FullName: boolean = True; const _Mask: string = '*');
22-procedure EnumFiles(const _Base: string; const _Mask: string; _Files: TStrings; _Sorted: boolean = True;
23- _FullName: boolean = True; _AdditionalAttribs: integer = 0); overload;
24-procedure EnumFiles(const _FullMask: string; _Files: TStrings; _Sorted: boolean = True;
25- _FullName: boolean = True; _AdditionalAttribs: integer = 0); overload;
21+procedure EnumDirectories(const _Base: String; _Dirs: TStrings;
22+ _Sorted: Boolean = True; _FullName: Boolean = True; const _Mask: String = '*');
23+procedure EnumFiles(const _Base: String; const _Mask: String; _Files: TStrings; _Sorted: Boolean = True;
24+ _FullName: Boolean = True; _AdditionalAttribs: Integer = 0); overload;
25+procedure EnumFiles(const _FullMask: String; _Files: TStrings; _Sorted: Boolean = True;
26+ _FullName: Boolean = True; _AdditionalAttribs: Integer = 0); overload;
2627 ///<summary>
2728 /// Find a file matching the mask and return its name. If there are more than one matches, return
2829 /// the first.
@@ -29,9 +30,9 @@
2930 /// @param Mask is the mask the filen name must match
3031 /// @param fn is the first file that was found, if any. Only valid if Result >0
3132 /// @returns the number of matching files found. </summary>
32-function FindMatchingFile(const _Mask: string; out _fn: string; _FullName: boolean = True): integer;
33+function FindMatchingFile(const _Mask: String; out _fn: String; _FullName: Boolean = True): Integer;
3334
34-function IsValidFileName(const _Filename: string): boolean;
35+function IsValidFileName(const _Filename: String): Boolean;
3536
3637 procedure TForm_CenterOn(_frm: TForm; _Owner: TWinControl); overload;
3738 function TForm_GetCenter(_frm: TForm): TPoint;
@@ -40,36 +41,57 @@
4041
4142 procedure TWinControl_SetFocus(_ctrl: TWinControl);
4243
43-function TApplication_GetDefaultIniFile: string;
44-function TApplication_GetExeDir: string;
45-function TApplication_GetExeDirBS: string;
44+function TApplication_GetDefaultIniFile: String;
45+function TApplication_GetExeDir: String;
46+function TApplication_GetExeDirBS: String;
4647
4748 procedure TButton_DrowpdownMenu(_btn: TButton; _pm: TPopupMenu);
4849
49-function MessageDlgCentered(_Owner: TWinControl; const aMsg: string; DlgType: TMsgDlgType;
50- Buttons: TMsgDlgButtons; HelpCtx: longint = 0): TModalResult;
50+function MessageDlgCentered(_Owner: TWinControl; const aMsg: String; DlgType: TMsgDlgType;
51+ Buttons: TMsgDlgButtons; HelpCtx: Longint = 0): TModalResult;
5152
53+type
54+
55+ { TIncLookupHelper }
56+
57+ TIncLookupHelper = class(TComponent)
58+ private
59+ FEdit: TEdit;
60+ FList: TListBox;
61+ FOldEditChange: TNotifyEvent;
62+ FOldEditKeyDown: TKeyEvent;
63+ FOldListKeyDown: TKeyEvent;
64+ FOldListKeyPress: TKeyPressEvent;
65+ procedure HandleEditChange(Sender: TObject);
66+ procedure HandleEditKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
67+ procedure HandleListKeyPress(Sender: TObject; var Key: Char);
68+ procedure HandleListKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
69+ public
70+ constructor Create(_ed: TEdit; _lb: TListBox); reintroduce;
71+ destructor Destroy; override;
72+ end;
73+
5274 implementation
5375
54-function TApplication_GetDefaultIniFile: string;
76+function TApplication_GetDefaultIniFile: String;
5577 begin
5678 Result := ChangeFileExt(Application.ExeName, '.ini');
5779 end;
5880
59-function TApplication_GetExeDir: string;
81+function TApplication_GetExeDir: String;
6082 begin
6183 Result := ExtractFileDir(Application.ExeName);
6284 end;
6385
64-function TApplication_GetExeDirBS: string;
86+function TApplication_GetExeDirBS: String;
6587 begin
6688 Result := IncludeTrailingPathDelimiter(TApplication_GetExeDir);
6789 end;
6890
69-procedure EnumDirectories(const _Base: string; _Dirs: TStrings;
70- _Sorted: boolean = True; _FullName: boolean = True; const _Mask: string = '*');
91+procedure EnumDirectories(const _Base: String; _Dirs: TStrings;
92+ _Sorted: Boolean = True; _FullName: Boolean = True; const _Mask: String = '*');
7193 var
72- Base: string;
94+ Base: String;
7395 SearchRec: TRawByteSearchRec;
7496 Dirs: TStringList;
7597 begin
@@ -96,18 +118,18 @@
96118 end;
97119 end;
98120
99-procedure EnumFiles(const _Base: string; const _Mask: string; _Files: TStrings; _Sorted: boolean = True;
100- _FullName: boolean = True; _AdditionalAttribs: integer = 0);
121+procedure EnumFiles(const _Base: String; const _Mask: String; _Files: TStrings; _Sorted: Boolean = True;
122+ _FullName: Boolean = True; _AdditionalAttribs: Integer = 0);
101123 begin
102124 EnumFiles(IncludeTrailingPathDelimiter(_Base) + _Mask, _Files, _Sorted, _FullName, _AdditionalAttribs);
103125 end;
104126
105-procedure EnumFiles(const _FullMask: string; _Files: TStrings; _Sorted: boolean = True;
106- _FullName: boolean = True; _AdditionalAttribs: integer = 0);
127+procedure EnumFiles(const _FullMask: String; _Files: TStrings; _Sorted: Boolean = True;
128+ _FullName: Boolean = True; _AdditionalAttribs: Integer = 0);
107129 var
108130 SearchRec: TRawbyteSearchRec;
109131 Files: TStringList;
110- Base: string;
132+ Base: String;
111133 begin
112134 _Files.Clear;
113135 if FindFirst(_FullMask, faArchive + _AdditionalAttribs, SearchRec) = 0 then begin
@@ -133,7 +155,7 @@
133155 end;
134156 end;
135157
136-function FindMatchingFile(const _Mask: string; out _fn: string; _FullName: boolean = True): integer;
158+function FindMatchingFile(const _Mask: String; out _fn: String; _FullName: Boolean = True): Integer;
137159 var
138160 Files: TStringList;
139161 begin
@@ -186,8 +208,8 @@
186208 _pm.PopUp(pnt.x, pnt.y);
187209 end;
188210
189-function MessageDlgCentered(_Owner: TWinControl; const aMsg: string; DlgType: TMsgDlgType;
190- Buttons: TMsgDlgButtons; HelpCtx: longint): TModalResult;
211+function MessageDlgCentered(_Owner: TWinControl; const aMsg: String; DlgType: TMsgDlgType;
212+ Buttons: TMsgDlgButtons; HelpCtx: Longint): TModalResult;
191213 var
192214 Center: TPoint;
193215 begin
@@ -195,11 +217,11 @@
195217 Result := MessageDlgPos(aMsg, DlgType, Buttons, HelpCtx, Center.x, Center.y);
196218 end;
197219
198-function IsValidFileName(const _Filename: string): boolean;
220+function IsValidFileName(const _Filename: String): Boolean;
199221 const
200- InvalidCharacters: set of char = ['\', '/', ':', '*', '?', '"', '<', '>', '|', #9, #13, #10];
222+ InvalidCharacters: set of Char = ['\', '/', ':', '*', '?', '"', '<', '>', '|', #9, #13, #10];
201223 var
202- c: char;
224+ c: Char;
203225 begin
204226 Result := _Filename <> '';
205227
@@ -211,6 +233,138 @@
211233 end;
212234 end;
213235
236+{ TIncLookupHelper }
237+
238+constructor TIncLookupHelper.Create(_ed: TEdit; _lb: TListBox);
239+begin
240+ inherited Create(_ed);
241+ FEdit := _ed;
242+ FList := _lb;
243+
244+ FOldEditKeyDown := FEdit.OnKeyDown;
245+ FEdit.OnKeyDown := @HandleEditKeyDown;
246+
247+ FOldEditChange := FEdit.OnChange;
248+ FEdit.OnChange := @HandleEditChange;
249+
250+ FOldListKeyDown := FList.OnKeyDown;
251+ FList.OnKeyDown := @HandleListKeyDown;
252+
253+ FOldListKeyPress := FList.OnKeyPress;
254+ FList.OnKeyPress := @HandleListKeyPress;
255+end;
256+
257+destructor TIncLookupHelper.Destroy;
258+begin
259+ if Assigned(FEdit) then begin
260+ FEdit.OnKeyDown := FOldEditKeyDown;
261+ FEdit.OnChange := FOldEditChange;
262+ end;
263+ if Assigned(FList) then begin
264+ FList.OnKeyDown := FOldListKeyDown;
265+ FList.OnKeyPress := FOldListKeyPress;
266+ end;
267+ inherited Destroy;
268+end;
269+
270+procedure TIncLookupHelper.HandleEditChange(Sender: TObject);
271+var
272+ s: String;
273+ i: Integer;
274+begin
275+ s := FEdit.Text;
276+ while s <> '' do begin
277+ for i := 0 to FList.Items.Count - 1 do begin
278+ if SameText(s, LeftStr(FList.Items[i], Length(s))) then begin
279+ FList.ItemIndex := i;
280+ Exit; //==>
281+ end;
282+ end;
283+ s := LeftStr(s, Length(s) - 1);
284+ end;
285+ if Assigned(FOldEditChange) then
286+ FOldEditChange(Sender);
287+end;
288+
289+procedure TIncLookupHelper.HandleEditKeyDown(Sender: TObject; var Key: Word;
290+ Shift: TShiftState);
291+var
292+ Idx: Integer;
293+begin
294+ Idx := FList.ItemIndex;
295+ case Key of
296+ VK_UP: begin
297+ Key := 0;
298+ if Idx > 0 then
299+ FList.ItemIndex := Idx - 1;
300+ end;
301+ VK_DOWN: begin
302+ Key := 0;
303+ if Idx < FList.Items.Count then
304+ FList.ItemIndex := Idx + 1;
305+ end;
306+ VK_PRIOR: begin
307+ Key := 0;
308+ if Idx > 0 then begin
309+ Dec(Idx, 10);
310+ if Idx < 0 then
311+ Idx := 0;
312+ FList.ItemIndex := Idx;
313+ end;
314+ end;
315+ VK_NEXT: begin
316+ Key := 0;
317+ if Idx < FList.Items.Count then
318+ Inc(Idx, 10);
319+ if Idx >= FList.Items.Count then
320+ Idx := FList.Items.Count - 1;
321+ FList.ItemIndex := Idx;
322+ end;
323+ VK_ESCAPE: begin
324+ Key := 0;
325+ FEdit.Text := '';
326+ FEdit.Visible := False;
327+ end;
328+ end;
329+ if Assigned(FOldEditKeyDown) then
330+ FOldEditKeyDown(Sender, Key, Shift);
331+end;
332+
333+procedure TIncLookupHelper.HandleListKeyDown(Sender: TObject; var Key: Word;
334+ Shift: TShiftState);
335+var
336+ s: TCaption;
337+begin
338+ if Key = VK_F3 then begin
339+ Key := 0;
340+ FEdit.Visible := True;
341+ FEdit.SetFocus;
342+ end else if Key = VK_BACK then begin
343+ Key := 0;
344+ s := FEdit.Text;
345+ if s <> '' then
346+ FEdit.Text := LeftStr(s, Length(s) - 1);
347+ end else if Key = VK_ESCAPE then begin
348+ Key := 0;
349+ FEdit.Text := '';
350+ FEdit.Visible := False;
351+ end;
352+ if Assigned(FOldListKeyDown) then
353+ FOldListKeyDown(Sender, key, Shift);
354+end;
355+
356+procedure TIncLookupHelper.HandleListKeyPress(Sender: TObject; var Key: Char);
357+begin
358+ if Key in ['a'..'z', 'A'..'Z', '0'..'1'] then begin
359+ FEdit.Visible := True;
360+ FEdit.SelText := Key;
361+ FEdit.SetFocus;
362+ FEdit.SelStart := Length(FEdit.Text);
363+ Key := #0;
364+ end;
365+ if Assigned(FOldListKeyPress) then
366+ FOldListKeyPress(Sender, key);
367+end;
368+
214369 end.
215370
216-
--- trunk/src/wf_categories.pas (revision 52)
+++ trunk/src/wf_categories.pas (revision 53)
@@ -5,7 +5,9 @@
55 interface
66
77 uses
8+ Windows,
89 Classes,
10+ Types,
911 SysUtils,
1012 FileUtil,
1113 Forms,
@@ -13,8 +15,7 @@
1315 StdCtrls,
1416 ExtCtrls,
1517 Menus,
16- wf_Notes,
17- Types;
18+ wf_Notes;
1819
1920 type
2021
@@ -23,7 +24,8 @@
2324 Tfr_Categories = class(TFrame)
2425 b_Menu: TButton;
2526 b_NewCategory: TButton;
26- lb_Categories: TListBox;
27+ ed_Filter: TEdit;
28+ lb_Items: TListBox;
2729 l_NoNotes: TLabel;
2830 mi_About: TMenuItem;
2931 mi_Configure: TMenuItem;
@@ -33,28 +35,29 @@
3335 p_Main: TPanel;
3436 p_NoCategories: TPanel;
3537 procedure b_MenuClick(Sender: TObject);
38+ procedure ed_FilterKeyPress(Sender: TObject; var Key: char);
3639 procedure FrameEnter(Sender: TObject);
3740 procedure FrameResize(Sender: TObject);
38- procedure lb_CategoriesDrawItem(Control: TWinControl; Index: integer;
41+ procedure lb_ItemsDrawItem(Control: TWinControl; Index: Integer;
3942 ARect: TRect; State: TOwnerDrawState);
4043 procedure mi_AboutClick(Sender: TObject);
4144 procedure mi_NewCategoryClick(Sender: TObject);
4245 procedure mi_ConfigureClick(Sender: TObject);
43- procedure lb_CategoriesDblClick(Sender: TObject);
44- procedure lb_CategoriesKeyPress(Sender: TObject; var Key: char);
46+ procedure lb_ItemsDblClick(Sender: TObject);
47+ procedure lb_ItemsKeyPress(Sender: TObject; var Key: Char);
4548 private
46- FBasePath: ^string;
49+ FBasePath: ^String;
4750 FNotesFrame: Tfr_Notes;
48- function BasePathBS: string;
49- function TryGetCategory(out _Category: string): boolean;
51+ function BasePathBS: String;
52+ function TryGetCategory(out _Category: String): Boolean;
5053 procedure OnCloseCategory(_Sender: TObject);
5154 public
5255 constructor Create(_Owner: TComponent); override;
53- procedure Init(var _BasePath: string);
56+ procedure Init(var _BasePath: String);
5457 procedure GoBack;
5558 procedure OpenSelected;
5659 procedure ShowMenu;
57- procedure OnCloseQuery(_Sender: TObject; var _CanClose: boolean);
60+ procedure OnCloseQuery(_Sender: TObject; var _CanClose: Boolean);
5861 end;
5962
6063 implementation
@@ -83,18 +86,20 @@
8386 FNotesFrame.Parent := Self;
8487 FNotesFrame.Align := alClient;
8588 FNotesFrame.OnClose := @OnCloseCategory;
89+
90+ TIncLookupHelper.Create(ed_Filter, lb_Items);
8691 end;
8792
88-procedure Tfr_Categories.Init(var _BasePath: string);
93+procedure Tfr_Categories.Init(var _BasePath: String);
8994 begin
9095 FBasePath := @_BasePath;
9196
92- EnumDirectories(BasePathBS, lb_Categories.Items, True, False);
93- p_NoCategories.Visible := (lb_Categories.Count = 0);
94- TWinControl_SetFocus(lb_Categories);
97+ EnumDirectories(BasePathBS, lb_Items.Items, True, False);
98+ p_NoCategories.Visible := (lb_Items.Count = 0);
99+ TWinControl_SetFocus(lb_Items);
95100 end;
96101
97-procedure Tfr_Categories.OnCloseQuery(_Sender: TObject; var _CanClose: boolean);
102+procedure Tfr_Categories.OnCloseQuery(_Sender: TObject; var _CanClose: Boolean);
98103 begin
99104 if not Assigned(FNotesFrame) or not FNotesFrame.Visible then
100105 Exit; //==>
@@ -103,7 +108,7 @@
103108
104109 procedure Tfr_Categories.OpenSelected;
105110 var
106- Category: string;
111+ Category: String;
107112 begin
108113 if not Assigned(FNotesFrame) then
109114 Exit; //==>
@@ -112,18 +117,18 @@
112117 else begin
113118 if not TryGetCategory(Category) then
114119 Exit; //==>
115- FNotesFrame.Init(Category, BasePathBS + Category, lb_Categories.Items);
120+ FNotesFrame.Init(Category, BasePathBS + Category, lb_Items.Items);
116121 FNotesFrame.Visible := True;
117122 p_Main.Visible := False;
118123 end;
119124 end;
120125
121-procedure Tfr_Categories.lb_CategoriesDblClick(Sender: TObject);
126+procedure Tfr_Categories.lb_ItemsDblClick(Sender: TObject);
122127 begin
123128 OpenSelected;
124129 end;
125130
126-procedure Tfr_Categories.lb_CategoriesKeyPress(Sender: TObject; var Key: char);
131+procedure Tfr_Categories.lb_ItemsKeyPress(Sender: TObject; var Key: Char);
127132 begin
128133 if Key in [#13, #10] then
129134 OpenSelected;
@@ -154,32 +159,38 @@
154159 ShowMenu;
155160 end;
156161
162+procedure Tfr_Categories.ed_FilterKeyPress(Sender: TObject; var Key: char);
163+begin
164+ if Key in [#13, #10] then
165+ OpenSelected;
166+end;
167+
157168 procedure Tfr_Categories.FrameEnter(Sender: TObject);
158169 begin
159- TWinControl_SetFocus(lb_Categories);
160- if lb_Categories.ItemIndex = -1 then
161- if lb_Categories.Items.Count > 0 then
162- lb_Categories.ItemIndex := 0;
170+ TWinControl_SetFocus(lb_Items);
171+ if lb_Items.ItemIndex = -1 then
172+ if lb_Items.Items.Count > 0 then
173+ lb_Items.ItemIndex := 0;
163174 end;
164175
165176 procedure Tfr_Categories.FrameResize(Sender: TObject);
166177 var
167- w, h: integer;
178+ w, h: Integer;
168179 begin
169- w := lb_Categories.Width;
180+ w := lb_Items.Width;
170181 w := w - p_NoCategories.Width;
171- p_NoCategories.Left := lb_Categories.Left + w div 2;
172- h := lb_Categories.Height;
182+ p_NoCategories.Left := lb_Items.Left + w div 2;
183+ h := lb_Items.Height;
173184 h := h - p_NoCategories.Height;
174- p_NoCategories.Top := lb_Categories.Top + h div 2;
185+ p_NoCategories.Top := lb_Items.Top + h div 2;
175186 end;
176187
177-procedure Tfr_Categories.lb_CategoriesDrawItem(Control: TWinControl;
178- Index: integer; ARect: TRect; State: TOwnerDrawState);
188+procedure Tfr_Categories.lb_ItemsDrawItem(Control: TWinControl;
189+ Index: Integer; ARect: TRect; State: TOwnerDrawState);
179190 var
180191 lb: TListBox absolute Control;
181192 cnv: TCanvas;
182- s: string;
193+ s: String;
183194 begin
184195 s := lb.Items[Index];
185196 cnv := lb.Canvas;
@@ -195,7 +206,7 @@
195206
196207 procedure Tfr_Categories.mi_NewCategoryClick(Sender: TObject);
197208 var
198- NewCategory: string;
209+ NewCategory: String;
199210 begin
200211 if Tf_NewCategory.Execute(Self, BasePathBS, NewCategory) then
201212 Init(FBasePath^);
@@ -207,20 +218,20 @@
207218 Init(FBasePath^);
208219 end;
209220
210-function Tfr_Categories.BasePathBS: string;
221+function Tfr_Categories.BasePathBS: String;
211222 begin
212223 Result := IncludeTrailingPathDelimiter(FBasePath^);
213224 end;
214225
215-function Tfr_Categories.TryGetCategory(out _Category: string): boolean;
226+function Tfr_Categories.TryGetCategory(out _Category: String): Boolean;
216227 var
217- Idx: integer;
228+ Idx: Integer;
218229 begin
219230 Result := False;
220- Idx := lb_Categories.ItemIndex;
231+ Idx := lb_Items.ItemIndex;
221232 if Idx = -1 then
222233 Exit; //==>
223- _Category := lb_Categories.Items[Idx];
234+ _Category := lb_Items.Items[Idx];
224235 Result := (_Category <> '');
225236 end;
226237
@@ -228,7 +239,7 @@
228239 begin
229240 FNotesFrame.Visible := False;
230241 p_Main.Visible := True;
231- TWinControl_SetFocus(lb_Categories);
242+ TWinControl_SetFocus(lb_Items);
232243 end;
233244
234245 end.
--- trunk/src/wf_notes.pas (revision 52)
+++ trunk/src/wf_notes.pas (revision 53)
@@ -24,6 +24,7 @@
2424 b_NewChecklist: TButton;
2525 b_NewNote: TButton;
2626 b_Menu: TButton;
27+ ed_Filter: TEdit;
2728 l_NoNotes: TLabel;
2829 mi_Move: TMenuItem;
2930 mi_Delete: TMenuItem;
@@ -33,13 +34,14 @@
3334 mi_About: TMenuItem;
3435 mi_NewNote: TMenuItem;
3536 b_Back: TButton;
36- lb_Notes: TListBox;
37+ lb_Items: TListBox;
3738 p_Main: TPanel;
3839 p_Top: TPanel;
40+ procedure ed_FilterKeyPress(Sender: TObject; var Key: char);
3941 procedure FrameEnter(Sender: TObject);
4042 procedure FrameResize(Sender: TObject);
41- procedure lb_NotesDrawItem(Control: TWinControl; Index: integer;
42- ARect: TRect; State: TOwnerDrawState);
43+ procedure lb_ItemsDrawItem(Control: TWinControl; Index: Integer; ARect: TRect;
44+ State: TOwnerDrawState);
4345 procedure mi_AboutClick(Sender: TObject);
4446 procedure b_BackClick(Sender: TObject);
4547 procedure b_MenuClick(Sender: TObject);
@@ -46,11 +48,11 @@
4648 procedure mi_DeleteClick(Sender: TObject);
4749 procedure mi_NewChecklistClick(Sender: TObject);
4850 procedure mi_NewNoteClick(Sender: TObject);
49- procedure lb_NotesDblClick(Sender: TObject);
50- procedure lb_NotesKeyPress(Sender: TObject; var Key: char);
51+ procedure lb_ItemsDblClick(Sender: TObject);
52+ procedure lb_ItemsKeyPress(Sender: TObject; var Key: Char);
5153 private
52- FCategory: string;
53- FCategoryPathBS: string;
54+ FCategory: String;
55+ FCategoryPathBS: String;
5456 FOnClose: TNotifyEvent;
5557 FEditFrame: Tfr_NoteEditor;
5658 FCategories: TStrings;
@@ -57,12 +59,12 @@
5759 procedure doOnClose;
5860 procedure mi_MoveToCategoryClick(_Sender: TObject);
5961 procedure OnCloseNote(_Sender: TObject);
60- function TryGetNoteFn(out _fn: string): boolean;
62+ function TryGetNoteFn(out _fn: String): Boolean;
6163 public
6264 constructor Create(_Owner: TComponent); override;
6365 destructor Destroy; override;
64- procedure Init(const _Category: string; const _CategoryPath: string; _Categories: TStrings);
65- procedure FormCloseQuery(_Sender: TObject; var _CanClose: boolean);
66+ procedure Init(const _Category: String; const _CategoryPath: String; _Categories: TStrings);
67+ procedure FormCloseQuery(_Sender: TObject; var _CanClose: Boolean);
6668 procedure GoBack;
6769 procedure OpenSelected;
6870 procedure ShowMenu;
@@ -96,6 +98,8 @@
9698 FEditFrame.Parent := Self;
9799 FEditFrame.Align := alClient;
98100 FEditFrame.OnClose := @OnCloseNote;
101+
102+ TIncLookupHelper.Create(ed_Filter, lb_Items);
99103 end;
100104
101105 destructor Tfr_Notes.Destroy;
@@ -104,12 +108,12 @@
104108 inherited Destroy;
105109 end;
106110
107-procedure Tfr_Notes.Init(const _Category: string; const _CategoryPath: string; _Categories: TStrings);
111+procedure Tfr_Notes.Init(const _Category: String; const _CategoryPath: String; _Categories: TStrings);
108112 var
109113 Files: TStringList;
110- i: integer;
111- fn, Title: string;
112- IsChecklist: boolean;
114+ i: Integer;
115+ fn, Title: String;
116+ IsChecklist: Boolean;
113117 NoteColor: TDenkzettelColor;
114118 mi: TMenuItem;
115119 begin
@@ -129,7 +133,7 @@
129133
130134 p_Top.Caption := _Category;
131135
132- lb_Notes.Items.Clear;
136+ lb_Items.Items.Clear;
133137 Files := TStringList.Create;
134138 try
135139 EnumFiles(FCategoryPathBS, '*.txt', Files, True, False);
@@ -137,13 +141,13 @@
137141 fn := files[i];
138142 if not DecodeFilename(fn, Title, IsChecklist, NoteColor) then
139143 Title := fn;
140- lb_Notes.Items.AddObject(Title, TObject(PropertiesToPointer(NoteColor, IsChecklist)));
144+ lb_Items.Items.AddObject(Title, TObject(PropertiesToPointer(NoteColor, IsChecklist)));
141145 end;
142146 p_NoNotes.Visible := (Files.Count = 0);
143147 finally
144148 FreeAndNil(Files);
145149 end;
146- TWinControl_SetFocus(lb_Notes);
150+ TWinControl_SetFocus(lb_Items);
147151 end;
148152
149153 procedure Tfr_Notes.OnCloseNote(_Sender: TObject);
@@ -153,7 +157,7 @@
153157 Init(FCategory, FCategoryPathBS, nil);
154158 end;
155159
156-procedure Tfr_Notes.FormCloseQuery(_Sender: TObject; var _CanClose: boolean);
160+procedure Tfr_Notes.FormCloseQuery(_Sender: TObject; var _CanClose: Boolean);
157161 begin
158162 if not Assigned(FEditFrame) or not FEditFrame.Visible then
159163 Exit; //==>
@@ -160,16 +164,16 @@
160164 FEditFrame.FormCloseQuery(_Sender, _CanClose);
161165 end;
162166
163-function Tfr_Notes.TryGetNoteFn(out _fn: string): boolean;
167+function Tfr_Notes.TryGetNoteFn(out _fn: String): Boolean;
164168 var
165- Idx: integer;
166- s: string;
169+ Idx: Integer;
170+ s: String;
167171 begin
168172 Result := False;
169- Idx := lb_Notes.ItemIndex;
173+ Idx := lb_Items.ItemIndex;
170174 if Idx = -1 then
171175 Exit; //==>
172- s := lb_Notes.Items[Idx];
176+ s := lb_Items.Items[Idx];
173177 if s = '' then
174178 Exit; //==>
175179 Result := FindMatchingFile(FCategoryPathBS + s + '*.*', _fn, False) > 0;
@@ -183,7 +187,7 @@
183187
184188 procedure Tfr_Notes.OpenSelected;
185189 var
186- fn: string;
190+ fn: String;
187191 begin
188192 if not Assigned(FEditFrame) then
189193 Exit; //==>
@@ -194,12 +198,12 @@
194198 p_Main.Visible := False;
195199 end;
196200
197-procedure Tfr_Notes.lb_NotesDblClick(Sender: TObject);
201+procedure Tfr_Notes.lb_ItemsDblClick(Sender: TObject);
198202 begin
199203 OpenSelected;
200204 end;
201205
202-procedure Tfr_Notes.lb_NotesKeyPress(Sender: TObject; var Key: char);
206+procedure Tfr_Notes.lb_ItemsKeyPress(Sender: TObject; var Key: Char);
203207 begin
204208 if Key in [#13, #10] then
205209 OpenSelected;
@@ -235,7 +239,7 @@
235239
236240 procedure Tfr_Notes.mi_DeleteClick(Sender: TObject);
237241 var
238- Note: string;
242+ Note: String;
239243 begin
240244 if not TryGetNoteFn(Note) then
241245 Exit; //==>
@@ -266,11 +270,11 @@
266270 end;
267271
268272 // for whatever reason menus.pp does not have StripHotKey
269-// (even though it was added in may 2016, but that's probably not the main repository
273+// (even though it was added in May 2016, but that's probably not the main repository
270274 // https://github.com/alrieckert/lazarus/commit/8919d979e8cd628d1af2035fd9d230c69150c3cf
271-function StripHotkey(const Text: string): string;
275+function StripHotkey(const Text: String): String;
272276 var
273- I, R: integer;
277+ I, R: Integer;
274278 begin
275279 SetLength(Result, Length(Text));
276280 I := 1;
@@ -294,8 +298,8 @@
294298
295299 procedure Tfr_Notes.mi_MoveToCategoryClick(_Sender: TObject);
296300 var
297- Category: string;
298- Path, fn: string;
301+ Category: String;
302+ Path, fn: String;
299303 begin
300304 if not TryGetNoteFn(fn) then
301305 Exit; //==>
@@ -307,7 +311,7 @@
307311 Path := ExtractFileDir(path);
308312 Path := IncludeTrailingPathDelimiter(Path) + Category;
309313 Path := IncludeTrailingPathDelimiter(Path);
310- if not RenameFile(FCategoryPathBS+fn, Path+fn) then
314+ if not RenameFile(FCategoryPathBS + fn, Path + fn) then
311315 raise Exception.Create('Moving the note failed.');
312316 Init(FCategory, FCategoryPathBS, nil);
313317 end;
@@ -314,32 +318,38 @@
314318
315319 procedure Tfr_Notes.FrameEnter(Sender: TObject);
316320 begin
317- TWinControl_SetFocus(lb_Notes);
318- if lb_Notes.ItemIndex = -1 then
319- if lb_Notes.Items.Count > 0 then
320- lb_Notes.ItemIndex := 0;
321+ TWinControl_SetFocus(lb_Items);
322+ if lb_Items.ItemIndex = -1 then
323+ if lb_Items.Items.Count > 0 then
324+ lb_Items.ItemIndex := 0;
321325 end;
322326
327+procedure Tfr_Notes.ed_FilterKeyPress(Sender: TObject; var Key: char);
328+begin
329+ if Key in [#13, #10] then
330+ OpenSelected;
331+end;
332+
323333 procedure Tfr_Notes.FrameResize(Sender: TObject);
324334 var
325- w, h: integer;
335+ w, h: Integer;
326336 begin
327- w := lb_Notes.Width;
337+ w := lb_Items.Width;
328338 w := w - p_NoNotes.Width;
329- p_NoNotes.Left := lb_Notes.Left + w div 2;
330- h := lb_Notes.Height;
339+ p_NoNotes.Left := lb_Items.Left + w div 2;
340+ h := lb_Items.Height;
331341 h := h - p_NoNotes.Height;
332- p_NoNotes.Top := lb_Notes.Top + h div 2;
342+ p_NoNotes.Top := lb_Items.Top + h div 2;
333343 end;
334344
335-procedure Tfr_Notes.lb_NotesDrawItem(Control: TWinControl; Index: integer;
336- ARect: TRect; State: TOwnerDrawState);
345+procedure Tfr_Notes.lb_ItemsDrawItem(Control: TWinControl; Index: Integer; ARect: TRect;
346+ State: TOwnerDrawState);
337347 var
338348 lb: TListBox absolute Control;
339349 NoteColor: TDenkzettelColor;
340- IsChecklist: boolean;
350+ IsChecklist: Boolean;
341351 cnv: TCanvas;
342- s: string;
352+ s: String;
343353 begin
344354 s := lb.Items[Index];
345355 PointerToProperties(lb.Items.Objects[Index], NoteColor, IsChecklist);
Show on old repository browser