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

Function refreshShowHints

tools/shell/linenoise.cpp:1398–1423  ·  view source on GitHub ↗

Helper of refreshSingleLine() and refreshMultiLine() to show hints * to the right of the prompt. */

Source from the content-addressed store, hash-verified

1396/* Helper of refreshSingleLine() and refreshMultiLine() to show hints
1397 * to the right of the prompt. */
1398void refreshShowHints(AppendBuffer& append_buffer, struct linenoiseState* l, int plen) {
1399 char seq[64];
1400 if (hintsCallback && plen + l->len < l->cols) {
1401 int color = -1, bold = 0;
1402 char* hint = hintsCallback(l->buf, &color, &bold);
1403 if (hint) {
1404 int hintlen = strlen(hint);
1405 int hintmaxlen = l->cols - (plen + l->len);
1406 if (hintlen > hintmaxlen)
1407 hintlen = hintmaxlen;
1408 if (bold == 1 && color == -1)
1409 color = 37;
1410 if (color != -1 || bold != 0)
1411 snprintf(seq, 64, "\033[%d;%d;49m", bold, color);
1412 else
1413 seq[0] = '\0';
1414 append_buffer.abAppend(seq, strlen(seq));
1415 append_buffer.abAppend(hint, hintlen);
1416 if (color != -1 || bold != 0)
1417 append_buffer.abAppend("\033[0m");
1418 /* Call the function to free the hint returned. */
1419 if (freeHintsCallback)
1420 freeHintsCallback(hint);
1421 }
1422 }
1423}
1424
1425uint32_t linenoiseComputeRenderWidth(const char* buf, size_t len) {
1426 // UTF8 in prompt, get render width.

Callers 3

refreshSingleLineFunction · 0.85
refreshMultiLineFunction · 0.85
refreshSearchMultiLineFunction · 0.85

Calls 1

abAppendMethod · 0.80

Tested by

no test coverage detected