From 493869843705806e174191a46cbefdadd0763594 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Tue, 26 Feb 2019 23:42:57 +0000 Subject: [PATCH] add typedef for PagerFlags --- curs_lib.c | 5 +++-- curs_lib.h | 3 ++- pager.c | 32 ++++++++++++++++---------------- pager.h | 5 +++-- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/curs_lib.c b/curs_lib.c index 08da92c66..514eef688 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -562,12 +562,13 @@ int mutt_any_key_to_continue(const char *s) * mutt_do_pager - Display some page-able text to the user * @param banner Message for status bar * @param tempfile File to display - * @param do_color Flags, e.g. #MUTT_PAGER_MESSAGE + * @param do_color Flags, see #PagerFlags * @param info Info about current mailbox (OPTIONAL) * @retval 0 Success * @retval -1 Error */ -int mutt_do_pager(const char *banner, const char *tempfile, int do_color, struct Pager *info) +int mutt_do_pager(const char *banner, const char *tempfile, PagerFlags do_color, + struct Pager *info) { int rc; diff --git a/curs_lib.h b/curs_lib.h index b18231be6..de51e9b94 100644 --- a/curs_lib.h +++ b/curs_lib.h @@ -28,6 +28,7 @@ #include #include "mutt.h" #include "browser.h" +#include "pager.h" struct Context; struct Pager; @@ -44,7 +45,7 @@ extern int MuttGetchTimeout; ///< Timeout in ms for mutt_getch() int mutt_addwch(wchar_t wc); int mutt_any_key_to_continue(const char *s); -int mutt_do_pager(const char *banner, const char *tempfile, int do_color, struct Pager *info); +int mutt_do_pager(const char *banner, const char *tempfile, PagerFlags do_color, struct Pager *info); void mutt_edit_file(const char *editor, const char *file); void mutt_endwin(void); int mutt_enter_fname_full(const char *prompt, char *buf, size_t blen, bool mailbox, bool multiple, char ***files, int *numfiles, int flags); diff --git a/pager.c b/pager.c index ca72a5d37..558b2623a 100644 --- a/pager.c +++ b/pager.c @@ -278,12 +278,12 @@ static int comp_syntax_t(const void *m1, const void *m2) * @param line_info Line info array * @param n Line Number (index into line_info) * @param cnt If true, this is a continuation line - * @param flags Flags, e.g. #MUTT_PAGER_LOGS + * @param flags Flags, see #PagerFlags * @param special Flags, e.g. A_BOLD * @param a ANSI attributes */ -static void resolve_color(struct Line *line_info, int n, int cnt, int flags, - int special, struct AnsiAttr *a) +static void resolve_color(struct Line *line_info, int n, int cnt, + PagerFlags flags, int special, struct AnsiAttr *a) { int def_color; /* color without syntax highlight */ int color; /* final color */ @@ -1351,7 +1351,7 @@ static int fill_buffer(FILE *f, LOFF_T *last_pos, LOFF_T offset, unsigned char * * @param[out] line_info Line info * @param[in] n Line number (index into line_info) * @param[in] buf Text to display - * @param[in] flags Flags, e.g. #MUTT_PAGER_NOWRAP + * @param[in] flags Flags, see #PagerFlags * @param[out] pa ANSI attributes used * @param[in] cnt Length of text buffer * @param[out] pspace Index of last whitespace character @@ -1361,9 +1361,9 @@ static int fill_buffer(FILE *f, LOFF_T *last_pos, LOFF_T offset, unsigned char * * @param[in] pager_window Window to write to * @retval num Number of characters displayed */ -static int format_line(struct Line **line_info, int n, unsigned char *buf, int flags, - struct AnsiAttr *pa, int cnt, int *pspace, int *pvch, - int *pcol, int *pspecial, struct MuttWindow *pager_window) +static int format_line(struct Line **line_info, int n, unsigned char *buf, + PagerFlags flags, struct AnsiAttr *pa, int cnt, int *pspace, + int *pvch, int *pcol, int *pspecial, struct MuttWindow *pager_window) { int space = -1; /* index of the last space or TAB */ int col = C_Markers ? (*line_info)[n].continuation : 0; @@ -1542,7 +1542,7 @@ static int format_line(struct Line **line_info, int n, unsigned char *buf, int f * @param[in] n Line number * @param[out] last Last line * @param[out] max Maximum number of lines - * @param[in] flags Flags, e.g. #MUTT_SHOWFLAT + * @param[in] flags Flags, see #PagerFlags * @param[out] quote_list Email quoting style * @param[out] q_level Level of quoting * @param[out] force_redraw Force a repaint @@ -1552,10 +1552,10 @@ static int format_line(struct Line **line_info, int n, unsigned char *buf, int f * @retval 0 normal exit, line was not displayed * @retval >0 normal exit, line was displayed */ -static int display_line(FILE *f, LOFF_T *last_pos, struct Line **line_info, int n, - int *last, int *max, int flags, struct QClass **quote_list, - int *q_level, bool *force_redraw, regex_t *search_re, - struct MuttWindow *pager_window) +static int display_line(FILE *f, LOFF_T *last_pos, struct Line **line_info, + int n, int *last, int *max, PagerFlags flags, + struct QClass **quote_list, int *q_level, bool *force_redraw, + regex_t *search_re, struct MuttWindow *pager_window) { unsigned char *buf = NULL, *fmt = NULL; size_t buflen = 0; @@ -1881,7 +1881,7 @@ void mutt_clear_pager_position(void) */ struct PagerRedrawData { - int flags; + PagerFlags flags; struct Pager *extra; int indexlen; int indicator; /**< the indicator line of the PI */ @@ -1893,7 +1893,7 @@ struct PagerRedrawData int topline; bool force_redraw; int has_types; - int hide_quoted; + PagerFlags hide_quoted; int q_level; struct QClass *quote_list; LOFF_T last_pos; @@ -1905,7 +1905,7 @@ struct PagerRedrawData struct Menu *index; /**< the Pager Index (PI) */ regex_t search_re; bool search_compiled; - int search_flag; + PagerFlags search_flag; bool search_back; const char *banner; char *helpstr; @@ -2226,7 +2226,7 @@ static void pager_custom_redraw(struct Menu *pager_menu) * there so that we can do operations on the current message without the need * to pop back out to the main-menu. */ -int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *extra) +int mutt_pager(const char *banner, const char *fname, PagerFlags flags, struct Pager *extra) { static char searchbuf[256] = ""; char buffer[1024]; diff --git a/pager.h b/pager.h index c85e44891..8d065626a 100644 --- a/pager.h +++ b/pager.h @@ -38,7 +38,8 @@ extern bool C_SmartWrap; extern struct Regex *C_Smileys; extern bool C_Tilde; -/* dynamic internal flags */ +typedef uint16_t PagerFlags; ///< Flags for mutt_pager(), e.g. #MUTT_SHOWFLAT +#define MUTT_PAGER_NO_FLAGS 0 ///< No flags are set #define MUTT_SHOWFLAT (1 << 0) ///< Show characters (used for displaying help) #define MUTT_SHOWCOLOR (1 << 1) ///< Show characters in color otherwise don't show characters #define MUTT_HIDE (1 << 2) ///< Don't show quoted text @@ -69,7 +70,7 @@ struct Pager struct AttachCtx *actx; /**< attachment information */ }; -int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *extra); +int mutt_pager(const char *banner, const char *fname, PagerFlags flags, struct Pager *extra); void mutt_clear_pager_position(void); -- 2.40.0