Added a "GetRepeatCommand" to the command object. The Interpreter uses this
instead of the last history item to provide a command for the "empty" command. Use this in the source-file command to make <RETURN> continue the listing rather than relist the first listing... llvm-svn: 107736
This commit is contained in:
parent
49f1e908b2
commit
1308bb2791
|
@ -260,6 +260,7 @@ private:
|
|||
VariableMap m_variables;
|
||||
OptionArgMap m_alias_options; // Stores any options (with or without arguments) that go with any alias.
|
||||
std::vector<std::string> m_command_history;
|
||||
std::string m_repeat_command; // Stores the command that will be executed for an empty command string.
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -252,6 +252,21 @@ public:
|
|||
//------------------------------------------------------------------
|
||||
const Flags&
|
||||
GetFlags() const;
|
||||
|
||||
//------------------------------------------------------------------
|
||||
/// Get the command that appropriate for a "repeat" of the current command.
|
||||
///
|
||||
/// @param[in] current_command_line
|
||||
/// The complete current command line.
|
||||
///
|
||||
/// @return
|
||||
/// NULL if the command is not to be repeated.
|
||||
/// Otherwise a pointer to the command to be repeated.
|
||||
//------------------------------------------------------------------
|
||||
virtual const char *GetRepeatCommand (const char *current_command_line)
|
||||
{
|
||||
return current_command_line;
|
||||
}
|
||||
|
||||
protected:
|
||||
std::string m_cmd_name;
|
||||
|
|
|
@ -69,6 +69,13 @@ public:
|
|||
virtual
|
||||
Options *
|
||||
GetOptions ();
|
||||
|
||||
virtual const char *GetRepeatCommand (const char *current_command_line)
|
||||
{
|
||||
printf("\nReturning: \"%s\"\n", m_cmd_name.c_str());
|
||||
return m_cmd_name.c_str();
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
CommandOptions m_options;
|
||||
|
|
|
@ -627,7 +627,13 @@ CommandInterpreter::HandleCommand
|
|||
}
|
||||
else
|
||||
{
|
||||
command_line = m_command_history.back().c_str();
|
||||
command_line = m_repeat_command.c_str();
|
||||
if (m_repeat_command.empty())
|
||||
{
|
||||
result.AppendError("");
|
||||
result.SetStatus (eReturnStatusFailed);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
add_to_history = false;
|
||||
}
|
||||
|
@ -653,6 +659,18 @@ CommandInterpreter::HandleCommand
|
|||
return false;
|
||||
}
|
||||
|
||||
if (add_to_history)
|
||||
{
|
||||
const char *repeat_command = command_obj->GetRepeatCommand(command_line);
|
||||
if (repeat_command)
|
||||
m_repeat_command.assign(repeat_command);
|
||||
else
|
||||
m_repeat_command.clear();
|
||||
|
||||
m_command_history.push_back (command_line);
|
||||
}
|
||||
|
||||
|
||||
if (command_obj->WantsRawCommandString())
|
||||
{
|
||||
const char *stripped_command = ::strstr (command_line, command_cstr);
|
||||
|
@ -666,9 +684,6 @@ CommandInterpreter::HandleCommand
|
|||
}
|
||||
else
|
||||
{
|
||||
if (add_to_history)
|
||||
m_command_history.push_back (command_line);
|
||||
|
||||
// Remove the command from the args.
|
||||
command_args.Shift();
|
||||
command_obj->ExecuteWithOptions (*this, command_args, result);
|
||||
|
|
Loading…
Reference in New Issue