Discussion:
[Bug tui/14126] New: Color escape sequences don't work in tui mode
jan at majutsushi dot net
2012-05-21 03:57:50 UTC
Permalink
http://sourceware.org/bugzilla/show_bug.cgi?id=14126

Bug #: 14126
Summary: Color escape sequences don't work in tui mode
Product: gdb
Version: unknown
Status: NEW
Severity: normal
Priority: P2
Component: tui
AssignedTo: ***@sourceware.org
ReportedBy: ***@majutsushi.net
Classification: Unclassified


If TUI mode is enabled then coloring the prompt or output using escape
sequences doesn't work, the sequences are instead shown as-is.

Example:

In normal mode, "echo \033[32mFOO\033[0m\n" will print "FOO" in green. However,
if the TUI is enabled, it will print "^[[32mFOO^[[0m" instead. This makes
trying to make the output more readable rather difficult.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
dilyan.palauzov at aegee dot org
2015-07-08 15:44:59 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=14126

dilyan.palauzov at aegee dot org <dilyan.palauzov at aegee dot org> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |dilyan.palauzov at aegee dot org

--- Comment #1 from dilyan.palauzov at aegee dot org <dilyan.palauzov at aegee dot org> ---
\w is expanded to the working directory, the problem with TUI and
extended-prompt are (only) the escape sequences. The proposed patch below just
discards all non-printing characters, between \[ and \], in TUI mode.

diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index a2df254..cab10d2 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -5137,7 +5137,8 @@ Substitute the current working directory.
Begin a sequence of non-printing characters. These sequences are
typically used with the ESC character, and are not counted in the string
length. Example: ``\[\e[0;34m\](gdb)\[\e[0m\]'' will return a
-blue-colored ``(gdb)'' prompt where the length is five.
+blue-colored ``(gdb)'' prompt where the length is five. In TUI mode
+these characters are discarded.
@item \]
End a sequence of non-printing characters.
@end table
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 97906ce..b77866a 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -232,6 +232,22 @@ tui_redisplay_readline (void)
height = 1;
for (in = 0; prompt && prompt[in]; in++)
{
+ /* Drop characters from extended-prompt between \[ == \001 and \] = \002
+ The point is, that waddch prints ^ instead of control characters and
+ in turn the latter are not interpreted by the terminal. TUI prints
+ then ^ and this is ugly.
+
+ It seems there is no way to send escape characters to the terminal
+ under curses, at least not with fputc (c , stdout);
+
+ Skiping escape sequences, which are not within \[ and \] is hard, as
+ only the terminal has knowledge where the sequence ends and where the
+ actual input starts. */
+ if (prompt[in] == '\001')
+ {
+ do { in++; } while (prompt[in] != '\002' && prompt[in] != '\0');
+ continue;
+ }
waddch (w, prompt[in]);
getyx (w, line, col);
if (col <= prev_col)
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-09-01 19:06:41 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=14126

Tom Tromey <tromey at sourceware dot org> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at sourceware dot org

--- Comment #2 from Tom Tromey <tromey at sourceware dot org> ---
I can think of two options here.

One is to change the tui-out object to be able to parse
terminal escape sequences. Then it could turn these into
ncurses color calls. This seems like a pain but maybe it
would not be too bad.

The other is to change extended-prompt to have explicit
color support and then change the TUI to understand that somehow.
This route may not be so easy since normally gdb just
prints whatever the python code gave it.
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-09-02 14:57:45 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=14126

--- Comment #3 from Tom Tromey <tromey at sourceware dot org> ---
I'm working on a patch for this.
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-09-08 09:14:05 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=14126

Tom Tromey <tromey at sourceware dot org> changed:

What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at sourceware dot org |tromey at sourceware dot org
--
You are receiving this mail because:
You are on the CC list for the bug.
Loading...