57 bool word = (keycode & WKC_CTRL) != 0;
59 keycode &= ~WKC_SPECIAL_KEYS;
60 if (keycode != WKC_BACKSPACE && keycode != WKC_DELETE)
return false;
62 bool backspace = keycode == WKC_BACKSPACE;
80 for (
const char *ss = s; ss < s + len; Utf8Consume(&ss)) {
95 for (
const char *ss = s; ss < s + len; Utf8Consume(&ss)) {
102 memmove(s, s + len, this->
bytes - (s - this->
buf) - len);
105 if (backspace) this->caretpos -= len;
164 bool Textbuf::InsertString(
const char *str,
bool marked,
const char *caret,
const char *insert_location,
const char *replacement_end)
167 if (insert_location != NULL) {
168 insertpos = insert_location - this->
buf;
169 if (insertpos > this->
bytes)
return false;
171 if (replacement_end != NULL) {
172 this->
DeleteText(insertpos, replacement_end - this->buf, str == NULL);
178 if (str == NULL)
return false;
182 for (
const char *ptr = str; (c = Utf8Consume(&ptr)) !=
'\0';) {
186 if (this->bytes + bytes + len > this->
max_bytes)
break;
196 if (bytes == 0)
return false;
203 memmove(this->
buf + insertpos + bytes, this->
buf + insertpos, this->bytes - insertpos);
204 memcpy(this->
buf + insertpos, str, bytes);
206 this->bytes +=
bytes;
211 this->
buf[this->bytes - 1] =
'\0';
245 const char *s = this->
buf + from;
246 while (s < this->
buf + to) {
252 memmove(this->
buf + from, this->
buf + to, this->
bytes - to);
253 this->
bytes -= to - from;
278 if (this->
markend == 0)
return;
325 case WKC_CTRL | WKC_LEFT: {
337 case WKC_CTRL | WKC_RIGHT: {
375 : buf(
MallocT<char>(max_bytes))
377 assert(max_bytes != 0);
378 assert(max_chars != 0);
384 this->max_chars = max_chars == UINT16_MAX ? max_bytes :
max_chars;
391 delete this->char_iter;
421 va_start(va, format);
435 const char *
buf = this->
buf;
440 while ((c = Utf8Consume(&buf)) !=
'\0') {
462 bool b = !!(_caret_timer & 0x20);
464 if (b != this->
caret) {
478 case WKC_RETURN:
case WKC_NUM_ENTER:
return HKPR_CONFIRM;
480 case (WKC_CTRL |
'V'):
484 case (WKC_CTRL |
'U'):
489 case WKC_BACKSPACE:
case WKC_DELETE:
490 case WKC_CTRL | WKC_BACKSPACE:
case WKC_CTRL | WKC_DELETE:
494 case WKC_LEFT:
case WKC_RIGHT:
case WKC_END:
case WKC_HOME:
495 case WKC_CTRL | WKC_LEFT:
case WKC_CTRL | WKC_RIGHT: