mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-29 20:10:20 +02:00
MWE:
* Some minor debugger updates + Added evaluate to debugboss + Added hint debug evaluation git-svn-id: trunk@2990 -
This commit is contained in:
parent
f9ffe04081
commit
2a52f19b83
@ -40,10 +40,13 @@ uses
|
|||||||
{$IFDEF IDE_MEM_CHECK}
|
{$IFDEF IDE_MEM_CHECK}
|
||||||
MemCheck,
|
MemCheck,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Classes, SysUtils, Forms;
|
Classes, SysUtils, Forms, Debugger;
|
||||||
|
|
||||||
type
|
type
|
||||||
TBaseDebugManager = class(TComponent)
|
TBaseDebugManager = class(TComponent)
|
||||||
|
protected
|
||||||
|
function GetState: TDBGState; virtual; abstract;
|
||||||
|
function GetCommands: TDBGCommands; virtual; abstract;
|
||||||
public
|
public
|
||||||
procedure ConnectMainBarEvents; virtual; abstract;
|
procedure ConnectMainBarEvents; virtual; abstract;
|
||||||
procedure ConnectSourceNotebookEvents; virtual; abstract;
|
procedure ConnectSourceNotebookEvents; virtual; abstract;
|
||||||
@ -58,6 +61,11 @@ type
|
|||||||
|
|
||||||
procedure RunDebugger; virtual; abstract;
|
procedure RunDebugger; virtual; abstract;
|
||||||
procedure EndDebugging; virtual; abstract;
|
procedure EndDebugging; virtual; abstract;
|
||||||
|
function Evaluate(const AExpression: String; var AResult: String): Boolean; virtual; abstract; // Evaluates the given expression, returns true if valid
|
||||||
|
|
||||||
|
property Commands: TDBGCommands read GetCommands; // All current available commands of the debugger
|
||||||
|
property State: TDBGState read GetState; // The current state of the debugger
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
const
|
const
|
||||||
|
@ -47,7 +47,7 @@ uses
|
|||||||
SynEdit, SynEditHighlighter, SynHighlighterPas, SynEditAutoComplete,
|
SynEdit, SynEditHighlighter, SynHighlighterPas, SynEditAutoComplete,
|
||||||
SynEditKeyCmds, SynCompletion, GraphType, Graphics, Extctrls, Menus, Splash,
|
SynEditKeyCmds, SynCompletion, GraphType, Graphics, Extctrls, Menus, Splash,
|
||||||
FindInFilesDlg, LMessages, IDEProcs, IDEOptionDefs, InputHistory,
|
FindInFilesDlg, LMessages, IDEProcs, IDEOptionDefs, InputHistory,
|
||||||
LazarusIDEStrConsts;
|
LazarusIDEStrConsts, BaseDebugManager, Debugger;
|
||||||
|
|
||||||
type
|
type
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@ -90,6 +90,8 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
TCharSet = set of Char;
|
||||||
|
|
||||||
{---- TSource Editor ---
|
{---- TSource Editor ---
|
||||||
TSourceEditor is the class that controls access for the Editor.
|
TSourceEditor is the class that controls access for the Editor.
|
||||||
It creates the PopupMenu that appears when you right-click on the editor.
|
It creates the PopupMenu that appears when you right-click on the editor.
|
||||||
@ -136,7 +138,8 @@ type
|
|||||||
Procedure EditorMouseUp(Sender: TObject; Button: TMouseButton;
|
Procedure EditorMouseUp(Sender: TObject; Button: TMouseButton;
|
||||||
Shift: TShiftState; X,Y: Integer);
|
Shift: TShiftState; X,Y: Integer);
|
||||||
Procedure EditorKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
Procedure EditorKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||||
Function GetWordFromCaret(CaretPos : TPoint) : String;
|
function GetWordFromCaret(const ACaretPos: TPoint) : String;
|
||||||
|
function GetWordFromCaretEx(const ACaretPos: TPoint; const ALeftLimit, ARightLimit: TCharSet): String;
|
||||||
procedure SetCodeBuffer(NewCodeBuffer: TCodeBuffer);
|
procedure SetCodeBuffer(NewCodeBuffer: TCodeBuffer);
|
||||||
Function GetSource : TStrings;
|
Function GetSource : TStrings;
|
||||||
Procedure SetSource(Value : TStrings);
|
Procedure SetSource(Value : TStrings);
|
||||||
@ -1725,51 +1728,39 @@ begin
|
|||||||
Result := GetWordFromCaret(CaretPos);
|
Result := GetWordFromCaret(CaretPos);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TSourceEditor.GetWordFromCaret(CaretPos : TPoint) : String;
|
function TSourceEditor.GetWordFromCaret(const ACaretPos : TPoint) : String;
|
||||||
|
begin
|
||||||
|
Result := GetWordFromCaretEx(ACaretPos, ['A'..'Z', 'a'..'z', '0'..'9'], ['A'..'Z', 'a'..'z', '0'..'9']);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TSourceEditor.GetWordFromCaretEx(const ACaretPos: TPoint; const ALeftLimit, ARightLimit: TCharSet): String;
|
||||||
var
|
var
|
||||||
XLine,YLine : Integer;
|
XLine,YLine : Integer;
|
||||||
EditorLine,Texts : String;
|
EditorLine: String;
|
||||||
begin
|
begin
|
||||||
YLine := CaretPos.Y;
|
Result := '';
|
||||||
XLine := CaretPos.X;
|
|
||||||
|
YLine := ACaretPos.Y;
|
||||||
|
XLine := ACaretPos.X;
|
||||||
EditorLine := FEditor.Lines[YLine-1];
|
EditorLine := FEditor.Lines[YLine-1];
|
||||||
|
|
||||||
if Length(trim(EditorLine)) = 0 then Exit;
|
if Length(trim(EditorLine)) = 0 then Exit;
|
||||||
if XLine > Length(EditorLine) then Exit;
|
if XLine > Length(EditorLine) then Exit;
|
||||||
|
if not (EditorLine[XLine] in ALeftLimit) then Exit;
|
||||||
|
|
||||||
//walk backwards to a space or non-standard character.
|
//walk backwards to a space or non-standard character.
|
||||||
while (
|
while (XLine > 1) and (EditorLine[XLine - 1] in ALeftLimit) do Dec(XLine);
|
||||||
(upcase(EditorLine[XLine]) in (['A'..'Z'])) or
|
|
||||||
(upcase(EditorLine[XLine]) in (['0'..'9']))
|
|
||||||
) and
|
|
||||||
(XLine>1) do
|
|
||||||
dec(xLine);
|
|
||||||
|
|
||||||
if ( (XLine > 1) and (XLine < Length(EditorLine))) then Inc(xLine);
|
//chop off the beginning
|
||||||
|
Result := Copy(EditorLine, XLine, Length(EditorLine));
|
||||||
|
|
||||||
Texts := Copy(EditorLine,XLine,length(EditorLine)); //chop off the beginning
|
//start forward search
|
||||||
|
XLine := ACaretPos.X - XLine + 1;
|
||||||
|
|
||||||
XLine := 1;
|
while (XLine <= Length(Result)) and (Result[XLine] in ARightLimit) do Inc(Xline);
|
||||||
|
|
||||||
while (
|
// Strip remainder
|
||||||
(upcase(Texts[XLine]) in (['A'..'Z'])) or
|
SetLength(Result, XLine - 1);
|
||||||
(upcase(Texts[XLine]) in (['0'..'9']))
|
|
||||||
) and
|
|
||||||
(XLine< Length(Texts)) do
|
|
||||||
|
|
||||||
inc(xLine);
|
|
||||||
|
|
||||||
if (XLine < Length(Texts) ) and (XLine >1) then dec(xLine);
|
|
||||||
|
|
||||||
if not(
|
|
||||||
(upcase(Texts[XLine]) in (['A'..'Z'])) or
|
|
||||||
(upcase(Texts[XLine]) in (['0'..'9']))
|
|
||||||
) then
|
|
||||||
dec(xLine);
|
|
||||||
|
|
||||||
Texts := Copy(Texts,1,XLine);
|
|
||||||
|
|
||||||
Result := Texts;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSourceEditor.LinesDeleted(sender : TObject; FirstLine,
|
procedure TSourceEditor.LinesDeleted(sender : TObject; FirstLine,
|
||||||
@ -3496,7 +3487,7 @@ end;
|
|||||||
Procedure TSourceNotebook.HintTimer(sender : TObject);
|
Procedure TSourceNotebook.HintTimer(sender : TObject);
|
||||||
var
|
var
|
||||||
Rect : TRect;
|
Rect : TRect;
|
||||||
AHint : String;
|
AHint, HintEval : String;
|
||||||
cPosition : TPoint;
|
cPosition : TPoint;
|
||||||
TextPosition : TPoint;
|
TextPosition : TPoint;
|
||||||
SE : TSourceEditor;
|
SE : TSourceEditor;
|
||||||
@ -3523,17 +3514,33 @@ begin
|
|||||||
//Account for the gutter and tabs
|
//Account for the gutter and tabs
|
||||||
TextPosition.x := cPosition.X-EditorOPts.GutterWidth;
|
TextPosition.x := cPosition.X-EditorOPts.GutterWidth;
|
||||||
TextPosition.Y := cPosition.Y - 28;
|
TextPosition.Y := cPosition.Y - 28;
|
||||||
AHint := SE.GetWordAtPosition(TextPosition);
|
|
||||||
|
if (dcEvaluate in DebugBoss.Commands)
|
||||||
|
and SE.EditorComponent.SelAvail
|
||||||
|
then AHint := SE.EditorComponent.SelText
|
||||||
|
else AHint := '';
|
||||||
|
if AHint = ''
|
||||||
|
then AHint := SE.GetWordFromCaretEx(
|
||||||
|
SE.GetCaretPosFromCursorPos(TextPosition),
|
||||||
|
[#33..#255]-['!', '%', '*', '+', '-', '/', '?', ',', ';', ':', '{', '}', '(', ')', '='],
|
||||||
|
[#33..#255]-['!', '%', '*', '+', '-', '/', '?', ',', ';', ':', '{', '}', '(', ')', '=', '.']
|
||||||
|
);
|
||||||
|
|
||||||
|
SE.GetWordAtPosition(TextPosition);
|
||||||
|
|
||||||
|
//If no hint, then Exit
|
||||||
|
if AHint = '' then Exit;
|
||||||
|
|
||||||
//defaults for now just to demonstrate
|
//defaults for now just to demonstrate
|
||||||
if lowercase(AHint) = 'integer' then
|
if lowercase(AHint) = 'integer' then
|
||||||
AHint := 'type System.integer: -2147483648..214748347 system.pas'
|
AHint := 'type System.integer: -2147483648..214748347 system.pas'
|
||||||
else
|
else
|
||||||
if lowercase(AHint) = 'real' then
|
if lowercase(AHint) = 'real' then
|
||||||
AHint := 'type System.Real: Double -system.pas';
|
AHint := 'type System.Real: Double -system.pas'
|
||||||
|
else
|
||||||
|
if DebugBoss.Evaluate(AHint, HintEval) then
|
||||||
|
AHint := AHint + ' = ' + HintEval;
|
||||||
|
|
||||||
//If no hint, then Exit
|
|
||||||
if AHint = '' then Exit;
|
|
||||||
|
|
||||||
Caret := SE.GetCaretPosfromCursorPos(TextPosition);
|
Caret := SE.GetCaretPosfromCursorPos(TextPosition);
|
||||||
AHint := inttostr(Caret.Y)+','+Inttostr(Caret.X)+' : '+aHint;
|
AHint := inttostr(Caret.Y)+','+Inttostr(Caret.X)+' : '+aHint;
|
||||||
|
Loading…
Reference in New Issue
Block a user