mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[apps] When editing an expression model, replace UnknownX with 'x'
This commit is contained in:
@@ -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){
|
||||
|
||||
@@ -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'... */
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user