mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 15:19:19 +02:00
debugger: add CopyRAWValue to locals dialog
git-svn-id: trunk@51375 -
This commit is contained in:
parent
4b5db67a88
commit
16c4777cbe
@ -75,6 +75,11 @@ object LocalsDlg: TLocalsDlg
|
|||||||
OnExecute = actCopyAllExecute
|
OnExecute = actCopyAllExecute
|
||||||
OnUpdate = actCopyAllUpdate
|
OnUpdate = actCopyAllUpdate
|
||||||
end
|
end
|
||||||
|
object actCopyRAWValue: TAction
|
||||||
|
Category = 'copy'
|
||||||
|
Caption = 'actCopyRAWValue'
|
||||||
|
OnExecute = actCopyRAWValueExecute
|
||||||
|
end
|
||||||
end
|
end
|
||||||
object PopupMenu1: TPopupMenu
|
object PopupMenu1: TPopupMenu
|
||||||
left = 38
|
left = 38
|
||||||
@ -97,6 +102,9 @@ object LocalsDlg: TLocalsDlg
|
|||||||
object MenuItem6: TMenuItem
|
object MenuItem6: TMenuItem
|
||||||
Action = actCopyValue
|
Action = actCopyValue
|
||||||
end
|
end
|
||||||
|
object MenuItem8: TMenuItem
|
||||||
|
Action = actCopyRAWValue
|
||||||
|
end
|
||||||
object MenuItem7: TMenuItem
|
object MenuItem7: TMenuItem
|
||||||
Action = actCopyAll
|
Action = actCopyAll
|
||||||
end
|
end
|
||||||
|
@ -50,6 +50,7 @@ type
|
|||||||
actCopyName: TAction;
|
actCopyName: TAction;
|
||||||
actCopyValue: TAction;
|
actCopyValue: TAction;
|
||||||
actCopyAll: TAction;
|
actCopyAll: TAction;
|
||||||
|
actCopyRAWValue: TAction;
|
||||||
actWath: TAction;
|
actWath: TAction;
|
||||||
ActionList1: TActionList;
|
ActionList1: TActionList;
|
||||||
lvLocals: TListView;
|
lvLocals: TListView;
|
||||||
@ -60,6 +61,7 @@ type
|
|||||||
MenuItem5: TMenuItem;
|
MenuItem5: TMenuItem;
|
||||||
MenuItem6: TMenuItem;
|
MenuItem6: TMenuItem;
|
||||||
MenuItem7: TMenuItem;
|
MenuItem7: TMenuItem;
|
||||||
|
MenuItem8: TMenuItem;
|
||||||
PopupMenu1: TPopupMenu;
|
PopupMenu1: TPopupMenu;
|
||||||
procedure actCopyAllExecute(Sender: TObject);
|
procedure actCopyAllExecute(Sender: TObject);
|
||||||
procedure actCopyAllUpdate(Sender: TObject);
|
procedure actCopyAllUpdate(Sender: TObject);
|
||||||
@ -68,6 +70,7 @@ type
|
|||||||
procedure actEvaluateExecute(Sender: TObject);
|
procedure actEvaluateExecute(Sender: TObject);
|
||||||
procedure actInspectExecute(Sender: TObject);
|
procedure actInspectExecute(Sender: TObject);
|
||||||
procedure actInspectUpdate(Sender: TObject);
|
procedure actInspectUpdate(Sender: TObject);
|
||||||
|
procedure actCopyRAWValueExecute(Sender: TObject);
|
||||||
procedure actWathExecute(Sender: TObject);
|
procedure actWathExecute(Sender: TObject);
|
||||||
private
|
private
|
||||||
FUpdateFlags: set of (ufNeedUpdating);
|
FUpdateFlags: set of (ufNeedUpdating);
|
||||||
@ -89,6 +92,7 @@ type
|
|||||||
property SnapshotManager;
|
property SnapshotManager;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function ValueToRAW(const AValue: string): string;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -119,6 +123,97 @@ begin
|
|||||||
TLocalsDlg(AForm).ColSizeSetter(AColId, ASize);
|
TLocalsDlg(AForm).ColSizeSetter(AColId, ASize);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function ValueToRAW(const AValue: string): string;
|
||||||
|
var
|
||||||
|
I: Integer; //current char in AValue
|
||||||
|
M: Integer; //max char in AValue
|
||||||
|
L: Integer; //current char in Result
|
||||||
|
|
||||||
|
procedure ProcessCharConsts;
|
||||||
|
var
|
||||||
|
xNum: string;
|
||||||
|
xCharOrd: Integer;
|
||||||
|
begin
|
||||||
|
while (I <= M) and (AValue[I] = '#') do
|
||||||
|
begin
|
||||||
|
Inc(I);
|
||||||
|
xNum := '';
|
||||||
|
while (I <= M) and (AValue[I] in ['0'..'9']) do
|
||||||
|
begin
|
||||||
|
xNum := xNum + AValue[I]; // not really fast, but OK for this purpose
|
||||||
|
Inc(I);
|
||||||
|
end;
|
||||||
|
if TryStrToInt(xNum, xCharOrd) then
|
||||||
|
begin
|
||||||
|
Result[L] := Char(xCharOrd);
|
||||||
|
Inc(L);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure ProcessQuote;
|
||||||
|
begin
|
||||||
|
Inc(I);
|
||||||
|
if AValue[I] = '''' then // "''" => "'"
|
||||||
|
begin
|
||||||
|
Result[L] := AValue[I];
|
||||||
|
Inc(L);
|
||||||
|
end else
|
||||||
|
if AValue[I] = '#' then // "'#13#10'" => [CRLF]
|
||||||
|
ProcessCharConsts;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure ProcessString;
|
||||||
|
begin
|
||||||
|
I := 2;
|
||||||
|
L := 1;
|
||||||
|
M := Length(AValue);
|
||||||
|
if AValue[M] = '''' then
|
||||||
|
Dec(M);
|
||||||
|
SetLength(Result, Length(AValue)-2);
|
||||||
|
while I <= M do
|
||||||
|
begin
|
||||||
|
if AValue[I] = '''' then
|
||||||
|
begin
|
||||||
|
ProcessQuote;
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
Result[L] := AValue[I];
|
||||||
|
Inc(L);
|
||||||
|
end;
|
||||||
|
Inc(I);
|
||||||
|
end;
|
||||||
|
SetLength(Result, L-1);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure ProcessOther;
|
||||||
|
begin
|
||||||
|
I := Pos('(', AValue);
|
||||||
|
if I > 0 then
|
||||||
|
begin
|
||||||
|
// Invalid enum value: "true (85)" => "85"
|
||||||
|
L := Pos(')', AValue, I+1);
|
||||||
|
Result := Copy(AValue, I+1, L-I-1);
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
//no formatting
|
||||||
|
Result := AValue;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
begin
|
||||||
|
// try to guess and format value back to raw data, e.g.
|
||||||
|
// "'value'" => "value"
|
||||||
|
// "true (85)" => "85"
|
||||||
|
if AValue='' then
|
||||||
|
Exit('');
|
||||||
|
|
||||||
|
if AValue[1] = '''' then
|
||||||
|
//string "'val''ue'" => "val'ue"
|
||||||
|
ProcessString
|
||||||
|
else
|
||||||
|
ProcessOther;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TLocalsDlg }
|
{ TLocalsDlg }
|
||||||
|
|
||||||
constructor TLocalsDlg.Create(AOwner: TComponent);
|
constructor TLocalsDlg.Create(AOwner: TComponent);
|
||||||
@ -139,6 +234,7 @@ begin
|
|||||||
actEvaluate.Caption := lisEvaluateModify;
|
actEvaluate.Caption := lisEvaluateModify;
|
||||||
actCopyName.Caption := lisLocalsDlgCopyName;
|
actCopyName.Caption := lisLocalsDlgCopyName;
|
||||||
actCopyValue.Caption := lisLocalsDlgCopyValue;
|
actCopyValue.Caption := lisLocalsDlgCopyValue;
|
||||||
|
actCopyRAWValue.Caption := lisLocalsDlgCopyRAWValue;
|
||||||
actCopyAll.Caption := lisCopyAll;
|
actCopyAll.Caption := lisCopyAll;
|
||||||
|
|
||||||
for i := low(COL_WIDTHS) to high(COL_WIDTHS) do
|
for i := low(COL_WIDTHS) to high(COL_WIDTHS) do
|
||||||
@ -150,6 +246,13 @@ begin
|
|||||||
(Sender as TAction).Enabled := Assigned(lvLocals.Selected);
|
(Sender as TAction).Enabled := Assigned(lvLocals.Selected);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TLocalsDlg.actCopyRAWValueExecute(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Clipboard.Open;
|
||||||
|
Clipboard.AsText := ValueToRAW(lvLocals.Selected.SubItems[0]);
|
||||||
|
Clipboard.Close;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TLocalsDlg.actWathExecute(Sender: TObject);
|
procedure TLocalsDlg.actWathExecute(Sender: TObject);
|
||||||
var
|
var
|
||||||
S: String;
|
S: String;
|
||||||
|
@ -5346,6 +5346,7 @@ resourcestring
|
|||||||
lisEvaluateModify = '&Evaluate/Modify';
|
lisEvaluateModify = '&Evaluate/Modify';
|
||||||
lisLocalsDlgCopyName = '&Copy Name';
|
lisLocalsDlgCopyName = '&Copy Name';
|
||||||
lisLocalsDlgCopyValue = 'C&opy Value';
|
lisLocalsDlgCopyValue = 'C&opy Value';
|
||||||
|
lisLocalsDlgCopyRAWValue = 'Copy &RAW Value';
|
||||||
|
|
||||||
// Registers Dialog
|
// Registers Dialog
|
||||||
lisRegisters = 'Registers';
|
lisRegisters = 'Registers';
|
||||||
|
Loading…
Reference in New Issue
Block a user