summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpgen <p.gen.progs@gmail.com>2022-01-06 20:53:51 +0100
committerpgen <p.gen.progs@gmail.com>2022-01-06 20:53:51 +0100
commit1876444897e8ddb10082b7a588ba830f71a6bbc0 (patch)
tree38fb716acb9395ed55388ea3a40138fa4bea78e8
parent73b4707b66f23104b8c2122b541df73dc558319d (diff)
Use enum for the color method (classic or ANSI)
-rw-r--r--smenu.c14
-rw-r--r--smenu.h20
2 files changed, 21 insertions, 13 deletions
diff --git a/smenu.c b/smenu.c
index 053448e..1b9b85e 100644
--- a/smenu.c
+++ b/smenu.c
@@ -526,9 +526,9 @@ ini_cb(win_t * win, term_t * term, limit_t * limits, ticker_t * timers,
if (strcmp(name, "method") == 0)
{
if (strcmp(value, "classic") == 0)
- term->color_method = 0;
+ term->color_method = CLASSIC;
else if (strcmp(value, "ansi") == 0)
- term->color_method = 1;
+ term->color_method = ANSI;
else
{
error = 1;
@@ -2843,7 +2843,7 @@ color_transcode(short color)
void
set_foreground_color(term_t * term, short color)
{
- if (term->color_method == 0)
+ if (term->color_method == CLASSIC)
{
if (term->has_setf)
(void)tputs(TPARM2(set_foreground, color), 1, outch);
@@ -2851,7 +2851,7 @@ set_foreground_color(term_t * term, short color)
(void)tputs(TPARM2(set_a_foreground, color_transcode(color)), 1, outch);
}
- else if (term->color_method == 1)
+ else if (term->color_method == ANSI)
{
if (term->has_setaf)
(void)tputs(TPARM2(set_a_foreground, color), 1, outch);
@@ -2866,7 +2866,7 @@ set_foreground_color(term_t * term, short color)
void
set_background_color(term_t * term, short color)
{
- if (term->color_method == 0)
+ if (term->color_method == CLASSIC)
{
if (term->has_setb)
(void)tputs(TPARM2(set_background, color), 1, outch);
@@ -2874,7 +2874,7 @@ set_background_color(term_t * term, short color)
(void)tputs(TPARM2(set_a_background, color_transcode(color)), 1, outch);
}
- else if (term->color_method == 1)
+ else if (term->color_method == ANSI)
{
if (term->has_setab)
(void)tputs(TPARM2(set_a_background, color), 1, outch);
@@ -7161,7 +7161,7 @@ main(int argc, char * argv[])
win.start = 0;
- term.color_method = 1; /* We default to setaf/setbf to set colors. */
+ term.color_method = ANSI; /* We default to setaf/setbf to set colors. */
term.curs_line = term.curs_column = 0;
{
diff --git a/smenu.h b/smenu.h
index baf1b41..649fbb5 100644
--- a/smenu.h
+++ b/smenu.h
@@ -91,6 +91,14 @@ typedef enum attribute_settings
FORCED /* an attribute setting has been given in the command line. */
} attr_set_t;
+/* Method used to interpret the color numbers. */
+/* """"""""""""""""""""""""""""""""""""""""""" */
+typedef enum color_method
+{
+ CLASSIC,
+ ANSI
+} color_method_t;
+
/* Constant to distinguish between the various search modes. */
/* """"""""""""""""""""""""""""""""""""""""""""""""""""""""" */
typedef enum search_modes
@@ -223,12 +231,12 @@ struct attrib_s
/* """"""""""""""""""""""""""""""""""""""""""""""""""" */
struct term_s
{
- int ncolumns; /* number of columns. */
- int nlines; /* number of lines. */
- int curs_column; /* current cursor column. */
- int curs_line; /* current cursor line. */
- short colors; /* number of available colors. */
- short color_method; /* color method (0=classic (0-7), 1=ANSI). */
+ int ncolumns; /* number of columns. */
+ int nlines; /* number of lines. */
+ int curs_column; /* current cursor column. */
+ int curs_line; /* current cursor line. */
+ short colors; /* number of available colors. */
+ color_method_t color_method; /* color method (CLASSIC (0-7), ANSI). */
char has_cursor_up; /* has cuu1 terminfo capability. */
char has_cursor_down; /* has cud1 terminfo capability. */