Coverage Report

Created: 2025-04-22 06:17

/src/neomutt/index/config.c
Line
Count
Source
1
/**
2
 * @file
3
 * Config used by libindex
4
 *
5
 * @authors
6
 * Copyright (C) 2021 Richard Russon <rich@flatcap.org>
7
 *
8
 * @copyright
9
 * This program is free software: you can redistribute it and/or modify it under
10
 * the terms of the GNU General Public License as published by the Free Software
11
 * Foundation, either version 2 of the License, or (at your option) any later
12
 * version.
13
 *
14
 * This program is distributed in the hope that it will be useful, but WITHOUT
15
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
17
 * details.
18
 *
19
 * You should have received a copy of the GNU General Public License along with
20
 * this program.  If not, see <http://www.gnu.org/licenses/>.
21
 */
22
23
/**
24
 * @page index_config Config used by the Index
25
 *
26
 * Config used by libindex
27
 */
28
29
#include "config.h"
30
#include <stdbool.h>
31
#include <stddef.h>
32
#include "mutt/lib.h"
33
#include "config/lib.h"
34
#include "expando/lib.h"
35
#include "menu/lib.h"
36
#include "shared_data.h"
37
38
/**
39
 * StatusFormatDef - Expando definitions
40
 *
41
 * Config:
42
 * - $new_mail_command
43
 * - $status_format
44
 * - $ts_icon_format
45
 * - $ts_status_format
46
 */
47
const struct ExpandoDefinition StatusFormatDef[] = {
48
  // clang-format off
49
  { "*", "padding-soft",     ED_GLOBAL, ED_GLO_PADDING_SOFT,       node_padding_parse },
50
  { ">", "padding-hard",     ED_GLOBAL, ED_GLO_PADDING_HARD,       node_padding_parse },
51
  { "|", "padding-eol",      ED_GLOBAL, ED_GLO_PADDING_EOL,        node_padding_parse },
52
  { "b", "unread-mailboxes", ED_INDEX,  ED_IND_UNREAD_MAILBOXES,   NULL },
53
  { "d", "deleted-count",    ED_INDEX,  ED_IND_DELETED_COUNT,      NULL },
54
  { "D", "description",      ED_INDEX,  ED_IND_DESCRIPTION,        NULL },
55
  { "f", "mailbox-path",     ED_INDEX,  ED_IND_MAILBOX_PATH,       NULL },
56
  { "F", "flagged-count",    ED_INDEX,  ED_IND_FLAGGED_COUNT,      NULL },
57
  { "h", "hostname",         ED_GLOBAL, ED_GLO_HOSTNAME,           NULL },
58
  { "l", "mailbox-size",     ED_INDEX,  ED_IND_MAILBOX_SIZE,       NULL },
59
  { "L", "limit-size",       ED_INDEX,  ED_IND_LIMIT_SIZE,         NULL },
60
  { "m", "message-count",    ED_INDEX,  ED_IND_MESSAGE_COUNT,      NULL },
61
  { "M", "limit-count",      ED_INDEX,  ED_IND_LIMIT_COUNT,        NULL },
62
  { "n", "new-count",        ED_INDEX,  ED_IND_NEW_COUNT,          NULL },
63
  { "o", "old-count",        ED_INDEX,  ED_IND_OLD_COUNT,          NULL },
64
  { "p", "postponed-count",  ED_INDEX,  ED_IND_POSTPONED_COUNT,    NULL },
65
  { "P", "percentage",       ED_MENU,   ED_MEN_PERCENTAGE,         NULL },
66
  { "r", "readonly",         ED_INDEX,  ED_IND_READONLY,           NULL },
67
  { "R", "read-count",       ED_INDEX,  ED_IND_READ_COUNT,         NULL },
68
  { "s", "sort",             ED_GLOBAL, ED_GLO_CONFIG_SORT,        NULL },
69
  { "S", "sort-aux",         ED_GLOBAL, ED_GLO_CONFIG_SORT_AUX,    NULL },
70
  { "t", "tagged-count",     ED_INDEX,  ED_IND_TAGGED_COUNT,       NULL },
71
  { "T", "use-threads",      ED_GLOBAL, ED_GLO_CONFIG_USE_THREADS, NULL },
72
  { "u", "unread-count",     ED_INDEX,  ED_IND_UNREAD_COUNT,       NULL },
73
  { "v", "version",          ED_GLOBAL, ED_GLO_VERSION,            NULL },
74
  { "V", "limit-pattern",    ED_INDEX,  ED_IND_LIMIT_PATTERN,      NULL },
75
  { NULL, NULL, 0, -1, NULL }
76
  // clang-format on
77
};
78
79
/**
80
 * IndexVars - Config definitions for the Index
81
 */
82
static struct ConfigDef IndexVars[] = {
83
  // clang-format off
84
  { "change_folder_next", DT_BOOL, false, 0, NULL,
85
    "Suggest the next folder, rather than the first when using '<change-folder>'"
86
  },
87
  { "collapse_all", DT_BOOL, false, 0, NULL,
88
    "Collapse all threads when entering a folder"
89
  },
90
  { "mark_macro_prefix", DT_STRING, IP "'", 0, NULL,
91
    "Prefix for macros using '<mark-message>'"
92
  },
93
  // L10N: $status_format default format
94
  { "status_format", DT_EXPANDO|D_L10N_STRING, IP N_("-%r-NeoMutt: %D [Msgs:%<M?%M/>%m%<n? New:%n>%<o? Old:%o>%<d? Del:%d>%<F? Flag:%F>%<t? Tag:%t>%<p? Post:%p>%<b? Inc:%b>%<l? %l>]---(%<T?%T/>%s/%S)-%>-(%P)---"), IP &StatusFormatDef, NULL,
95
    "printf-like format string for the index's status line"
96
  },
97
  { "uncollapse_jump", DT_BOOL, false, 0, NULL,
98
    "When opening a thread, jump to the next unread message"
99
  },
100
  { "uncollapse_new", DT_BOOL, true, 0, NULL,
101
    "Open collapsed threads when new mail arrives"
102
  },
103
  { NULL },
104
  // clang-format on
105
};
106
107
/**
108
 * config_init_index - Register index config variables - Implements ::module_init_config_t - @ingroup cfg_module_api
109
 */
110
bool config_init_index(struct ConfigSet *cs)
111
9.62k
{
112
9.62k
  return cs_register_variables(cs, IndexVars);
113
9.62k
}