mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-26 01:00:50 +01:00
[escher] Fix signed/unsigned int comparison
Change-Id: I72b6dc3f46ee585814a540fc999001e113db0ea1
This commit is contained in:
committed by
EmilieNumworks
parent
96310c75c8
commit
0294ebc448
@@ -2,10 +2,11 @@
|
||||
#define ESCHER_TEXT_INPUT_HELPERS_H
|
||||
|
||||
#include <escher/i18n.h>
|
||||
#include <stddef.h>
|
||||
|
||||
namespace TextInputHelpers {
|
||||
|
||||
int CursorIndexInCommand(const char * text);
|
||||
size_t CursorIndexInCommand(const char * text);
|
||||
/* Returns the index of the cursor position in a Command, which is the smallest
|
||||
* index between :
|
||||
* - The first EmptyChar index (which is the position of the first argument)
|
||||
|
||||
@@ -294,7 +294,7 @@ TextArea::TextArea(Responder * parentResponder, char * textBuffer,
|
||||
bool TextArea::handleEventWithText(const char * text, bool indentation) {
|
||||
int nextCursorLocation = cursorLocation();
|
||||
|
||||
int cursorIndexInCommand = TextInputHelpers::CursorIndexInCommand(text);
|
||||
size_t cursorIndexInCommand = TextInputHelpers::CursorIndexInCommand(text);
|
||||
|
||||
size_t eventTextSize = strlen(text) + 1;
|
||||
char buffer[eventTextSize];
|
||||
|
||||
@@ -4,16 +4,17 @@
|
||||
|
||||
namespace TextInputHelpers {
|
||||
|
||||
int CursorIndexInCommand(const char * text) {
|
||||
int textLength = strlen(text);
|
||||
for (int i = 0; i < textLength - 1; i++) {
|
||||
if (text[i] == '\'' && text[i+1] == '\'') {
|
||||
return i + 1;
|
||||
} else if (text[i] == Ion::Charset::Empty) {
|
||||
return i;
|
||||
size_t CursorIndexInCommand(const char * text) {
|
||||
size_t index = 0;
|
||||
while (text[index] != 0) {
|
||||
if (text[index] == '\'' && text[index+1] == '\'') {
|
||||
return index + 1;
|
||||
} else if (text[index] == Ion::Charset::Empty) {
|
||||
return index;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
return textLength;
|
||||
return index;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user