mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 09:59:23 +02:00
ide: minor refactoring:
- add GetOperandFromCaret, GetOperandAtCurrentCaret to the TSourceEditor class - use that methods for the debugger tooltip evaluation and for the debugger evaluate dialog git-svn-id: trunk@21969 -
This commit is contained in:
parent
b11fa376c6
commit
71d8ecf4de
@ -1690,7 +1690,7 @@ begin
|
|||||||
if SourceNotebook.GetActiveSE.SelectionAvailable then
|
if SourceNotebook.GetActiveSE.SelectionAvailable then
|
||||||
TEvaluateDlg(CurDialog).FindText := SourceNotebook.GetActiveSE.Selection
|
TEvaluateDlg(CurDialog).FindText := SourceNotebook.GetActiveSE.Selection
|
||||||
else
|
else
|
||||||
TEvaluateDlg(CurDialog).FindText := SourceNotebook.GetActiveSE.GetWordAtCurrentCaret;
|
TEvaluateDlg(CurDialog).FindText := SourceNotebook.GetActiveSE.GetOperandAtCurrentCaret;
|
||||||
end;
|
end;
|
||||||
FDialogs[ADialogType].Show;
|
FDialogs[ADialogType].Show;
|
||||||
end;
|
end;
|
||||||
|
18
ide/main.pp
18
ide/main.pp
@ -13513,9 +13513,7 @@ procedure TMainIDE.OnSrcNotebookShowHintForSource(SrcEdit: TSourceEditor;
|
|||||||
var
|
var
|
||||||
ActiveSrcEdit: TSourceEditor;
|
ActiveSrcEdit: TSourceEditor;
|
||||||
ActiveUnitInfo: TUnitInfo;
|
ActiveUnitInfo: TUnitInfo;
|
||||||
Identifier, SmartHintStr: string;
|
BaseURL, SmartHintStr, Expression, DebugEval: String;
|
||||||
Expression, DebugEval: string;
|
|
||||||
BaseURL: String;
|
|
||||||
begin
|
begin
|
||||||
//DebugLn(['TMainIDE.OnSrcNotebookShowHintForSource START']);
|
//DebugLn(['TMainIDE.OnSrcNotebookShowHintForSource START']);
|
||||||
if (SrcEdit=nil) then exit;
|
if (SrcEdit=nil) then exit;
|
||||||
@ -13538,16 +13536,10 @@ begin
|
|||||||
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.OnSrcNotebookShowHintForSource B');{$ENDIF}
|
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.OnSrcNotebookShowHintForSource B');{$ENDIF}
|
||||||
end;
|
end;
|
||||||
itDebugger: begin
|
itDebugger: begin
|
||||||
Identifier := SrcEdit.GetWordFromCaret(CaretPos);
|
if SrcEdit.SelectionAvailable and SrcEdit.CaretInSelection(CaretPos) then
|
||||||
//DebugLn(['TMainIDE.OnSrcNotebookShowHintForSource ',Identifier]);
|
|
||||||
if Identifier = '' then Exit;
|
|
||||||
if SrcEdit.SelectionAvailable and SrcEdit.CaretInSelection(CaretPos) then
|
|
||||||
Expression := SrcEdit.GetText(True)
|
Expression := SrcEdit.GetText(True)
|
||||||
else
|
else
|
||||||
if not CodeToolBoss.ExtractOperand(SrcEdit.CodeBuffer,
|
Expression := SrcEdit.GetOperandFromCaret(CaretPos);
|
||||||
CaretPos.X,CaretPos.Y,Expression,false) then
|
|
||||||
Expression := Identifier;
|
|
||||||
//DebugLn(['TMainIDE.OnSrcNotebookShowHintForSource Expr="',Expression,'"']);
|
|
||||||
if not DebugBoss.Evaluate(Expression, DebugEval) or (DebugEval = '') then
|
if not DebugBoss.Evaluate(Expression, DebugEval) or (DebugEval = '') then
|
||||||
DebugEval := '???';
|
DebugEval := '???';
|
||||||
SmartHintStr := Expression + ' = ' + DebugEval;
|
SmartHintStr := Expression + ' = ' + DebugEval;
|
||||||
@ -13556,8 +13548,8 @@ begin
|
|||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if SmartHintStr<>'' then
|
if SmartHintStr <> '' then
|
||||||
SrcEdit.ActivateHint(ClientPos,BaseURL,SmartHintStr);
|
SrcEdit.ActivateHint(ClientPos, BaseURL, SmartHintStr);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.OnSrcNoteBookActivated(Sender: TObject);
|
procedure TMainIDE.OnSrcNoteBookActivated(Sender: TObject);
|
||||||
|
@ -312,6 +312,8 @@ type
|
|||||||
function GetWordAtPosition(Position: TPoint): String;
|
function GetWordAtPosition(Position: TPoint): String;
|
||||||
function GetWordFromCaret(const ACaretPos: TPoint): String;
|
function GetWordFromCaret(const ACaretPos: TPoint): String;
|
||||||
function GetWordAtCurrentCaret: String;
|
function GetWordAtCurrentCaret: String;
|
||||||
|
function GetOperandFromCaret(const ACaretPos: TPoint): String;
|
||||||
|
function GetOperandAtCurrentCaret: String;
|
||||||
function CaretInSelection(const ACaretPos: TPoint): Boolean;
|
function CaretInSelection(const ACaretPos: TPoint): Boolean;
|
||||||
function PositionInSelection(const APosition: TPoint): Boolean;
|
function PositionInSelection(const APosition: TPoint): Boolean;
|
||||||
|
|
||||||
@ -3274,16 +3276,30 @@ begin
|
|||||||
FillExecutionMarks;
|
FillExecutionMarks;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TSourceEditor.GetWordAtCurrentCaret: String;
|
function TSourceEditor.GetWordAtCurrentCaret: String;
|
||||||
var
|
var
|
||||||
CaretPos: TPoint;
|
CaretPos: TPoint;
|
||||||
begin
|
begin
|
||||||
Result := '';
|
|
||||||
CaretPos.Y := CurrentCursorYLine;
|
CaretPos.Y := CurrentCursorYLine;
|
||||||
CaretPos.X := CurrentCursorXLine;
|
CaretPos.X := CurrentCursorXLine;
|
||||||
Result := GetWordFromCaret(ScreenToTextPosition(CaretPos));
|
Result := GetWordFromCaret(ScreenToTextPosition(CaretPos));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TSourceEditor.GetOperandFromCaret(const ACaretPos: TPoint): String;
|
||||||
|
begin
|
||||||
|
if not CodeToolBoss.ExtractOperand(CodeBuffer, ACaretPos.X, ACaretPos.Y, Result, False) then
|
||||||
|
Result := GetWordFromCaret(ACaretPos);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TSourceEditor.GetOperandAtCurrentCaret: String;
|
||||||
|
var
|
||||||
|
CaretPos: TPoint;
|
||||||
|
begin
|
||||||
|
CaretPos.Y := CurrentCursorYLine;
|
||||||
|
CaretPos.X := CurrentCursorXLine;
|
||||||
|
Result := GetOperandFromCaret(ScreenToTextPosition(CaretPos));
|
||||||
|
end;
|
||||||
|
|
||||||
function TSourceEditor.GetWordFromCaret(const ACaretPos: TPoint): String;
|
function TSourceEditor.GetWordFromCaret(const ACaretPos: TPoint): String;
|
||||||
begin
|
begin
|
||||||
Result := FEditor.GetWordAtRowCol(ACaretPos);
|
Result := FEditor.GetWordAtRowCol(ACaretPos);
|
||||||
|
Loading…
Reference in New Issue
Block a user