[apps/calculation] Improve text inserted in EditExpressionController

when handling OK events on additional outputs pop-ups
This commit is contained in:
Émilie Feral
2020-01-13 14:36:45 +01:00
committed by Léa Saviot
parent fef0538941
commit a4e8d24a23
6 changed files with 14 additions and 1 deletions

View File

@@ -59,4 +59,8 @@ Poincare::Layout ExpressionsListController::layoutAtIndex(int index) {
return m_layouts[index];
}
int ExpressionsListController::textAtIndex(char * buffer, size_t bufferSize, int index) {
return m_layouts[index].serializeParsedExpression(buffer, bufferSize);
}
}

View File

@@ -32,6 +32,7 @@ protected:
mutable Poincare::Layout m_layouts[k_maxNumberOfCells];
private:
Poincare::Layout layoutAtIndex(int index);
virtual int textAtIndex(char * buffer, size_t bufferSize, int index) override;
virtual void computeLayoutAtIndex(int index) = 0;
virtual I18n::Message messageAtIndex(int index) = 0;
// Cells

View File

@@ -119,4 +119,8 @@ void IllustratedListController::setExpression(Poincare::Expression e) {
context->setExpressionForSymbolAbstract(e, s);
}
int IllustratedListController::textAtIndex(char * buffer, size_t bufferSize, int index) {
return strlcpy(buffer, m_calculationStore.calculationAtIndex(index-1)->exactOutputText(), bufferSize);
}
}

View File

@@ -36,6 +36,7 @@ protected:
Poincare::Expression m_savedExpression;
CalculationStore m_calculationStore;
private:
int textAtIndex(char * buffer, size_t bufferSize, int index) override;
virtual CodePoint expressionSymbol() const = 0;
constexpr static int k_maxNumberOfAdditionalCalculations = 4;
// Cells

View File

@@ -30,7 +30,9 @@ ListController::ListController(Responder * parentResponder, EditExpressionContro
bool ListController::handleEvent(Ion::Events::Event event) {
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
m_editExpressionController->insertTextBody("TODO");
char buffer[Constant::MaxSerializedExpressionSize];
textAtIndex(buffer, Constant::MaxSerializedExpressionSize, selectedRow());
m_editExpressionController->insertTextBody(buffer);
Container::activeApp()->dismissModalViewController();
Container::activeApp()->setFirstResponder(m_editExpressionController);
return true;

View File

@@ -30,6 +30,7 @@ protected:
private:
SelectableTableView m_selectableTableView;
};
virtual int textAtIndex(char * buffer, size_t bufferSize, int index) = 0;
InnerListController m_listController;
EditExpressionController * m_editExpressionController;
};