NeoMutt  2023-03-22
Teaching an old dog new tricks
DOXYGEN
debug.h File Reference

Colour Debugging. More...

#include "config.h"
#include <stdbool.h>
#include "mutt/lib.h"
#include "color.h"
+ Include dependency graph for debug.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

const char * color_debug_log_color_attrs (int fg, int bg, int attrs)
 Get a colourful string to represent a colour in the log. More...
 
const char * color_debug_log_name (char *buf, int buflen, int color)
 Get a string to represent a colour name. More...
 
const char * color_debug_log_attrs_list (int attrs)
 Get a string to represent some attributes in the log. More...
 
static const char * color_debug_log_attrs (int attrs)
 
static const char * color_debug_log_color (int fg, int bg)
 
static void attr_color_dump (struct AttrColor *ac, const char *prefix)
 
static void attr_color_list_dump (struct AttrColorList *acl, const char *title)
 
static void curses_color_dump (struct CursesColor *cc, const char *prefix)
 
static void curses_colors_dump (void)
 
static void merged_colors_dump (void)
 
static void quoted_color_dump (struct AttrColor *ac, int q_level, const char *prefix)
 
static void quoted_color_list_dump (void)
 
static void regex_color_dump (struct RegexColor *rcol, const char *prefix)
 
static void regex_color_list_dump (const char *name, struct RegexColorList *rcl)
 
static void regex_colors_dump_all (void)
 
static void simple_color_dump (enum ColorId cid, const char *prefix)
 
static void simple_colors_dump (bool force)
 
static int color_debug (enum LogLevel level, const char *format,...)
 

Detailed Description

Colour Debugging.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file debug.h.

Function Documentation

◆ color_debug_log_color_attrs()

const char * color_debug_log_color_attrs ( int  fg,
int  bg,
int  attrs 
)

Get a colourful string to represent a colour in the log.

Parameters
fgForeground colour
bgBackground colour
attrsAttributes, e.g. A_UNDERLINE
Return values
ptrGenerated string
Note
Do not free the returned string

Definition at line 67 of file debug.c.

68{
69 static char text[64];
70 int pos = 0;
71
72 if (attrs & A_BLINK)
73 pos += snprintf(text + pos, sizeof(text) - pos, "\033[5m");
74 if (attrs & A_BOLD)
75 pos += snprintf(text + pos, sizeof(text) - pos, "\033[1m");
76 if (attrs & A_NORMAL)
77 pos += snprintf(text + pos, sizeof(text) - pos, "\033[0m");
78 if (attrs & A_REVERSE)
79 pos += snprintf(text + pos, sizeof(text) - pos, "\033[7m");
80 if (attrs & A_STANDOUT)
81 pos += snprintf(text + pos, sizeof(text) - pos, "\033[1m");
82 if (attrs & A_UNDERLINE)
83 pos += snprintf(text + pos, sizeof(text) - pos, "\033[4m");
84
85 if (fg >= 0)
86 pos += snprintf(text + pos, sizeof(text) - pos, "\033[38;5;%dm", fg);
87 if (bg >= 0)
88 pos += snprintf(text + pos, sizeof(text) - pos, "\033[48;5;%dm", bg);
89
90 snprintf(text + pos, sizeof(text) - pos, "XXXXXX\033[0m");
91
92 return text;
93}

◆ color_debug_log_name()

const char * color_debug_log_name ( char *  buf,
int  buflen,
int  color 
)

Get a string to represent a colour name.

Parameters
bufBuffer for the result
buflenLength of the Buffer
colorPalette colour number
Return values
ptrGenerated string

Definition at line 181 of file debug.c.

182{
183 if (color < 0)
184 return "default";
185
186 if (color < 256)
187 snprintf(buf, buflen, "color%d", color);
188 else
189 snprintf(buf, buflen, "BAD:%d", color);
190
191 return buf;
192}

