mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[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:
@@ -98,9 +98,8 @@ void ConsoleController::didBecomeFirstResponder() {
|
||||
|
||||
bool ConsoleController::handleEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::Up) {
|
||||
if (m_consoleStore.numberOfLines() > 0) {
|
||||
m_editCell.setEditing(false, true);
|
||||
m_editCell.setText("");
|
||||
if (m_consoleStore.numberOfLines() > 0 && m_selectableTableView.selectedRow() == m_consoleStore.numberOfLines()) {
|
||||
m_editCell.setEditing(false);
|
||||
m_selectableTableView.selectCellAtLocation(0, m_consoleStore.numberOfLines()-1);
|
||||
return true;
|
||||
}
|
||||
@@ -110,15 +109,10 @@ bool ConsoleController::handleEvent(Ion::Events::Event event) {
|
||||
m_editCell.setEditing(true);
|
||||
m_selectableTableView.selectCellAtLocation(0, m_consoleStore.numberOfLines());
|
||||
app()->setFirstResponder(&m_editCell);
|
||||
m_editCell.setText(text);
|
||||
return true;
|
||||
return m_editCell.insertText(text);
|
||||
}
|
||||
} else if (event == Ion::Events::Copy) {
|
||||
int row = m_selectableTableView.selectedRow();
|
||||
if (row < m_consoleStore.numberOfLines()) {
|
||||
Clipboard::sharedClipboard()->store(m_consoleStore.lineAtIndex(row).text());
|
||||
return true;
|
||||
}
|
||||
return copyCurrentLineToClipboard();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -204,7 +198,6 @@ bool ConsoleController::textFieldDidReceiveEvent(TextField * textField, Ion::Eve
|
||||
if (pythonText == nullptr) {
|
||||
return false;
|
||||
}
|
||||
textField->setEditing(true, false);
|
||||
if (textField->insertTextAtLocation(pythonText, textField->cursorLocation())) {
|
||||
textField->setCursorLocation(textField->cursorLocation()+strlen(pythonText));
|
||||
if (pythonText[strlen(pythonText)-1] == ')') {
|
||||
@@ -315,4 +308,14 @@ StackViewController * ConsoleController::stackViewController() {
|
||||
return static_cast<StackViewController *>(parentResponder());
|
||||
}
|
||||
|
||||
bool ConsoleController::copyCurrentLineToClipboard() {
|
||||
int row = m_selectableTableView.selectedRow();
|
||||
if (row < m_consoleStore.numberOfLines()) {
|
||||
Clipboard::sharedClipboard()->store(m_consoleStore.lineAtIndex(row).text());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user