From 17a643a5a5c5ff9fd17aa726fba2c36eedb295fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Tue, 28 Nov 2017 17:42:06 +0100 Subject: [PATCH] [poincare] WirteToText always use MultiplicationSign and Layouts use MiddleDot Change-Id: I4ffff6e6634deba376f083ef382e6bec0ff0883b --- poincare/include/poincare/complex.h | 2 +- poincare/src/complex.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/poincare/include/poincare/complex.h b/poincare/include/poincare/complex.h index c5120e6a8..bdd5ad43d 100644 --- a/poincare/include/poincare/complex.h +++ b/poincare/include/poincare/complex.h @@ -81,7 +81,7 @@ private: constexpr static int k_maxComplexBufferLength = 14+14+7+1; /* convertComplexToText and convertFloatToTextPrivate return the string length * of the buffer (does not count the 0 last char)*/ - int convertComplexToText(char * buffer, int bufferSize, Expression::FloatDisplayMode floatDisplayMode, Expression::ComplexFormat complexFormat) const; + int convertComplexToText(char * buffer, int bufferSize, Expression::FloatDisplayMode floatDisplayMode, Expression::ComplexFormat complexFormat, char multiplicationSign) const; static int convertFloatToTextPrivate(T f, char * buffer, int numberOfSignificantDigits, Expression::FloatDisplayMode mode); ExpressionLayout * createPolarLayout(Expression::FloatDisplayMode floatDisplayMode) const; ExpressionLayout * createCartesianLayout(Expression::FloatDisplayMode floatDisplayMode) const; diff --git a/poincare/src/complex.cpp b/poincare/src/complex.cpp index cce5517fc..390c858c0 100644 --- a/poincare/src/complex.cpp +++ b/poincare/src/complex.cpp @@ -200,7 +200,7 @@ T Complex::toScalar() const { template int Complex::writeTextInBuffer(char * buffer, int bufferSize) const { - return convertComplexToText(buffer, bufferSize, Preferences::sharedPreferences()->displayMode(), Preferences::sharedPreferences()->complexFormat()); + return convertComplexToText(buffer, bufferSize, Preferences::sharedPreferences()->displayMode(), Preferences::sharedPreferences()->complexFormat(), Ion::Charset::MultiplicationSign); } template @@ -253,7 +253,7 @@ Complex * Complex::templatedApproximate(Context& context, Expression::Angl } template -int Complex::convertComplexToText(char * buffer, int bufferSize, Expression::FloatDisplayMode displayMode, Expression::ComplexFormat complexFormat) const { +int Complex::convertComplexToText(char * buffer, int bufferSize, Expression::FloatDisplayMode displayMode, Expression::ComplexFormat complexFormat, char multiplicationSpecialChar) const { assert(displayMode != Expression::FloatDisplayMode::Default); int numberOfChars = 0; if (std::isnan(m_a) || std::isnan(m_b)) { @@ -263,7 +263,7 @@ int Complex::convertComplexToText(char * buffer, int bufferSize, Expression:: if (r() != 1 || th() == 0) { numberOfChars = convertFloatToText(r(), buffer, bufferSize, k_numberOfSignificantDigits, displayMode); if (r() != 0 && th() != 0 && bufferSize > numberOfChars+1) { - buffer[numberOfChars++] = Ion::Charset::MiddleDot; + buffer[numberOfChars++] = multiplicationSpecialChar; // Ensure that the string is null terminated even if buffer size is to small buffer[numberOfChars] = 0; } @@ -278,7 +278,7 @@ int Complex::convertComplexToText(char * buffer, int bufferSize, Expression:: } numberOfChars += convertFloatToText(th(), buffer+numberOfChars, bufferSize-numberOfChars, k_numberOfSignificantDigits, displayMode); if (bufferSize > numberOfChars+3) { - buffer[numberOfChars++] = Ion::Charset::MiddleDot; + buffer[numberOfChars++] = multiplicationSpecialChar; buffer[numberOfChars++] = Ion::Charset::IComplex; buffer[numberOfChars++] = ')'; buffer[numberOfChars] = 0; @@ -297,7 +297,7 @@ int Complex::convertComplexToText(char * buffer, int bufferSize, Expression:: } if (m_b != 1 && m_b != -1 && m_b != 0) { numberOfChars += convertFloatToText(m_b, buffer+numberOfChars, bufferSize-numberOfChars, k_numberOfSignificantDigits, displayMode); - buffer[numberOfChars++] = Ion::Charset::MiddleDot; + buffer[numberOfChars++] = multiplicationSpecialChar; } if (m_b == -1 && bufferSize > numberOfChars+1) { buffer[numberOfChars++] = '-'; @@ -472,7 +472,7 @@ ExpressionLayout * Complex::createPolarLayout(Expression::FloatDisplayMode fl template ExpressionLayout * Complex::createCartesianLayout(Expression::FloatDisplayMode floatDisplayMode) const { char buffer[k_maxComplexBufferLength]; - int numberOfChars = convertComplexToText(buffer, k_maxComplexBufferLength, floatDisplayMode, Expression::ComplexFormat::Cartesian); + int numberOfChars = convertComplexToText(buffer, k_maxComplexBufferLength, floatDisplayMode, Expression::ComplexFormat::Cartesian, Ion::Charset::MiddleDot); return new StringLayout(buffer, numberOfChars); }