-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathphpdbg-prompt.patch
52 lines (43 loc) · 1.91 KB
/
phpdbg-prompt.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
From: Peter Kokot <peterkokot@gmail.com>
Subject: 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 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-libedit --enable-phpdbg-readline
make
./sapi/phpdbg/phpdb
CMake:
cmake -DPHP_SAPI_PHPDBG_READLINE=ON .
cmake --build .
./sapi/phpdbg/phpdbg
In the phpdbg, the "prompt" should be colored (or bold) in some
terminals.
---
sapi/phpdbg/phpdbg_utils.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/sapi/phpdbg/phpdbg_utils.c b/sapi/phpdbg/phpdbg_utils.c
index 329ee9a8830..c2a73d37096 100644
--- a/sapi/phpdbg/phpdbg_utils.c
+++ b/sapi/phpdbg/phpdbg_utils.c
@@ -318,10 +318,14 @@ PHPDBG_API const char *phpdbg_get_prompt(void) /* {{{ */
}
/* create cached prompt */
-#ifndef HAVE_LIBEDIT
- /* 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 "
+# else
+# define PHPDBG_PROMPT_FORMAT "\033[%sm%s\033[0m "
+# endif
if ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED)) {
- ZEND_IGNORE_VALUE(asprintf(&PHPDBG_G(prompt)[1], "\033[%sm%s\033[0m ",
+ ZEND_IGNORE_VALUE(asprintf(&PHPDBG_G(prompt)[1], PHPDBG_PROMPT_FORMAT,
PHPDBG_G(colors)[PHPDBG_COLOR_PROMPT]->code,
PHPDBG_G(prompt)[0]));
} else