Debugger: Simplify toggle breakpoint code & improve its behavior in source view
This commit is contained in:
parent
1c0921624f
commit
0b54ef6c0b
3 changed files with 11 additions and 36 deletions
|
@ -289,17 +289,17 @@ namespace Mesen.GUI.Debugger.Controls
|
||||||
|
|
||||||
public void ToggleBreakpoint(bool toggleEnabledFlag)
|
public void ToggleBreakpoint(bool toggleEnabledFlag)
|
||||||
{
|
{
|
||||||
int lineIndex = Viewer.CodeViewer.SelectedLine;
|
AddressTypeInfo info = Viewer.GetAddressInfo(Viewer.CodeViewer.SelectedLine);
|
||||||
int relativeAddress = Viewer.CodeViewer.GetLineNumber(lineIndex);
|
if(info.Address >= 0) {
|
||||||
if(relativeAddress < 0 && Viewer.CodeViewer.LineCount > lineIndex + 1) {
|
BreakpointManager.ToggleBreakpoint(-1, info, toggleEnabledFlag);
|
||||||
|
} else {
|
||||||
//Current line has no address, try using the next line instead.
|
//Current line has no address, try using the next line instead.
|
||||||
//(Used when trying to set a breakpoint on a row containing only a label)
|
//(Used when trying to set a breakpoint on a row containing only a label)
|
||||||
lineIndex++;
|
info = Viewer.GetAddressInfo(Viewer.CodeViewer.SelectedLine + 1);
|
||||||
relativeAddress = Viewer.CodeViewer.GetLineNumber(lineIndex);
|
if(info.Address >= 0) {
|
||||||
|
BreakpointManager.ToggleBreakpoint(-1, info, toggleEnabledFlag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AddressTypeInfo info = Viewer.GetAddressInfo(lineIndex);
|
|
||||||
BreakpointManager.ToggleBreakpoint(relativeAddress, info, toggleEnabledFlag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mnuShowByteCodeOnLeft_Click(object sender, EventArgs e)
|
private void mnuShowByteCodeOnLeft_Click(object sender, EventArgs e)
|
||||||
|
|
|
@ -273,17 +273,7 @@ namespace Mesen.GUI.Debugger
|
||||||
_tooltipManager.Close();
|
_tooltipManager.Close();
|
||||||
|
|
||||||
if(e.Button == MouseButtons.Left && e.Location.X < this.ctrlCodeViewer.CodeMargin / 4) {
|
if(e.Button == MouseButtons.Left && e.Location.X < this.ctrlCodeViewer.CodeMargin / 4) {
|
||||||
int lineIndex = ctrlCodeViewer.GetLineIndexAtPosition(e.Y);
|
_codeViewerActions.ToggleBreakpoint(false);
|
||||||
int relativeAddress = ctrlCodeViewer.GetLineNumber(lineIndex);
|
|
||||||
if(relativeAddress < 0 && ctrlCodeViewer.LineCount > lineIndex + 1) {
|
|
||||||
//Current line has no address, try using the next line instead.
|
|
||||||
//(Used when trying to set a breakpoint on a row containing only a label)
|
|
||||||
lineIndex++;
|
|
||||||
relativeAddress = ctrlCodeViewer.GetLineNumber(lineIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
AddressTypeInfo info = GetAddressInfo(lineIndex);
|
|
||||||
BreakpointManager.ToggleBreakpoint(relativeAddress, info, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -191,7 +191,7 @@ namespace Mesen.GUI.Debugger.Controls
|
||||||
|
|
||||||
private void mnuToggleBreakpoint_Click(object sender, EventArgs e)
|
private void mnuToggleBreakpoint_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ToggleBreakpoint();
|
_codeViewerActions.ToggleBreakpoint(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AddressTypeInfo GetAddressInfo(int lineIndex)
|
public AddressTypeInfo GetAddressInfo(int lineIndex)
|
||||||
|
@ -237,21 +237,6 @@ namespace Mesen.GUI.Debugger.Controls
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ToggleBreakpoint()
|
|
||||||
{
|
|
||||||
AddressTypeInfo info = GetAddressInfo(ctrlCodeViewer.SelectedLine);
|
|
||||||
if(info.Address >= 0) {
|
|
||||||
BreakpointManager.ToggleBreakpoint(-1, info, false);
|
|
||||||
} else {
|
|
||||||
//Current line has no address, try using the next line instead.
|
|
||||||
//(Used when trying to set a breakpoint on a row containing only a label)
|
|
||||||
info = GetAddressInfo(ctrlCodeViewer.SelectedLine + 1);
|
|
||||||
if(info.Address >= 0) {
|
|
||||||
BreakpointManager.ToggleBreakpoint(-1, info, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ctrlCodeViewer_MouseMove(object sender, MouseEventArgs e)
|
private void ctrlCodeViewer_MouseMove(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
if(e.Location.X < this.ctrlCodeViewer.CodeMargin / 4) {
|
if(e.Location.X < this.ctrlCodeViewer.CodeMargin / 4) {
|
||||||
|
@ -266,7 +251,7 @@ namespace Mesen.GUI.Debugger.Controls
|
||||||
private void ctrlCodeViewer_MouseDown(object sender, MouseEventArgs e)
|
private void ctrlCodeViewer_MouseDown(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
if(e.Button == MouseButtons.Left && e.Location.X < this.ctrlCodeViewer.CodeMargin / 4) {
|
if(e.Button == MouseButtons.Left && e.Location.X < this.ctrlCodeViewer.CodeMargin / 4) {
|
||||||
ToggleBreakpoint();
|
_codeViewerActions.ToggleBreakpoint(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue