Debugger: Simplify toggle breakpoint code & improve its behavior in source view

This commit is contained in:
Sour 2019-01-01 14:32:01 -05:00
parent 1c0921624f
commit 0b54ef6c0b
3 changed files with 11 additions and 36 deletions

View file

@ -289,17 +289,17 @@ namespace Mesen.GUI.Debugger.Controls
public void ToggleBreakpoint(bool toggleEnabledFlag)
{
int lineIndex = Viewer.CodeViewer.SelectedLine;
int relativeAddress = Viewer.CodeViewer.GetLineNumber(lineIndex);
if(relativeAddress < 0 && Viewer.CodeViewer.LineCount > lineIndex + 1) {
AddressTypeInfo info = Viewer.GetAddressInfo(Viewer.CodeViewer.SelectedLine);
if(info.Address >= 0) {
BreakpointManager.ToggleBreakpoint(-1, info, toggleEnabledFlag);
} 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)
lineIndex++;
relativeAddress = Viewer.CodeViewer.GetLineNumber(lineIndex);
info = Viewer.GetAddressInfo(Viewer.CodeViewer.SelectedLine + 1);
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)

View file

@ -273,17 +273,7 @@ namespace Mesen.GUI.Debugger
_tooltipManager.Close();
if(e.Button == MouseButtons.Left && e.Location.X < this.ctrlCodeViewer.CodeMargin / 4) {
int lineIndex = ctrlCodeViewer.GetLineIndexAtPosition(e.Y);
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);
_codeViewerActions.ToggleBreakpoint(false);
}
}

View file

@ -191,7 +191,7 @@ namespace Mesen.GUI.Debugger.Controls
private void mnuToggleBreakpoint_Click(object sender, EventArgs e)
{
ToggleBreakpoint();
_codeViewerActions.ToggleBreakpoint(false);
}
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)
{
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)
{
if(e.Button == MouseButtons.Left && e.Location.X < this.ctrlCodeViewer.CodeMargin / 4) {
ToggleBreakpoint();
_codeViewerActions.ToggleBreakpoint(false);
}
}