From 3b57602a867647a6e6ae41baf1c336131cd17a86 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Tue, 26 Feb 2019 23:35:15 +0000 Subject: [PATCH] add typedef for CompletionFlags --- config/set.h | 2 +- curs_lib.c | 10 +++++----- curs_lib.h | 4 ++-- enter.c | 11 ++++++----- mutt.h | 3 ++- protos.h | 7 ++++--- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/config/set.h b/config/set.h index 357d2c5b0..f0f413d80 100644 --- a/config/set.h +++ b/config/set.h @@ -162,7 +162,7 @@ struct ConfigDef { const char *name; /**< User-visible name */ unsigned int type; /**< Variable type, e.g. #DT_STRING */ - intptr_t flags; /**< Notification flags, e.g. #R_PAGER */ + intptr_t flags; /**< Notification flags, see #ConfigRedrawFlags */ void *var; /**< Pointer to the global variable */ intptr_t initial; /**< Initial value */ cs_validator validator; /**< Validator callback function */ diff --git a/curs_lib.c b/curs_lib.c index df8e6ba6a..08da92c66 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -240,7 +240,7 @@ struct Event mutt_getch(void) * @param[in] field Prompt * @param[in] buf Buffer for the result * @param[in] buflen Length of buffer - * @param[in] complete Flags for completion, e.g. #MUTT_FILE + * @param[in] complete Flags, see #CompletionFlags * @param[in] multiple Allow multiple selections * @param[out] files List of files selected * @param[out] numfiles Number of files selected @@ -248,8 +248,8 @@ struct Event mutt_getch(void) * @retval 0 Selection made * @retval -1 Aborted */ -int mutt_get_field_full(const char *field, char *buf, size_t buflen, - int complete, bool multiple, char ***files, int *numfiles) +int mutt_get_field_full(const char *field, char *buf, size_t buflen, CompletionFlags complete, + bool multiple, char ***files, int *numfiles) { int ret; int x; @@ -284,12 +284,12 @@ int mutt_get_field_full(const char *field, char *buf, size_t buflen, * @param msg Prompt * @param buf Buffer for the result * @param buflen Length of buffer - * @param flags Flags for completion, e.g. #MUTT_FILE + * @param flags Flags, see #CompletionFlags * @retval 1 Redraw the screen and call the function again * @retval 0 Selection made * @retval -1 Aborted */ -int mutt_get_field_unbuffered(const char *msg, char *buf, size_t buflen, int flags) +int mutt_get_field_unbuffered(const char *msg, char *buf, size_t buflen, CompletionFlags flags) { int rc; diff --git a/curs_lib.h b/curs_lib.h index ec9d720ad..b18231be6 100644 --- a/curs_lib.h +++ b/curs_lib.h @@ -55,8 +55,8 @@ void mutt_format_s(char *buf, size_t buflen, const char *prec, const cha void mutt_format_s_tree(char *buf, size_t buflen, const char *prec, const char *s); void mutt_getch_timeout(int delay); struct Event mutt_getch(void); -int mutt_get_field_full(const char *field, char *buf, size_t buflen, int complete, bool multiple, char ***files, int *numfiles); -int mutt_get_field_unbuffered(const char *msg, char *buf, size_t buflen, int flags); +int mutt_get_field_full(const char *field, char *buf, size_t buflen, CompletionFlags complete, bool multiple, char ***files, int *numfiles); +int mutt_get_field_unbuffered(const char *msg, char *buf, size_t buflen, CompletionFlags flags); int mutt_multi_choice(const char *prompt, const char *letters); void mutt_need_hard_redraw(void); void mutt_paddstr(int n, const char *s); diff --git a/enter.c b/enter.c index b784c8441..9f9c5d5d9 100644 --- a/enter.c +++ b/enter.c @@ -133,7 +133,7 @@ struct EnterState *mutt_enter_state_new(void) * @param buf Buffer to store the string * @param buflen Buffer length * @param col Initial cursor position - * @param flags Flags such as MUTT_FILE + * @param flags Flags, see #CompletionFlags * @retval 0 if input was given * @retval -1 if abort * @@ -142,7 +142,7 @@ struct EnterState *mutt_enter_state_new(void) * well, because there is no active menu for the built-in editor. * Most callers should prefer mutt_get_field() instead. */ -int mutt_enter_string(char *buf, size_t buflen, int col, int flags) +int mutt_enter_string(char *buf, size_t buflen, int col, CompletionFlags flags) { int rc; struct EnterState *es = mutt_enter_state_new(); @@ -165,7 +165,7 @@ int mutt_enter_string(char *buf, size_t buflen, int col, int flags) * @param[in] buf Buffer to store the string * @param[in] buflen Buffer length * @param[in] col Initial cursor position - * @param[in] flags Flags such as MUTT_FILE + * @param[in] flags Flags, see #CompletionFlags * @param[in] multiple Allow multiple matches * @param[out] files List of files selected * @param[out] numfiles Number of files selected @@ -174,8 +174,9 @@ int mutt_enter_string(char *buf, size_t buflen, int col, int flags) * @retval 0 Selection made * @retval -1 Aborted */ -int mutt_enter_string_full(char *buf, size_t buflen, int col, int flags, bool multiple, - char ***files, int *numfiles, struct EnterState *state) +int mutt_enter_string_full(char *buf, size_t buflen, int col, + CompletionFlags flags, bool multiple, char ***files, + int *numfiles, struct EnterState *state) { int width = MuttMessageWindow->cols - col - 1; int redraw; diff --git a/mutt.h b/mutt.h index bcd090c9b..e5fffe8b9 100644 --- a/mutt.h +++ b/mutt.h @@ -55,7 +55,8 @@ struct Mapping; #define fgetc fgetc_unlocked #endif -/* flags for mutt_enter_string_full() */ +typedef uint16_t CompletionFlags; ///< Flags for mutt_enter_string_full(), e.g. #MUTT_ALIAS +#define MUTT_COMP_NO_FLAGS 0 ///< No flags are set #define MUTT_ALIAS (1 << 0) ///< Do alias "completion" by calling up the alias-menu #define MUTT_FILE (1 << 1) ///< Do file completion #define MUTT_EFILE (1 << 2) ///< Do file completion, plus incoming folders diff --git a/protos.h b/protos.h index 2c24248c6..461fb8b3d 100644 --- a/protos.h +++ b/protos.h @@ -29,6 +29,7 @@ #include #include #include "config/lib.h" +#include "mutt.h" struct Context; struct EnterState; @@ -70,9 +71,9 @@ int mutt_change_flag(struct Mailbox *m, struct EmailList *el, int bf); int mutt_complete(char *buf, size_t buflen); int mutt_prepare_template(FILE *fp, struct Mailbox *m, struct Email *newhdr, struct Email *e, bool resend); -int mutt_enter_string(char *buf, size_t buflen, int col, int flags); -int mutt_enter_string_full(char *buf, size_t buflen, int col, int flags, bool multiple, - char ***files, int *numfiles, struct EnterState *state); +int mutt_enter_string(char *buf, size_t buflen, int col, CompletionFlags flags); +int mutt_enter_string_full(char *buf, size_t buflen, int col, CompletionFlags flags, bool multiple, + char ***files, int *numfiles, struct EnterState *state); int mutt_get_postponed(struct Context *ctx, struct Email *e, struct Email **cur, char *fcc, size_t fcclen); int mutt_parse_crypt_hdr(const char *p, int set_empty_signas, int crypt_app); int mutt_num_postponed(struct Mailbox *m, bool force); -- 2.40.0