Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2001-12

Find and replace history

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Jarto Tarpio

I've just finished Find&Replace history. It works but unfortunately it's not really user friendly thanks to some bugs in TComboBox.

I changed the two TEdit-fields to TComboBox:s. Their Items-lists are filled with values from TEnvironmentOptions when the FindReplaceDlg is created. (At Lazarus startup)

When I open Find for the first time, the uniteditor does a FindReplaceDlg.FindText := whatever but this doesn't change anything in the ComboBox. It's showing the last string in the Items- list. On the following times the text is updated correctly but the TComboBox never gets focus. Not even if a
TextToFindEdit.SetFocus is added to
TLazFindReplaceDialog.SetFindText.

In other words: You have to click on the find-line Every Single Time you want to search for something. Needless to say that most of us are used to ctrl-F + happy typing + enter. So think twice before adding these diffs before TComboBox is fixed.

/jarto

diff -a -b environmentopts.pp orig/environmentopts.pp 93,97d92
< // Find- and replace-history
< FFindHistory: TStringList;
< FReplaceHistory: TStringList;
< FMaxFindHistory: Integer;
<
170,176d164
< // Find- and replace-history
< property FindHistory: TStringList read FFindHistory write FFindHistory;
< property ReplaceHistory: TStringList read FReplaceHistory write FReplaceHistory;
< property MaxFindHistory: Integer read FMaxFindHistory write FMaxFindHistory;
< procedure AddToFindHistory(const AFindStr: string); < procedure AddToReplaceHistory(const AReplaceStr: String); <
402,405d389
< FFindHistory:=TStringList.Create;
< FReplaceHistory:=TStringList.Create;
< FMaxFindHistory:=10;
<
591,595d574
< FMaxFindHistory:=XMLConfig.GetValue(
< 'EnvironmentOptions/Recent/Find/Max',FMaxFindHistory); <
LoadRecentList(FFindHistory,'EnvironmentOptions/Recent/Find/'); <
LoadRecentList(FReplaceHistory,'EnvironmentOptions/Recent/Repl ace/');
<
739,744d717
< // Find-history
< XMLConfig.SetValue(
< 'EnvironmentOptions/Recent/Find/Max',FMaxFindHistory); <
SaveRecentList(FFindHistory,'EnvironmentOptions/Recent/Find/'); <
SaveRecentList(FReplaceHistory,'EnvironmentOptions/Recent/Repl ace/');
<
823,832d795
< procedure TEnvironmentOptions.AddToFindHistory(const AFindStr: string);
< begin
< AddToRecentList(AFindStr,FFindHistory,FMaxFindHistory); < end;
<
< procedure TEnvironmentOptions.AddToReplaceHistory(const AReplaceStr: String);
< begin
<
AddToRecentList(AReplaceStr,FReplaceHistory,FMaxFindHistory); < end;
<

diff -b findreplacedialog.pp orig/findreplacedialog.pp
39,40d38
<     procedure ShowHistory;
<     procedure UpdateHistory;
44,45c42,43
<     TextToFindEdit:TComboBox;
<     ReplaceTextEdit:TComboBox;
---
TextToFindEdit:TEdit; ReplaceTextEdit:TEdit;

74d71
< uses EnvironmentOpts;
110c107
< TextToFindEdit:=TComboBox.Create(Self);
---

TextToFindEdit:=TEdit.Create(Self);

123c120
< ReplaceTextEdit:=TComboBox.Create(Self);
---

ReplaceTextEdit:=Tedit.Create(Self);
296,297d292
<
<   ShowHistory;
319d313
<   UpdateHistory;
386d379
<   TextToFindEdit.SetFocus;
399,416d391
< procedure TLazFindReplaceDialog.ShowHistory;
< begin
<   TextToFindEdit.Items.Clear;
<
TextToFindEdit.Items.AddStrings(EnvironmentOptions.FindHistory);
<   ReplaceTextEdit.Items.Clear;
<
ReplaceTextEdit.Items.AddStrings(EnvironmentOptions.ReplaceHis
tory);
< end;
<
< procedure TLazFindReplaceDialog.UpdateHistory;
< begin
<   with EnvironmentOptions do begin
<     AddToFindHistory(FindText);
<     if ReplaceTextEdit.Enabled then
AddToReplaceHistory(ReplaceText);
<     Save(false);
<   end;
<   ShowHistory;
< end;
<

Reply by email

Mattias Gaertner
to Jarto Tarpio
When I open Find for the first time, the uniteditor does a FindReplaceDlg.FindText := whatever but this doesn't change anything in the ComboBox.

That's right. It's a bug in TComboBox. You can only set text, that is already in the list. (I have added a little workaround SetComboBoxText).

TComboBox never gets focus.

Yes, but something of the combobox gets the focus. After pressing tab once the combobox has focus.

In other words: You have to click on the find-line Every Single Time you want to search for something. Needless to say that most of us are used to ctrl-F + happy typing + enter. So think twice before adding these diffs before TComboBox is fixed.

There is another serious bug: When the list of the TCombobox gots the focus and you press Return, the find dialog is hidden, but the list stays. Shane has implemented the TCombobox, so perhaps he knows why. I think, this should be fixed, before we use it.

I added your history list to the editoroptions instead of the environment options.

Mattias

Reply by email