MCPcopy Create free account
hub / github.com/antirez/ds4 / refreshStatusLinePart

Function refreshStatusLinePart

linenoise.c:951–970  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

949
950static int linenoiseStatusActive(struct linenoiseState *l) {
951 return l->status && l->status[0];
952}
953
954static int linenoiseStatusRows(struct linenoiseState *l) {
955 if (!linenoiseStatusActive(l)) return 0;
956 int rows = 1;
957 for (char *p = l->status; *p; p++) {
958 if (*p == '\n') rows++;
959 }
960 return rows;
961}
962
963/* Append at most maxcols terminal cells of UTF-8 text. Status text is
964 * expected to be plain text, with styling supplied separately by the caller,
965 * but we still treat ANSI CSI escapes as zero-width so a caller can pass a
966 * pre-colored status without corrupting cursor accounting. */
967static size_t abAppendUtf8Clipped(struct abuf *ab, const char *s, size_t len,
968 size_t maxcols) {
969 size_t i = 0, width = 0;
970 while (i < len) {
971 if (s[i] == 0x1b) {
972 size_t skip = ansiEscapeLen(s + i, len - i);
973 if (skip > 0) {

Callers 1

refreshStatusLineFunction · 0.85

Calls 2

abAppendFunction · 0.85
abAppendUtf8ClippedFunction · 0.85

Tested by

no test coverage detected