]> granicus.if.org Git - neomutt/commitdiff
refactor: move colour definitions to color.h
authorRichard Russon <rich@flatcap.org>
Fri, 27 Sep 2019 11:29:19 +0000 (12:29 +0100)
committerRichard Russon <rich@flatcap.org>
Sat, 28 Sep 2019 02:18:27 +0000 (03:18 +0100)
The colour defines and structures don't depend on curses.

color.h
compose.c
curs_lib.c
hdrline.c
index.c
mutt_curses.h
mutt_logging.c
progress.c
remailer.c
sidebar.c

diff --git a/color.h b/color.h
index 85c08b293f17f0806f142ee0e6a50cf6a7c87975..b14e80194557329b130c1cea3960e4c445e99d9a 100644 (file)
--- a/color.h
+++ b/color.h
 #ifndef MUTT_COLOR_H
 #define MUTT_COLOR_H
 
+#include "config.h"
+#include <regex.h>
+#include <stdbool.h>
 #include <stdint.h>
+#include "mutt/mutt.h"
 #include "mutt_commands.h"
 
-struct Buffer;
+/**
+ * struct ColorLine - A regular expression and a color to highlight a line
+ */
+struct ColorLine
+{
+  regex_t regex;                     ///< Compiled regex
+  int match;                         ///< Substring to match, 0 for old behaviour
+  char *pattern;                     ///< Pattern to match
+  struct PatternList *color_pattern; ///< compiled pattern to speed up index color calculation
+  uint32_t fg;                       ///< Foreground colour
+  uint32_t bg;                       ///< Background colour
+  int pair;                          ///< Colour pair index
+
+  bool stop_matching : 1;            ///< used by the pager for body patterns, to prevent the color from being retried once it fails
+
+  STAILQ_ENTRY(ColorLine) entries;   ///< Linked list
+};
+STAILQ_HEAD(ColorLineList, ColorLine);
+
+/**
+ * enum ColorId - List of all colored objects
+ */
+enum ColorId
+{
+  MT_COLOR_HDEFAULT = 0,             ///< Header default colour
+  MT_COLOR_QUOTED,                   ///< Pager: quoted text
+  MT_COLOR_SIGNATURE,                ///< Pager: signature lines
+  MT_COLOR_INDICATOR,                ///< Selected item in list
+  MT_COLOR_STATUS,                   ///< Status bar
+  MT_COLOR_TREE,                     ///< Index: tree-drawing characters
+  MT_COLOR_NORMAL,                   ///< Plain text
+  MT_COLOR_ERROR,                    ///< Error message
+  MT_COLOR_TILDE,                    ///< Pager: empty lines after message
+  MT_COLOR_MARKERS,                  ///< Pager: markers, line continuation
+  MT_COLOR_BODY,                     ///< Pager: highlight body of message (takes a pattern)
+  MT_COLOR_HEADER,                   ///< Message headers (takes a pattern)
+  MT_COLOR_MESSAGE,                  ///< Informational message
+  MT_COLOR_ATTACHMENT,               ///< MIME attachments text (entire line)
+  MT_COLOR_ATTACH_HEADERS,           ///< MIME attachment test (takes a pattern)
+  MT_COLOR_SEARCH,                   ///< Pager: search matches
+  MT_COLOR_BOLD,                     ///< Bold text
+  MT_COLOR_UNDERLINE,                ///< Underlined text
+  MT_COLOR_PROMPT,                   ///< Question/user input
+  MT_COLOR_PROGRESS,                 ///< Progress bar
+#ifdef USE_SIDEBAR
+  MT_COLOR_DIVIDER,                  ///< Line dividing sidebar from the index/pager
+  MT_COLOR_FLAGGED,                  ///< Mailbox with flagged messages
+  MT_COLOR_HIGHLIGHT,                ///< Select cursor
+  MT_COLOR_NEW,                      ///< Mailbox with new mail
+  MT_COLOR_ORDINARY,                 ///< Mailbox with no new or flagged messages
+  MT_COLOR_SB_INDICATOR,             ///< Current open mailbox
+  MT_COLOR_SB_SPOOLFILE,             ///< $spoolfile (Spool mailbox)
+#endif
+  MT_COLOR_MESSAGE_LOG,              ///< Menu showing log messages
+  /* please no non-MT_COLOR_INDEX objects after this point */
+  MT_COLOR_INDEX,                    ///< Index: default colour (takes a pattern)
+  MT_COLOR_INDEX_AUTHOR,             ///< Index: author field (takes a pattern)
+  MT_COLOR_INDEX_FLAGS,              ///< Index: flags field (takes a pattern)
+  MT_COLOR_INDEX_TAG,                ///< Index: tag field (%g, takes a pattern)
+  MT_COLOR_INDEX_SUBJECT,            ///< Index: subject field (takes a pattern)
+  /* below here - only index coloring stuff that doesn't have a pattern */
+  MT_COLOR_INDEX_COLLAPSED,          ///< Index: number of messages in collapsed thread
+  MT_COLOR_INDEX_DATE,               ///< Index: date field
+  MT_COLOR_INDEX_LABEL,              ///< Index: label field
+  MT_COLOR_INDEX_NUMBER,             ///< Index: index number
+  MT_COLOR_INDEX_SIZE,               ///< Index: size field
+  MT_COLOR_INDEX_TAGS,               ///< Index: tags field (%g, %J)
+  MT_COLOR_COMPOSE_HEADER,           ///< Header labels, e.g. From:
+  MT_COLOR_COMPOSE_SECURITY_ENCRYPT, ///< Mail will be encrypted
+  MT_COLOR_COMPOSE_SECURITY_SIGN,    ///< Mail will be signed
+  MT_COLOR_COMPOSE_SECURITY_BOTH,    ///< Mail will be encrypted and signed
+  MT_COLOR_COMPOSE_SECURITY_NONE,    ///< Mail will not be encrypted or signed
+  MT_COLOR_OPTIONS,                  ///< Options in prompt
+  MT_COLOR_MAX,
+};
+
+extern int *ColorQuote;                            ///< Array of colours for quoted email text
+extern int ColorQuoteUsed;                         ///< Number of colours for quoted email text
+extern int ColorDefs[];                            ///< Array of all fixed colours, see enum ColorId
+extern struct ColorLineList ColorAttachList;       ///< List of colours applied to the attachment headers
+extern struct ColorLineList ColorBodyList;         ///< List of colours applied to the email body
+extern struct ColorLineList ColorHdrList;          ///< List of colours applied to the email headers
+extern struct ColorLineList ColorIndexAuthorList;  ///< List of colours applied to the author in the index
+extern struct ColorLineList ColorIndexFlagsList;   ///< List of colours applied to the flags in the index
+extern struct ColorLineList ColorIndexList;        ///< List of default colours applied to the index
+extern struct ColorLineList ColorIndexSubjectList; ///< List of colours applied to the subject in the index
+extern struct ColorLineList ColorIndexTagList;     ///< List of colours applied to tags in the index
+extern struct ColorLineList ColorStatusList;       ///< List of colours applied to the status bar
 
 void ci_start_color(void);
 int  mutt_alloc_color(uint32_t fg, uint32_t bg);
 int  mutt_combine_color(uint32_t fg_attr, uint32_t bg_attr);
 void mutt_color_free(uint32_t fg, uint32_t bg);
 void mutt_colors_free(void);
