diff --git a/apps/code/app.cpp b/apps/code/app.cpp index a640ded5a..3d554a61b 100644 --- a/apps/code/app.cpp +++ b/apps/code/app.cpp @@ -48,7 +48,7 @@ bool App::Snapshot::lockOnConsole() const { void App::Snapshot::setOpt(const char * name, char * value) { if (strcmp(name, "script") == 0) { m_scriptStore.deleteAllScripts(); - char * separator = const_cast(UTF8Helper::CodePointSearch(value, ':')); + char * separator = const_cast(Ion::UTF8Helper::CodePointSearch(value, ':')); if (!separator) { return; } diff --git a/apps/code/editor_controller.cpp b/apps/code/editor_controller.cpp index 854793fc9..00f0524bb 100644 --- a/apps/code/editor_controller.cpp +++ b/apps/code/editor_controller.cpp @@ -70,9 +70,9 @@ bool EditorController::textAreaDidReceiveEvent(TextArea * textArea, Ion::Events: /* If the cursor is on the left of the text of a line, backspace one * indentation space at a time. */ const char * text = textArea->text(); - const char * firstNonSpace = UTF8Helper::NotCodePointSearch(text, ' ', true, textArea->cursorLocation()); + const char * firstNonSpace = Ion::UTF8Helper::NotCodePointSearch(text, ' ', true, textArea->cursorLocation()); assert(firstNonSpace >= text); - if (UTF8Helper::CodePointIs(firstNonSpace, '\n') && ((text - firstNonSpace)/UTF8Decoder::CharSizeOfCodePoint(' ')) >= k_indentationSpacesNumber) { + if (Ion::UTF8Helper::CodePointIs(firstNonSpace, '\n') && ((text - firstNonSpace)/Ion::UTF8Decoder::CharSizeOfCodePoint(' ')) >= k_indentationSpacesNumber) { for (int i = 0; i < k_indentationSpacesNumber; i++) { textArea->removeCodePoint(); } @@ -82,10 +82,10 @@ bool EditorController::textAreaDidReceiveEvent(TextArea * textArea, Ion::Events: /* If the cursor is on the left of the text of a line, a space triggers an * indentation. */ const char * text = textArea->text(); - const char * firstNonSpace = UTF8Helper::NotCodePointSearch(text, ' ', true, textArea->cursorLocation()); + const char * firstNonSpace = Ion::UTF8Helper::NotCodePointSearch(text, ' ', true, textArea->cursorLocation()); assert(firstNonSpace >= text); - if (UTF8Helper::CodePointIs(firstNonSpace, '\n')) { - assert(UTF8Decoder::CharSizeOfCodePoint(' ') == 1); + if (Ion::UTF8Helper::CodePointIs(firstNonSpace, '\n')) { + assert(Ion::UTF8Decoder::CharSizeOfCodePoint(' ') == 1); char indentationBuffer[k_indentationSpacesNumber+1]; for (int i = 0; i < k_indentationSpacesNumber; i++) { indentationBuffer[i] = ' '; diff --git a/apps/code/menu_controller.cpp b/apps/code/menu_controller.cpp index 78adafc2f..f88f0c610 100644 --- a/apps/code/menu_controller.cpp +++ b/apps/code/menu_controller.cpp @@ -313,7 +313,7 @@ bool MenuController::textFieldDidFinishEditing(TextField * textField, const char bool foundDefaultName = Script::DefaultName(numberedDefaultName, Script::k_defaultScriptNameMaxSize); int defaultNameLength = strlen(numberedDefaultName); assert(defaultNameLength < bufferSize); - assert(UTF8Decoder::CharSizeOfCodePoint('.') == 1); + assert(Ion::UTF8Decoder::CharSizeOfCodePoint('.') == 1); numberedDefaultName[defaultNameLength++] = '.'; strlcpy(numberedDefaultName + defaultNameLength, ScriptStore::k_scriptExtension, bufferSize - defaultNameLength); /* If there are already scripts named script1.py, script2.py,... until diff --git a/apps/code/python_text_area.cpp b/apps/code/python_text_area.cpp index c7e958aab..acb84d98a 100644 --- a/apps/code/python_text_area.cpp +++ b/apps/code/python_text_area.cpp @@ -99,8 +99,8 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char LOG_DRAW("Drawing \"%.*s\"\n", byteLength, text); if (!m_pythonDelegate->isPythonUser(this)) { - const char * lineStart = UTF8Helper::CodePointAtGlyphOffset(text, fromColumn); - const char * lineEnd = UTF8Helper::CodePointAtGlyphOffset(text, toColumn); + const char * lineStart = Ion::UTF8Helper::CodePointAtGlyphOffset(text, fromColumn); + const char * lineEnd = Ion::UTF8Helper::CodePointAtGlyphOffset(text, toColumn); drawStringAt( ctx, line, @@ -119,8 +119,8 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char * basis. This can work, however the MicroPython lexer won't accept a line * starting with a whitespace. So we're discarding leading whitespaces * beforehand. */ - const char * firstNonSpace = UTF8Helper::NotCodePointSearch(text, ' '); - if (UTF8Helper::CodePointIs(firstNonSpace, UCodePointNull)) { + const char * firstNonSpace = Ion::UTF8Helper::NotCodePointSearch(text, ' '); + if (Ion::UTF8Helper::CodePointIs(firstNonSpace, UCodePointNull)) { nlr_pop(); return; } @@ -136,7 +136,7 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char tokenLength = TokenLength(lex); LOG_DRAW("Draw \"%.*s\" for token %d\n", tokenLength, tokenFrom, lex->tok_kind); drawStringAt(ctx, line, - UTF8Helper::GlyphOffsetAtCodePoint(text, tokenFrom), + Ion::UTF8Helper::GlyphOffsetAtCodePoint(text, tokenFrom), tokenFrom, tokenLength, TokenColor(lex->tok_kind), @@ -151,7 +151,7 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char if (tokenFrom < text + byteLength) { LOG_DRAW("Draw comment \"%.*s\" from %d\n", byteLength - (tokenFrom - text), firstNonSpace, tokenFrom); drawStringAt(ctx, line, - UTF8Helper::GlyphOffsetAtCodePoint(text, tokenFrom), + Ion::UTF8Helper::GlyphOffsetAtCodePoint(text, tokenFrom), tokenFrom, text + byteLength - tokenFrom, CommentColor, diff --git a/apps/code/python_toolbox.cpp b/apps/code/python_toolbox.cpp index 63b70cc20..1ee763338 100644 --- a/apps/code/python_toolbox.cpp +++ b/apps/code/python_toolbox.cpp @@ -330,7 +330,7 @@ bool PythonToolbox::handleEvent(Ion::Events::Event event) { } if (event.hasText() && strlen(event.text()) == 1 ) { char c = event.text()[0]; - if (UTF8Helper::CodePointIsLetter(c)) { + if (Ion::UTF8Helper::CodePointIsLetter(c)) { scrollToLetter(c); return true; } @@ -390,7 +390,7 @@ int PythonToolbox::maxNumberOfDisplayedRows() { } void PythonToolbox::scrollToLetter(char letter) { - assert(UTF8Helper::CodePointIsLetter(letter)); + assert(Ion::UTF8Helper::CodePointIsLetter(letter)); /* We look for a child MessageTree that starts with the wanted letter. If we * do not find one, we scroll to the first child MessageTree that starts with * a letter higher than the wanted letter. */ @@ -402,7 +402,7 @@ void PythonToolbox::scrollToLetter(char letter) { index = i; break; } - if (index < 0 && l >= lowerLetter && UTF8Helper::CodePointIsLowerCaseLetter(l)) { + if (index < 0 && l >= lowerLetter && Ion::UTF8Helper::CodePointIsLowerCaseLetter(l)) { index = i; } } diff --git a/apps/code/script.cpp b/apps/code/script.cpp index 12a88c976..895554e9e 100644 --- a/apps/code/script.cpp +++ b/apps/code/script.cpp @@ -46,9 +46,9 @@ bool Script::nameCompliant(const char * name) { * We do not allow upper cases in the script names because script names are * used in the URLs of the NumWorks workshop website and we do not want * problems with case sensitivity. */ - UTF8Decoder decoder(name); + Ion::UTF8Decoder decoder(name); CodePoint c = decoder.nextCodePoint(); - if (c == UCodePointNull || !(UTF8Helper::CodePointIsLowerCaseLetter(c) || c == '_' || c == '.')) { + if (c == UCodePointNull || !(Ion::UTF8Helper::CodePointIsLowerCaseLetter(c) || c == '_' || c == '.')) { /* The name cannot be empty. Its first letter must be in [a-z_] or the * extension dot. */ return false; @@ -57,7 +57,7 @@ bool Script::nameCompliant(const char * name) { if (c == '.' && strcmp(decoder.stringPosition(), ScriptStore::k_scriptExtension) == 0) { return true; } - if (!(UTF8Helper::CodePointIsLowerCaseLetter(c) || c == '_' || UTF8Helper::CodePointIsNumber(c))) { + if (!(Ion::UTF8Helper::CodePointIsLowerCaseLetter(c) || c == '_' || Ion::UTF8Helper::CodePointIsNumber(c))) { return false; } c = decoder.nextCodePoint(); diff --git a/apps/code/variable_box_controller.cpp b/apps/code/variable_box_controller.cpp index 13f086a57..4735d0258 100644 --- a/apps/code/variable_box_controller.cpp +++ b/apps/code/variable_box_controller.cpp @@ -41,7 +41,7 @@ static bool shouldAddObject(const char * name, int maxLength) { return false; } assert(name != nullptr); - if (UTF8Helper::CodePointIs(name, '_')) { + if (Ion::UTF8Helper::CodePointIs(name, '_')) { return false; } return true; diff --git a/apps/probability/calculation_controller.cpp b/apps/probability/calculation_controller.cpp index 3ce66b908..6aa788001 100644 --- a/apps/probability/calculation_controller.cpp +++ b/apps/probability/calculation_controller.cpp @@ -298,7 +298,7 @@ void CalculationController::updateTitle() { if (currentChar >= k_titleBufferSize) { break; } - currentChar += UTF8Decoder::CodePointToChars(' ', m_titleBuffer + currentChar, k_titleBufferSize - currentChar); + currentChar += Ion::UTF8Decoder::CodePointToChars(' ', m_titleBuffer + currentChar, k_titleBufferSize - currentChar); } m_titleBuffer[minInt(currentChar, k_titleBufferSize) - 1] = 0; } diff --git a/apps/regression/graph_controller.cpp b/apps/regression/graph_controller.cpp index 04be6f253..4d0e0cb54 100644 --- a/apps/regression/graph_controller.cpp +++ b/apps/regression/graph_controller.cpp @@ -127,7 +127,7 @@ void GraphController::reloadBannerView() { } numberOfChar += strlcpy(buffer, legend, bufferSize); numberOfChar += PoincareHelpers::ConvertFloatToText(x, buffer+numberOfChar, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits), Constant::MediumNumberOfSignificantDigits); - assert(UTF8Decoder::CharSizeOfCodePoint(' ') == 1); + assert(Ion::UTF8Decoder::CharSizeOfCodePoint(' ') == 1); for (int i = numberOfChar; i < k_maxLegendLength; i++) { buffer[numberOfChar++] = ' '; } diff --git a/apps/shared/cartesian_function.cpp b/apps/shared/cartesian_function.cpp index b6d304e61..294f0b511 100644 --- a/apps/shared/cartesian_function.cpp +++ b/apps/shared/cartesian_function.cpp @@ -67,15 +67,15 @@ CartesianFunction CartesianFunction::NewModel(Ion::Storage::Record::ErrorStatus int CartesianFunction::derivativeNameWithArgument(char * buffer, size_t bufferSize, CodePoint arg) { // Fill buffer with f(x). Keep size for derivative sign. - int derivativeSize = UTF8Decoder::CharSizeOfCodePoint('\''); + int derivativeSize = Ion::UTF8Decoder::CharSizeOfCodePoint('\''); int numberOfChars = nameWithArgument(buffer, bufferSize - derivativeSize, arg); assert(numberOfChars + derivativeSize < bufferSize); - char * firstParenthesis = const_cast(UTF8Helper::CodePointSearch(buffer, '(')); - if (!UTF8Helper::CodePointIs(firstParenthesis, '(')) { + char * firstParenthesis = const_cast(Ion::UTF8Helper::CodePointSearch(buffer, '(')); + if (!Ion::UTF8Helper::CodePointIs(firstParenthesis, '(')) { return numberOfChars; } memmove(firstParenthesis + derivativeSize, firstParenthesis, buffer + numberOfChars - firstParenthesis); - UTF8Decoder::CodePointToChars('\'', firstParenthesis, derivativeSize); + Ion::UTF8Decoder::CodePointToChars('\'', firstParenthesis, derivativeSize); return numberOfChars + derivativeSize; } diff --git a/apps/shared/function.cpp b/apps/shared/function.cpp index bc454ed42..96356dd1f 100644 --- a/apps/shared/function.cpp +++ b/apps/shared/function.cpp @@ -17,9 +17,9 @@ constexpr char Function::k_parenthesedArgument[]; bool Function::BaseNameCompliant(const char * baseName, NameNotCompliantError * error) { assert(baseName[0] != 0); - UTF8Decoder decoder(baseName); + Ion::UTF8Decoder decoder(baseName); CodePoint c = decoder.nextCodePoint(); - if (UTF8Helper::CodePointIsNumber(c)) { + if (Ion::UTF8Helper::CodePointIsNumber(c)) { // The name cannot start with a number if (error != nullptr) { *error = NameNotCompliantError::NameCannotStartWithNumber; @@ -29,9 +29,9 @@ bool Function::BaseNameCompliant(const char * baseName, NameNotCompliantError * // The name should only have allowed characters while (c != UCodePointNull) { - if (!(UTF8Helper::CodePointIsUpperCaseLetter(c) - || UTF8Helper::CodePointIsLowerCaseLetter(c) - || UTF8Helper::CodePointIsNumber(c)) + if (!(Ion::UTF8Helper::CodePointIsUpperCaseLetter(c) + || Ion::UTF8Helper::CodePointIsLowerCaseLetter(c) + || Ion::UTF8Helper::CodePointIsNumber(c)) || c == '_') { if (error != nullptr) { @@ -65,13 +65,13 @@ void Function::setActive(bool active) { } int Function::nameWithArgument(char * buffer, size_t bufferSize, CodePoint arg) { - assert(UTF8Decoder::CharSizeOfCodePoint(arg) == 1); + assert(Ion::UTF8Decoder::CharSizeOfCodePoint(arg) == 1); const char * functionName = fullName(); size_t baseNameLength = SymbolAbstract::TruncateExtension(buffer, functionName, bufferSize - k_parenthesedArgumentLength); int result = baseNameLength + strlcpy(&buffer[baseNameLength], k_parenthesedArgument, bufferSize-baseNameLength); int bufferRemainingSize = bufferSize - (baseNameLength+1); if (bufferRemainingSize > 0) { - UTF8Decoder::CodePointToChars(arg, buffer+baseNameLength+1, bufferRemainingSize); + Ion::UTF8Decoder::CodePointToChars(arg, buffer+baseNameLength+1, bufferRemainingSize); } return result; } diff --git a/apps/shared/text_field_delegate_app.cpp b/apps/shared/text_field_delegate_app.cpp index 720b6c0b1..57b1233d3 100644 --- a/apps/shared/text_field_delegate_app.cpp +++ b/apps/shared/text_field_delegate_app.cpp @@ -57,7 +57,7 @@ bool TextFieldDelegateApp::fieldDidReceiveEvent(EditableField * field, Responder /* TODO decode here to encode again in handleEventWithText? */ constexpr int bufferSize = CodePoint::MaxCodePointCharLength+1; char buffer[bufferSize]; - size_t length = UTF8Decoder::CodePointToChars(field->XNTCodePoint(XNT()), buffer, bufferSize); + size_t length = Ion::UTF8Decoder::CodePointToChars(field->XNTCodePoint(XNT()), buffer, bufferSize); assert(length < bufferSize - 1); buffer[length] = 0; return field->handleEventWithText(buffer); diff --git a/apps/shared/toolbox_helpers.cpp b/apps/shared/toolbox_helpers.cpp index 589615b89..39997e7dd 100644 --- a/apps/shared/toolbox_helpers.cpp +++ b/apps/shared/toolbox_helpers.cpp @@ -8,7 +8,7 @@ namespace Shared { namespace ToolboxHelpers { int CursorIndexInCommandText(const char * text) { - UTF8Decoder decoder(text); + Ion::UTF8Decoder decoder(text); size_t index = 0; const char * currentPointer = text; CodePoint codePoint = decoder.nextCodePoint(); @@ -39,7 +39,7 @@ void TextToInsertForCommandText(const char * command, char * buffer, int bufferS bool insideQuote = false; bool argumentAlreadyReplaced = false; - UTF8Decoder decoder(command); + Ion::UTF8Decoder decoder(command); CodePoint codePoint = decoder.nextCodePoint(); while (codePoint != UCodePointNull) { if (codePoint == ')') { @@ -59,10 +59,10 @@ void TextToInsertForCommandText(const char * command, char * buffer, int bufferS if (argumentAlreadyReplaced) { argumentAlreadyReplaced = false; } - index += UTF8Decoder::CodePointToChars(codePoint, buffer + index, bufferSize - index); + index += Ion::UTF8Decoder::CodePointToChars(codePoint, buffer + index, bufferSize - index); } else { if (replaceArgsWithEmptyChar && !argumentAlreadyReplaced) { - index += UTF8Decoder::CodePointToChars(UCodePointEmpty, buffer + index, bufferSize - index); + index += Ion::UTF8Decoder::CodePointToChars(UCodePointEmpty, buffer + index, bufferSize - index); argumentAlreadyReplaced = true; } } diff --git a/apps/solver/list_controller.cpp b/apps/solver/list_controller.cpp index bd8cb69a0..8d592d740 100644 --- a/apps/solver/list_controller.cpp +++ b/apps/solver/list_controller.cpp @@ -116,7 +116,7 @@ void ListController::didEnterResponderChain(Responder * previousFirstResponder) bool textRepresentsAnEquality(const char * text) { char equal = '='; - return UTF8Helper::CodePointIs(UTF8Helper::CodePointSearch(text, equal), equal); + return Ion::UTF8Helper::CodePointIs(Ion::UTF8Helper::CodePointSearch(text, equal), equal); } bool layoutRepresentsAnEquality(Poincare::Layout l) { diff --git a/apps/statistics/box_controller.cpp b/apps/statistics/box_controller.cpp index 5d02868a4..bc13ec0c0 100644 --- a/apps/statistics/box_controller.cpp +++ b/apps/statistics/box_controller.cpp @@ -51,7 +51,7 @@ void BoxController::reloadBannerView() { m_view.editableBannerView()->setMessageAtIndex(calculationName[selectedQuantile], 1); // Set calculation result - assert(UTF8Decoder::CharSizeOfCodePoint(' ') == 1); + assert(Ion::UTF8Decoder::CharSizeOfCodePoint(' ') == 1); constexpr int bufferSize = PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits) + 1; char buffer[bufferSize]; CalculPointer calculationMethods[5] = {&Store::minValue, &Store::firstQuartile, &Store::median, &Store::thirdQuartile, diff --git a/apps/statistics/histogram_controller.cpp b/apps/statistics/histogram_controller.cpp index e8dc3c9dd..291b095d7 100644 --- a/apps/statistics/histogram_controller.cpp +++ b/apps/statistics/histogram_controller.cpp @@ -110,18 +110,18 @@ void HistogramController::reloadBannerView() { numberOfChar += PoincareHelpers::ConvertFloatToText(lowerBound, buffer+numberOfChar, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); } - numberOfChar+= UTF8Decoder::CodePointToChars(';', buffer + numberOfChar, bufferSize - numberOfChar); + numberOfChar+= Ion::UTF8Decoder::CodePointToChars(';', buffer + numberOfChar, bufferSize - numberOfChar); // Add upper bound if (selectedSeriesIndex() >= 0) { double upperBound = m_store->endOfBarAtIndex(selectedSeriesIndex(), *m_selectedBarIndex); numberOfChar += PoincareHelpers::ConvertFloatToText(upperBound, buffer+numberOfChar, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); } - numberOfChar+= UTF8Decoder::CodePointToChars('[', buffer + numberOfChar, bufferSize - numberOfChar); + numberOfChar+= Ion::UTF8Decoder::CodePointToChars('[', buffer + numberOfChar, bufferSize - numberOfChar); // Padding for (int i = numberOfChar; i < k_maxIntervalLegendLength; i++) { - numberOfChar+= UTF8Decoder::CodePointToChars(' ', buffer + numberOfChar, bufferSize - numberOfChar); + numberOfChar+= Ion::UTF8Decoder::CodePointToChars(' ', buffer + numberOfChar, bufferSize - numberOfChar); } buffer[k_maxIntervalLegendLength] = 0; m_view.editableBannerView()->setLegendAtIndex(buffer, 1); @@ -139,7 +139,7 @@ void HistogramController::reloadBannerView() { } // Padding for (int i = numberOfChar; i < k_maxLegendLength; i++) { - numberOfChar+= UTF8Decoder::CodePointToChars(' ', buffer + numberOfChar, bufferSize - numberOfChar); + numberOfChar+= Ion::UTF8Decoder::CodePointToChars(' ', buffer + numberOfChar, bufferSize - numberOfChar); } buffer[k_maxLegendLength] = 0; m_view.editableBannerView()->setLegendAtIndex(buffer, 3); @@ -156,7 +156,7 @@ void HistogramController::reloadBannerView() { } // Padding for (int i = numberOfChar; i < k_maxLegendLength; i++) { - numberOfChar+= UTF8Decoder::CodePointToChars(' ', buffer + numberOfChar, bufferSize - numberOfChar); + numberOfChar+= Ion::UTF8Decoder::CodePointToChars(' ', buffer + numberOfChar, bufferSize - numberOfChar); } buffer[k_maxLegendLength] = 0; m_view.editableBannerView()->setLegendAtIndex(buffer, 5); diff --git a/apps/variable_box_controller.cpp b/apps/variable_box_controller.cpp index 13c790278..62189becf 100644 --- a/apps/variable_box_controller.cpp +++ b/apps/variable_box_controller.cpp @@ -200,11 +200,11 @@ bool VariableBoxController::selectLeaf(int selectedRow) { if (m_currentPage == Page::Function) { // Add parentheses to a function name assert(nameLength < nameToHandleMaxSize); - nameLength += UTF8Decoder::CodePointToChars('(', nameToHandle+nameLength, nameToHandleMaxSize - nameLength); + nameLength += Ion::UTF8Decoder::CodePointToChars('(', nameToHandle+nameLength, nameToHandleMaxSize - nameLength); assert(nameLength < nameToHandleMaxSize); - nameLength+= UTF8Decoder::CodePointToChars(UCodePointEmpty, nameToHandle+nameLength, nameToHandleMaxSize - nameLength); + nameLength+= Ion::UTF8Decoder::CodePointToChars(UCodePointEmpty, nameToHandle+nameLength, nameToHandleMaxSize - nameLength); assert(nameLength < nameToHandleMaxSize); - nameLength += UTF8Decoder::CodePointToChars(')', nameToHandle+nameLength, nameToHandleMaxSize - nameLength); + nameLength += Ion::UTF8Decoder::CodePointToChars(')', nameToHandle+nameLength, nameToHandleMaxSize - nameLength); assert(nameLength < nameToHandleMaxSize); nameToHandle[nameLength] = 0; } diff --git a/escher/src/text_area.cpp b/escher/src/text_area.cpp index d8bf93d67..4854b88aa 100644 --- a/escher/src/text_area.cpp +++ b/escher/src/text_area.cpp @@ -24,12 +24,12 @@ static inline void InsertSpacesAtLocation(int spacesCount, char * buffer, int bu assert(strlen(buffer) + spacesCount < bufferSize); size_t sizeToMove = strlen(buffer) + 1; - size_t spaceCharSize = UTF8Decoder::CharSizeOfCodePoint(' '); + size_t spaceCharSize = Ion::UTF8Decoder::CharSizeOfCodePoint(' '); size_t spacesLength = spacesCount * spaceCharSize; memmove(buffer + spacesLength, buffer, sizeToMove); for (int i = 0; i < spacesCount; i++) { int spaceOffset = i * spaceCharSize; - UTF8Decoder::CodePointToChars(' ', buffer + spaceOffset, bufferSize - spaceOffset); + Ion::UTF8Decoder::CodePointToChars(' ', buffer + spaceOffset, bufferSize - spaceOffset); } } @@ -44,20 +44,20 @@ bool TextArea::handleEventWithText(const char * text, bool indentation, bool for // Compute the indentation int spacesCount = indentationBeforeCursor(); const char * teaxtAreaBuffer = contentView()->text(); - if (cursorLocation() > teaxtAreaBuffer && UTF8Helper::PreviousCodePointIs(teaxtAreaBuffer, cursorLocation(), ':')) { + if (cursorLocation() > teaxtAreaBuffer && Ion::UTF8Helper::PreviousCodePointIs(teaxtAreaBuffer, cursorLocation(), ':')) { spacesCount += k_indentationSpaces; } // Check the text will not overflow the buffer - int totalIndentationSize = UTF8Helper::CountOccurrences(text, '\n') * spacesCount; + int totalIndentationSize = Ion::UTF8Helper::CountOccurrences(text, '\n') * spacesCount; if (contentView()->getText()->textLength() + textLength + totalIndentationSize >= contentView()->getText()->bufferSize() || textLength == 0) { return false; } - UTF8Helper::PerformAtCodePoints( + Ion::UTF8Helper::PerformAtCodePoints( buffer, '\n', [](int codePointOffset, void * text, int indentation) { - int offset = codePointOffset + UTF8Decoder::CharSizeOfCodePoint('\n'); + int offset = codePointOffset + Ion::UTF8Decoder::CharSizeOfCodePoint('\n'); InsertSpacesAtLocation(indentation, (char *)text + offset, TextField::maxBufferSize() - offset); //TODO }, [](int c1, void * c2, int c3) {}, @@ -67,7 +67,7 @@ bool TextArea::handleEventWithText(const char * text, bool indentation, bool for const char * cursorPositionInCommand = TextInputHelpers::CursorPositionInCommand(buffer); // Remove the Empty code points - UTF8Helper::RemoveCodePoint(buffer, UCodePointEmpty, &cursorPositionInCommand); + Ion::UTF8Helper::RemoveCodePoint(buffer, UCodePointEmpty, &cursorPositionInCommand); // Insert the text if (insertTextAtLocation(buffer, cursorLocation())) { @@ -88,14 +88,14 @@ bool TextArea::handleEvent(Ion::Events::Event event) { assert(cursorLocation() == text()); return false; } - UTF8Decoder decoder(text(), cursorLocation()); + Ion::UTF8Decoder decoder(text(), cursorLocation()); decoder.previousCodePoint(); return setCursorLocation(decoder.stringPosition()); } else if (event == Ion::Events::Right) { - if (UTF8Helper::CodePointIs(cursorLocation(), UCodePointNull)) { + if (Ion::UTF8Helper::CodePointIs(cursorLocation(), UCodePointNull)) { return false; } - UTF8Decoder decoder(cursorLocation()); + Ion::UTF8Decoder decoder(cursorLocation()); decoder.nextCodePoint(); return setCursorLocation(decoder.stringPosition()); } else if (event == Ion::Events::Up) { @@ -135,7 +135,7 @@ int TextArea::indentationBeforeCursor() const { /* Compute the number of spaces at the beginning of the line. Increase the * indentation size when encountering spaces, reset it to 0 when encountering * another code point, until reaching the beginning of the line. */ - UTF8Helper::PerformAtCodePoints(const_cast