Don't destroy the new command being entered in ConsoleView
Not a perfect solution as it doesn't remember the modifications made to previous commands, but it's more common to be concerned about the command being entered than about the changes made to the previous commands.
This commit is contained in:
parent
0e237a1f4b
commit
66ef37e778
@ -58,6 +58,10 @@ void ConsoleView::DoKeyPress(int key, int scan, bool repeat, bool shift, bool ct
|
|||||||
c->NextCommand();
|
c->NextCommand();
|
||||||
break;
|
break;
|
||||||
case SDLK_UP:
|
case SDLK_UP:
|
||||||
|
if (editingNewCommand)
|
||||||
|
{
|
||||||
|
newCommand = commandField->GetText();
|
||||||
|
}
|
||||||
c->PreviousCommand();
|
c->PreviousCommand();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -105,7 +109,16 @@ void ConsoleView::NotifyPreviousCommandsChanged(ConsoleModel * sender)
|
|||||||
|
|
||||||
void ConsoleView::NotifyCurrentCommandChanged(ConsoleModel * sender)
|
void ConsoleView::NotifyCurrentCommandChanged(ConsoleModel * sender)
|
||||||
{
|
{
|
||||||
commandField->SetText(sender->GetCurrentCommand().Command);
|
bool oldEditingNewCommand = editingNewCommand;
|
||||||
|
editingNewCommand = sender->GetCurrentCommandIndex() >= sender->GetPreviousCommands().size();
|
||||||
|
if (!oldEditingNewCommand && editingNewCommand)
|
||||||
|
{
|
||||||
|
commandField->SetText(newCommand);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
commandField->SetText(sender->GetCurrentCommand().Command);
|
||||||
|
}
|
||||||
commandField->SetDisplayText(c->FormatCommand(commandField->GetText()));
|
commandField->SetDisplayText(c->FormatCommand(commandField->GetText()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@ class ConsoleView: public ui::Window
|
|||||||
ui::Textbox * commandField;
|
ui::Textbox * commandField;
|
||||||
std::vector<ui::Label*> commandList;
|
std::vector<ui::Label*> commandList;
|
||||||
bool doClose = false;
|
bool doClose = false;
|
||||||
|
String newCommand;
|
||||||
|
bool editingNewCommand = true;
|
||||||
public:
|
public:
|
||||||
ConsoleView();
|
ConsoleView();
|
||||||
void OnDraw() override;
|
void OnDraw() override;
|
||||||
|
Loading…
Reference in New Issue
Block a user