NeoMutt  2025-12-11-435-g4ac674
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
expando_browser.c
Go to the documentation of this file.
1
24
30
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 "expando_browser.h"
38#include "browser/lib.h"
39#include "expando/lib.h"
40#include "mdata.h"
41
45static void group_index_description(const struct ExpandoNode *node, void *data,
46 MuttFormatFlags flags, struct Buffer *buf)
47{
48 const struct Folder *folder = data;
49
50 if (!folder->ff->nd->desc)
51 return;
52
53 char *desc = mutt_str_dup(folder->ff->nd->desc);
54 const char *const c_newsgroups_charset = cs_subset_string(NeoMutt->sub, "newsgroups_charset");
55 if (c_newsgroups_charset)
56 {
57 mutt_ch_convert_string(&desc, c_newsgroups_charset, cc_charset(), MUTT_ICONV_HOOK_FROM);
58 }
60 buf_strcpy(buf, desc);
61 FREE(&desc);
62}
63
67static void group_index_flags(const struct ExpandoNode *node, void *data,
68 MuttFormatFlags flags, struct Buffer *buf)
69{
70 const struct Folder *folder = data;
71
72 const char *s = NULL;
73 // NOTE(g0mb4): use $flag_chars?
74 if (folder->ff->nd->deleted)
75 {
76 s = "D";
77 }
78 else
79 {
80 s = folder->ff->nd->allowed ? " " : "-";
81 }
82
83 buf_strcpy(buf, s);
84}
85
89static void group_index_flags2(const struct ExpandoNode *node, void *data,
90 MuttFormatFlags flags, struct Buffer *buf)
91{
92 const struct Folder *folder = data;
93
94 const char *s = NULL;
95 // NOTE(g0mb4): use $flag_chars?
96 if (folder->ff->nd->subscribed)
97 {
98 s = " ";
99 }
100 else
101 {
102 s = folder->ff->has_new_mail ? "N" : "u";
103 }
104
105 buf_strcpy(buf, s);
106}
107
111static void group_index_newsgroup(const struct ExpandoNode *node, void *data,
112 MuttFormatFlags flags, struct Buffer *buf)
113{
114 const struct Folder *folder = data;
115
116 const char *s = folder->ff->name;
117 buf_strcpy(buf, s);
118}
119
123static long group_index_notify_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
124{
125 const struct Folder *folder = data;
126
127 return folder->ff->notify_user;
128}
129
133static long group_index_new_count_num(const struct ExpandoNode *node,
134 void *data, MuttFormatFlags flags)
135{
136 const struct Folder *folder = data;
137 const struct NntpMboxData *nd = folder->ff->nd;
138
139 const bool c_mark_old = cs_subset_bool(NeoMutt->sub, "mark_old");
140
141 if (c_mark_old && (nd->last_cached >= nd->first_message) &&
142 (nd->last_cached <= nd->last_message))
143 {
144 return nd->last_message - nd->last_cached;
145 }
146
147 return nd->unread;
148}
149
153static long group_index_number_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
154{
155 const struct Folder *folder = data;
156
157 return folder->num + 1;
158}
159
163static long group_index_poll_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
164{
165 const struct Folder *folder = data;
166
167 return folder->ff->poll_new_mail;
168}
169
173static long group_index_unread_count_num(const struct ExpandoNode *node,
174 void *data, MuttFormatFlags flags)
175{
176 const struct Folder *folder = data;
177
178 return folder->ff->nd->unread;
179}
180
Select a Mailbox from a list.
@ ED_FOL_POLL
FolderFile.poll_new_mail.
Definition lib.h:136
@ ED_FOL_NOTIFY
FolderFile.notify_user.
Definition lib.h:134
@ ED_FOL_NEW_COUNT
FolderFile.nd (NntpMboxData)
Definition lib.h:132
@ ED_FOL_UNREAD_COUNT
FolderFile.msg_unread.
Definition lib.h:138
@ ED_FOL_FLAGS2
FolderFile.nd (NntpMboxData)
Definition lib.h:128
@ ED_FOL_NUMBER
Folder.num.
Definition lib.h:135
@ ED_FOL_DESCRIPTION
FolderFile.desc, FolderFile.name.
Definition lib.h:121
@ ED_FOL_NEWSGROUP
FolderFile.name.
Definition lib.h:131
@ ED_FOL_FLAGS
FolderFile.nd (NntpMboxData)
Definition lib.h:127
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.
Convenience wrapper for the core headers.
@ ED_FOLDER
Folder ED_FOL_ ExpandoDataFolder.
Definition domain.h:43
Parse Expando string.
const struct ExpandoRenderCallback GroupIndexRenderCallbacks[]
Callbacks for Nntp Browser Expandos.
NNTP Expando definitions.
static long group_index_notify_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
NNTP: Alert for new mail - Implements get_number_t -.
static long group_index_new_count_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
NNTP: Number of new articles - Implements get_number_t -.
static long group_index_poll_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
NNTP: Poll for new mail - Implements get_number_t -.
static long group_index_unread_count_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
NNTP: Number of unread articles - Implements get_number_t -.
static long group_index_number_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
NNTP: Index number - Implements get_number_t -.
static void group_index_description(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
NNTP: Description - Implements get_string_t -.
static void group_index_flags2(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
NNTP: New flag - Implements get_string_t -.
static void group_index_newsgroup(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
NNTP: Newsgroup name - Implements get_string_t -.
static void group_index_flags(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
NNTP: Moderated flag - Implements get_string_t -.
int mutt_mb_filter_unprintable(char **s)
Replace unprintable characters.
Definition mbyte.c:424
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
int mutt_ch_convert_string(char **ps, const char *from, const char *to, uint8_t flags)
Convert a string between encodings.
Definition charset.c:817
#define MUTT_ICONV_HOOK_FROM
apply charset-hooks to fromcode
Definition charset.h:67
Convenience wrapper for the library headers.
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition string.c:257
Nntp-specific Mailbox data.
uint8_t MuttFormatFlags
Flags for expando_render(), e.g. MUTT_FORMAT_FORCESUBJ.
Definition render.h:32
String manipulation buffer.
Definition buffer.h:36
Basic Expando Node.
Definition node.h:67
char * name
Name of file/dir/mailbox.
Definition lib.h:87
bool has_new_mail
true if mailbox has "new mail"
Definition lib.h:90
bool poll_new_mail
Check mailbox for new mail.
Definition lib.h:102
bool notify_user
User will be notified of new mail.
Definition lib.h:101
struct NntpMboxData * nd
Extra NNTP data.
Definition lib.h:104
A folder/dir in the browser.
Definition lib.h:70
int num
Number in the index.
Definition lib.h:72
struct FolderFile * ff
File / Dir / Mailbox.
Definition lib.h:71
Container for Accounts, Notifications.
Definition neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49
NNTP-specific Mailbox data -.
Definition mdata.h:34
anum_t last_cached
Last cached article.
Definition mdata.h:40
bool deleted
Newsgroup is deleted.
Definition mdata.h:45
bool allowed
Posting allowed.
Definition mdata.h:44
anum_t last_message
Last article number.
Definition mdata.h:38
char * desc
Description of newsgroup.
Definition mdata.h:36
anum_t unread
Unread articles.
Definition mdata.h:41
anum_t first_message
First article number.
Definition mdata.h:37
bool subscribed
Subscribed to this newsgroup.
Definition mdata.h:42