NeoMutt  2025-12-11-911-gd8d604
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
73static void group_index_flags(const struct ExpandoNode *node, void *data,
74 MuttFormatFlags flags, struct Buffer *buf)
75{
76 const struct Folder *folder = data;
77
78 const char *s = NULL;
79 // NOTE(g0mb4): use $flag_chars?
80
81 /* Tagged status has priority */
82 if (folder->ff->tagged)
83 {
84 s = "*";
85 }
86 else if (folder->ff->nd->deleted)
87 {
88 s = "D";
89 }
90 else
91 {
92 s = folder->ff->nd->allowed ? " " : "-";
93 }
94
95 buf_strcpy(buf, s);
96}
97
101static void group_index_flags2(const struct ExpandoNode *node, void *data,
102 MuttFormatFlags flags, struct Buffer *buf)
103{
104 const struct Folder *folder = data;
105
106 const char *s = NULL;
107 // NOTE(g0mb4): use $flag_chars?
108 if (folder->ff->nd->subscribed)
109 {
110 s = " ";
111 }
112 else
113 {
114 s = folder->ff->has_new_mail ? "N" : "u";
115 }
116
117 buf_strcpy(buf, s);
118}
119
123static void group_index_newsgroup(const struct ExpandoNode *node, void *data,
124 MuttFormatFlags flags, struct Buffer *buf)
125{
126 const struct Folder *folder = data;
127
128 const char *s = folder->ff->name;
129 buf_strcpy(buf, s);
130}
131
135static long group_index_notify_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
136{
137 const struct Folder *folder = data;
138
139 return folder->ff->notify_user;
140}
141
145static long group_index_new_count_num(const struct ExpandoNode *node,
146 void *data, MuttFormatFlags flags)
147{
148 const struct Folder *folder = data;
149 const struct NntpMboxData *nd = folder->ff->nd;
150
151 const bool c_mark_old = cs_subset_bool(NeoMutt->sub, "mark_old");
152
153 if (c_mark_old && (nd->last_cached >= nd->first_message) &&
154 (nd->last_cached <= nd->last_message))
155 {
156 return nd->last_message - nd->last_cached;
157 }
158
159 return nd->unread;
160}
161
165static long group_index_number_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
166{
167 const struct Folder *folder = data;
168
169 return folder->num + 1;
170}
171
175static long group_index_poll_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
176{
177 const struct Folder *folder = data;
178
179 return folder->ff->poll_new_mail;
180}
181
185static long group_index_unread_count_num(const struct ExpandoNode *node,
186 void *data, MuttFormatFlags flags)
187{
188 const struct Folder *folder = data;
189
190 return folder->ff->nd->unread;
191}
192
Select a Mailbox from a list.
@ ED_FOL_POLL
FolderFile.poll_new_mail.
Definition lib.h:139
@ ED_FOL_NOTIFY
FolderFile.notify_user.
Definition lib.h:137
@ ED_FOL_NEW_COUNT
FolderFile.nd (NntpMboxData)
Definition lib.h:135
@ ED_FOL_UNREAD_COUNT
FolderFile.msg_unread.
Definition lib.h:141
@ ED_FOL_FLAGS2
FolderFile.nd (NntpMboxData)
Definition lib.h:131
@ ED_FOL_NUMBER
Folder.num.
Definition lib.h:138
@ ED_FOL_DESCRIPTION
FolderFile.desc, FolderFile.name.
Definition lib.h:124
@ ED_FOL_NEWSGROUP
FolderFile.name.
Definition lib.h:134
@ ED_FOL_FLAGS
FolderFile.nd (NntpMboxData)
Definition lib.h:130
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
Definition render.h:45
String manipulation buffer.
Definition buffer.h:36
Basic Expando Node.
Definition node.h:67
char * name
Name of file/dir/mailbox.
Definition lib.h:90
bool tagged
Folder is tagged.
Definition lib.h:106
bool has_new_mail
true if mailbox has "new mail"
Definition lib.h:93
bool poll_new_mail
Check mailbox for new mail.
Definition lib.h:105
bool notify_user
User will be notified of new mail.
Definition lib.h:104
struct NntpMboxData * nd
Extra NNTP data.
Definition lib.h:107
A folder/dir in the browser.
Definition lib.h:73
int num
Number in the index.
Definition lib.h:75
struct FolderFile * ff
File / Dir / Mailbox.
Definition lib.h:74
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