From 67970298c6760d2c874a555eb2f023b33b2a305b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Wed, 24 Oct 2018 17:57:35 +0200 Subject: [PATCH] [poincare] Default integral has 'dx' and cursor skips dx when moving towards right --- apps/math_toolbox.cpp | 18 +++++++++++------- apps/shared.universal.i18n | 1 + poincare/src/integral_layout.cpp | 6 +++--- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/apps/math_toolbox.cpp b/apps/math_toolbox.cpp index d40b48406..fcef3f16c 100644 --- a/apps/math_toolbox.cpp +++ b/apps/math_toolbox.cpp @@ -13,7 +13,7 @@ using namespace Poincare; const ToolboxMessageTree calculChildren[4] = { ToolboxMessageTree(I18n::Message::DiffCommandWithArg, I18n::Message::DerivateNumber, I18n::Message::DiffCommandWithArg), - ToolboxMessageTree(I18n::Message::IntCommandWithArg, I18n::Message::Integral, I18n::Message::IntCommandWithArg), + ToolboxMessageTree(I18n::Message::IntCommandWithArg, I18n::Message::Integral, I18n::Message::IntCommand), ToolboxMessageTree(I18n::Message::SumCommandWithArg, I18n::Message::Sum, I18n::Message::SumCommandWithArg), ToolboxMessageTree(I18n::Message::ProductCommandWithArg, I18n::Message::Product, I18n::Message::ProductCommandWithArg)}; @@ -115,14 +115,18 @@ bool MathToolbox::selectLeaf(int selectedRow) { ToolboxMessageTree * messageTree = (ToolboxMessageTree *)m_messageTreeModel->children(selectedRow); m_selectableTableView.deselectTable(); - // Translate the message and remove the arguments + // Translate the message const char * text = I18n::translate(messageTree->insertedText()); - int maxTextToInsertLength = strlen(text) + 1; - assert(maxTextToInsertLength <= k_maxMessageSize); - char textToInsert[k_maxMessageSize]; - Shared::ToolboxHelpers::TextToInsertForCommandText(text, textToInsert, maxTextToInsertLength, true); + if (messageTree->label() == messageTree->insertedText()) { + // Remove the arguments if we kept one message for both inserted and displayed message + int maxTextToInsertLength = strlen(text) + 1; + assert(maxTextToInsertLength <= k_maxMessageSize); + char textToInsert[k_maxMessageSize]; + Shared::ToolboxHelpers::TextToInsertForCommandText(text, textToInsert, maxTextToInsertLength, true); + text = textToInsert; + } - sender()->handleEventWithText(textToInsert); + sender()->handleEventWithText(text); app()->dismissModalViewController(); return true; } diff --git a/apps/shared.universal.i18n b/apps/shared.universal.i18n index f367b8316..30b96a019 100644 --- a/apps/shared.universal.i18n +++ b/apps/shared.universal.i18n @@ -31,6 +31,7 @@ FloorCommandWithArg = "floor(x)" FracCommandWithArg = "frac(x)" GcdCommandWithArg = "gcd(p,q)" ImCommandWithArg = "im(z)" +IntCommand = "int(ø,x,ø,ø)" IntCommandWithArg = "int(f(x),x,a,b)" InverseCommandWithArg = "inverse(M)" InvSortCommandWithArg = "sort>(L)" diff --git a/poincare/src/integral_layout.cpp b/poincare/src/integral_layout.cpp index f4ad46e21..b53035fa6 100644 --- a/poincare/src/integral_layout.cpp +++ b/poincare/src/integral_layout.cpp @@ -76,9 +76,9 @@ void IntegralLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRec if (cursor->layoutNode() == integrandLayout()) { assert(cursor->position() == LayoutCursor::Position::Right); - // Case: Right the integrand. Go right of the differential. - cursor->setLayoutNode(differentialLayout()); - cursor->setPosition(LayoutCursor::Position::Left); + // Case: Right the differential. Go Right. + cursor->setLayoutNode(this); + cursor->setPosition(LayoutCursor::Position::Right); return; } if (cursor->layoutNode() == differentialLayout())