From 259eb35cf4abb71549633d985a24238f93e1d0c2 Mon Sep 17 00:00:00 2001 From: Ruben Dashyan Date: Thu, 26 Sep 2019 09:57:39 +0200 Subject: [PATCH] Revert ""Almost equal to" sign in banner views" This reverts commit bd5a247858de8f3709291bfd76f90b0f2bfbfba2. --- apps/graph/graph/graph_controller_helper.cpp | 4 ++-- apps/graph/graph/intersection_graph_controller.cpp | 13 +++++++------ apps/graph/graph/tangent_graph_controller.cpp | 9 ++++----- apps/shared/function_banner_delegate.cpp | 2 +- ion/include/ion/unicode/code_point.h | 1 - 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/apps/graph/graph/graph_controller_helper.cpp b/apps/graph/graph/graph_controller_helper.cpp index cd1c7e521..acfe76b2a 100644 --- a/apps/graph/graph/graph_controller_helper.cpp +++ b/apps/graph/graph/graph_controller_helper.cpp @@ -1,7 +1,6 @@ #include "graph_controller_helper.h" #include "../../shared/function_banner_delegate.h" #include "../app.h" -#include #include "../../shared/poincare_helpers.h" #include @@ -48,8 +47,9 @@ void GraphControllerHelper::reloadDerivativeInBannerViewForCursorOnFunction(Shar char buffer[bufferSize]; const char * space = " "; int numberOfChar = function->derivativeNameWithArgument(buffer, bufferSize); + const char * legend = "="; assert(numberOfChar <= bufferSize); - numberOfChar += UTF8Decoder::CodePointToChars(UCodePointAlmostEqualTo, buffer+numberOfChar, bufferSize-numberOfChar); + numberOfChar += strlcpy(buffer+numberOfChar, legend, bufferSize-numberOfChar); double y = function->approximateDerivative(cursor->x(), App::app()->localContext()); numberOfChar += PoincareHelpers::ConvertFloatToText(y, buffer + numberOfChar, bufferSize-numberOfChar, Preferences::ShortNumberOfSignificantDigits); assert(numberOfChar <= bufferSize); diff --git a/apps/graph/graph/intersection_graph_controller.cpp b/apps/graph/graph/intersection_graph_controller.cpp index 2354d6446..1691e4239 100644 --- a/apps/graph/graph/intersection_graph_controller.cpp +++ b/apps/graph/graph/intersection_graph_controller.cpp @@ -1,5 +1,4 @@ #include "intersection_graph_controller.h" -#include #include "../../shared/poincare_helpers.h" #include @@ -22,15 +21,17 @@ void IntersectionGraphController::reloadBannerView() { constexpr size_t bufferSize = FunctionBannerDelegate::k_maxNumberOfCharacters+Poincare::PrintFloat::bufferSizeForFloatsWithPrecision(Poincare::Preferences::LargeNumberOfSignificantDigits); char buffer[bufferSize]; const char * space = " "; - // 'f(x)=g(x)≈' + const char * legend = "="; + // 'f(x)=g(x)=', keep 2 chars for '=' ExpiringPointer f = functionStore()->modelForRecord(m_record); - int numberOfChar = f->nameWithArgument(buffer, bufferSize - UTF8Decoder::CharSizeOfCodePoint('=') - UTF8Decoder::CharSizeOfCodePoint(UCodePointAlmostEqualTo)); + int numberOfChar = f->nameWithArgument(buffer, bufferSize-2); assert(numberOfChar <= bufferSize); - numberOfChar += strlcpy(buffer+numberOfChar, "=", bufferSize-numberOfChar); + numberOfChar += strlcpy(buffer+numberOfChar, legend, bufferSize-numberOfChar); + // keep 1 char for '='; ExpiringPointer g = functionStore()->modelForRecord(m_intersectedRecord); - numberOfChar += g->nameWithArgument(buffer + numberOfChar, bufferSize - numberOfChar - UTF8Decoder::CharSizeOfCodePoint(UCodePointAlmostEqualTo)); + numberOfChar += g->nameWithArgument(buffer+numberOfChar, bufferSize-numberOfChar-1); assert(numberOfChar <= bufferSize); - numberOfChar += UTF8Decoder::CodePointToChars(UCodePointAlmostEqualTo, buffer+numberOfChar, bufferSize-numberOfChar); + numberOfChar += strlcpy(buffer+numberOfChar, legend, bufferSize-numberOfChar); numberOfChar += PoincareHelpers::ConvertFloatToText(m_cursor->y(), buffer+numberOfChar, bufferSize-numberOfChar, Poincare::Preferences::MediumNumberOfSignificantDigits); assert(numberOfChar <= bufferSize); strlcpy(buffer+numberOfChar, space, bufferSize-numberOfChar); diff --git a/apps/graph/graph/tangent_graph_controller.cpp b/apps/graph/graph/tangent_graph_controller.cpp index 56f38bd65..00db23d43 100644 --- a/apps/graph/graph/tangent_graph_controller.cpp +++ b/apps/graph/graph/tangent_graph_controller.cpp @@ -1,7 +1,6 @@ #include "tangent_graph_controller.h" #include "../app.h" #include "../../apps_container.h" -#include #include "../../shared/poincare_helpers.h" #include @@ -73,15 +72,15 @@ void TangentGraphController::reloadBannerView() { Poincare::Context * context = textFieldDelegateApp()->localContext(); constexpr int precision = Preferences::MediumNumberOfSignificantDigits; - int legendLength = strlcpy(buffer, "a", bufferSize); - legendLength += UTF8Decoder::CodePointToChars(UCodePointAlmostEqualTo, buffer+legendLength, bufferSize-legendLength); + const char * legend = "a="; + int legendLength = strlcpy(buffer, legend, bufferSize); ExpiringPointer function = App::app()->functionStore()->modelForRecord(m_record); double y = function->approximateDerivative(m_cursor->x(), context); PoincareHelpers::ConvertFloatToText(y, buffer + legendLength, PrintFloat::bufferSizeForFloatsWithPrecision(precision), precision); m_bannerView->aView()->setText(buffer); - legendLength = strlcpy(buffer, "b", bufferSize); - legendLength += UTF8Decoder::CodePointToChars(UCodePointAlmostEqualTo, buffer+legendLength, bufferSize-legendLength); + legend = "b="; + legendLength = strlcpy(buffer, legend, bufferSize); Shared::TextFieldDelegateApp * myApp = textFieldDelegateApp(); assert(function->plotType() == Shared::ContinuousFunction::PlotType::Cartesian); y = -y*m_cursor->x()+function->evaluate2DAtParameter(m_cursor->x(), myApp->localContext()).x2(); diff --git a/apps/shared/function_banner_delegate.cpp b/apps/shared/function_banner_delegate.cpp index 035d23749..98d98eecf 100644 --- a/apps/shared/function_banner_delegate.cpp +++ b/apps/shared/function_banner_delegate.cpp @@ -27,7 +27,7 @@ void FunctionBannerDelegate::reloadBannerViewForCursorOnFunction(CurveViewCursor numberOfChar = function->nameWithArgument(buffer, bufferSize); assert(numberOfChar <= bufferSize); - numberOfChar += UTF8Decoder::CodePointToChars(UCodePointAlmostEqualTo, buffer+numberOfChar, bufferSize-numberOfChar); + numberOfChar += strlcpy(buffer+numberOfChar, "=", bufferSize-numberOfChar); numberOfChar += function->printValue(cursor->t(), cursor->x(),cursor->y(), buffer+numberOfChar, bufferSize-numberOfChar, precision, context); assert(numberOfChar <= bufferSize); strlcpy(buffer+numberOfChar, space, bufferSize-numberOfChar); diff --git a/ion/include/ion/unicode/code_point.h b/ion/include/ion/unicode/code_point.h index 7f7de9326..52708cfed 100644 --- a/ion/include/ion/unicode/code_point.h +++ b/ion/include/ion/unicode/code_point.h @@ -39,7 +39,6 @@ static constexpr CodePoint UCodePointRightwardsArrow = 0x2192; // → static constexpr CodePoint UCodePointNArySummation = 0x2211; // ∑ static constexpr CodePoint UCodePointSquareRoot = 0x221a; // √ static constexpr CodePoint UCodePointIntegral = 0x222b; // ∫ -static constexpr CodePoint UCodePointAlmostEqualTo = 0x2248; // ≈ static constexpr CodePoint UCodePointMathematicalBoldSmallI = 0x1d422; // 𝐢 #endif