mirror of https://gitlab.com/basile.b/dexed.git
#97, declare a main menu entry + add shortcuts
This commit is contained in:
parent
5cb37dd538
commit
f74c62cc83
181
src/ce_gdb.pas
181
src/ce_gdb.pas
|
@ -178,9 +178,27 @@ type
|
||||||
procedure clear;
|
procedure clear;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// TODO-cGDB: shortcuts
|
|
||||||
// TODO-cGDB: assembly view
|
// TODO-cGDB: assembly view
|
||||||
|
|
||||||
|
// Makes a category for shortcuts in the option editor.
|
||||||
|
TCEDebugShortcuts = class(TPersistent)
|
||||||
|
private
|
||||||
|
fStart, fStop, fPause, fContinue, fStep, fStepOver, fStack, fRegs,
|
||||||
|
fVariables: TShortCut;
|
||||||
|
published
|
||||||
|
property start: TShortCut read fStart write fStart;
|
||||||
|
property stop: TShortCut read fStop write fStop;
|
||||||
|
property pause: TShortCut read fPause write fPause;
|
||||||
|
property continue: TShortcut read fContinue write fContinue;
|
||||||
|
property step: TShortCut read fStep write fStep;
|
||||||
|
property stepOver: TShortCut read fStepOver write fStepOver;
|
||||||
|
property updateStack: TShortCut read fStack write fStack;
|
||||||
|
property updateRegisters: TShortCut read fRegs write fRegs;
|
||||||
|
property updateVariables: TShortCut read fVariables write fVariables;
|
||||||
|
public
|
||||||
|
procedure assign(source: TPersistent); override;
|
||||||
|
end;
|
||||||
|
|
||||||
TCEDebugOptionsBase = class(TWritableLfmTextComponent)
|
TCEDebugOptionsBase = class(TWritableLfmTextComponent)
|
||||||
private
|
private
|
||||||
fAutoDemangle: boolean;
|
fAutoDemangle: boolean;
|
||||||
|
@ -191,8 +209,10 @@ type
|
||||||
fIgnoredSignals: TStringList;
|
fIgnoredSignals: TStringList;
|
||||||
fShowGdbOutput: boolean;
|
fShowGdbOutput: boolean;
|
||||||
fShowOutput: boolean;
|
fShowOutput: boolean;
|
||||||
|
fShortcuts: TCEDebugShortcuts;
|
||||||
procedure setIgnoredSignals(value: TStringList);
|
procedure setIgnoredSignals(value: TStringList);
|
||||||
procedure setCommandsHistory(value: TStringList);
|
procedure setCommandsHistory(value: TStringList);
|
||||||
|
procedure setShortcuts(value: TCEDebugShortcuts);
|
||||||
published
|
published
|
||||||
property autoDemangle: boolean read fAutoDemangle write fAutoDemangle;
|
property autoDemangle: boolean read fAutoDemangle write fAutoDemangle;
|
||||||
property autoGetCallStack: boolean read fAutoGetCallStack write fAutoGetCallStack;
|
property autoGetCallStack: boolean read fAutoGetCallStack write fAutoGetCallStack;
|
||||||
|
@ -200,6 +220,7 @@ type
|
||||||
property autoGetVariables: boolean read fAutoGetVariables write fAutoGetVariables;
|
property autoGetVariables: boolean read fAutoGetVariables write fAutoGetVariables;
|
||||||
property commandsHistory: TStringList read fCommandsHistory write setCommandsHistory;
|
property commandsHistory: TStringList read fCommandsHistory write setCommandsHistory;
|
||||||
property ignoredSignals: TStringList read fIgnoredSignals write setIgnoredSignals;
|
property ignoredSignals: TStringList read fIgnoredSignals write setIgnoredSignals;
|
||||||
|
property shortcuts: TCEDebugShortcuts read fShortcuts write setShortcuts;
|
||||||
property showGdbOutput: boolean read fShowGdbOutput write fShowGdbOutput;
|
property showGdbOutput: boolean read fShowGdbOutput write fShowGdbOutput;
|
||||||
property showOutput: boolean read fShowOutput write fShowOutput;
|
property showOutput: boolean read fShowOutput write fShowOutput;
|
||||||
public
|
public
|
||||||
|
@ -224,7 +245,7 @@ type
|
||||||
TGdbState = (gsNone, gsRunning, gsPaused);
|
TGdbState = (gsNone, gsRunning, gsPaused);
|
||||||
|
|
||||||
{ TCEGdbWidget }
|
{ TCEGdbWidget }
|
||||||
TCEGdbWidget = class(TCEWidget, ICEProjectObserver, ICEDocumentObserver, ICEDebugger)
|
TCEGdbWidget = class(TCEWidget, ICEProjectObserver, ICEDocumentObserver, ICEDebugger, ICEMainMenuProvider)
|
||||||
btnContinue: TCEToolButton;
|
btnContinue: TCEToolButton;
|
||||||
btnVariables: TCEToolButton;
|
btnVariables: TCEToolButton;
|
||||||
btnNext: TCEToolButton;
|
btnNext: TCEToolButton;
|
||||||
|
@ -271,6 +292,9 @@ type
|
||||||
fCatchPause: boolean;
|
fCatchPause: boolean;
|
||||||
fOptions: TCEDebugOptions;
|
fOptions: TCEDebugOptions;
|
||||||
//
|
//
|
||||||
|
procedure menuDeclare(item: TMenuItem);
|
||||||
|
procedure menuUpdate(item: TMenuItem);
|
||||||
|
//
|
||||||
procedure setState(value: TGdbState);
|
procedure setState(value: TGdbState);
|
||||||
procedure updateButtonsState;
|
procedure updateButtonsState;
|
||||||
procedure startDebugging;
|
procedure startDebugging;
|
||||||
|
@ -304,6 +328,7 @@ type
|
||||||
function singleServiceName: string;
|
function singleServiceName: string;
|
||||||
procedure addBreakPoint(const fname: string; line: integer; kind: TBreakPointKind);
|
procedure addBreakPoint(const fname: string; line: integer; kind: TBreakPointKind);
|
||||||
procedure removeBreakPoint(const fname: string; line: integer);
|
procedure removeBreakPoint(const fname: string; line: integer);
|
||||||
|
procedure executeFromShortcut(sender: TObject);
|
||||||
public
|
public
|
||||||
constructor create(aOwner: TComponent); override;
|
constructor create(aOwner: TComponent); override;
|
||||||
destructor destroy; override;
|
destructor destroy; override;
|
||||||
|
@ -316,6 +341,27 @@ implementation
|
||||||
{$REGION TCEDebugOption --------------------------------------------------------}
|
{$REGION TCEDebugOption --------------------------------------------------------}
|
||||||
const optFname = 'gdbcommander.txt';
|
const optFname = 'gdbcommander.txt';
|
||||||
|
|
||||||
|
|
||||||
|
procedure TCEDebugShortcuts.assign(source: TPersistent);
|
||||||
|
var
|
||||||
|
src: TCEDebugShortcuts;
|
||||||
|
begin
|
||||||
|
if source is TCEDebugShortcuts then
|
||||||
|
begin
|
||||||
|
src := TCEDebugShortcuts(source);
|
||||||
|
fStart := src.fStart;
|
||||||
|
fStop := src.fStop;
|
||||||
|
fPause := src.fPause;
|
||||||
|
fContinue := src.fContinue;
|
||||||
|
fStep := src.fStep;
|
||||||
|
fStepOver := src.fStepOver;
|
||||||
|
fStack := src.fStack;
|
||||||
|
fRegs := src.fRegs;
|
||||||
|
fVariables:= src.fVariables;
|
||||||
|
end
|
||||||
|
else inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TCEDebugOptionsBase.create(aOwner: TComponent);
|
constructor TCEDebugOptionsBase.create(aOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
@ -328,6 +374,7 @@ begin
|
||||||
fIgnoredSignals.Duplicates:= dupIgnore;
|
fIgnoredSignals.Duplicates:= dupIgnore;
|
||||||
fCommandsHistory := TStringList.Create;
|
fCommandsHistory := TStringList.Create;
|
||||||
fCommandsHistory.Duplicates:= dupIgnore;
|
fCommandsHistory.Duplicates:= dupIgnore;
|
||||||
|
fShortcuts := TCEDebugShortcuts.Create;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TCEDebugOptionsBase.destroy;
|
destructor TCEDebugOptionsBase.destroy;
|
||||||
|
@ -347,6 +394,11 @@ begin
|
||||||
fCommandsHistory.Assign(value);
|
fCommandsHistory.Assign(value);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCEDebugOptionsBase.setShortcuts(value: TCEDebugShortcuts);
|
||||||
|
begin
|
||||||
|
fShortcuts.assign(value);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCEDebugOptionsBase.assign(source: TPersistent);
|
procedure TCEDebugOptionsBase.assign(source: TPersistent);
|
||||||
var
|
var
|
||||||
src: TCEDebugOptionsBase;
|
src: TCEDebugOptionsBase;
|
||||||
|
@ -362,6 +414,7 @@ begin
|
||||||
fShowOutput:=src.fShowOutput;
|
fShowOutput:=src.fShowOutput;
|
||||||
fIgnoredSignals.Assign(src.fIgnoredSignals);
|
fIgnoredSignals.Assign(src.fIgnoredSignals);
|
||||||
fCommandsHistory.Assign(src.fCommandsHistory);
|
fCommandsHistory.Assign(src.fCommandsHistory);
|
||||||
|
fShortcuts.assign(src.fShortcuts);
|
||||||
end
|
end
|
||||||
else inherited;
|
else inherited;
|
||||||
end;
|
end;
|
||||||
|
@ -653,6 +706,128 @@ begin
|
||||||
inherited setToolBarFLat(value);
|
inherited setToolBarFLat(value);
|
||||||
btnSendCom.Flat:=value;
|
btnSendCom.Flat:=value;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCEGdbWidget.menuDeclare(item: TMenuItem);
|
||||||
|
var
|
||||||
|
itm: TMenuItem;
|
||||||
|
begin
|
||||||
|
item.Caption:='Debugger';
|
||||||
|
item.Clear;
|
||||||
|
|
||||||
|
itm := TMenuItem.Create(item);
|
||||||
|
itm.ShortCut:=fOptions.shortcuts.start;
|
||||||
|
itm.Caption:='Start';
|
||||||
|
itm.OnClick:= @executeFromShortcut;
|
||||||
|
itm.Tag:=0;
|
||||||
|
AssignPng(itm.Bitmap, btnStart.resourceName);
|
||||||
|
item.Add(itm);
|
||||||
|
|
||||||
|
itm := TMenuItem.Create(item);
|
||||||
|
itm.ShortCut:=fOptions.shortcuts.stop;
|
||||||
|
itm.Caption:='Stop';
|
||||||
|
itm.OnClick:= @executeFromShortcut;
|
||||||
|
itm.Tag:=1;
|
||||||
|
AssignPng(itm.Bitmap, btnStop.resourceName);
|
||||||
|
item.Add(itm);
|
||||||
|
|
||||||
|
itm := TMenuItem.Create(item);
|
||||||
|
itm.ShortCut:=fOptions.shortcuts.pause;
|
||||||
|
itm.Caption:='Pause';
|
||||||
|
itm.OnClick:= @executeFromShortcut;
|
||||||
|
itm.Tag:=2;
|
||||||
|
AssignPng(itm.Bitmap, btnPause.resourceName);
|
||||||
|
item.Add(itm);
|
||||||
|
|
||||||
|
itm := TMenuItem.Create(item);
|
||||||
|
itm.ShortCut:=fOptions.shortcuts.continue;
|
||||||
|
itm.Caption:='Continue';
|
||||||
|
itm.OnClick:= @executeFromShortcut;
|
||||||
|
itm.Tag:=3;
|
||||||
|
AssignPng(itm.Bitmap, btnContinue.resourceName);
|
||||||
|
item.Add(itm);
|
||||||
|
|
||||||
|
itm := TMenuItem.Create(item);
|
||||||
|
itm.ShortCut:=fOptions.shortcuts.step;
|
||||||
|
itm.Caption:='Step';
|
||||||
|
itm.OnClick:= @executeFromShortcut;
|
||||||
|
itm.Tag:=4;
|
||||||
|
AssignPng(itm.Bitmap, btnNext.resourceName);
|
||||||
|
item.Add(itm);
|
||||||
|
|
||||||
|
itm := TMenuItem.Create(item);
|
||||||
|
itm.ShortCut:=fOptions.shortcuts.stepOver;
|
||||||
|
itm.Caption:='Step over';
|
||||||
|
itm.OnClick:= @executeFromShortcut;
|
||||||
|
itm.Tag:=5;
|
||||||
|
AssignPng(itm.Bitmap, btnOver.resourceName);
|
||||||
|
item.Add(itm);
|
||||||
|
|
||||||
|
itm := TMenuItem.Create(item);
|
||||||
|
itm.Caption:= '-';
|
||||||
|
itm.Tag:=-1;
|
||||||
|
item.Add(itm);
|
||||||
|
|
||||||
|
itm := TMenuItem.Create(item);
|
||||||
|
itm.ShortCut:=fOptions.shortcuts.updateRegisters;
|
||||||
|
itm.Caption:='Update registers';
|
||||||
|
itm.OnClick:= @executeFromShortcut;
|
||||||
|
itm.Tag:=6;
|
||||||
|
AssignPng(itm.Bitmap, btnReg.resourceName);
|
||||||
|
item.Add(itm);
|
||||||
|
|
||||||
|
itm := TMenuItem.Create(item);
|
||||||
|
itm.ShortCut:=fOptions.shortcuts.updateStack;
|
||||||
|
itm.Caption:='Update call stack';
|
||||||
|
itm.OnClick:= @executeFromShortcut;
|
||||||
|
itm.Tag:=7;
|
||||||
|
AssignPng(itm.Bitmap, btnStack.resourceName);
|
||||||
|
item.Add(itm);
|
||||||
|
|
||||||
|
itm := TMenuItem.Create(item);
|
||||||
|
itm.ShortCut:=fOptions.shortcuts.updateVariables;
|
||||||
|
itm.Caption:='Update the variables';
|
||||||
|
itm.OnClick:= @executeFromShortcut;
|
||||||
|
itm.Tag:=8;
|
||||||
|
AssignPng(itm.Bitmap, btnVariables.resourceName);
|
||||||
|
item.Add(itm);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCEGdbWidget.menuUpdate(item: TMenuItem);
|
||||||
|
var
|
||||||
|
i: integer;
|
||||||
|
itm: TMenuItem;
|
||||||
|
begin
|
||||||
|
if item.isNil then
|
||||||
|
exit;
|
||||||
|
for i:= 0 to item.Count-1 do
|
||||||
|
begin
|
||||||
|
itm := item.Items[i];
|
||||||
|
case itm.Tag of
|
||||||
|
0:
|
||||||
|
begin
|
||||||
|
itm.ShortCut:=fOptions.shortcuts.start;
|
||||||
|
// TODO-cGDB: image assigned from toolbar button not displayed in menu
|
||||||
|
//if itm.Bitmap.Empty then
|
||||||
|
// AssignPng(itm.Bitmap, btnStart.resourceName);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCEGdbWidget.executeFromShortcut(sender: TObject);
|
||||||
|
begin
|
||||||
|
case TMenuItem(sender).Tag of
|
||||||
|
0: btnStart.Click;
|
||||||
|
1: btnStop.Click;
|
||||||
|
2: btnPause.Click;
|
||||||
|
3: btnContinue.Click;
|
||||||
|
4: btnNext.Click;
|
||||||
|
5: btnOver.Click;
|
||||||
|
6: btnReg.Click;
|
||||||
|
7: btnStack.Click;
|
||||||
|
8: btnVariables.Click;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
{$ENDREGION}
|
{$ENDREGION}
|
||||||
|
|
||||||
{$REGION ICEProjectObserver ----------------------------------------------------}
|
{$REGION ICEProjectObserver ----------------------------------------------------}
|
||||||
|
@ -1379,7 +1554,7 @@ begin
|
||||||
end;
|
end;
|
||||||
{$ENDREGION}
|
{$ENDREGION}
|
||||||
|
|
||||||
{$REGIOn GDB commands & actions ------------------------------------------------}
|
{$REGION GDB commands & actions ------------------------------------------------}
|
||||||
procedure TCEGdbWidget.gdbCommand(aCommand: string; gdbOutProcessor: TNotifyEvent = nil);
|
procedure TCEGdbWidget.gdbCommand(aCommand: string; gdbOutProcessor: TNotifyEvent = nil);
|
||||||
begin
|
begin
|
||||||
if fGdb.isNil or not fGdb.Running then
|
if fGdb.isNil or not fGdb.Running then
|
||||||
|
|
Loading…
Reference in New Issue