added clearHistory command for PromptWidget (see #240)

This commit is contained in:
Thomas Jentzsch 2021-05-10 20:30:32 +02:00
parent b8ed09695f
commit 6172943aaf
5 changed files with 31 additions and 2 deletions

View File

@ -936,6 +936,7 @@ Type "help 'cmd'" to see extended information about the given command.</p>
cheat - Use a cheat code (see manual for cheat types)
clearBreaks - Clear all breakpoints
clearConfig - Clear DiStella config directives [bank xx]
clearHistory - Clear the prompt history
clearSaveStateIfs - Clear all saveState points
clearTraps - Clear all traps
clearWatches - Clear all watches

View File

@ -950,6 +950,14 @@ void DebuggerParser::executeClearConfig()
commandResult << debugger.cartDebug().clearConfig();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "clearHistory"
void DebuggerParser::executeClearHistory()
{
debugger.prompt().clearHistory();
commandResult << "";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "clearBreaks"
void DebuggerParser::executeClearSaveStateIfs()
@ -2600,6 +2608,16 @@ DebuggerParser::CommandArray DebuggerParser::commands = { {
std::mem_fn(&DebuggerParser::executeClearConfig)
},
{
"clearHistory",
"Clear the prompt history",
"Example: clearhisotry (no parameters)",
false,
true,
{ Parameters::ARG_END_ARGS },
std::mem_fn(&DebuggerParser::executeClearHistory)
},
{
"clearSaveStateIfs",
"Clear all saveState points",

View File

@ -101,7 +101,7 @@ class DebuggerParser
std::array<Parameters, 10> parms;
std::function<void (DebuggerParser*)> executor;
};
using CommandArray = std::array<Command, 101>;
using CommandArray = std::array<Command, 102>;
static CommandArray commands;
struct Trap
@ -159,6 +159,7 @@ class DebuggerParser
void executeCheat();
void executeClearBreaks();
void executeClearConfig();
void executeClearHistory();
void executeClearSaveStateIfs();
void executeClearTraps();
void executeClearWatches();

View File

@ -966,6 +966,13 @@ void PromptWidget::clearScreen()
resetFunctions();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PromptWidget::clearHistory()
{
_history.clear();
_historyIndex = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PromptWidget::resetFunctions()
{

View File

@ -46,8 +46,10 @@ class PromptWidget : public Widget, public CommandSender
void printPrompt();
string saveBuffer(const FilesystemNode& file);
// Clear screen and erase all history
// Clear screen
void clearScreen();
// Erase all history
void clearHistory();
void addToHistory(const char *str);