mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[escher/run_loop] Move kandinksy include
To check whether an ExternalText could be written with Epsilon's fonts, UTF8Helper made a reference to Kandinsky, which is prohibited. This check is now done in Escher, before dispatching the event. Change-Id: I55e9db1ba43c3115775499db47b90a6bdd7cc7b3
This commit is contained in:
committed by
Émilie Feral
parent
d5e810f2b8
commit
0185e0562c
@@ -1,4 +1,5 @@
|
||||
#include <escher/run_loop.h>
|
||||
#include <kandinsky/font.h>
|
||||
#include <assert.h>
|
||||
|
||||
RunLoop::RunLoop() :
|
||||
@@ -64,6 +65,11 @@ bool RunLoop::step() {
|
||||
#endif
|
||||
|
||||
if (event != Ion::Events::None) {
|
||||
#if !PLATFORM_DEVICE
|
||||
if (event == Ion::Events::ExternalText && !KDFont::CanBeWrittenWithGlyphs(event.text())) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
dispatchEvent(event);
|
||||
}
|
||||
|
||||
|
||||
@@ -234,7 +234,7 @@ constexpr Event USBPlug = Event::Special(4);
|
||||
constexpr Event BatteryCharging = Event::Special(5);
|
||||
/* This event is only used in the simulator, to handle text that cannot be
|
||||
* associated with a key. */
|
||||
// constexpr Event ExternalText = Event::Special(6);
|
||||
constexpr Event ExternalText = Event::Special(6);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,10 +124,6 @@ const char * EndOfWord(const char * word);
|
||||
// On a line, count number of glyphs before and after locations
|
||||
void countGlyphsInLine(const char * text, int * before, int * after, const char * beforeLocation, const char *afterLocation = nullptr);
|
||||
|
||||
/* Returns false if one of text's code points does not have a corresponding
|
||||
* glyph in Epsilon's fonts.*/
|
||||
bool CanBeWrittenWithGlyphs(const char * text);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -489,18 +489,4 @@ void countGlyphsInLine(const char * text, int * before, int * after, const char
|
||||
UTF8Helper::PerformAtCodePoints(afterLocation, UCodePointLineFeed, nullptr, countGlyph, after, 0, 0, UCodePointLineFeed);
|
||||
}
|
||||
|
||||
bool CanBeWrittenWithGlyphs(const char * text) {
|
||||
UTF8Decoder decoder(text);
|
||||
CodePoint cp = decoder.nextCodePoint();
|
||||
while(cp != UCodePointNull) {
|
||||
if (KDFont::LargeFont->indexForCodePoint(cp) == KDFont::IndexForReplacementCharacterCodePoint
|
||||
|| KDFont::SmallFont->indexForCodePoint(cp) == KDFont::IndexForReplacementCharacterCodePoint)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
cp = decoder.nextCodePoint();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ namespace Events {
|
||||
|
||||
static constexpr size_t sharedExternalTextBufferSize = sizeof(SDL_TextInputEvent::text);
|
||||
char * sharedExternalTextBuffer();
|
||||
constexpr Event ExternalText = Event::Special(6);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,9 +166,6 @@ static Event eventFromSDLTextInputEvent(SDL_TextInputEvent event) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!UTF8Helper::CanBeWrittenWithGlyphs(event.text)) {
|
||||
return None;
|
||||
}
|
||||
Ion::Events::removeShift();
|
||||
strlcpy(sharedExternalTextBuffer(), event.text, sharedExternalTextBufferSize);
|
||||
return ExternalText;
|
||||
|
||||
@@ -33,6 +33,8 @@ public:
|
||||
static constexpr const KDFont * LargeFont = &privateLargeFont;
|
||||
static constexpr const KDFont * SmallFont = &privateSmallFont;
|
||||
|
||||
static bool CanBeWrittenWithGlyphs(const char * text);
|
||||
|
||||
KDSize stringSize(const char * text, int textLength = -1) const {
|
||||
return stringSizeUntil(text, textLength < 0 ? nullptr : text + textLength);
|
||||
}
|
||||
|
||||
@@ -159,3 +159,17 @@ KDFont::GlyphIndex KDFont::indexForCodePoint(CodePoint c) const {
|
||||
return IndexForReplacementCharacterCodePoint;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool KDFont::CanBeWrittenWithGlyphs(const char * text) {
|
||||
UTF8Decoder decoder(text);
|
||||
CodePoint cp = decoder.nextCodePoint();
|
||||
while(cp != UCodePointNull) {
|
||||
if (LargeFont->indexForCodePoint(cp) == KDFont::IndexForReplacementCharacterCodePoint
|
||||
|| SmallFont->indexForCodePoint(cp) == KDFont::IndexForReplacementCharacterCodePoint)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
cp = decoder.nextCodePoint();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user