mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[escher] Fixed bugs in previous commit (XNT)
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <apps/i18n.h>
|
||||
#include "helpers.h"
|
||||
#include <ion/unicode/utf8_helper.h>
|
||||
#include <apps/apps_container.h>
|
||||
|
||||
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<char *>(buffer), false, false, shouldRemoveLastCharacter);
|
||||
return true;
|
||||
}
|
||||
const char * pythonText = Helpers::PythonTextForEvent(event);
|
||||
if (pythonText != nullptr) {
|
||||
textInput->handleEventWithText(pythonText);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -1,24 +1,17 @@
|
||||
#include "helpers.h"
|
||||
#include <escher/clipboard.h>
|
||||
#include <apps/apps_container.h>
|
||||
|
||||
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; i<NumberOfPythonTextPairs; i++) {
|
||||
UTF8Helper::TextPair pair = PythonTextPairs[i];
|
||||
if (event.text() == pair.firstString()) {
|
||||
strcpy(buffer, pair.secondString());
|
||||
return true;
|
||||
return pair.secondString();
|
||||
}
|
||||
if (event == Ion::Events::XNT) {
|
||||
CodePoint XNT = AppsContainer::sharedAppsContainer()->XNT('x', shouldRemoveLastCharacter);
|
||||
buffer[UTF8Decoder::CodePointToChars(XNT, buffer, CodePoint::MaxCodePointCharLength + 1)] = 0;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user