diff --git a/apps/apps_container.h b/apps/apps_container.h index 1366b01e7..0d49cdedb 100644 --- a/apps/apps_container.h +++ b/apps/apps_container.h @@ -49,7 +49,7 @@ public: void displayExamModePopUp(GlobalPreferences::ExamMode mode); void shutdownDueToLowBattery(); void setShiftAlphaStatus(Ion::Events::ShiftAlphaStatus newStatus); - CodePoint XNT(CodePoint defaultXNT, bool * shouldRemoveLastCharacter) { m_XNTLoop.XNT(defaultXNT, shouldRemoveLastCharacter); } + CodePoint XNT(CodePoint defaultXNT, bool * shouldRemoveLastCharacter) { return m_XNTLoop.XNT(defaultXNT, shouldRemoveLastCharacter); } void resetXNT() { m_XNTLoop.reset(); } OnBoarding::PromptController * promptController(); void redrawWindow(bool force = false); diff --git a/apps/code/app.cpp b/apps/code/app.cpp index d865e7a46..12833f6f8 100644 --- a/apps/code/app.cpp +++ b/apps/code/app.cpp @@ -3,6 +3,7 @@ #include #include "helpers.h" #include +#include namespace Code { @@ -129,10 +130,19 @@ VariableBoxController * App::variableBoxForInputEventHandler(InputEventHandler * } bool App::textInputDidReceiveEvent(InputEventHandler * textInput, Ion::Events::Event event) { - bool shouldRemoveLastCharacter = false; - char buffer[CodePoint::MaxCodePointCharLength + 1]; - if (Helpers::PythonTextForEvent(event, buffer, &shouldRemoveLastCharacter)) { - textInput->handleEventWithText(buffer, false, false, shouldRemoveLastCharacter); + if (event == Ion::Events::XNT) { + int bufferSize = CodePoint::MaxCodePointCharLength + 1; + char buffer[bufferSize]; + bool shouldRemoveLastCharacter = false; + CodePoint codePoint = AppsContainer::sharedAppsContainer()->XNT('x', &shouldRemoveLastCharacter); + UTF8Decoder::CodePointToChars(codePoint, buffer, bufferSize); + buffer[UTF8Decoder::CharSizeOfCodePoint(codePoint)] = 0; + textInput->handleEventWithText(const_cast(buffer), false, false, shouldRemoveLastCharacter); + return true; + } + const char * pythonText = Helpers::PythonTextForEvent(event); + if (pythonText != nullptr) { + textInput->handleEventWithText(pythonText); return true; } return false; diff --git a/apps/code/helpers.cpp b/apps/code/helpers.cpp index 37ec97405..7a74f724b 100644 --- a/apps/code/helpers.cpp +++ b/apps/code/helpers.cpp @@ -1,24 +1,17 @@ #include "helpers.h" #include -#include namespace Code { namespace Helpers { -bool PythonTextForEvent(Ion::Events::Event event, char * buffer, bool * shouldRemoveLastCharacter) { +const char * PythonTextForEvent(Ion::Events::Event event) { for (size_t i=0; iXNT('x', shouldRemoveLastCharacter); - buffer[UTF8Decoder::CodePointToChars(XNT, buffer, CodePoint::MaxCodePointCharLength + 1)] = 0; - return true; - } - return false; } + return nullptr; } } } diff --git a/apps/code/helpers.h b/apps/code/helpers.h index 69b6b3842..1273ca045 100644 --- a/apps/code/helpers.h +++ b/apps/code/helpers.h @@ -6,7 +6,7 @@ namespace Code { namespace Helpers { -bool PythonTextForEvent(Ion::Events::Event event, char * buffer, bool * shouldRemoveLastCharacter); +const char * PythonTextForEvent(Ion::Events::Event event); } }