-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix colors in phpdbg prompt with libedit integration #15722
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
base: master
Are you sure you want to change the base?
Conversation
4ea4704
to
c0e1f29
Compare
When building phpdbg SAPI with libedit/readline integration, also start and end ignore characters need to be added in the prompt pattern. This should now work for libedit, readline, and phpdbg without readline/libedit. The RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE macros are checked to ensure libedit has these available. Otherwise, this could be further improved by concatenating strings and literal strings into single argument or similar using these two symbols directly. Autotools: ./configure --with-readline --enable-phpdbg-readline make ./sapi/phpdbg/phpdb In the phpdbg, the "prompt" should be colored (or bold) in some terminals.
006ec3e
to
6031c7e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't actually tested this, but it looks fine (see the nit below, though).
/* TODO: libedit doesn't seems to support coloured prompt */ | ||
#if !defined(HAVE_LIBEDIT) || (defined(HAVE_LIBEDIT) && defined(RL_PROMPT_START_IGNORE) && defined(RL_PROMPT_END_IGNORE)) | ||
# if defined(HAVE_LIBEDIT) && defined(RL_PROMPT_START_IGNORE) && defined(RL_PROMPT_END_IGNORE) | ||
# define PHPDBG_PROMPT_FORMAT "\1\033[%sm\2%s\1\033[0m\2 " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to actually use the macros, i.e.
# define PHPDBG_PROMPT_FORMAT "\1\033[%sm\2%s\1\033[0m\2 " | |
# define PHPDBG_PROMPT_FORMAT RL_PROMPT_START_IGNORE "\033[%sm\2%s\1\033[0m" RL_PROMPT_END_IGNORE " " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll check. Last time I've tried this there were some errors and these strings should be then concatenated differently. The libraries define them as this (with single quotes):
/usr/include/readline/readline.h:#define RL_PROMPT_START_IGNORE '\001'
/usr/include/editline/readline.h:#define RL_PROMPT_START_IGNORE '\1'
/usr/include/readline/readline.h:#define RL_PROMPT_END_IGNORE '\002'
/usr/include/editline/readline.h:#define RL_PROMPT_END_IGNORE '\2'
This is another step required for #13184
When building with:
The phpdbg prompt is not colored (or bold in some terminals):