Rev 24 | Rev 49 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 24 | Rev 25 | ||
---|---|---|---|
Line 41... | Line 41... | ||
41 | TSynEditFindReplace = class(TComponent) |
41 | TSynEditFindReplace = class(TComponent) |
42 | private |
42 | private |
43 | fEditor: TSynEdit; |
43 | fEditor: TSynEdit; |
44 | fReplaceDialog: TReplaceDialog; |
44 | fReplaceDialog: TReplaceDialog; |
45 | fFindDialog: TFindDialog; |
45 | fFindDialog: TFindDialog; |
- | 46 | fAutofocus: boolean; |
|
46 | protected |
47 | protected |
47 | type |
48 | type |
48 | TFindDirection = (sdDefault, sdForwards, sdBackwards); |
49 | TFindDirection = (sdDefault, sdForwards, sdBackwards); |
49 | 50 | ||
50 | procedure OnFind(Sender: TObject); virtual; |
51 | procedure OnFind(Sender: TObject); virtual; |
Line 72... | Line 73... | ||
72 | 73 | ||
73 | procedure GoToLine(LineNumber: integer); |
74 | procedure GoToLine(LineNumber: integer); |
74 | 75 | ||
75 | published |
76 | published |
76 | property Editor: TSynEdit read fEditor write fEditor; |
77 | property Editor: TSynEdit read fEditor write fEditor; |
- | 78 | property Autofocus: boolean read fAutofocus write fAutofocus; |
|
77 | end; |
79 | end; |
78 | 80 | ||
79 | implementation |
81 | implementation |
80 | 82 | ||
81 | uses |
83 | uses |
Line 140... | Line 142... | ||
140 | if direction = sdForwards then |
142 | if direction = sdForwards then |
141 | ShowMessage('End of document reached.') |
143 | ShowMessage('End of document reached.') |
142 | else |
144 | else |
143 | ShowMessage('Begin of document reached.'); |
145 | ShowMessage('Begin of document reached.'); |
144 | end; |
146 | end; |
- | 147 | ||
- | 148 | if fAutofocus and fEditor.CanFocus then fEditor.SetFocus; |
|
145 | end; |
149 | end; |
146 | 150 | ||
147 | procedure TSynEditFindReplace.DoReplace(dialog: TReplaceDialog; direction: TFindDirection); |
151 | procedure TSynEditFindReplace.DoReplace(dialog: TReplaceDialog; direction: TFindDirection); |
148 | var |
152 | var |
149 | opt: TSynSearchOptions; |
153 | opt: TSynSearchOptions; |
Line 168... | Line 172... | ||
168 | finally |
172 | finally |
169 | //fEditor.EndUndoBlock; |
173 | //fEditor.EndUndoBlock; |
170 | fEditor.EndUpdate; |
174 | fEditor.EndUpdate; |
171 | end; |
175 | end; |
172 | 176 | ||
173 | // TODO: numReplacements anzeigen |
177 | ShowMessageFmt('%d replaced.', [numReplacements]); |
- | 178 | ||
- | 179 | if fAutofocus and fEditor.CanFocus then fEditor.SetFocus; |
|
174 | end; |
180 | end; |
175 | 181 | ||
176 | procedure TSynEditFindReplace.OnFind(Sender: TObject); |
182 | procedure TSynEditFindReplace.OnFind(Sender: TObject); |
177 | begin |
183 | begin |
178 | DoFind(Sender as TFindDialog, sdDefault); |
184 | DoFind(Sender as TFindDialog, sdDefault); |