diff options
author | Andrei Pikas <gdb@mail.api.win> | 2024-10-05 22:27:44 +0300 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2025-01-12 13:30:43 -0700 |
commit | 6447969d0ac774b6dec0f95a0d3d27c27d158690 (patch) | |
tree | e9812cfdd956f4c8e89f596b276ddc1c4ad8da45 /gdb/testsuite/gdb.python/py-parameter.exp | |
parent | 338e0b05d8f2dd404eb0015bee31461dfe5ba307 (diff) | |
download | binutils-6447969d0ac774b6dec0f95a0d3d27c27d158690.zip binutils-6447969d0ac774b6dec0f95a0d3d27c27d158690.tar.gz binutils-6447969d0ac774b6dec0f95a0d3d27c27d158690.tar.bz2 |
Add an option with a color type.
Colors can be specified as "none" for terminal's default color, as a name of
one of the eight standard colors of ISO/IEC 6429 "black", "red", "green", etc.,
as an RGB hexadecimal tripplet #RRGGBB for 24-bit TrueColor, or as an
integer from 0 to 255. Integers 0 to 7 are the synonyms for the standard
colors. Integers 8-15 are used for the so-called bright colors from the
aixterm extended 16-color palette. Integers 16-255 are the indexes into xterm
extended 256-color palette (usually 6x6x6 cube plus gray ramp). In
general, 256-color palette is terminal dependent and sometimes can be
changed with OSC 4 sequences, e.g. "\033]4;1;rgb:00/FF/00\033\\".
It is the responsibility of the user to verify that the terminal supports
the specified colors.
PATCH v5 changes: documentation fixed.
PATCH v6 changes: documentation fixed.
PATCH v7 changes: rebase onto master and fixes after review.
PATCH v8 changes: fixes after review.
Diffstat (limited to 'gdb/testsuite/gdb.python/py-parameter.exp')
-rw-r--r-- | gdb/testsuite/gdb.python/py-parameter.exp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.python/py-parameter.exp b/gdb/testsuite/gdb.python/py-parameter.exp index de524f4..74e4178 100644 --- a/gdb/testsuite/gdb.python/py-parameter.exp +++ b/gdb/testsuite/gdb.python/py-parameter.exp @@ -185,6 +185,58 @@ proc_with_prefix test_enum_parameter { } { "Undefined item: \"three\".*" "set invalid enum parameter" } +# Test an color parameter. +proc_with_prefix test_color_parameter { } { + global env + with_ansi_styling_terminal { + # This enables 256 colors support and disables colors approximation. + setenv TERM xterm-256color + setenv COLORTERM truecolor + + clean_restart + + gdb_test_multiline "color gdb parameter" \ + "python" "" \ + "class TestColorParam (gdb.Parameter):" "" \ + " \"\"\"When set, test param does something useful. When disabled, does nothing.\"\"\"" "" \ + " show_doc = \"Show the state of the color\"" ""\ + " set_doc = \"Set the state of the color\"" "" \ + " def get_show_string (self, pvalue):" ""\ + " return \"The state of the color is \" + str(pvalue)" ""\ + " def get_set_string (self):" ""\ + " return \"The state of the color has been set to \" + str(self.value)" ""\ + " def __init__ (self, name):" "" \ + " super (TestColorParam, self).__init__ (name, gdb.COMMAND_DATA, gdb.PARAM_COLOR)" "" \ + " self.value = gdb.Color(\"green\")" "" \ + "test_color_param = TestColorParam ('print test-color-param')" ""\ + "end" + + gdb_test "python print (test_color_param.value)" "green" \ + "test color parameter value is green" + gdb_test "show print test-color-param" \ + "The state of the color is green.*" \ + "show parameter is initial value" + gdb_test "set print test-color-param 255" \ + "The state of the color has been set to 255" "set color to 255" + gdb_test "show print test-color-param" \ + "The state of the color is 255.*" "show parameter is new value" + gdb_test "python print (test_color_param.value)" "255" \ + "test color parameter value is 255" + gdb_test_no_output "python test_color_param.value = gdb.Color(254)" \ + "assign test_color_param.value to 254" + gdb_test "python print (test_color_param.value)" "254" \ + "test color parameter value is integer" + gdb_test_no_output "python test_color_param.value = gdb.Color('#FED210')" \ + "assign test_color_param.value to #FED210" + gdb_test "python print (test_color_param.value.components)" "\\(254, 210, 16\\)" \ + "test color parameter components from RGB hex tripple value" + gdb_test "set print test-color-param 256" \ + "integer 256 out of range.*" "set invalid color parameter" + gdb_test "python test_color_param.value = gdb.Color(256)" \ + ".*Error occurred in Python: Palette color index 256 is out of range.*" "set invalid color value" + } +} + # Test a file parameter. proc_with_prefix test_file_parameter { } { clean_restart @@ -623,6 +675,7 @@ test_directories test_data_directory test_boolean_parameter test_enum_parameter +test_color_parameter test_file_parameter test_undocumented_parameter test_really_undocumented_parameter |