312 for (
size_t i = 0; he_list[i]; i++)
392 buf_printf(err,
_(
"Command '%s' can only be used with bool/quad variables"),
"toggle");
473 static const char *set_commands[] = {
"set",
"toggle",
"unset",
"reset" };
504 else if (*s->
dptr ==
'&')
513 buf_printf(err,
_(
"Can't use 'inv', 'no', '&' or '?' with the '%s' command"),
524 bool bool_or_quad =
false;
525 bool invertible =
false;
527 bool increment =
false;
528 bool decrement =
false;
543 buf_printf(err,
_(
"Can't use a prefix when querying a variable"));
547 if (reset || unset || inv)
549 buf_printf(err,
_(
"Can't query option with the '%s' command"), set_commands[
data]);
556 else if ((*s->
dptr ==
'+') || (*s->
dptr ==
'-'))
560 buf_printf(err,
_(
"Can't use prefix when incrementing or decrementing a variable"));
564 if (reset || unset || inv)
566 buf_printf(err,
_(
"Can't set option with the '%s' command"), set_commands[
data]);
582 buf_printf(err,
_(
"'+' and '-' must be followed by '='"));
586 else if (*s->
dptr ==
'=')
590 buf_printf(err,
_(
"Can't use prefix when setting a variable"));
594 if (reset || unset || inv)
596 buf_printf(err,
_(
"Can't set option with the '%s' command"), set_commands[
data]);
604 if (!invertible && (inv || (unset && prefix)))
608 buf_printf(err,
_(
"Prefixes 'no' and 'inv' may only be used with bool/quad/number variables"));
612 buf_printf(err,
_(
"Command '%s' can only be used with bool/quad/number variables"),
622 ASSERT(!inv || !( unset || reset || query || equals ));
623 ASSERT(!unset || !(inv || reset || query || equals ));
624 ASSERT(!reset || !(inv || unset || query || equals ));
625 ASSERT(!query || !(inv || unset || reset || equals ));
626 ASSERT(!equals || !(inv || unset || reset || query || prefix));
628 ASSERT(!(increment && decrement));
629 ASSERT(!(increment || decrement) || equals);
630 ASSERT(!inv || invertible);
int bool_he_toggle(struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Toggle the value of a bool.
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
size_t buf_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
size_t buf_copy(struct Buffer *dst, const struct Buffer *src)
Copy a Buffer's contents to another Buffer.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
CommandResult
Error codes for command_t parse functions.
@ MUTT_CMD_SUCCESS
Success: Command worked.
@ MUTT_CMD_ERROR
Error: Can't help the user.
@ MUTT_CMD_WARNING
Warning: Help given to the user.
enum CommandResult set_dump(ConfigDumpFlags flags, struct Buffer *err)
Dump list of config variables into a file/pager.
Functions to parse commands in a config file.
size_t pretty_var(const char *str, struct Buffer *buf)
Escape and stringify a config item value.
void mutt_pretty_mailbox(char *buf, size_t buflen)
Shorten a mailbox path using '~' or '='.
#define CS_DUMP_ONLY_CHANGED
Only show config that the user has changed.
#define CS_DUMP_NO_FLAGS
No flags are set.
Convenience wrapper for the config headers.
char * HomeDir
User's home directory.
struct HashElem * cs_create_variable(const struct ConfigSet *cs, struct ConfigDef *cdef, struct Buffer *err)
Create and register one config item.
#define CSR_ERR_CODE
Problem with the code.
bool StartupComplete
When the config has been read.
#define CSR_SUCCESS
Action completed successfully.
Convenience wrapper for the core headers.
enum CommandResult parse_set(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'set' family of commands - Implements Command::parse() -.
#define mutt_warning(...)
Convenience wrapper for the library headers.
bool mutt_path_tilde(struct Buffer *path, const char *homedir)
Expand '~' in a path.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
Many unsorted constants and some structs.
void buf_expand_path(struct Buffer *buf)
Create the canonical path.
Some miscellaneous functions.
int number_he_toggle(struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Toggle the value of a number (value <-> 0)
static enum CommandResult command_set_toggle(struct Buffer *name, struct Buffer *err)
Toggle a boolean, quad, or number variable.
static enum CommandResult command_set_set(struct Buffer *name, struct Buffer *value, struct Buffer *err)
Set a variable to the given value.
static enum CommandResult command_set_reset(struct Buffer *name, struct Buffer *err)
Reset a variable.
static enum CommandResult command_set_unset(struct Buffer *name, struct Buffer *err)
Unset a variable.
static enum CommandResult command_set_query(struct Buffer *name, struct Buffer *err)
Query a variable.
static enum CommandResult command_set_increment(struct Buffer *name, struct Buffer *value, struct Buffer *err)
Increment a variable by a value.
static void command_set_expand_value(uint32_t type, struct Buffer *value)
Expand special characters.
static enum CommandResult command_set_decrement(struct Buffer *name, struct Buffer *value, struct Buffer *err)
Decrement a variable by a value.
@ MUTT_SET_INV
default is to invert all vars
@ MUTT_SET_SET
default is to set all vars
@ MUTT_SET_RESET
default is to reset all vars to default
@ MUTT_SET_UNSET
default is to unset all vars
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
int quad_he_toggle(struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Toggle the value of a quad.
String manipulation buffer.
char * dptr
Current read/write position.
size_t dsize
Length of data.
char * data
Pointer to data.
const char * name
User-visible name.
uint32_t type
Variable type, e.g. DT_STRING.
struct ConfigSet * cs
Parent ConfigSet.
The item stored in a Hash Table.
union HashKey key
Key representing the data.
int type
Type of data stored in Hash Table, e.g. DT_STRING.
void * data
User-supplied data.
Container for Accounts, Notifications.
struct ConfigSubset * sub
Inherited config items.
int cs_subset_he_string_minus_equals(const struct ConfigSubset *sub, struct HashElem *he, const char *value, struct Buffer *err)
Remove from a config item by string.
int cs_subset_he_string_get(const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *result)
Get a config item as a string.
int cs_subset_he_native_set(const struct ConfigSubset *sub, struct HashElem *he, intptr_t value, struct Buffer *err)
Natively set the value of a HashElem config item.
int cs_subset_he_delete(const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Delete config item from a config.
struct HashElem ** get_elem_list(struct ConfigSet *cs)
Create a sorted list of all config items.
int cs_subset_he_reset(const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Reset a config item to its initial value.
int cs_subset_he_string_set(const struct ConfigSubset *sub, struct HashElem *he, const char *value, struct Buffer *err)
Set a config item by string.
int cs_subset_he_string_plus_equals(const struct ConfigSubset *sub, struct HashElem *he, const char *value, struct Buffer *err)
Add to a config item by string.
struct HashElem * cs_subset_lookup(const struct ConfigSubset *sub, const char *name)
Find an inherited config item.
#define IS_MAILBOX(flags)
#define D_INTERNAL_DEPRECATED
Config item shouldn't be used any more.
#define D_PATH_DIR
Path is a directory.
#define D_PATH_FILE
Path is a file.
@ DT_QUAD
quad-option (no/yes/ask-no/ask-yes)
@ DT_MYVAR
a user-defined variable (my_foo)
@ DT_PATH
a path to a file/directory
#define IS_COMMAND(flags)
const char * strkey
String key.