Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Fix prompt issues #381

Merged
merged 9 commits into from
Sep 26, 2024
Merged

[FIX] Fix prompt issues #381

merged 9 commits into from
Sep 26, 2024

Conversation

itislu
Copy link
Collaborator

@itislu itislu commented Sep 23, 2024

Now there are no weird issues with the prompt anymore! 🎉


readline needs "zero-length" characters to be wrapped in special markers: \001 and \002.

\001 and \002 are defined in readline.h as RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE respectively.

I use \1 and \2 bc they're shorter. Mentions of using the markers like this are also in the man of readline.

Source: https://tiswww.cwru.edu/php/chet/readline/readline.html#index-rl_005fexpand_005fprompt


Once the color escape sequences caused no issues anymore, there were sometimes still small issues. '🌊' is a 4-byte character, but only takes up width of 2 characters, which caused those remaining issues with readline.
The solution is to use hexcode representation of '🌊' to be able to mark 2 out of the 4 bytes as invisible characters for readline.

I found out about this workaround here: https://stackoverflow.com/a/56688167/24880406

readline needs "zero-length" characters to be wrapped in special markers: `\001` and `\002`.

`\001` and `\002` are defined in `readline.h` as `RL_PROMPT_START_IGNORE` and `RL_PROMPT_END_IGNORE` respectively.

Source: https://tiswww.cwru.edu/php/chet/readline/readline.html#index-rl_005fexpand_005fprompt
@itislu itislu added the bug Something isn't working label Sep 23, 2024
…l files"

These special markers are only needed for prompts when most likely there is a call to readline behind it.

This reverts commit 221dc86.
@itislu itislu marked this pull request as draft September 24, 2024 20:01
@itislu
Copy link
Collaborator Author

itislu commented Sep 24, 2024

Converted to draft to also fix the same problem with the emoji. The emoji is 4 bytes long but only takes up 2 characters on screen. This also causes issues.
Still searching for a way to fix that.

Mentions of using the markers like this are also in the `man` of readline.
The `\1`& `\2` markers are only needed for readline, so for us it means only for the prompt.
@itislu itislu marked this pull request as ready for review September 24, 2024 22:04
Once the color escape sequences caused no issues anymore, there were sometimes still small issues.
'🌊' is a 4-byte character, but only takes up width of 2 characters, which caused those remaining issues with readline.
The solution is to use hexcode representation of '🌊' to be able to mark 2 out of the 4 bytes as invisible characters for readline.

I found out about this workaround here: https://stackoverflow.com/a/56688167/24880406
@itislu itislu force-pushed the fix-color-prompt-issues branch from 6f52b6f to 0f07b8f Compare September 24, 2024 22:10
@itislu itislu changed the title [FIX] Fix color prompt issues [FIX] Fix prompt issues Sep 24, 2024
@itislu itislu requested a review from LeaYeh September 24, 2024 22:14
@LeaYeh
Copy link
Owner

LeaYeh commented Sep 26, 2024

For me it is clear. but there are too many commits a bit confused. Maybe next time you could squash them

@LeaYeh LeaYeh merged commit d963b63 into main Sep 26, 2024
41 checks passed
@LeaYeh LeaYeh deleted the fix-color-prompt-issues branch September 26, 2024 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants