Skip to content

Commit 4ea4704

Browse files
committed
Fix colors in phpdbg prompt
When using libedit with phpdbg, the prompt needs to have starting and ending ignore characters added. These characters are defined by RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE and depend whether readline or libedit is used. [skip ci]
1 parent a7f789e commit 4ea4704

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

sapi/phpdbg/phpdbg_utils.c

+9-3
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,16 @@ 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_PHPDBG_READLINE) || (defined(HAVE_PHPDBG_READLINE) && defined(RL_PROMPT_START_IGNORE) && defined(RL_PROMPT_END_IGNORE))
323322
if ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED)) {
324-
ZEND_IGNORE_VALUE(asprintf(&PHPDBG_G(prompt)[1], "\033[%sm%s\033[0m ",
323+
ZEND_IGNORE_VALUE(asprintf(&PHPDBG_G(prompt)[1],
324+
#if defined(HAVE_LIBEDIT) && defined(RL_PROMPT_START_IGNORE) && defined(RL_PROMPT_END_IGNORE)
325+
"\1\033[%sm\2%s\1\033[0m\2 ",
326+
#elif defined(HAVE_LIBREADLINE) && defined(RL_PROMPT_START_IGNORE) && defined(RL_PROMPT_END_IGNORE)
327+
"\001\033[%sm\002%s\001\033[0m\002 ",
328+
#else
329+
"\033[%sm%s\033[0m ",
330+
#endif
325331
PHPDBG_G(colors)[PHPDBG_COLOR_PROMPT]->code,
326332
PHPDBG_G(prompt)[0]));
327333
} else

0 commit comments

Comments
 (0)