MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / linenoiseEditBackspace

Function linenoiseEditBackspace

tools/shell/linenoise.cpp:3235–3248  ·  view source on GitHub ↗

Backspace implementation. */

Source from the content-addressed store, hash-verified

3233
3234/* Backspace implementation. */
3235void 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. */

Callers 1

linenoiseEditFunction · 0.85

Calls 2

prevCharFunction · 0.85
refreshLineFunction · 0.85

Tested by

no test coverage detected