Remember the current row being edited in Console.

This commit is contained in:
Lasse Öörni 2011-03-02 22:51:21 +00:00
parent 97370cc707
commit 1a04680907
2 changed files with 8 additions and 2 deletions

View File

@ -198,7 +198,9 @@ void Console::handleTextFinished(StringHash eventType, VariantMap& eventData)
if (mHistory.size() > mHistoryRows)
mHistory.erase(mHistory.begin());
mHistoryPosition = mHistory.size();
mLineEdit->setText(std::string());
mCurrentRow = std::string();
mLineEdit->setText(mCurrentRow);
}
}
@ -216,6 +218,8 @@ void Console::handleLineEditKey(StringHash eventType, VariantMap& eventData)
case KEY_UP:
if (mHistoryPosition > 0)
{
if (mHistoryPosition == mHistory.size())
mCurrentRow = mLineEdit->getText();
--mHistoryPosition;
changed = true;
}
@ -235,7 +239,7 @@ void Console::handleLineEditKey(StringHash eventType, VariantMap& eventData)
if (mHistoryPosition < mHistory.size())
mLineEdit->setText(mHistory[mHistoryPosition]);
else
mLineEdit->setText(std::string());
mLineEdit->setText(mCurrentRow);
}
}

View File

@ -95,6 +95,8 @@ private:
SharedPtr<LineEdit> mLineEdit;
//! Command history
std::vector<std::string> mHistory;
//! Current row being edited
std::string mCurrentRow;
//! Command history maximum rows
unsigned mHistoryRows;
//! Command history current position