NeoMutt  2024-04-25-89-g194907
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
browse.c
Go to the documentation of this file.
1
31#include "config.h"
32#include <stdbool.h>
33#include <stdio.h>
34#include "mutt/lib.h"
35#include "config/lib.h"
36#include "core/lib.h"
37#include "lib.h"
38#include "browser/lib.h"
39#include "expando/lib.h"
40#include "mdata.h"
41
45long group_index_a_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
46{
47 const struct Folder *folder = data;
48
49 return folder->ff->notify_user;
50}
51
55long group_index_C_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
56{
57 const struct Folder *folder = data;
58
59 return folder->num + 1;
60}
61
65void group_index_d(const struct ExpandoNode *node, void *data,
66 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
67{
68 const struct Folder *folder = data;
69
70 char tmp[128] = { 0 };
71
72 if (!folder->ff->nd->desc)
73 return;
74
75 char *desc = mutt_str_dup(folder->ff->nd->desc);
76 const char *const c_newsgroups_charset = cs_subset_string(NeoMutt->sub, "newsgroups_charset");
77 if (c_newsgroups_charset)
78 {
79 mutt_ch_convert_string(&desc, c_newsgroups_charset, cc_charset(), MUTT_ICONV_HOOK_FROM);
80 }
82 mutt_str_copy(tmp, desc, sizeof(tmp));
83 FREE(&desc);
84
85 buf_strcpy(buf, tmp);
86}
87
91void group_index_f(const struct ExpandoNode *node, void *data,
92 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
93{
94 const struct Folder *folder = data;
95
96 const char *s = folder->ff->name;
97 buf_strcpy(buf, s);
98}
99
103void group_index_M(const struct ExpandoNode *node, void *data,
104 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
105{
106 const struct Folder *folder = data;
107
108 const char *s = NULL;
109 // NOTE(g0mb4): use $flag_chars?
110 if (folder->ff->nd->deleted)
111 {
112 s = "D";
113 }
114 else
115 {
116 s = folder->ff->nd->allowed ? " " : "-";
117 }
118
119 buf_strcpy(buf, s);
120}
121
125long group_index_n_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
126{
127 const struct Folder *folder = data;
128 const struct NntpMboxData *nd = folder->ff->nd;
129
130 const bool c_mark_old = cs_subset_bool(NeoMutt->sub, "mark_old");
131
132 if (c_mark_old && (nd->last_cached >= nd->first_message) &&
133 (nd->last_cached <= nd->last_message))
134 {
135 return nd->last_message - nd->last_cached;
136 }
137
138 return nd->unread;
139}
140
144void group_index_N(const struct ExpandoNode *node, void *data,
145 MuttFormatFlags flags, int max_cols, struct Buffer *buf)
146{
147 const struct Folder *folder = data;
148
149 const char *s = NULL;
150 // NOTE(g0mb4): use $flag_chars?
151 if (folder->ff->nd->subscribed)
152 {
153 s = " ";
154 }
155 else
156 {
157 s = folder->ff->has_new_mail ? "N" : "u";
158 }
159
160 buf_strcpy(buf, s);
161}
162
166long group_index_p_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
167{
168 const struct Folder *folder = data;
169
170 return folder->ff->poll_new_mail;
171}
172
176long group_index_s_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
177{
178 const struct Folder *folder = data;
179
180 // NOTE(g0mb4): is long required for unread?
181 return folder->ff->nd->unread;
182}
Select a Mailbox from a list.
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:395
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:291
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:47
Convenience wrapper for the config headers.
const char * cc_charset(void)
Get the cached value of $charset.
Definition: config_cache.c:116
Convenience wrapper for the core headers.
Parse Expando string.
long group_index_a_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
NNTP: Alert for new mail - Implements ExpandoRenderData::get_number() -.
Definition: browse.c:45
long group_index_p_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
NNTP: Poll for new mail - Implements ExpandoRenderData::get_number() -.
Definition: browse.c:166
long group_index_s_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
NNTP: Number of unread articles - Implements ExpandoRenderData::get_number() -.
Definition: browse.c:176
long group_index_C_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
NNTP: Index number - Implements ExpandoRenderData::get_number() -.
Definition: browse.c:55
long group_index_n_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
NNTP: Number of new articles - Implements ExpandoRenderData::get_number() -.
Definition: browse.c:125
void group_index_M(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
NNTP: Moderated flag - Implements ExpandoRenderData::get_string() -.
Definition: browse.c:103
void group_index_d(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
NNTP: Description - Implements ExpandoRenderData::get_string() -.
Definition: browse.c:65
void group_index_f(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
NNTP: Newsgroup name - Implements ExpandoRenderData::get_string() -.
Definition: browse.c:91
void group_index_N(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
NNTP: New flag - Implements ExpandoRenderData::get_string() -.
Definition: browse.c:144
int mutt_mb_filter_unprintable(char **s)
Replace unprintable characters.
Definition: mbyte.c:423
#define FREE(x)
Definition: memory.h:45
int mutt_ch_convert_string(char **ps, const char *from, const char *to, uint8_t flags)
Convert a string between encodings.
Definition: charset.c:831
#define MUTT_ICONV_HOOK_FROM
apply charset-hooks to fromcode
Definition: charset.h:74
Convenience wrapper for the library headers.
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:253
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:581
Notmuch-specific Mailbox data.
uint8_t MuttFormatFlags
Flags for expando_render(), e.g. MUTT_FORMAT_FORCESUBJ.
Definition: render.h:32
Key value store.
String manipulation buffer.
Definition: buffer.h:36
Basic Expando Node.
Definition: node.h:69
char * name
Name of file/dir/mailbox.
Definition: lib.h:86
bool has_new_mail
true if mailbox has "new mail"
Definition: lib.h:89
bool poll_new_mail
Check mailbox for new mail.
Definition: lib.h:101
bool notify_user
User will be notified of new mail.
Definition: lib.h:100
struct NntpMboxData * nd
Extra NNTP data.
Definition: lib.h:103
A folder/dir in the browser.
Definition: lib.h:69
int num
Number in the index.
Definition: lib.h:71
struct FolderFile * ff
File / Dir / Mailbox.
Definition: lib.h:70
Container for Accounts, Notifications.
Definition: neomutt.h:42
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:46
NNTP-specific Mailbox data -.
Definition: mdata.h:34
anum_t last_cached
Definition: mdata.h:40
bool deleted
Definition: mdata.h:45
bool allowed
Definition: mdata.h:44
anum_t last_message
Definition: mdata.h:38
char * desc
Description of newsgroup.
Definition: mdata.h:36
anum_t unread
Definition: mdata.h:41
anum_t first_message
Definition: mdata.h:37
bool subscribed
Definition: mdata.h:42