From b567a09103c4029883a7a0b04b6702aaa97cf55a Mon Sep 17 00:00:00 2001 From: Arthur Camouseigt Date: Thu, 15 Oct 2020 11:29:21 +0200 Subject: [PATCH] [VariableBox] Allowing sequences to display their type Change-Id: I2929f7d9f3a266fbff81100a39f793fe6200da1d --- apps/math_variable_box_controller.cpp | 2 +- apps/shared/sequence.cpp | 18 ++++++++++++++++++ apps/shared/sequence.h | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/apps/math_variable_box_controller.cpp b/apps/math_variable_box_controller.cpp index f1032a5b5..f8e01ea9f 100644 --- a/apps/math_variable_box_controller.cpp +++ b/apps/math_variable_box_controller.cpp @@ -120,7 +120,7 @@ void MathVariableBoxController::willDisplayCellForIndex(HighlightCell * cell, in } else { assert(m_currentPage == Page::Sequence); Shared::Sequence u(record); - symbolLength = u.nameWithArgument( + symbolLength = u.nameWithArgumentAndType( symbolName, Shared::Sequence::k_maxNameWithArgumentSize ); diff --git a/apps/shared/sequence.cpp b/apps/shared/sequence.cpp index 7b4acf86d..d9ffbb591 100644 --- a/apps/shared/sequence.cpp +++ b/apps/shared/sequence.cpp @@ -36,6 +36,24 @@ int Sequence::nameWithArgument(char * buffer, size_t bufferSize) { return result; } +int Sequence::nameWithArgumentAndType(char * buffer, size_t bufferSize) { + int result = nameWithArgument(buffer, bufferSize); + assert(result >= 1); + int offset = result - 1; + switch (type()) + { + case Type::SingleRecurrence: + result += strlcpy(buffer+offset, "+1)", bufferSize-offset); + break; + case Type::DoubleRecurrence: + result += strlcpy(buffer+offset, "+2)", bufferSize-offset); + break; + default: + break; + } + return result; +} + void Sequence::tidy() { m_definition.tidyName(); Function::tidy(); // m_definitionName.tidy() diff --git a/apps/shared/sequence.h b/apps/shared/sequence.h index d53422c52..e3c6b92ad 100644 --- a/apps/shared/sequence.h +++ b/apps/shared/sequence.h @@ -30,6 +30,7 @@ public: I18n::Message parameterMessageName() const override; CodePoint symbol() const override { return 'n'; } int nameWithArgument(char * buffer, size_t bufferSize) override; + int nameWithArgumentAndType(char * buffer, size_t bufferSize); void tidy() override; // MetaData getters Type type() const;