diff options
Diffstat (limited to 'gdb/ui-style.h')
-rw-r--r-- | gdb/ui-style.h | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/gdb/ui-style.h b/gdb/ui-style.h index d814588..f61152f 100644 --- a/gdb/ui-style.h +++ b/gdb/ui-style.h @@ -1,5 +1,5 @@ /* Styling for ui_file - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of GDB. @@ -151,22 +151,12 @@ struct ui_file_style return ! (*this == other); } - bool operator< (const color &other) const + /* Compute a simple hash code for this object. */ + size_t hash () const { - if (m_color_space != other.m_color_space) - return m_color_space < other.m_color_space; if (is_simple ()) - return m_value < other.m_value; - if (m_red < other.m_red) - return true; - if (m_red == other.m_red) - { - if (m_green < other.m_green) - return true; - if (m_green == other.m_green) - return m_blue < other.m_blue; - } - return false; + return m_value; + return (m_red << 16) + (m_green << 8) + m_red; } color_space colorspace () const @@ -364,11 +354,35 @@ private: bool m_reverse = false; }; +/* Possible results for checking an ANSI escape sequence. */ +enum class ansi_escape_result +{ + /* The escape sequence is definitely not recognizable. */ + NO_MATCH, + + /* The escape sequence might be recognizable with more input. */ + INCOMPLETE, + + /* The escape sequence is definitely recognizable. */ + MATCHED, +}; + +/* Examine an ANSI escape sequence in BUF. BUF must begin with an ESC + character. Return a value indicating whether the sequence was + recognizable. If MATCHED is returned, then N_READ is updated to + reflect the number of chars read from BUF. */ + +extern ansi_escape_result examine_ansi_escape (const char *buf, int *n_read); + /* Skip an ANSI escape sequence in BUF. BUF must begin with an ESC character. Return true if an escape sequence was successfully skipped; false otherwise. If an escape sequence was skipped, N_READ is updated to reflect the number of chars read from BUF. */ -extern bool skip_ansi_escape (const char *buf, int *n_read); +static inline bool +skip_ansi_escape (const char *buf, int *n_read) +{ + return examine_ansi_escape (buf, n_read) == ansi_escape_result::MATCHED; +} #endif /* GDB_UI_STYLE_H */ |