Skip to content

Commit 6031c7e

Browse files
committed
Fix phpdbg prompt with editline/readline integration
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.
1 parent 2513258 commit 6031c7e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

sapi/phpdbg/phpdbg_utils.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,14 @@ PHPDBG_API const char *phpdbg_get_prompt(void) /* {{{ */
318318
}
319319

320320
/* create cached prompt */
321-
#ifndef HAVE_LIBEDIT
322-
/* TODO: libedit doesn't seems to support coloured prompt */
321+
#if !defined(HAVE_LIBEDIT) || (defined(HAVE_LIBEDIT) && defined(RL_PROMPT_START_IGNORE) && defined(RL_PROMPT_END_IGNORE))
322+
# if defined(HAVE_LIBEDIT) && defined(RL_PROMPT_START_IGNORE) && defined(RL_PROMPT_END_IGNORE)
323+
# define PHPDBG_PROMPT_FORMAT "\1\033[%sm\2%s\1\033[0m\2 "
324+
# else
325+
# define PHPDBG_PROMPT_FORMAT "\033[%sm%s\033[0m "
326+
# endif
323327
if ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED)) {
324-
ZEND_IGNORE_VALUE(asprintf(&PHPDBG_G(prompt)[1], "\033[%sm%s\033[0m ",
328+
ZEND_IGNORE_VALUE(asprintf(&PHPDBG_G(prompt)[1], PHPDBG_PROMPT_FORMAT,
325329
PHPDBG_G(colors)[PHPDBG_COLOR_PROMPT]->code,
326330
PHPDBG_G(prompt)[0]));
327331
} else

0 commit comments

Comments
 (0)