NeoMutt  2024-11-14-138-ge5ca67
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
expando_browser.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 "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 char tmp[128] = { 0 };
51
52 if (!folder->ff->nd->desc)
53 return;
54
55 char *desc = mutt_str_dup(folder->ff->nd->desc);
56 const char *const c_newsgroups_charset = cs_subset_string(NeoMutt->sub, "newsgroups_charset");
57 if (c_newsgroups_charset)
58 {
59 mutt_ch_convert_string(&desc, c_newsgroups_charset, cc_charset(), MUTT_ICONV_HOOK_FROM);
60 }
62 mutt_str_copy(tmp, desc, sizeof(tmp));
63 FREE(&desc);
64
65 buf_strcpy(buf, tmp);
66}
67
71static void group_index_flags(const struct ExpandoNode *node, void *data,
72 MuttFormatFlags flags, struct Buffer *buf)
73{
74 const struct Folder *folder = data;
75
76 const char *s = NULL;
77 // NOTE(g0mb4): use $flag_chars?
78 if (folder->ff->nd->deleted)
79 {
80 s = "D";
81 }
82 else
83 {
84 s = folder->ff->nd->allowed ? " " : "-";
85 }
86
87 buf_strcpy(buf, s);
88}
89
93static void group_index_flags2(const struct ExpandoNode *node, void *data,
94 MuttFormatFlags flags, struct Buffer *buf)
95{
96 const struct Folder *folder = data;
97
98 const char *s = NULL;
99 // NOTE(g0mb4): use $flag_chars?
100 if (folder->ff->nd->subscribed)
101 {
102 s = " ";
103 }
104 else
105 {
106 s = folder->ff->has_new_mail ? "N" : "u";
107 }
108
109 buf_strcpy(buf, s);
110}
111
115static void group_index_newsgroup(const struct ExpandoNode *node, void *data,
116 MuttFormatFlags flags, struct Buffer *buf)
117{
118 const struct Folder *folder = data;
119
120 const char *s = folder->ff->name;
121 buf_strcpy(buf, s);
122}
123
127static long group_index_notify_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
128{
129 const struct Folder *folder = data;
130
131 return folder->ff->notify_user;
132}
133
137static long group_index_new_count_num(const struct ExpandoNode *node,
138 void *data, MuttFormatFlags flags)
139{
140 const struct Folder *folder = data;
141 const struct NntpMboxData *nd = folder->ff->nd;
142
143 const bool c_mark_old = cs_subset_bool(NeoMutt->sub, "mark_old");
144
145 if (c_mark_old && (nd->last_cached >= nd->first_message) &&
146 (nd->last_cached <= nd->last_message))
147 {
148 return nd->last_message - nd->last_cached;
149 }
150
151 return nd->unread;
152}
153
157static long group_index_number_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
158{
159 const struct Folder *folder = data;
160
161 return folder->num + 1;
162}
163
167static long group_index_poll_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
168{
169 const struct Folder *folder = data;
170
171 return folder->ff->poll_new_mail;
172}
173
177static long group_index_unread_count_num(const struct ExpandoNode *node,
178 void *data, MuttFormatFlags flags)
179{
180 const struct Folder *folder = data;
181
182 return folder->ff->nd->unread;
183}
184
191 // clang-format off
201 { -1, -1, NULL, NULL },
202 // clang-format on
203};
Select a Mailbox from a list.
@ ED_FOL_POLL
FolderFile.poll_new_mail.
Definition: lib.h:135
@ ED_FOL_NOTIFY
FolderFile.notify_user.
Definition: lib.h:133
@ ED_FOL_NEW_COUNT
FolderFile.nd (NntpMboxData)
Definition: lib.h:131
@ ED_FOL_UNREAD_COUNT
FolderFile.msg_unread.
Definition: lib.h:137
@ ED_FOL_FLAGS2
FolderFile.nd (NntpMboxData)
Definition: lib.h:127
@ ED_FOL_NUMBER
Folder.num.
Definition: lib.h:134
@ ED_FOL_DESCRIPTION
FolderFile.desc, FolderFile.name.
Definition: lib.h:120
@ ED_FOL_NEWSGROUP
FolderFile.name.
Definition: lib.h:130
@ ED_FOL_FLAGS
FolderFile.nd (NntpMboxData)
Definition: lib.h:126
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.
@ 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:423
#define FREE(x)
Definition: memory.h:55
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:65
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
String manipulation buffer.
Definition: buffer.h:36
Basic Expando Node.
Definition: node.h:67
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