mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 18:59:21 +02:00
ide: use unit dialog: start with selected text or word at cursor.
git-svn-id: trunk@51919 -
This commit is contained in:
parent
712eae76cd
commit
5149a4f43b
19
ide/main.pp
19
ide/main.pp
@ -72,7 +72,7 @@ uses
|
|||||||
FileUtil, LazFileUtils, LazFileCache, LazUTF8, LazUTF8Classes, UTF8Process,
|
FileUtil, LazFileUtils, LazFileCache, LazUTF8, LazUTF8Classes, UTF8Process,
|
||||||
LConvEncoding, Laz2_XMLCfg, LazLogger,
|
LConvEncoding, Laz2_XMLCfg, LazLogger,
|
||||||
// SynEdit
|
// SynEdit
|
||||||
AllSynEdit, SynEditKeyCmds, SynEditMarks, SynEditHighlighter,
|
SynEdit, AllSynEdit, SynEditKeyCmds, SynEditMarks, SynEditHighlighter,
|
||||||
// IDE interface
|
// IDE interface
|
||||||
IDEIntf, ObjectInspector, PropEdits, PropEditUtils,
|
IDEIntf, ObjectInspector, PropEdits, PropEditUtils,
|
||||||
MacroIntf, IDECommands, IDEWindowIntf, ComponentReg,
|
MacroIntf, IDECommands, IDEWindowIntf, ComponentReg,
|
||||||
@ -9974,8 +9974,23 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TMainIDE.DoUseUnit: TModalResult;
|
function TMainIDE.DoUseUnit: TModalResult;
|
||||||
|
var
|
||||||
|
TempEditor: TSourceEditorInterface;
|
||||||
|
DefText: String;
|
||||||
begin
|
begin
|
||||||
Result:=ShowUseUnitDialog;
|
DefText:='';
|
||||||
|
TempEditor := SourceEditorManagerIntf.ActiveEditor;
|
||||||
|
if TempEditor <> nil then
|
||||||
|
begin
|
||||||
|
if EditorOpts.FindTextAtCursor then
|
||||||
|
begin
|
||||||
|
if TempEditor.SelectionAvailable and (TempEditor.BlockBegin.Y = TempEditor.BlockEnd.Y)
|
||||||
|
then DefText := TempEditor.Selection
|
||||||
|
else DefText := TSynEdit(TempEditor.EditorControl).GetWordAtRowCol(TempEditor.CursorTextXY);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Result:=ShowUseUnitDialog(DefText);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMainIDE.DoFindOverloads: TModalResult;
|
function TMainIDE.DoFindOverloads: TModalResult;
|
||||||
|
@ -73,13 +73,13 @@ type
|
|||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ShowUseUnitDialog: TModalResult;
|
function ShowUseUnitDialog(const DefText: string): TModalResult;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
function ShowUseUnitDialog: TModalResult;
|
function ShowUseUnitDialog(const DefText: string): TModalResult;
|
||||||
var
|
var
|
||||||
UseUnitDlg: TUseUnitDialog;
|
UseUnitDlg: TUseUnitDialog;
|
||||||
SrcEdit: TSourceEditor;
|
SrcEdit: TSourceEditor;
|
||||||
@ -125,6 +125,8 @@ begin
|
|||||||
Exit(mrCancel);
|
Exit(mrCancel);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
UseUnitDlg.FilterEdit.Text := DefText;
|
||||||
|
|
||||||
// Show the dialog.
|
// Show the dialog.
|
||||||
if UseUnitDlg.ShowModal=mrOk then begin
|
if UseUnitDlg.ShowModal=mrOk then begin
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user