Skip to content

Commit

Permalink
Added show info with debug
Browse files Browse the repository at this point in the history
  • Loading branch information
maccasoft committed Oct 30, 2024
1 parent faa5f57 commit 396a9ea
Showing 1 changed file with 35 additions and 9 deletions.
44 changes: 35 additions & 9 deletions modules/spin-tools/src/com/maccasoft/propeller/SpinTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -1666,7 +1666,8 @@ public void widgetSelected(SelectionEvent e) {
@Override
public void widgetSelected(SelectionEvent e) {
try {
handleShowInfo();
boolean forceDebug = (e.stateMask & SWT.MOD1) != 0;
handleShowInfo(forceDebug);
} catch (Exception e1) {
e1.printStackTrace();
}
Expand Down Expand Up @@ -2711,7 +2712,18 @@ Menu createToolsMenu(Menu parent) {

@Override
public void handleEvent(Event e) {
handleShowInfo();
handleShowInfo(false);
}
});

item = new MenuItem(menu, SWT.PUSH);
item.setText("Show Info with Debug\tCtrl+F8");
item.setAccelerator(SWT.MOD1 | SWT.F8);
item.addListener(SWT.Selection, new Listener() {

@Override
public void handleEvent(Event e) {
handleShowInfo(true);
}
});

Expand Down Expand Up @@ -3022,7 +3034,7 @@ public void menuHidden(MenuEvent e) {
item.setMenu(menu);
}

private void handleShowInfo() {
private void handleShowInfo(boolean forceDebug) {
EditorTab editorTab = getTargetObjectEditorTab();
if (editorTab == null) {
return;
Expand All @@ -3034,21 +3046,35 @@ private void handleShowInfo() {
return;
}

SpinObject object = editorTab.getObject();
if (object == null) {
SpinObject obj = editorTab.getObject();
if (obj == null) {
return;
}
if (obj instanceof Spin1Object) {
forceDebug = false;
}

if (object instanceof Spin1Object) {
boolean isDebug = (obj instanceof Spin2Object) && ((Spin2Object) obj).getDebugger() != null;
if (isDebug != forceDebug) {
editorTab.runCompile(forceDebug);
if (editorTab.hasErrors()) {
MessageDialog.openError(shell, APP_TITLE, "Program has errors.");
editorTab.goToFirstError();
return;
}
obj = editorTab.getObject();
}

if (obj instanceof Spin1Object) {
P1MemoryDialog dlg = new P1MemoryDialog(shell);
dlg.setTheme(preferences.getTheme());
dlg.setObject((Spin1Object) object, editorTab.getObjectTree(), editorTab.isTopObject());
dlg.setObject((Spin1Object) obj, editorTab.getObjectTree(), editorTab.isTopObject());
dlg.open();
}
else if (object instanceof Spin2Object) {
else if (obj instanceof Spin2Object) {
P2MemoryDialog dlg = new P2MemoryDialog(shell);
dlg.setTheme(preferences.getTheme());
dlg.setObject((Spin2Object) object, editorTab.getObjectTree(), editorTab.isTopObject());
dlg.setObject((Spin2Object) obj, editorTab.getObjectTree(), editorTab.isTopObject());
dlg.open();
}
}
Expand Down

0 comments on commit 396a9ea

Please sign in to comment.