Skip to content

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

petk
Copy link
Member

@petk petk commented Sep 3, 2024

This is another step required for #13184

When building with:

./configure --enable-phpdbg-readline --with-libedit

The phpdbg prompt is not colored (or bold in some terminals):

./sapi/phpdbg/phpdbg

@petk petk mentioned this pull request Sep 3, 2024
6 tasks
@petk petk force-pushed the patch-phpdbg-prompt branch from 4ea4704 to c0e1f29 Compare September 13, 2024 16:08
@petk petk marked this pull request as ready for review September 13, 2024 16:08
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.
@petk petk force-pushed the patch-phpdbg-prompt branch from 006ec3e to 6031c7e Compare September 14, 2024 14:27
Copy link
Member

@cmb69 cmb69 left a 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 "
Copy link
Member

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.

Suggested change
# 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 " "

Copy link
Member Author

@petk petk Jan 15, 2025

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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants