mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-04 19:19:26 +01:00
IDE: added command for Context sensitive smart hint, from Ondrej
git-svn-id: trunk@49870 -
This commit is contained in:
parent
e2932283ec
commit
ee08d00d18
@ -335,6 +335,7 @@ const
|
|||||||
ecEditContextHelp = ecFirstLazarus + 904;
|
ecEditContextHelp = ecFirstLazarus + 904;
|
||||||
ecReportingBug = ecFirstLazarus + 905;
|
ecReportingBug = ecFirstLazarus + 905;
|
||||||
ecFocusHint = ecFirstLazarus + 906;
|
ecFocusHint = ecFirstLazarus + 906;
|
||||||
|
ecSmartHint = ecFirstLazarus + 907;
|
||||||
|
|
||||||
// designer
|
// designer
|
||||||
ecDesignerCopy = ecFirstLazarus + 1000;
|
ecDesignerCopy = ecFirstLazarus + 1000;
|
||||||
@ -1227,7 +1228,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
const
|
const
|
||||||
IDEEditorCommandStrs: array[0..308] of TIdentMapEntry = (
|
IDEEditorCommandStrs: array[0..309] of TIdentMapEntry = (
|
||||||
// search
|
// search
|
||||||
(Value: ecFind; Name: 'ecFind'),
|
(Value: ecFind; Name: 'ecFind'),
|
||||||
(Value: ecFindAgain; Name: 'ecFindAgain'),
|
(Value: ecFindAgain; Name: 'ecFindAgain'),
|
||||||
@ -1511,6 +1512,7 @@ const
|
|||||||
(Value: ecEditContextHelp; Name: 'ecEditContextHelp'),
|
(Value: ecEditContextHelp; Name: 'ecEditContextHelp'),
|
||||||
(Value: ecReportingBug; Name: 'ecReportingBug'),
|
(Value: ecReportingBug; Name: 'ecReportingBug'),
|
||||||
(Value: ecFocusHint; Name: 'ecFocusHint'),
|
(Value: ecFocusHint; Name: 'ecFocusHint'),
|
||||||
|
(Value: ecSmartHint; Name: 'ecSmartHint'),
|
||||||
|
|
||||||
// designer
|
// designer
|
||||||
(Value: ecDesignerCopy; Name: 'ecDesignerCopy'),
|
(Value: ecDesignerCopy; Name: 'ecDesignerCopy'),
|
||||||
|
|||||||
@ -705,6 +705,7 @@ begin
|
|||||||
ecEditContextHelp : Result:= lisMenuEditContextHelp;
|
ecEditContextHelp : Result:= lisMenuEditContextHelp;
|
||||||
ecReportingBug : Result:= srkmecReportingBug;
|
ecReportingBug : Result:= srkmecReportingBug;
|
||||||
ecFocusHint : Result:= lisFocusHint;
|
ecFocusHint : Result:= lisFocusHint;
|
||||||
|
ecSmartHint : Result:= lisMenuShowSmartHint;
|
||||||
|
|
||||||
// desginer
|
// desginer
|
||||||
ecDesignerCopy : Result:= lisDsgCopyComponents;
|
ecDesignerCopy : Result:= lisDsgCopyComponents;
|
||||||
@ -2344,6 +2345,7 @@ begin
|
|||||||
ecEditContextHelp: SetSingle(VK_F1,[ssShift,ssCtrl], VK_HELP,[ssCtrl]);
|
ecEditContextHelp: SetSingle(VK_F1,[ssShift,ssCtrl], VK_HELP,[ssCtrl]);
|
||||||
ecReportingBug: SetSingle(VK_UNKNOWN,[]);
|
ecReportingBug: SetSingle(VK_UNKNOWN,[]);
|
||||||
ecFocusHint: SetSingle(VK_UNKNOWN,[]);
|
ecFocusHint: SetSingle(VK_UNKNOWN,[]);
|
||||||
|
ecSmartHint: SetSingle(VK_UNKNOWN,[]);
|
||||||
|
|
||||||
// designer
|
// designer
|
||||||
ecDesignerCopy: SetSingle(VK_C,[ssMeta]);
|
ecDesignerCopy: SetSingle(VK_C,[ssMeta]);
|
||||||
@ -3038,6 +3040,7 @@ begin
|
|||||||
AddDefault(C, 'Edit context sensitive help', lisKMEditContextSensitiveHelp, ecEditContextHelp);
|
AddDefault(C, 'Edit context sensitive help', lisKMEditContextSensitiveHelp, ecEditContextHelp);
|
||||||
AddDefault(C, 'Reporting a bug', srkmecReportingBug, ecReportingBug);
|
AddDefault(C, 'Reporting a bug', srkmecReportingBug, ecReportingBug);
|
||||||
AddDefault(C, 'Focus hint', lisFocusHint, ecFocusHint);
|
AddDefault(C, 'Focus hint', lisFocusHint, ecFocusHint);
|
||||||
|
AddDefault(C, 'Context sensitive smart hint', lisMenuShowSmartHint, ecSmartHint);
|
||||||
|
|
||||||
// designer - without menu items in the IDE bar (at least not directly)
|
// designer - without menu items in the IDE bar (at least not directly)
|
||||||
C:=Categories[AddCategory('Designer',lisKeyCatDesigner,IDECmdScopeDesignerOnly)];
|
C:=Categories[AddCategory('Designer',lisKeyCatDesigner,IDECmdScopeDesignerOnly)];
|
||||||
|
|||||||
@ -599,6 +599,7 @@ resourcestring
|
|||||||
lisKMEditContextSensitiveHelp = 'Edit context sensitive help';
|
lisKMEditContextSensitiveHelp = 'Edit context sensitive help';
|
||||||
lisMenuContextHelp = 'Context sensitive Help';
|
lisMenuContextHelp = 'Context sensitive Help';
|
||||||
lisMenuEditContextHelp = 'Edit context sensitive Help';
|
lisMenuEditContextHelp = 'Edit context sensitive Help';
|
||||||
|
lisMenuShowSmartHint = 'Context sensitive smart hint';
|
||||||
|
|
||||||
lisDsgCopyComponents = 'Copy selected components to clipboard';
|
lisDsgCopyComponents = 'Copy selected components to clipboard';
|
||||||
lisDsgCutComponents = 'Cut selected components to clipboard';
|
lisDsgCutComponents = 'Cut selected components to clipboard';
|
||||||
|
|||||||
@ -471,7 +471,7 @@ type
|
|||||||
procedure OnSrcNotebookReadOnlyChanged(Sender: TObject);
|
procedure OnSrcNotebookReadOnlyChanged(Sender: TObject);
|
||||||
procedure OnSrcNotebookSaveAll(Sender: TObject);
|
procedure OnSrcNotebookSaveAll(Sender: TObject);
|
||||||
procedure OnSrcNotebookShowHintForSource(SrcEdit: TSourceEditor;
|
procedure OnSrcNotebookShowHintForSource(SrcEdit: TSourceEditor;
|
||||||
ClientPos: TPoint; CaretPos: TPoint);
|
ClientPos: TPoint; CaretPos: TPoint; ShowByCommand: Boolean);
|
||||||
procedure OnSrcNoteBookShowUnitInfo(Sender: TObject);
|
procedure OnSrcNoteBookShowUnitInfo(Sender: TObject);
|
||||||
procedure OnSrcNotebookToggleFormUnit(Sender: TObject);
|
procedure OnSrcNotebookToggleFormUnit(Sender: TObject);
|
||||||
procedure OnSrcNotebookToggleObjectInsp(Sender: TObject);
|
procedure OnSrcNotebookToggleObjectInsp(Sender: TObject);
|
||||||
@ -10331,7 +10331,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.OnSrcNotebookShowHintForSource(SrcEdit: TSourceEditor;
|
procedure TMainIDE.OnSrcNotebookShowHintForSource(SrcEdit: TSourceEditor;
|
||||||
ClientPos: TPoint; CaretPos: TPoint);
|
ClientPos: TPoint; CaretPos: TPoint; ShowByCommand: Boolean);
|
||||||
|
|
||||||
function CheckExpressionIsValid(var Expr: String): boolean;
|
function CheckExpressionIsValid(var Expr: String): boolean;
|
||||||
var
|
var
|
||||||
@ -10443,7 +10443,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
if HasHint then
|
if HasHint then
|
||||||
SrcEdit.ActivateHint(ClientPos, BaseURL, SmartHintStr);
|
SrcEdit.ActivateHint(ClientPos, BaseURL, SmartHintStr, ShowByCommand);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.OnSrcNoteBookActivated(Sender: TObject);
|
procedure TMainIDE.OnSrcNoteBookActivated(Sender: TObject);
|
||||||
|
|||||||
@ -370,7 +370,8 @@ type
|
|||||||
|
|
||||||
// dialogs
|
// dialogs
|
||||||
procedure GetDialogPosition(Width, Height: integer; out Left, Top: integer);
|
procedure GetDialogPosition(Width, Height: integer; out Left, Top: integer);
|
||||||
procedure ActivateHint(ClientPos: TPoint; const BaseURL, TheHint: string);
|
procedure ActivateHint(ClientPos: TPoint; const BaseURL, TheHint: string;
|
||||||
|
ShowByCommand: Boolean = False);
|
||||||
|
|
||||||
// selections
|
// selections
|
||||||
function SelectionAvailable: boolean; override;
|
function SelectionAvailable: boolean; override;
|
||||||
@ -422,6 +423,8 @@ type
|
|||||||
|
|
||||||
// context help
|
// context help
|
||||||
procedure FindHelpForSourceAtCursor;
|
procedure FindHelpForSourceAtCursor;
|
||||||
|
//Smart hint
|
||||||
|
procedure ShowSmartHintForSourceAtCursor;
|
||||||
|
|
||||||
// editor commands
|
// editor commands
|
||||||
procedure DoEditorExecuteCommand(EditorCommand: word);
|
procedure DoEditorExecuteCommand(EditorCommand: word);
|
||||||
@ -538,7 +541,7 @@ type
|
|||||||
OldPageIndex, NewPageIndex: integer) of object;
|
OldPageIndex, NewPageIndex: integer) of object;
|
||||||
TOnCloseSrcEditor = procedure(Sender: TObject; InvertedClose: boolean) of object;
|
TOnCloseSrcEditor = procedure(Sender: TObject; InvertedClose: boolean) of object;
|
||||||
TOnShowHintForSource = procedure(SrcEdit: TSourceEditor; ClientPos: TPoint;
|
TOnShowHintForSource = procedure(SrcEdit: TSourceEditor; ClientPos: TPoint;
|
||||||
CaretPos: TPoint) of object;
|
CaretPos: TPoint; ShowByCommand: Boolean) of object;
|
||||||
TOnInitIdentCompletion = procedure(Sender: TObject; JumpToError: boolean;
|
TOnInitIdentCompletion = procedure(Sender: TObject; JumpToError: boolean;
|
||||||
out Handled, Abort: boolean) of object;
|
out Handled, Abort: boolean) of object;
|
||||||
TSrcEditPopupMenuEvent = procedure(const AddMenuItemProc: TAddMenuItemProc
|
TSrcEditPopupMenuEvent = procedure(const AddMenuItemProc: TAddMenuItemProc
|
||||||
@ -950,6 +953,30 @@ type
|
|||||||
jmpInitialization);
|
jmpInitialization);
|
||||||
TJumpToProcedureType = (jmpHeader, jmpBegin);
|
TJumpToProcedureType = (jmpHeader, jmpBegin);
|
||||||
|
|
||||||
|
TSourceEditorHintWindowManager = class(TIDEHintWindowManager)
|
||||||
|
private
|
||||||
|
FManager: TSourceEditorManager;
|
||||||
|
FShowByCommand: Boolean;
|
||||||
|
FHintMousePos: TPoint;
|
||||||
|
FLastHint: string;
|
||||||
|
FMouseHintTimer: TIdleTimer;
|
||||||
|
FMouseHideHintTimer: TTimer;
|
||||||
|
|
||||||
|
procedure HintTimer(Sender: TObject);
|
||||||
|
procedure HideHintTimer(Sender: TObject);
|
||||||
|
public
|
||||||
|
procedure ActivateHint(const ScreenPos: TPoint; const ABaseURL, AHint: string;
|
||||||
|
AShowByCommand: Boolean = False);
|
||||||
|
procedure MaybeHideHintIfNotByCommand;
|
||||||
|
procedure HideHintIfNotByCommand;
|
||||||
|
procedure UpdateHintTimer;
|
||||||
|
public
|
||||||
|
constructor Create(AManager: TSourceEditorManager);
|
||||||
|
destructor Destroy; override;
|
||||||
|
public
|
||||||
|
property MouseHintTimer: TIdleTimer read FMouseHintTimer;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TSourceEditorManager }
|
{ TSourceEditorManager }
|
||||||
(* Reintroduce all Methods with the final types *)
|
(* Reintroduce all Methods with the final types *)
|
||||||
|
|
||||||
@ -1072,15 +1099,9 @@ type
|
|||||||
procedure HistoryJump(Sender: TObject; CloseAction: TJumpHistoryAction);
|
procedure HistoryJump(Sender: TObject; CloseAction: TJumpHistoryAction);
|
||||||
private
|
private
|
||||||
// Hints
|
// Hints
|
||||||
FHints: TIDEHintWindowManager;
|
FHints: TSourceEditorHintWindowManager;
|
||||||
FMouseHintTimer: TIdleTimer;
|
procedure ActivateHint(const ScreenPos: TPoint; const BaseURL, TheHint: string;
|
||||||
FMouseHideHintTimer: TTimer;
|
ShowByCommand: Boolean = False);
|
||||||
FHintMousePos: TPoint;
|
|
||||||
procedure HintTimer(Sender: TObject);
|
|
||||||
procedure HideHintTimer(Sender: TObject);
|
|
||||||
procedure ActivateHint(const ScreenPos: TPoint; const BaseURL, TheHint: string);
|
|
||||||
procedure MaybeHideHint;
|
|
||||||
procedure UpdateHintTimer;
|
|
||||||
private
|
private
|
||||||
FCodeTemplateModul: TSynEditAutoComplete;
|
FCodeTemplateModul: TSynEditAutoComplete;
|
||||||
FGotoDialog: TfrmGoto;
|
FGotoDialog: TfrmGoto;
|
||||||
@ -1665,6 +1686,171 @@ begin
|
|||||||
Result:=CompareFilenames(AnsiString(FileNameStr),SE1.FileName);
|
Result:=CompareFilenames(AnsiString(FileNameStr),SE1.FileName);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TSourceEditorHintWindowManager }
|
||||||
|
|
||||||
|
procedure TSourceEditorHintWindowManager.ActivateHint(const ScreenPos: TPoint;
|
||||||
|
const ABaseURL, AHint: string; AShowByCommand: Boolean);
|
||||||
|
begin
|
||||||
|
FShowByCommand := AShowByCommand;
|
||||||
|
BaseURL := ABaseURL;
|
||||||
|
FLastHint := AHint;
|
||||||
|
if AShowByCommand then
|
||||||
|
begin
|
||||||
|
if HintIsVisible and (FLastHint = AHint) then
|
||||||
|
HideIfVisible
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
ShowHint(ScreenPos,AHint);
|
||||||
|
FMouseHideHintTimer.Enabled := False;
|
||||||
|
end;
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
FHintMousePos := Mouse.CursorPos;
|
||||||
|
if ShowHint(ScreenPos,AHint) then
|
||||||
|
FMouseHideHintTimer.Enabled := True;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TSourceEditorHintWindowManager.Create(AManager: TSourceEditorManager
|
||||||
|
);
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
|
||||||
|
FManager := AManager;
|
||||||
|
// HintTimer
|
||||||
|
FMouseHintTimer := TIdleTimer.Create(nil);
|
||||||
|
with FMouseHintTimer do begin
|
||||||
|
Interval := EditorOpts.AutoDelayInMSec;
|
||||||
|
Enabled := False;
|
||||||
|
AutoEnabled := False;
|
||||||
|
OnTimer := @HintTimer;
|
||||||
|
end;
|
||||||
|
// Track mouse movements outside the IDE, if hint is visible
|
||||||
|
FMouseHideHintTimer := TTimer.Create(nil);
|
||||||
|
with FMouseHideHintTimer do begin
|
||||||
|
Interval := 500;
|
||||||
|
Enabled := False;
|
||||||
|
OnTimer := @HideHintTimer;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TSourceEditorHintWindowManager.Destroy;
|
||||||
|
begin
|
||||||
|
FMouseHintTimer.Free;
|
||||||
|
FMouseHideHintTimer.Free;
|
||||||
|
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSourceEditorHintWindowManager.HideHintIfNotByCommand;
|
||||||
|
begin
|
||||||
|
if FMouseHintTimer<>nil then
|
||||||
|
begin
|
||||||
|
FMouseHintTimer.AutoEnabled := false;
|
||||||
|
FMouseHintTimer.Enabled:=false;
|
||||||
|
end;
|
||||||
|
if FMouseHideHintTimer <> nil then
|
||||||
|
FMouseHideHintTimer.Enabled := False;
|
||||||
|
if AutoStartCompletionBoxTimer<>nil then
|
||||||
|
AutoStartCompletionBoxTimer.Enabled:=false;
|
||||||
|
if not FShowByCommand then
|
||||||
|
HideHint;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSourceEditorHintWindowManager.HideHintTimer(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if HintIsVisible and not FShowByCommand then begin
|
||||||
|
if ComparePoints(FHintMousePos, Mouse.CursorPos) <> 0 then begin
|
||||||
|
// TODO: introduce property, to indicate if hint is interactive
|
||||||
|
if HintIsComplex then
|
||||||
|
MaybeHideHintIfNotByCommand
|
||||||
|
else
|
||||||
|
HideHintIfNotByCommand;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
FMouseHideHintTimer.Enabled := false;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSourceEditorHintWindowManager.HintTimer(Sender: TObject);
|
||||||
|
var
|
||||||
|
MousePos: TPoint;
|
||||||
|
AControl: TControl;
|
||||||
|
begin
|
||||||
|
FMouseHintTimer.Enabled := False;
|
||||||
|
FMouseHintTimer.AutoEnabled := False;
|
||||||
|
if not FManager.ActiveSourceWindow.IsVisible then exit;
|
||||||
|
MousePos := Mouse.CursorPos;
|
||||||
|
AControl:=FindLCLControl(MousePos);
|
||||||
|
if (AControl=nil) or (not FManager.ActiveSourceWindow.ContainsControl(AControl)) then exit;
|
||||||
|
if AControl is TSynEdit then
|
||||||
|
FManager.ActiveSourceWindow.ShowSynEditHint(MousePos);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSourceEditorHintWindowManager.MaybeHideHintIfNotByCommand;
|
||||||
|
const
|
||||||
|
MaxJitter = 3;
|
||||||
|
var
|
||||||
|
Cur: TPoint;
|
||||||
|
OkX, OkY: Boolean;
|
||||||
|
hw: THintWindow;
|
||||||
|
begin
|
||||||
|
if HintIsVisible and FShowByCommand then Exit;
|
||||||
|
FMouseHideHintTimer.Enabled := False;
|
||||||
|
if HintIsVisible then begin
|
||||||
|
hw := CurHintWindow;
|
||||||
|
Cur := Mouse.CursorPos; // Desktop coordinates
|
||||||
|
OkX := ( (FHintMousePos.x <= hw.Left) and
|
||||||
|
(Cur.x > FHintMousePos.x) and (Cur.x <= hw.Left + hw.Width)
|
||||||
|
) or
|
||||||
|
( (FHintMousePos.x >= hw.Left + hw.Width) and
|
||||||
|
(Cur.x < FHintMousePos.x) and (Cur.x >= hw.Left)
|
||||||
|
) or
|
||||||
|
( (Cur.x >= hw.Left) and (Cur.x <= hw.Left + hw.Width) );
|
||||||
|
OkY := ( (FHintMousePos.y <= hw.Top) and
|
||||||
|
(Cur.y > FHintMousePos.y) and (Cur.y <= hw.Top + hw.Height)
|
||||||
|
) or
|
||||||
|
( (FHintMousePos.y >= hw.Top + hw.Height) and
|
||||||
|
(Cur.y < FHintMousePos.y) and (Cur.y >= hw.Top)
|
||||||
|
) or
|
||||||
|
( (Cur.y >= hw.Top) and (Cur.y <= hw.Top + hw.Height) );
|
||||||
|
|
||||||
|
if OkX then FHintMousePos.x := Cur.x;
|
||||||
|
if OkY then FHintMousePos.y := Cur.y;
|
||||||
|
|
||||||
|
|
||||||
|
OkX := OkX or
|
||||||
|
( (FHintMousePos.x <= hw.Left + MaxJitter) and
|
||||||
|
(Cur.x > FHintMousePos.x - MaxJitter) and (Cur.x <= hw.Left + hw.Width + MaxJitter)
|
||||||
|
) or
|
||||||
|
( (FHintMousePos.x >= hw.Left + hw.Width - MaxJitter) and
|
||||||
|
(Cur.x < FHintMousePos.x + MaxJitter) and (Cur.x >= hw.Left - MaxJitter)
|
||||||
|
);
|
||||||
|
OkY := OkY or
|
||||||
|
( (FHintMousePos.y <= hw.Top + MaxJitter) and
|
||||||
|
(Cur.y > FHintMousePos.y - MaxJitter) and (Cur.y <= hw.Top + hw.Height + MaxJitter)
|
||||||
|
) or
|
||||||
|
( (FHintMousePos.y >= hw.Top + hw.Height - MaxJitter) and
|
||||||
|
(Cur.y < FHintMousePos.y + MaxJitter) and (Cur.y >= hw.Top - MaxJitter)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (OkX and OkY) then begin
|
||||||
|
FMouseHideHintTimer.Enabled := True;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
HideHint;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSourceEditorHintWindowManager.UpdateHintTimer;
|
||||||
|
begin
|
||||||
|
with EditorOpts do
|
||||||
|
if (MainIDEInterface.ToolStatus=itDebugger) then
|
||||||
|
FMouseHintTimer.AutoEnabled := AutoToolTipExprEval or AutoToolTipSymbTools
|
||||||
|
else
|
||||||
|
FMouseHintTimer.AutoEnabled := AutoToolTipSymbTools;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TSourceEditCompletion }
|
{ TSourceEditCompletion }
|
||||||
|
|
||||||
@ -2870,6 +3056,16 @@ begin
|
|||||||
Self.FocusEditor;
|
Self.FocusEditor;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSourceEditor.ShowSmartHintForSourceAtCursor;
|
||||||
|
var
|
||||||
|
EditCaret, EditPos: Classes.TPoint;
|
||||||
|
begin
|
||||||
|
EditCaret := FEditor.LogicalCaretXY;
|
||||||
|
EditPos := FEditor.RowColumnToPixels(EditCaret);
|
||||||
|
if Assigned(Manager) and Assigned(Manager.OnShowHintForSource) then
|
||||||
|
Manager.OnShowHintForSource(Self,EditPos,EditCaret, True);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSourceEditor.GetDialogPosition(Width, Height: integer;
|
procedure TSourceEditor.GetDialogPosition(Width, Height: integer;
|
||||||
out Left, Top: integer);
|
out Left, Top: integer);
|
||||||
var
|
var
|
||||||
@ -2888,14 +3084,14 @@ begin
|
|||||||
if Top < ABounds.Top then Top := ABounds.Top;
|
if Top < ABounds.Top then Top := ABounds.Top;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSourceEditor.ActivateHint(ClientPos: TPoint;
|
procedure TSourceEditor.ActivateHint(ClientPos: TPoint; const BaseURL,
|
||||||
const BaseURL, TheHint: string);
|
TheHint: string; ShowByCommand: Boolean);
|
||||||
var
|
var
|
||||||
ScreenPos: TPoint;
|
ScreenPos: TPoint;
|
||||||
begin
|
begin
|
||||||
if SourceNotebook=nil then exit;
|
if SourceNotebook=nil then exit;
|
||||||
ScreenPos:=EditorComponent.ClientToScreen(ClientPos);
|
ScreenPos:=EditorComponent.ClientToScreen(ClientPos);
|
||||||
Manager.ActivateHint(ScreenPos,BaseURL,TheHint);
|
Manager.ActivateHint(ScreenPos,BaseURL,TheHint,ShowByCommand);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------S T A R T F I N D-----------------------------}
|
{------------------------------S T A R T F I N D-----------------------------}
|
||||||
@ -3268,6 +3464,7 @@ begin
|
|||||||
if (SrcEditHintWindow<>nil) then
|
if (SrcEditHintWindow<>nil) then
|
||||||
SrcEditHintWindow.Hide;
|
SrcEditHintWindow.Hide;
|
||||||
end;
|
end;
|
||||||
|
Manager.HideHint;
|
||||||
|
|
||||||
if (FSourceNoteBook<>nil)
|
if (FSourceNoteBook<>nil)
|
||||||
and (snIncrementalFind in FSourceNoteBook.States) then begin
|
and (snIncrementalFind in FSourceNoteBook.States) then begin
|
||||||
@ -3419,6 +3616,9 @@ Begin
|
|||||||
ecContextHelp:
|
ecContextHelp:
|
||||||
FindHelpForSourceAtCursor;
|
FindHelpForSourceAtCursor;
|
||||||
|
|
||||||
|
ecSmartHint:
|
||||||
|
ShowSmartHintForSourceAtCursor;
|
||||||
|
|
||||||
ecIdentCompletion :
|
ecIdentCompletion :
|
||||||
StartIdentCompletionBox(CodeToolsOpts.IdentComplJumpToError);
|
StartIdentCompletionBox(CodeToolsOpts.IdentComplJumpToError);
|
||||||
|
|
||||||
@ -8317,9 +8517,9 @@ end;
|
|||||||
procedure TSourceNotebook.EditorMouseMove(Sender: TObject; Shift: TShiftstate;
|
procedure TSourceNotebook.EditorMouseMove(Sender: TObject; Shift: TShiftstate;
|
||||||
X, Y: Integer);
|
X, Y: Integer);
|
||||||
begin
|
begin
|
||||||
Manager.MaybeHideHint;
|
Manager.FHints.MaybeHideHintIfNotByCommand;
|
||||||
if Visible then
|
if Visible then
|
||||||
Manager.UpdateHintTimer;
|
Manager.FHints.UpdateHintTimer;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSourceNotebook.EditorMouseWheel(Sender: TObject; Shift: TShiftState;
|
procedure TSourceNotebook.EditorMouseWheel(Sender: TObject; Shift: TShiftState;
|
||||||
@ -8400,6 +8600,8 @@ procedure TSourceNotebook.OnApplicationDeactivate(Sender: TObject);
|
|||||||
begin
|
begin
|
||||||
if (CodeContextFrm<>nil) then
|
if (CodeContextFrm<>nil) then
|
||||||
CodeContextFrm.Hide;
|
CodeContextFrm.Hide;
|
||||||
|
if (Manager<>nil) and (Manager.FHints<>nil) then
|
||||||
|
Manager.FHints.HideIfVisible;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSourceNotebook.EditorKeyDown(Sender: TObject; var Key: Word;
|
procedure TSourceNotebook.EditorKeyDown(Sender: TObject; var Key: Word;
|
||||||
@ -8462,7 +8664,7 @@ begin
|
|||||||
end else begin
|
end else begin
|
||||||
// hint for source
|
// hint for source
|
||||||
if Assigned(Manager) and Assigned(Manager.OnShowHintForSource) then
|
if Assigned(Manager) and Assigned(Manager.OnShowHintForSource) then
|
||||||
Manager.OnShowHintForSource(ASrcEdit,EditPos,EditCaret);
|
Manager.OnShowHintForSource(ASrcEdit,EditPos,EditCaret, False);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -9553,7 +9755,7 @@ begin
|
|||||||
IndentToTokenStart:=EditorOpts.CodeTemplateIndentToTokenStart;
|
IndentToTokenStart:=EditorOpts.CodeTemplateIndentToTokenStart;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FMouseHintTimer.Interval:=EditorOpts.AutoDelayInMSec;
|
FHints.MouseHintTimer.Interval:=EditorOpts.AutoDelayInMSec;
|
||||||
|
|
||||||
if FDefaultCompletionForm <> nil then begin
|
if FDefaultCompletionForm <> nil then begin
|
||||||
FDefaultCompletionForm.LongLineHintTime := EditorOpts.CompletionLongLineHintInMSec;
|
FDefaultCompletionForm.LongLineHintTime := EditorOpts.CompletionLongLineHintInMSec;
|
||||||
@ -9607,6 +9809,11 @@ begin
|
|||||||
if ActiveEditor <> nil then ActiveEditor.ShowGotoLineDialog;
|
if ActiveEditor <> nil then ActiveEditor.ShowGotoLineDialog;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSourceEditorManager.HideHint;
|
||||||
|
begin
|
||||||
|
FHints.HideHint;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSourceEditorManager.JumpBackClicked(Sender: TObject);
|
procedure TSourceEditorManager.JumpBackClicked(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if ActiveSourceWindow <> nil then HistoryJump(Sender,jhaBack);
|
if ActiveSourceWindow <> nil then HistoryJump(Sender,jhaBack);
|
||||||
@ -10104,7 +10311,7 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
if (Msg = WM_MOUSEMOVE) {$IFDEF WINDOWS} or (Msg = WM_NCMOUSEMOVE){$ENDIF} then begin
|
if (Msg = WM_MOUSEMOVE) {$IFDEF WINDOWS} or (Msg = WM_NCMOUSEMOVE){$ENDIF} then begin
|
||||||
MaybeHideHint;
|
FHints.MaybeHideHintIfNotByCommand;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -10112,7 +10319,7 @@ begin
|
|||||||
//debugln('TSourceEditorManager.OnUserInput');
|
//debugln('TSourceEditorManager.OnUserInput');
|
||||||
// don't hide hint if Sender is a hint window or child control
|
// don't hide hint if Sender is a hint window or child control
|
||||||
if not FHints.SenderIsHintControl(Sender) then
|
if not FHints.SenderIsHintControl(Sender) then
|
||||||
HideHint;
|
FHints.HideHintIfNotByCommand;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSourceEditorManager.LockAllEditorsInSourceChangeCache;
|
procedure TSourceEditorManager.LockAllEditorsInSourceChangeCache;
|
||||||
@ -10192,122 +10399,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSourceEditorManager.HintTimer(Sender: TObject);
|
|
||||||
var
|
|
||||||
MousePos: TPoint;
|
|
||||||
AControl: TControl;
|
|
||||||
begin
|
|
||||||
FMouseHintTimer.Enabled := False;
|
|
||||||
FMouseHintTimer.AutoEnabled := False;
|
|
||||||
if not FActiveWindow.IsVisible then exit;
|
|
||||||
MousePos := Mouse.CursorPos;
|
|
||||||
AControl:=FindLCLControl(MousePos);
|
|
||||||
if (AControl=nil) or (not FActiveWindow.ContainsControl(AControl)) then exit;
|
|
||||||
if AControl is TSynEdit then
|
|
||||||
FActiveWindow.ShowSynEditHint(MousePos);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSourceEditorManager.HideHintTimer(Sender: TObject);
|
|
||||||
begin
|
|
||||||
if FHints.HintIsVisible then begin
|
|
||||||
if ComparePoints(FHintMousePos, Mouse.CursorPos) <> 0 then begin
|
|
||||||
// TODO: introduce property, to indicate if hint is interactive
|
|
||||||
if FHints.HintIsComplex then
|
|
||||||
MaybeHideHint
|
|
||||||
else
|
|
||||||
HideHint;
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
FMouseHideHintTimer.Enabled := false;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSourceEditorManager.ActivateHint(const ScreenPos: TPoint;
|
procedure TSourceEditorManager.ActivateHint(const ScreenPos: TPoint;
|
||||||
const BaseURL, TheHint: string);
|
const BaseURL, TheHint: string; ShowByCommand: Boolean);
|
||||||
begin
|
begin
|
||||||
if csDestroying in ComponentState then exit;
|
if csDestroying in ComponentState then exit;
|
||||||
FHintMousePos := Mouse.CursorPos;
|
|
||||||
FHints.BaseURL := BaseURL;
|
|
||||||
if FHints.ShowHint(ScreenPos,TheHint) then
|
|
||||||
FMouseHideHintTimer.Enabled := True;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSourceEditorManager.HideHint;
|
FHints.ActivateHint(ScreenPos, BaseURL, TheHint, ShowByCommand);
|
||||||
begin
|
|
||||||
//DebugLn(['TSourceEditorManager.HideHint ']);
|
|
||||||
if FMouseHintTimer<>nil then
|
|
||||||
begin
|
|
||||||
FMouseHintTimer.AutoEnabled := false;
|
|
||||||
FMouseHintTimer.Enabled:=false;
|
|
||||||
end;
|
|
||||||
if FMouseHideHintTimer <> nil then
|
|
||||||
FMouseHideHintTimer.Enabled := False;
|
|
||||||
if AutoStartCompletionBoxTimer<>nil then
|
|
||||||
AutoStartCompletionBoxTimer.Enabled:=false;
|
|
||||||
FHints.HideHint;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSourceEditorManager.MaybeHideHint;
|
|
||||||
const
|
|
||||||
MaxJitter = 3;
|
|
||||||
var
|
|
||||||
Cur: TPoint;
|
|
||||||
OkX, OkY: Boolean;
|
|
||||||
hw: THintWindow;
|
|
||||||
begin
|
|
||||||
FMouseHideHintTimer.Enabled := False;
|
|
||||||
if FHints.HintIsVisible then begin
|
|
||||||
hw := FHints.CurHintWindow;
|
|
||||||
Cur := Mouse.CursorPos; // Desktop coordinates
|
|
||||||
OkX := ( (FHintMousePos.x <= hw.Left) and
|
|
||||||
(Cur.x > FHintMousePos.x) and (Cur.x <= hw.Left + hw.Width)
|
|
||||||
) or
|
|
||||||
( (FHintMousePos.x >= hw.Left + hw.Width) and
|
|
||||||
(Cur.x < FHintMousePos.x) and (Cur.x >= hw.Left)
|
|
||||||
) or
|
|
||||||
( (Cur.x >= hw.Left) and (Cur.x <= hw.Left + hw.Width) );
|
|
||||||
OkY := ( (FHintMousePos.y <= hw.Top) and
|
|
||||||
(Cur.y > FHintMousePos.y) and (Cur.y <= hw.Top + hw.Height)
|
|
||||||
) or
|
|
||||||
( (FHintMousePos.y >= hw.Top + hw.Height) and
|
|
||||||
(Cur.y < FHintMousePos.y) and (Cur.y >= hw.Top)
|
|
||||||
) or
|
|
||||||
( (Cur.y >= hw.Top) and (Cur.y <= hw.Top + hw.Height) );
|
|
||||||
|
|
||||||
if OkX then FHintMousePos.x := Cur.x;
|
|
||||||
if OkY then FHintMousePos.y := Cur.y;
|
|
||||||
|
|
||||||
|
|
||||||
OkX := OkX or
|
|
||||||
( (FHintMousePos.x <= hw.Left + MaxJitter) and
|
|
||||||
(Cur.x > FHintMousePos.x - MaxJitter) and (Cur.x <= hw.Left + hw.Width + MaxJitter)
|
|
||||||
) or
|
|
||||||
( (FHintMousePos.x >= hw.Left + hw.Width - MaxJitter) and
|
|
||||||
(Cur.x < FHintMousePos.x + MaxJitter) and (Cur.x >= hw.Left - MaxJitter)
|
|
||||||
);
|
|
||||||
OkY := OkY or
|
|
||||||
( (FHintMousePos.y <= hw.Top + MaxJitter) and
|
|
||||||
(Cur.y > FHintMousePos.y - MaxJitter) and (Cur.y <= hw.Top + hw.Height + MaxJitter)
|
|
||||||
) or
|
|
||||||
( (FHintMousePos.y >= hw.Top + hw.Height - MaxJitter) and
|
|
||||||
(Cur.y < FHintMousePos.y + MaxJitter) and (Cur.y >= hw.Top - MaxJitter)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (OkX and OkY) then begin
|
|
||||||
FMouseHideHintTimer.Enabled := True;
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
HideHint;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSourceEditorManager.UpdateHintTimer;
|
|
||||||
begin
|
|
||||||
with EditorOpts do
|
|
||||||
if (MainIDEInterface.ToolStatus=itDebugger) then
|
|
||||||
FMouseHintTimer.AutoEnabled := AutoToolTipExprEval or AutoToolTipSymbTools
|
|
||||||
else
|
|
||||||
FMouseHintTimer.AutoEnabled := AutoToolTipSymbTools;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSourceEditorManager.OnCodeTemplateTokenNotFound(Sender: TObject;
|
procedure TSourceEditorManager.OnCodeTemplateTokenNotFound(Sender: TObject;
|
||||||
@ -10547,26 +10644,9 @@ begin
|
|||||||
SourceEditorMarks.ExtToolsMarks.OnGetSynEditOfFile:=@OnSourceMarksGetSynEdit;
|
SourceEditorMarks.ExtToolsMarks.OnGetSynEditOfFile:=@OnSourceMarksGetSynEdit;
|
||||||
|
|
||||||
// HintWindow
|
// HintWindow
|
||||||
FHints := TIDEHintWindowManager.Create;
|
FHints := TSourceEditorHintWindowManager.Create(Self);
|
||||||
FHints.WindowName := Self.Name+'_HintWindow';
|
FHints.WindowName := Self.Name+'_HintWindow';
|
||||||
FHints.HideInterval := 4000;
|
FHints.HideInterval := 4000;
|
||||||
// HintTimer
|
|
||||||
FMouseHintTimer := TIdleTimer.Create(Self);
|
|
||||||
with FMouseHintTimer do begin
|
|
||||||
Name := Self.Name+'_MouseHintTimer';
|
|
||||||
Interval := EditorOpts.AutoDelayInMSec;
|
|
||||||
Enabled := False;
|
|
||||||
AutoEnabled := False;
|
|
||||||
OnTimer := @HintTimer;
|
|
||||||
end;
|
|
||||||
// Track mouse movements outside the IDE, if hint is visible
|
|
||||||
FMouseHideHintTimer := TTimer.Create(Self);
|
|
||||||
with FMouseHideHintTimer do begin
|
|
||||||
Name := Self.Name+'_MouseHintHideTimer';
|
|
||||||
Interval := 500;
|
|
||||||
Enabled := False;
|
|
||||||
OnTimer := @HideHintTimer;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// code templates
|
// code templates
|
||||||
FCodeTemplateModul:=TSynEditAutoComplete.Create(Self);
|
FCodeTemplateModul:=TSynEditAutoComplete.Create(Self);
|
||||||
@ -10600,8 +10680,6 @@ end;
|
|||||||
|
|
||||||
destructor TSourceEditorManager.Destroy;
|
destructor TSourceEditorManager.Destroy;
|
||||||
begin
|
begin
|
||||||
FreeAndNil(FMouseHideHintTimer);
|
|
||||||
FreeAndNil(FMouseHintTimer);
|
|
||||||
FreeAndNil(FHints);
|
FreeAndNil(FHints);
|
||||||
SourceEditorMarks.OnAction := nil;
|
SourceEditorMarks.OnAction := nil;
|
||||||
Application.RemoveAllHandlersOfObject(Self);
|
Application.RemoveAllHandlersOfObject(Self);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user