303 {
304 if (!fEnabled || fGlyphData.empty()) {
305 return false;
306 }
307
308 const auto& txt_str = fTextProp->get().fText;
309
310
311 switch (c) {
312 case '|':
314 break;
315 case ']': {
316 if (fCursorIndex < txt_str.size()) {
317 fCursorIndex =
next_utf8(txt_str, fCursorIndex);
318 }
319 } break;
320 case '[':
321 if (fCursorIndex > 0) {
322 fCursorIndex =
prev_utf8(txt_str, fCursorIndex);
323 }
324 break;
325 case '\\': {
326 if (!this->deleteSelection() && fCursorIndex > 0) {
327
328 const auto del_index =
prev_utf8(txt_str, fCursorIndex),
329 del_count = fCursorIndex - del_index;
330
331 this->deleteChars(del_index, del_count);
332 }
333 } break;
334 default:
335
336 this->deleteSelection();
337 this->insertChar(c);
338 break;
339 }
340
341
342 fTimeBase = std::chrono::steady_clock::now();
343
344 return true;
345}
static const char * prev_utf8(const char *p, const char *begin)
static const char * next_utf8(const char *p, const char *end)