mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Find and replace dialogs in grid popup text editor:
* Cancel dialog when user presses Cancel, regardless of which dialog has focus. * Show selection when dialog found some text, without having to focus the memo.
This commit is contained in:
@ -158,6 +158,9 @@ object frmTextEditor: TfrmTextEditor
|
|||||||
object actSearchFind: TSearchFind
|
object actSearchFind: TSearchFind
|
||||||
Category = 'Search'
|
Category = 'Search'
|
||||||
Caption = '&Find...'
|
Caption = '&Find...'
|
||||||
|
Dialog.OnClose = actSearchFindFindDialogClose
|
||||||
|
Dialog.OnShow = actSearchFindFindDialogShow
|
||||||
|
Dialog.Options = [frDown, frFindNext]
|
||||||
Hint = 'Find|Finds the specified text'
|
Hint = 'Find|Finds the specified text'
|
||||||
ImageIndex = 30
|
ImageIndex = 30
|
||||||
ShortCut = 16454
|
ShortCut = 16454
|
||||||
@ -172,6 +175,9 @@ object frmTextEditor: TfrmTextEditor
|
|||||||
object actSearchReplace: TSearchReplace
|
object actSearchReplace: TSearchReplace
|
||||||
Category = 'Search'
|
Category = 'Search'
|
||||||
Caption = '&Replace'
|
Caption = '&Replace'
|
||||||
|
Dialog.OnClose = actSearchReplaceReplaceDialogClose
|
||||||
|
Dialog.OnShow = actSearchReplaceReplaceDialogShow
|
||||||
|
Dialog.Options = [frDown, frFindNext, frReplace, frReplaceAll]
|
||||||
Hint = 'Replace|Replaces specific text with different text'
|
Hint = 'Replace|Replaces specific text with different text'
|
||||||
ImageIndex = 59
|
ImageIndex = 59
|
||||||
end
|
end
|
||||||
|
@ -48,6 +48,10 @@ type
|
|||||||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||||||
procedure SelectLinebreaks(Sender: TObject);
|
procedure SelectLinebreaks(Sender: TObject);
|
||||||
procedure TimerMemoChangeTimer(Sender: TObject);
|
procedure TimerMemoChangeTimer(Sender: TObject);
|
||||||
|
procedure actSearchFindFindDialogShow(Sender: TObject);
|
||||||
|
procedure actSearchFindFindDialogClose(Sender: TObject);
|
||||||
|
procedure actSearchReplaceReplaceDialogShow(Sender: TObject);
|
||||||
|
procedure actSearchReplaceReplaceDialogClose(Sender: TObject);
|
||||||
private
|
private
|
||||||
{ Private declarations }
|
{ Private declarations }
|
||||||
FModified: Boolean;
|
FModified: Boolean;
|
||||||
@ -55,6 +59,7 @@ type
|
|||||||
FDetectedLineBreaks,
|
FDetectedLineBreaks,
|
||||||
FSelectedLineBreaks: TLineBreaks;
|
FSelectedLineBreaks: TLineBreaks;
|
||||||
FmemoText: TLineNormalizingMemo;
|
FmemoText: TLineNormalizingMemo;
|
||||||
|
FFindDialogActive, FReplaceDialogActive: Boolean;
|
||||||
procedure SetModified(NewVal: Boolean);
|
procedure SetModified(NewVal: Boolean);
|
||||||
public
|
public
|
||||||
function GetText: String;
|
function GetText: String;
|
||||||
@ -186,6 +191,7 @@ begin
|
|||||||
FmemoText.OnChange := memoTextChange;
|
FmemoText.OnChange := memoTextChange;
|
||||||
FmemoText.OnKeyDown := memoTextKeyDown;
|
FmemoText.OnKeyDown := memoTextKeyDown;
|
||||||
FmemoText.OnClick := memoTextClick;
|
FmemoText.OnClick := memoTextClick;
|
||||||
|
FmemoText.HideSelection := False; // Make found text visible when find dialog has focus
|
||||||
// Use same text properties as in query/find/replace actions
|
// Use same text properties as in query/find/replace actions
|
||||||
actSearchFind.Caption := MainForm.actQueryFind.Caption;
|
actSearchFind.Caption := MainForm.actQueryFind.Caption;
|
||||||
actSearchFind.Hint := MainForm.actQueryFind.Hint;
|
actSearchFind.Hint := MainForm.actQueryFind.Hint;
|
||||||
@ -238,8 +244,15 @@ begin
|
|||||||
TimerMemoChange.Enabled := False;
|
TimerMemoChange.Enabled := False;
|
||||||
TimerMemoChange.Enabled := True;
|
TimerMemoChange.Enabled := True;
|
||||||
case Key of
|
case Key of
|
||||||
// Cancel by Escape
|
// Cancel active dialog by Escape
|
||||||
VK_ESCAPE: btnCancelClick(Sender);
|
VK_ESCAPE: begin
|
||||||
|
if FFindDialogActive then
|
||||||
|
actSearchFind.Dialog.CloseDialog
|
||||||
|
else if FReplaceDialogActive then
|
||||||
|
actSearchReplace.Dialog.CloseDialog
|
||||||
|
else
|
||||||
|
btnCancelClick(Sender);
|
||||||
|
end;
|
||||||
// Apply changes and end editing by Ctrl + Enter
|
// Apply changes and end editing by Ctrl + Enter
|
||||||
VK_RETURN: if ssCtrl in Shift then btnApplyClick(Sender);
|
VK_RETURN: if ssCtrl in Shift then btnApplyClick(Sender);
|
||||||
Ord('a'), Ord('A'): if (ssCtrl in Shift) and (not (ssAlt in Shift)) then Mainform.actSelectAllExecute(Sender);
|
Ord('a'), Ord('A'): if (ssCtrl in Shift) and (not (ssAlt in Shift)) then Mainform.actSelectAllExecute(Sender);
|
||||||
@ -343,4 +356,28 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TfrmTextEditor.actSearchFindFindDialogShow(Sender: TObject);
|
||||||
|
begin
|
||||||
|
FFindDialogActive := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TfrmTextEditor.actSearchFindFindDialogClose(Sender: TObject);
|
||||||
|
begin
|
||||||
|
FFindDialogActive := False;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TfrmTextEditor.actSearchReplaceReplaceDialogShow(Sender: TObject);
|
||||||
|
begin
|
||||||
|
FReplaceDialogActive := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TfrmTextEditor.actSearchReplaceReplaceDialogClose(Sender: TObject);
|
||||||
|
begin
|
||||||
|
FReplaceDialogActive := False;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Reference in New Issue
Block a user