aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/lib/tuiterm.exp
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2023-05-26 12:30:24 +0200
committerTom de Vries <tdevries@suse.de>2023-05-26 12:30:24 +0200
commita3b86780b6cc9d5915a781bef0d901dcc5d9c07f (patch)
treecb1c590ad52c5628047b636ea1879d10c0f65389 /gdb/testsuite/lib/tuiterm.exp
parent52141e2def780c8ff6f4233971f9007e5d712a5d (diff)
downloadgdb-a3b86780b6cc9d5915a781bef0d901dcc5d9c07f.zip
gdb-a3b86780b6cc9d5915a781bef0d901dcc5d9c07f.tar.gz
gdb-a3b86780b6cc9d5915a781bef0d901dcc5d9c07f.tar.bz2
[gdb/testsuite] Add test-case gdb.tui/color-prompt.exp
Add a test-case that sets a prompt with color in TUI. The line containing the prompt is shown by get_line_with_attrs as follows: ... <fg:31>(gdb) <fg:default> ... The 31 means red, but only for foreground colors, for background colors 41 means red. Make this more readable by using color names for both foreground and background, such that we have instead: .... <fg:red>(gdb) <fg:default> ... Tested on x86_64-linux.
Diffstat (limited to 'gdb/testsuite/lib/tuiterm.exp')
-rw-r--r--gdb/testsuite/lib/tuiterm.exp35
1 files changed, 33 insertions, 2 deletions
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index 90b885d..b7c8775 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -561,6 +561,37 @@ namespace eval Term {
}
}
+ # Translate the color numbers as used in proc _csi_m to a name.
+ proc _color_attr { n } {
+ switch -exact -- $n {
+ 0 {
+ return black
+ }
+ 1 {
+ return red
+ }
+ 2 {
+ return green
+ }
+ 3 {
+ return yellow
+ }
+ 4 {
+ return blue
+ }
+ 5 {
+ return magenta
+ }
+ 6 {
+ return cyan
+ }
+ 7 {
+ return white
+ }
+ default { error "unsupported color number: $n" }
+ }
+ }
+
# Select Graphic Rendition.
#
# https://vt100.net/docs/vt510-rm/SGR.html
@@ -607,13 +638,13 @@ namespace eval Term {
set _attrs(invisible) 0
}
30 - 31 - 32 - 33 - 34 - 35 - 36 - 37 {
- set _attrs(fg) $item
+ set _attrs(fg) [_color_attr [expr $item - 30]]
}
39 {
set _attrs(fg) default
}
40 - 41 - 42 - 43 - 44 - 45 - 46 - 47 {
- set _attrs(bg) $item
+ set _attrs(bg) [_color_attr [expr $item - 40]]
}
49 {
set _attrs(bg) default