[apps] When editing an expression model, replace UnknownX with 'x'

This commit is contained in:
Léa Saviot
2018-11-06 10:49:57 +01:00
committed by Émilie Feral
parent b73d066f2b
commit cce6591f54
3 changed files with 11 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
#include "storage_expression_model_list_controller.h"
#include <poincare/symbol.h>
namespace Shared {
@@ -183,9 +184,16 @@ void StorageExpressionModelListController::editExpression(Ion::Events::Event eve
char initialTextContent[TextField::maxBufferSize()];
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
Ion::Storage::Record record = modelStore()->recordAtIndex(modelIndexForRow(selectedRow()));
ExpiringPointer<StorageExpressionModel> model = modelStore()->modelForRecord(record);
ExpiringPointer<StorageExpressionModel> model = modelStore()->modelForRecord(record);
model->text(initialTextContent, TextField::maxBufferSize());
initialText = initialTextContent;
// Replace Poincare::Symbol::SpecialSymbols::UnknownX with 'x'
size_t initialTextLength = strlen(initialText);
for (size_t i = 0; i < initialTextLength; i++) {
if (initialTextContent[i] == Poincare::Symbol::SpecialSymbols::UnknownX) {
initialTextContent[i] = Poincare::Symbol::k_unknownXReadableChar;
}
}
}
inputController()->edit(this, event, this, initialText,
[](void * context, void * sender){

View File

@@ -48,6 +48,7 @@ class Symbol final : public SymbolAbstract {
friend class Store;
public:
static constexpr char k_ans[] = "ans";
static constexpr char k_unknownXReadableChar = 'x';
enum SpecialSymbols : char {
/* We can use characters from 1 to 31 as they do not correspond to usual
* characters but events as 'end of text', 'backspace'... */

View File

@@ -75,7 +75,7 @@ float SymbolNode::characteristicXRange(Context & context, Preferences::AngleUnit
Layout SymbolNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
if (m_name[0] == Symbol::SpecialSymbols::UnknownX) {
assert(m_name[1] == 0);
return CharLayout('x');
return CharLayout(Symbol::k_unknownXReadableChar);
}
if (strcmp(m_name, "u(n)") == 0) {
return HorizontalLayout(