Files
Upsilon/escher/src/text_input_helpers.cpp
Émilie Feral c50e57029b [escher] TextInputHelper: special case for 'random()' and handle
parenthesis already completed (ie 'u(n)')
2018-03-22 13:12:12 +01:00

21 lines
502 B
C++

#include <escher/text_input_helpers.h>
#include <string.h>
namespace TextInputHelpers {
int CursorIndexInCommand(const char * text) {
for (size_t i = 0; i < strlen(text)-1; i++) {
if (text[i] == '(' || text[i] == '\'') {
if (text[i+1] == ')' || text[i+1] == '\'' || text[i+1] == ',') {
if (i >= strlen(k_random) && memcmp(&text[i-strlen(k_random)], k_random, strlen(k_random)) == 0) {
break;
}
return i + 1;
}
}
}
return strlen(text);
}
}