◆ color_debug_log_attrs_list()

const char * color_debug_log_attrs_list ( int  attrs)

Get a string to represent some attributes in the log.

Parameters
attrsAttributes, e.g. A_UNDERLINE
Return values
ptrGenerated string
Note
Do not free the returned string

Definition at line 150 of file debug.c.

151{
152 static char text[64];
153
154 text[0] = '\0';
155 int pos = 0;
156 if (attrs & A_BLINK)
157 pos += snprintf(text + pos, sizeof(text) - pos, "blink ");
158 if (attrs & A_BOLD)
159 pos += snprintf(text + pos, sizeof(text) - pos, "bold ");
160 if (attrs & A_ITALIC)
161 pos += snprintf(text + pos, sizeof(text) - pos, "italic ");
162 if (attrs & A_NORMAL)
163 pos += snprintf(text + pos, sizeof(text) - pos, "normal ");
164 if (attrs & A_REVERSE)
165 pos += snprintf(text + pos, sizeof(text) - pos, "reverse ");
166 if (attrs & A_STANDOUT)
167 pos += snprintf(text + pos, sizeof(text) - pos, "standout ");
168 if (attrs & A_UNDERLINE)
169 pos += snprintf(text + pos, sizeof(text) - pos, "underline ");
170
171 return text;
172}

◆ color_debug_log_attrs()

static const char * color_debug_log_attrs ( int  attrs)
inlinestatic

Definition at line 67 of file debug.h.

67{ return ""; }

◆ color_debug_log_color()

static const char * color_debug_log_color ( int  fg,
int  bg 
)
inlinestatic

Definition at line 68 of file debug.h.

68{ return ""; }

◆ attr_color_dump()

static void attr_color_dump ( struct AttrColor ac,
const char *  prefix 
)
inlinestatic

Definition at line 70 of file debug.h.

70{}

◆ attr_color_list_dump()

static void attr_color_list_dump ( struct AttrColorList *  acl,
const char *  title 
)
inlinestatic

Definition at line 71 of file debug.h.

71{}

◆ curses_color_dump()

static void curses_color_dump ( struct CursesColor cc,
const char *  prefix 
)
inlinestatic

Definition at line 73 of file debug.h.

73{}

◆ curses_colors_dump()

static void curses_colors_dump ( void  )
inlinestatic

Definition at line 74 of file debug.h.

74{}

◆ merged_colors_dump()

static void merged_colors_dump ( void  )
inlinestatic

Definition at line 76 of file debug.h.

76{}

◆ quoted_color_dump()

static void quoted_color_dump ( struct AttrColor ac,
int  q_level,
const char *  prefix 
)
inlinestatic

Definition at line 78 of file debug.h.

78{}

◆ quoted_color_list_dump()

static void quoted_color_list_dump ( void  )
inlinestatic

Definition at line 79 of file debug.h.

79{}

◆ regex_color_dump()

static void regex_color_dump ( struct RegexColor rcol,
const char *  prefix 
)
inlinestatic

Definition at line 81 of file debug.h.

81{}

◆ regex_color_list_dump()

static void regex_color_list_dump ( const char *  name,
struct RegexColorList *  rcl 
)
inlinestatic

Definition at line 82 of file debug.h.

82{}

◆ regex_colors_dump_all()

static void regex_colors_dump_all ( void  )
inlinestatic

Definition at line 83 of file debug.h.

83{}

◆ simple_color_dump()

static void simple_color_dump ( enum ColorId  cid,
const char *  prefix 
)
inlinestatic

Definition at line 85 of file debug.h.

85{}

◆ simple_colors_dump()

static void simple_colors_dump ( bool  force)
inlinestatic

Definition at line 86 of file debug.h.

86{}

◆ color_debug()

static int color_debug ( enum LogLevel  level,
const char *  format,
  ... 
)
inlinestatic

Definition at line 88 of file debug.h.

88{ return 0; }