From d56013ef17d6c1b0d01d9fb905bdc5dd7c54acb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Wed, 6 Jun 2018 13:48:47 +0200 Subject: [PATCH] [escher] In ExpressionLayoutCursor, when inserting text, replace *_{*} by *(*) --- poincare/src/expression_layout_cursor.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/poincare/src/expression_layout_cursor.cpp b/poincare/src/expression_layout_cursor.cpp index dff7a5fc5..a1b141512 100644 --- a/poincare/src/expression_layout_cursor.cpp +++ b/poincare/src/expression_layout_cursor.cpp @@ -172,6 +172,7 @@ void ExpressionLayoutCursor::insertText(const char * text) { } ExpressionLayout * newChild = nullptr; ExpressionLayout * pointedChild = nullptr; + bool specialUnderScore = false; for (int i = 0; i < textLength; i++) { if (text[i] == Ion::Charset::Empty) { continue; @@ -185,8 +186,19 @@ void ExpressionLayoutCursor::insertText(const char * text) { } } else if (text[i] == ')') { newChild = new RightParenthesisLayout(); + } else if (text[i] == '_') { + specialUnderScore = ((i < textLength) && (text[i+1] == '{')) ? true : false; + if (!specialUnderScore) { + newChild = new CharLayout('_'); + } else { + continue; + } + } else if (text[i] == '{' && specialUnderScore) { + newChild = new CharLayout('('); + } else if (text[i] == '}' && specialUnderScore) { + newChild = new CharLayout(')'); + specialUnderScore = false; } - /* We never insert text with brackets for now. Removing this code saves the * binary file 2K. */ #if 0