[code] Improved console command editing.

When the user scrolls the history, the draft command is not erased.
When pasting a previous command, the text is inserted at the cursor
location.

Change-Id: I1cd9645de74f34fad4ed0898203e05bd3352456a
This commit is contained in:
Léa Saviot
2017-11-07 17:31:44 +01:00
committed by Romain Goyet
parent 0d6cb75425
commit 2456c7eeba
5 changed files with 25 additions and 15 deletions

View File

@@ -10,9 +10,8 @@ ConsoleEditCell::ConsoleEditCell(Responder * parentResponder, TextFieldDelegate
HighlightCell(),
Responder(parentResponder),
m_textBuffer{0},
m_draftTextBuffer{0},
m_promptView(ConsoleController::k_fontSize, I18n::Message::ConsolePrompt, 0, 0.5),
m_textField(this, m_textBuffer, m_draftTextBuffer, TextField::maxBufferSize(), delegate, true, ConsoleController::k_fontSize)
m_textField(this, m_textBuffer, m_textBuffer, TextField::maxBufferSize(), delegate, false, ConsoleController::k_fontSize)
{
}
@@ -47,4 +46,11 @@ void ConsoleEditCell::setText(const char * text) {
m_textField.setText(text);
}
bool ConsoleEditCell::insertText(const char * text) {
bool didCopy = m_textField.insertTextAtLocation(text, m_textField.cursorLocation());
if (didCopy) {
m_textField.setCursorLocation(m_textField.cursorLocation() + strlen(text));
}
return didCopy;
}
}