From 5db2d836f41e2d998c26628257cc8f0302c79c31 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Tue, 10 Oct 2017 12:00:10 +0200 Subject: [PATCH] prompt is initially filled by the executed script files commands --- src/debugger/Debugger.cxx | 6 +++--- src/debugger/Debugger.hxx | 2 +- src/debugger/DebuggerParser.cxx | 6 ++++-- src/debugger/DebuggerParser.hxx | 2 +- src/debugger/gui/PromptWidget.cxx | 9 ++++++++- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/debugger/Debugger.cxx b/src/debugger/Debugger.cxx index 50b86f042..de570fbba 100644 --- a/src/debugger/Debugger.cxx +++ b/src/debugger/Debugger.cxx @@ -207,18 +207,18 @@ void Debugger::quit(bool exitrom) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string Debugger::autoExec() +string Debugger::autoExec(StringList* history) { ostringstream buf; // autoexec.script is always run FilesystemNode autoexec(myOSystem.baseDir() + "autoexec.script"); buf << "autoExec():" << endl - << myParser->exec(autoexec) << endl; + << myParser->exec(autoexec, history) << endl; // Also, "romname.script" if present FilesystemNode romname(myOSystem.romFile().getPathWithExt(".script")); - buf << myParser->exec(romname) << endl; + buf << myParser->exec(romname, history) << endl; // Init builtins for(int i = 0; builtin_functions[i][0] != 0; i++) diff --git a/src/debugger/Debugger.hxx b/src/debugger/Debugger.hxx index 5c439f255..2d4582d74 100644 --- a/src/debugger/Debugger.hxx +++ b/src/debugger/Debugger.hxx @@ -154,7 +154,7 @@ class Debugger : public DialogContainer */ const string run(const string& command); - string autoExec(); + string autoExec(StringList* history); string showWatches(); diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index 6ed4f201d..dfbff36bc 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -126,7 +126,7 @@ string DebuggerParser::run(const string& command) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string DebuggerParser::exec(const FilesystemNode& file) +string DebuggerParser::exec(const FilesystemNode& file, StringList* history) { if(file.exists()) { @@ -143,6 +143,8 @@ string DebuggerParser::exec(const FilesystemNode& file) break; run(command); + if (history != nullptr) + history->push_back(command); count++; } buf << "\nExecuted " << count << " commands from \"" @@ -1026,7 +1028,7 @@ void DebuggerParser::executeExec() file += ".script"; FilesystemNode node(debugger.myOSystem.defaultSaveDir() + file); - commandResult << exec(node); + commandResult << exec(node, NULL); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/DebuggerParser.hxx b/src/debugger/DebuggerParser.hxx index fe686f523..c423a22e0 100644 --- a/src/debugger/DebuggerParser.hxx +++ b/src/debugger/DebuggerParser.hxx @@ -39,7 +39,7 @@ class DebuggerParser string run(const string& command); /** Execute parser commands given in 'file' */ - string exec(const FilesystemNode& file); + string exec(const FilesystemNode& file, StringList* history = nullptr); /** Given a substring, determine matching substrings from the list of available commands. Used in the debugger prompt for tab-completion */ diff --git a/src/debugger/gui/PromptWidget.cxx b/src/debugger/gui/PromptWidget.cxx index 65105d19a..33aa0284a 100644 --- a/src/debugger/gui/PromptWidget.cxx +++ b/src/debugger/gui/PromptWidget.cxx @@ -501,7 +501,14 @@ void PromptWidget::loadConfig() print(PROMPT); // Take care of one-time debugger stuff - print(instance().debugger().autoExec()); + // fill the history from the saves breaks, traps and watches commands + StringList history; + print(instance().debugger().autoExec(&history)); + for(uInt32 i = 0; i < history.size(); i++) + { + addToHistory(history[i].c_str()); + } + history.clear(); print(instance().debugger().cartDebug().loadConfigFile() + "\n"); print(instance().debugger().cartDebug().loadListFile() + "\n"); print(instance().debugger().cartDebug().loadSymbolFile() + "\n");