You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the prompt contains a color code, the cursor moves far to the right.
This is probably due to the fact that plen would include each char in the color code even though they have no bearing on cursor position (since they aren't printed to the screen like a char).
This is reproduce-able with this modified code: #ifndef NO_COLOR
If the prompt contains a color code, the cursor moves far to the right.
This is probably due to the fact that
plen
would include each char in the color code even though they have no bearing on cursor position (since they aren't printed to the screen like a char).This is reproduce-able with this modified code:
#ifndef NO_COLOR
#define RED "\x1B[31m"
#define WHITE "\x1B[37m"
#define RESET "\x1B[0m"
#else
#define RED ""
#define WHITE ""
#define RESET ""
#endif
char prompt[255] = {'\0'};
snprintf(prompt, 255, "%sexample%s@%sexample%s$ ", WHITE, RED, WHITE, RESET);
If you add that code to a program and call
linenoise(prompt)
the cursor moves over 20pts to the right but displays text correctly.If you compile the same program with the
-DNO_COLOR
flag then the issue does not happenI traced the cursor move to this line:
linenoise/linenoise.c
Line 537 in 4a961c0
The only work-around I found is to place two prompts (one above the real one) so at least part of it is in color.
Here is a picture comparing the two, note the white cursor on the left
The text was updated successfully, but these errors were encountered: