fixed duplicate prompt when stepping, tracing etc. after browser dialog

a few minor improvements
This commit is contained in:
thrust26 2020-12-28 17:16:49 +01:00
parent b81617d7d7
commit 14a0f5cc64
2 changed files with 20 additions and 29 deletions

View File

@ -1244,20 +1244,19 @@ void DebuggerParser::executeDump()
if(argCount == 4) if(argCount == 4)
{ {
string outStr = out.str(); // ugly, why can't we transfer directly? DebuggerDialog* dlg = debugger.myDialog;
string resultStr = commandResult.str(); // same const string outStr = out.str(); // ugly, why can't we capture directly?
BrowserDialog::show(debugger.myDialog, "Save Dump as", path.str(), const string resultStr = commandResult.str(); // same
BrowserDialog::show(dlg, "Save Dump as", path.str(),
BrowserDialog::Mode::FileSave, BrowserDialog::Mode::FileSave,
[this, outStr, resultStr](bool OK, const FilesystemNode& node) [=](bool OK, const FilesystemNode& node)
{ {
DebuggerDialog* dlg = debugger.myDialog;
if(OK) if(OK)
{ {
ostringstream out, result; ostringstream out, result;
out << outStr; // ...and ugly back out.str(outStr); // ...and ugly back
result << resultStr; result.str(resultStr);
saveDump(node, out, result); saveDump(node, out, result);
dlg->prompt().print(result.str() + '\n'); dlg->prompt().print(result.str() + '\n');
@ -1265,7 +1264,7 @@ void DebuggerParser::executeDump()
dlg->prompt().printPrompt(); dlg->prompt().printPrompt();
}); });
// avoid printing a new prompt // avoid printing a new prompt
commandResult.str("_EXIT_DEBUGGER"); commandResult.str("_NO_PROMPT");
} }
else else
saveDump(FilesystemNode(path.str()), out, commandResult); saveDump(FilesystemNode(path.str()), out, commandResult);
@ -1894,16 +1893,14 @@ void DebuggerParser::executeSave()
BrowserDialog::show(dlg, "Save Workbench as", BrowserDialog::show(dlg, "Save Workbench as",
dlg->instance().userDir().getPath() + cartName() + ".script", dlg->instance().userDir().getPath() + cartName() + ".script",
BrowserDialog::Mode::FileSave, BrowserDialog::Mode::FileSave,
[this](bool OK, const FilesystemNode& node) [=](bool OK, const FilesystemNode& node)
{ {
DebuggerDialog* dlg = debugger.myDialog;
if(OK) if(OK)
dlg->prompt().print(saveScriptFile(node.getPath()) + '\n'); dlg->prompt().print(saveScriptFile(node.getPath()) + '\n');
dlg->prompt().printPrompt(); dlg->prompt().printPrompt();
}); });
// avoid printing a new prompt // avoid printing a new prompt
commandResult.str("_EXIT_DEBUGGER"); commandResult.str("_NO_PROMPT");
} }
else else
commandResult << saveScriptFile(argStrings[0]); commandResult << saveScriptFile(argStrings[0]);
@ -1920,16 +1917,14 @@ void DebuggerParser::executeSaveAccess()
BrowserDialog::show(dlg, "Save Access Counters as", BrowserDialog::show(dlg, "Save Access Counters as",
dlg->instance().userDir().getPath() + cartName() + ".csv", dlg->instance().userDir().getPath() + cartName() + ".csv",
BrowserDialog::Mode::FileSave, BrowserDialog::Mode::FileSave,
[this](bool OK, const FilesystemNode& node) [=](bool OK, const FilesystemNode& node)
{ {
DebuggerDialog* dlg = debugger.myDialog;
if(OK) if(OK)
dlg->prompt().print(debugger.cartDebug().saveAccessFile(node.getPath()) + '\n'); dlg->prompt().print(debugger.cartDebug().saveAccessFile(node.getPath()) + '\n');
dlg->prompt().printPrompt(); dlg->prompt().printPrompt();
}); });
// avoid printing a new prompt // avoid printing a new prompt
commandResult.str("_EXIT_DEBUGGER"); commandResult.str("_NO_PROMPT");
} }
else else
commandResult << debugger.cartDebug().saveAccessFile(); commandResult << debugger.cartDebug().saveAccessFile();
@ -1953,16 +1948,14 @@ void DebuggerParser::executeSavedisassembly()
BrowserDialog::show(dlg, "Save Disassembly as", BrowserDialog::show(dlg, "Save Disassembly as",
dlg->instance().userDir().getPath() + cartName() + ".asm", dlg->instance().userDir().getPath() + cartName() + ".asm",
BrowserDialog::Mode::FileSave, BrowserDialog::Mode::FileSave,
[this](bool OK, const FilesystemNode& node) [=](bool OK, const FilesystemNode& node)
{ {
DebuggerDialog* dlg = debugger.myDialog;
if(OK) if(OK)
dlg->prompt().print(debugger.cartDebug().saveDisassembly(node.getPath()) + '\n'); dlg->prompt().print(debugger.cartDebug().saveDisassembly(node.getPath()) + '\n');
dlg->prompt().printPrompt(); dlg->prompt().printPrompt();
}); });
// avoid printing a new prompt // avoid printing a new prompt
commandResult.str("_EXIT_DEBUGGER"); commandResult.str("_NO_PROMPT");
} }
else else
commandResult << debugger.cartDebug().saveDisassembly(); commandResult << debugger.cartDebug().saveDisassembly();
@ -1979,16 +1972,14 @@ void DebuggerParser::executeSaverom()
BrowserDialog::show(dlg, "Save ROM as", BrowserDialog::show(dlg, "Save ROM as",
dlg->instance().userDir().getPath() + cartName() + ".a26", dlg->instance().userDir().getPath() + cartName() + ".a26",
BrowserDialog::Mode::FileSave, BrowserDialog::Mode::FileSave,
[this](bool OK, const FilesystemNode& node) [=](bool OK, const FilesystemNode& node)
{ {
DebuggerDialog* dlg = debugger.myDialog;
if(OK) if(OK)
dlg->prompt().print(debugger.cartDebug().saveRom(node.getPath()) + '\n'); dlg->prompt().print(debugger.cartDebug().saveRom(node.getPath()) + '\n');
dlg->prompt().printPrompt(); dlg->prompt().printPrompt();
}); });
// avoid printing a new prompt // avoid printing a new prompt
commandResult.str("_EXIT_DEBUGGER"); commandResult.str("_NO_PROMPT");
} }
else else
commandResult << debugger.cartDebug().saveRom(); commandResult << debugger.cartDebug().saveRom();
@ -2009,16 +2000,14 @@ void DebuggerParser::executeSaveses()
BrowserDialog::show(dlg, "Save Session as", BrowserDialog::show(dlg, "Save Session as",
dlg->instance().userDir().getPath() + filename.str(), dlg->instance().userDir().getPath() + filename.str(),
BrowserDialog::Mode::FileSave, BrowserDialog::Mode::FileSave,
[this](bool OK, const FilesystemNode& node) [=](bool OK, const FilesystemNode& node)
{ {
DebuggerDialog* dlg = debugger.myDialog;
if(OK) if(OK)
dlg->prompt().print(debugger.prompt().saveBuffer(node) + '\n'); dlg->prompt().print(debugger.prompt().saveBuffer(node) + '\n');
dlg->prompt().printPrompt(); dlg->prompt().printPrompt();
}); });
// avoid printing a new prompt // avoid printing a new prompt
commandResult.str("_EXIT_DEBUGGER"); commandResult.str("_NO_PROMPT");
} }
else else
{ {

View File

@ -191,6 +191,8 @@ bool PromptWidget::handleKeyDown(StellaKey key, StellaMod mod)
_exitedEarly = true; _exitedEarly = true;
return true; return true;
} }
else if(result == "_NO_PROMPT")
return true;
else if(result != "") else if(result != "")
print(result + "\n"); print(result + "\n");
} }