-enum CommandResult mutt_parse_color(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-enum CommandResult mutt_parse_mono(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+
+enum CommandResult mutt_parse_color  (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+enum CommandResult mutt_parse_mono   (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
 enum CommandResult mutt_parse_uncolor(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
-enum CommandResult mutt_parse_unmono(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
+enum CommandResult mutt_parse_unmono (struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
 
 #endif /* MUTT_COLOR_H */
index bbdcafcb9d2c3fa43ddc8d94fdeb9ea6b901d873..a806792c513957d4a16ac041fd745fd8882b756f 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -46,6 +46,7 @@
 #include "compose.h"
 #include "alias.h"
 #include "browser.h"
+#include "color.h"
 #include "commands.h"
 #include "context.h"
 #include "curs_lib.h"
index 7d22ed80c3de90545792ee2531b41995b2dfc0db..dbbf0c0eb1cd818dac11caa92b797f4f966ef553 100644 (file)
@@ -47,6 +47,7 @@
 #include "mutt.h"
 #include "curs_lib.h"
 #include "browser.h"
+#include "color.h"
 #include "enter_state.h"
 #include "globals.h"
 #include "mutt_curses.h"
index 75baac7b66de6a2ce1c97c5e9f727deffd4a54b2..6d901efc83b8c3cdbc5317e273f6402e1ceb4507 100644 (file)
--- a/hdrline.c
+++ b/hdrline.c
 #include "core/lib.h"
 #include "hdrline.h"
 #include "alias.h"
+#include "color.h"
 #include "context.h"
 #include "curs_lib.h"
 #include "format_flags.h"
 #include "globals.h"
 #include "hook.h"
-#include "mutt_curses.h"
 #include "mutt_menu.h"
 #include "mutt_parse.h"
 #include "mutt_thread.h"
diff --git a/index.c b/index.c
index f40deea962652bca2b0bf3209dbf010a049d5d96..25f50207420591d32cd5a9cdcb2addadaf837dd1 100644 (file)
--- a/index.c
+++ b/index.c
@@ -44,6 +44,7 @@
 #include "index.h"
 #include "alias.h"
 #include "browser.h"
+#include "color.h"
 #include "commands.h"
 #include "context.h"
 #include "curs_lib.h"
index b65fff553777b0654bb66feea47080ef319c27fb..b5e47d6a3ed48c70764580058c9c9aa5fbd8827e 100644 (file)
 #define MUTT_MUTT_CURSES_H
 
 #include "config.h"
-#include <regex.h>
 #include <stdbool.h>
-#include <stdint.h>
-#include "mutt/mutt.h"
 
 #ifdef USE_SLANG_CURSES
 
@@ -115,99 +112,6 @@ struct KeyEvent
 
 void mutt_resize_screen(void);
 
-/* ----------------------------------------------------------------------------
- * Support for color
- */
-
-/**
- * enum ColorId - List of all colored objects
- */
-enum ColorId
-{
-  MT_COLOR_HDEFAULT = 0, ///< Header default colour
-  MT_COLOR_QUOTED,       ///< Pager: quoted text
-  MT_COLOR_SIGNATURE,    ///< Pager: signature lines
-  MT_COLOR_INDICATOR,    ///< Selected item in list
-  MT_COLOR_STATUS,       ///< Status bar
-  MT_COLOR_TREE,         ///< Index: tree-drawing characters
-  MT_COLOR_NORMAL,       ///< Plain text
-  MT_COLOR_ERROR,        ///< Error message
-  MT_COLOR_TILDE,        ///< Pager: empty lines after message
-  MT_COLOR_MARKERS,      ///< Pager: markers, line continuation
-  MT_COLOR_BODY,         ///< Pager: highlight body of message (takes a pattern)
-  MT_COLOR_HEADER,       ///< Message headers (takes a pattern)
-  MT_COLOR_MESSAGE,      ///< Informational message
-  MT_COLOR_ATTACHMENT,   ///< MIME attachments text (entire line)
-  MT_COLOR_ATTACH_HEADERS, ///< MIME attachment test (takes a pattern)
-  MT_COLOR_SEARCH,         ///< Pager: search matches
-  MT_COLOR_BOLD,           ///< Bold text
-  MT_COLOR_UNDERLINE,      ///< Underlined text
-  MT_COLOR_PROMPT,         ///< Question/user input
-  MT_COLOR_PROGRESS,       ///< Progress bar
-#ifdef USE_SIDEBAR
-  MT_COLOR_DIVIDER,      ///< Line dividing sidebar from the index/pager
-  MT_COLOR_FLAGGED,      ///< Mailbox with flagged messages
-  MT_COLOR_HIGHLIGHT,    ///< Select cursor
-  MT_COLOR_NEW,          ///< Mailbox with new mail
-  MT_COLOR_ORDINARY,     ///< Mailbox with no new or flagged messages
-  MT_COLOR_SB_INDICATOR, ///< Current open mailbox
-  MT_COLOR_SB_SPOOLFILE, ///< $spoolfile (Spool mailbox)
-#endif
-  MT_COLOR_MESSAGE_LOG, ///< Menu showing log messages
-  /* please no non-MT_COLOR_INDEX objects after this point */
-  MT_COLOR_INDEX,         ///< Index: default colour (takes a pattern)
-  MT_COLOR_INDEX_AUTHOR,  ///< Index: author field (takes a pattern)
-  MT_COLOR_INDEX_FLAGS,   ///< Index: flags field (takes a pattern)
-  MT_COLOR_INDEX_TAG,     ///< Index: tag field (%g, takes a pattern)
-  MT_COLOR_INDEX_SUBJECT, ///< Index: subject field (takes a pattern)
-  /* below here - only index coloring stuff that doesn't have a pattern */
-  MT_COLOR_INDEX_COLLAPSED, ///< Index: number of messages in collapsed thread
-  MT_COLOR_INDEX_DATE,      ///< Index: date field
-  MT_COLOR_INDEX_LABEL,     ///< Index: label field
-  MT_COLOR_INDEX_NUMBER,    ///< Index: index number
-  MT_COLOR_INDEX_SIZE,      ///< Index: size field
-  MT_COLOR_INDEX_TAGS,      ///< Index: tags field (%g, %J)
-  MT_COLOR_COMPOSE_HEADER,  ///< Header labels, e.g. From:
-  MT_COLOR_COMPOSE_SECURITY_ENCRYPT, ///< Mail will be encrypted
-  MT_COLOR_COMPOSE_SECURITY_SIGN,    ///< Mail will be signed
-  MT_COLOR_COMPOSE_SECURITY_BOTH,    ///< Mail will be encrypted and signed
-  MT_COLOR_COMPOSE_SECURITY_NONE,    ///< Mail will not be encrypted or signed
-  MT_COLOR_OPTIONS,                  ///< Options in prompt
-  MT_COLOR_MAX,
-};
-
-/**
- * struct ColorLine - A regular expression and a color to highlight a line
- */
-struct ColorLine
-{
-  regex_t regex;                     ///< Compiled regex
-  int match;                         ///< Substring to match, 0 for old behaviour
-  char *pattern;                     ///< Pattern to match
-  struct PatternList *color_pattern; ///< compiled pattern to speed up index color calculation
-  uint32_t fg;                       ///< Foreground colour
-  uint32_t bg;                       ///< Background colour
-  int pair;                          ///< Colour pair index
-
-  bool stop_matching : 1;            ///< used by the pager for body patterns, to prevent the color from being retried once it fails
-
-  STAILQ_ENTRY(ColorLine) entries;   ///< Linked list
-};
-STAILQ_HEAD(ColorLineList, ColorLine);
-
-extern int *ColorQuote;                            ///< Array of colours for quoted email text
-extern int ColorQuoteUsed;                         ///< Number of colours for quoted email text
-extern int ColorDefs[];                            ///< Array of all fixed colours, see enum ColorId
-extern struct ColorLineList ColorHdrList;          ///< List of colours applied to the email headers
-extern struct ColorLineList ColorBodyList;         ///< List of colours applied to the email body
-extern struct ColorLineList ColorAttachList;       ///< List of colours applied to the attachment headers
-extern struct ColorLineList ColorStatusList;       ///< List of colours applied to the status bar
-extern struct ColorLineList ColorIndexList;        ///< List of default colours applied to the index
-extern struct ColorLineList ColorIndexAuthorList;  ///< List of colours applied to the author in the index
-extern struct ColorLineList ColorIndexFlagsList;   ///< List of colours applied to the flags in the index
-extern struct ColorLineList ColorIndexSubjectList; ///< List of colours applied to the subject in the index
-extern struct ColorLineList ColorIndexTagList;     ///< List of colours applied to tags in the index
-
 /* If the system has bkgdset() use it rather than attrset() so that the clr*()
  * functions will properly set the background attributes all the way to the
  * right column.
index 6fd6d71afe1482ad42ad77b0cc6e28b81ecbc437..e4e0ee910bd3d41159c95087ce77362e42b4b9cd 100644 (file)
@@ -37,6 +37,7 @@
 #include <time.h>
 #include "mutt/mutt.h"
 #include "config/lib.h"
+#include "color.h"
 #include "curs_lib.h"
 #include "globals.h"
 #include "mutt_curses.h"
index b4f3e3569b9660c0f45696dabe7a23244f1169fa..9f41eccdbbb516438e82d6bcfcfba17e8f19927c 100644 (file)
@@ -33,6 +33,7 @@
 #include <string.h>
 #include "mutt/mutt.h"
 #include "progress.h"
+#include "color.h"
 #include "curs_lib.h"
 #include "mutt_curses.h"
 #include "mutt_logging.h"
index 32306010077ecb8db165c505db8663c1a1abc880..3bc71617fdecc38d20d35159921ca14f26d6d9e3 100644 (file)
@@ -37,6 +37,7 @@
 #include "address/lib.h"
 #include "email/lib.h"
 #include "mutt.h"
+#include "color.h"
 #include "curs_lib.h"
 #include "filter.h"
 #include "format_flags.h"
index 88d8a33f924783e9be1213d62ef36790de3d2625..8aae4593bd8e0cc4cc48145b7e12f55166c21684 100644 (file)
--- a/sidebar.c
+++ b/sidebar.c
@@ -38,6 +38,7 @@
 #include "config/lib.h"
 #include "core/lib.h"
 #include "sidebar.h"
+#include "color.h"
 #include "context.h"
 #include "curs_lib.h"
 #include "format_flags.h"