| 949 | |
| 950 | static int linenoiseStatusActive(struct linenoiseState *l) { |
| 951 | return l->status && l->status[0]; |
| 952 | } |
| 953 | |
| 954 | static 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. */ |
| 967 | static 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) { |
no test coverage detected