Backspace implementation. */
| 3233 | |
| 3234 | /* Backspace implementation. */ |
| 3235 | void linenoiseEditBackspace(struct linenoiseState* l) { |
| 3236 | if (l->pos > 0 && l->len > 0) { |
| 3237 | uint32_t newPos = prevChar(l); |
| 3238 | uint32_t charSize = l->pos - newPos; |
| 3239 | memmove(l->buf + newPos, l->buf + l->pos, l->len - l->pos); |
| 3240 | l->len -= charSize; |
| 3241 | l->pos = newPos; |
| 3242 | if (charSize > 1) { |
| 3243 | l->totalUTF8Chars--; |
| 3244 | } |
| 3245 | l->buf[l->len] = '\0'; |
| 3246 | refreshLine(l); |
| 3247 | } |
| 3248 | } |
| 3249 | |
| 3250 | /* Delete the previous word, maintaining the cursor at the start of the |
| 3251 | * current word. */ |
no test coverage detected