mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-29 19:49:58 +02:00
32 lines
864 B
C++
32 lines
864 B
C++
#include <escher/text_input_helpers.h>
|
|
#include <ion/unicode/utf8_decoder.h>
|
|
#include <string.h>
|
|
|
|
namespace TextInputHelpers {
|
|
|
|
const char * CursorPositionInCommand(const char * text) {
|
|
UTF8Decoder decoder(text);
|
|
const char * currentPointer = text;
|
|
CodePoint codePoint = decoder.nextCodePoint();
|
|
while (codePoint != UCodePointNull) {
|
|
if (codePoint == UCodePointEmpty) {
|
|
return currentPointer;
|
|
}
|
|
//TODO make sure changing empty / ' order was OK
|
|
if (codePoint == '\'') {
|
|
currentPointer = decoder.stringPosition();
|
|
codePoint = decoder.nextCodePoint();
|
|
if (codePoint == '\'') {
|
|
return currentPointer;
|
|
}
|
|
// Continue because we already incremented codePoint
|
|
continue;
|
|
}
|
|
currentPointer = decoder.stringPosition();
|
|
codePoint = decoder.nextCodePoint();
|
|
}
|
|
return currentPointer;
|
|
}
|
|
|
|
}
|