NeoMutt  2024-12-12-14-g7b49f7
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
quoted.h File Reference

Quoted-Email colours. More...

#include "config.h"
#include <stdbool.h>
#include "core/lib.h"
#include "attr.h"
#include "color.h"
+ Include dependency graph for quoted.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define COLOR_QUOTES_MAX   10
 Ten colours, quoted0..quoted9 (quoted and quoted0 are equivalent)
 
#define COLOR_QUOTED(cid)   ((cid) == MT_COLOR_QUOTED)
 

Functions

void quoted_colors_init (void)
 Initialise the Quoted colours.
 
void quoted_colors_reset (void)
 Reset the quoted-email colours.
 
void quoted_colors_cleanup (void)
 Cleanup the quoted-email colours.
 
struct AttrColorquoted_colors_get (int q)
 Return the color of a quote, cycling through the used quotes.
 
int quoted_colors_num_used (void)
 Return the number of used quotes.
 
bool quoted_colors_parse_color (enum ColorId cid, struct AttrColor *ac_val, int q_level, int *rc, struct Buffer *err)
 Parse the 'color quoted' command.
 
enum CommandResult quoted_colors_parse_uncolor (enum ColorId cid, int q_level, struct Buffer *err)
 Parse the 'uncolor quoted' command.
 

Variables

struct AttrColor QuotedColors []
 Array of colours for quoted email text.
 

Detailed Description

Quoted-Email colours.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file quoted.h.

Macro Definition Documentation

◆ COLOR_QUOTES_MAX

#define COLOR_QUOTES_MAX   10

Ten colours, quoted0..quoted9 (quoted and quoted0 are equivalent)

Definition at line 35 of file quoted.h.

◆ COLOR_QUOTED

#define COLOR_QUOTED (   cid)    ((cid) == MT_COLOR_QUOTED)

Definition at line 39 of file quoted.h.

Function Documentation

◆ quoted_colors_init()

void quoted_colors_init ( void  )

Initialise the Quoted colours.

Definition at line 49 of file quoted.c.

50{
51 for (size_t i = 0; i < COLOR_QUOTES_MAX; i++)
52 {
53 struct AttrColor *ac = &QuotedColors[i];
56 }
58}
#define COLOR_DEFAULT
Definition: color.h:96
static int NumQuotedColors
Number of colours for quoted email text.
Definition: quoted.c:44
struct AttrColor QuotedColors[COLOR_QUOTES_MAX]
Array of colours for quoted email text.
Definition: quoted.c:43
#define COLOR_QUOTES_MAX
Ten colours, quoted0..quoted9 (quoted and quoted0 are equivalent)
Definition: quoted.h:35
A curses colour and its attributes.
Definition: attr.h:66
struct ColorElement bg
Background colour.
Definition: attr.h:68
struct ColorElement fg
Foreground colour.
Definition: attr.h:67
color_t color
Colour.
Definition: attr.h:57
+ Here is the caller graph for this function:

◆ quoted_colors_reset()

void quoted_colors_reset ( void  )

Reset the quoted-email colours.

Definition at line 63 of file quoted.c.

64{
65 color_debug(LL_DEBUG5, "QuotedColors: reset\n");
66 for (size_t i = 0; i < COLOR_QUOTES_MAX; i++)
67 {
69 }
71}
void attr_color_clear(struct AttrColor *ac)
Free the contents of an AttrColor.
Definition: attr.c:48
static int color_debug(enum LogLevel level, const char *format,...)
Definition: debug.h:52
@ LL_DEBUG5
Log at debug level 5.
Definition: logging2.h:47
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ quoted_colors_cleanup()

void quoted_colors_cleanup ( void  )

Cleanup the quoted-email colours.

Definition at line 76 of file quoted.c.

77{
79}
void quoted_colors_reset(void)
Reset the quoted-email colours.
Definition: quoted.c:63
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ quoted_colors_get()

struct AttrColor * quoted_colors_get ( int  q)

Return the color of a quote, cycling through the used quotes.

Parameters
qQuote level
Return values
enumColorId, e.g. MT_COLOR_QUOTED

Definition at line 86 of file quoted.c.

87{
88 if (NumQuotedColors == 0)
89 return NULL;
90 return &QuotedColors[q % NumQuotedColors];
91}
+ Here is the caller graph for this function:

◆ quoted_colors_num_used()

int quoted_colors_num_used ( void  )

Return the number of used quotes.

Return values
numNumber of used quotes

Definition at line 97 of file quoted.c.

98{
99 return NumQuotedColors;
100}
+ Here is the caller graph for this function:

◆ quoted_colors_parse_color()

bool quoted_colors_parse_color ( enum ColorId  cid,
struct AttrColor ac_val,
int  q_level,
int *  rc,
struct Buffer err 
)

Parse the 'color quoted' command.

Parameters
cidColour Id, should be MT_COLOR_QUOTED
ac_valColour value to use
q_levelQuoting depth level
rcReturn code, e.g. MUTT_CMD_SUCCESS
errBuffer for error messages
Return values
trueColour was parsed

Definition at line 125 of file quoted.c.

127{
128 if (!COLOR_QUOTED(cid))
129 return false;
130
131 color_debug(LL_DEBUG5, "quoted %d\n", q_level);
132 if (q_level >= COLOR_QUOTES_MAX)
133 {
134 buf_printf(err, _("Maximum quoting level is %d"), COLOR_QUOTES_MAX - 1);
135 return false;
136 }
137
138 if (q_level >= NumQuotedColors)
139 NumQuotedColors = q_level + 1;
140
141 struct AttrColor *ac = &QuotedColors[q_level];
142
143 attr_color_overwrite(ac, ac_val);
144
145 struct CursesColor *cc = ac->curses_color;
146 if (!cc)
148
149 struct Buffer *buf = buf_pool_get();
150 get_colorid_name(cid, buf);
151 color_debug(LL_DEBUG5, "NT_COLOR_SET: %s\n", buf->data);
152 buf_pool_release(&buf);
153
154 if (q_level == 0)
155 {
156 // Copy the colour into the SimpleColors
157 struct AttrColor *ac_quoted = simple_color_get(MT_COLOR_QUOTED);
158 curses_color_free(&ac_quoted->curses_color);
159 *ac_quoted = *ac;
160 ac_quoted->ref_count = 1;
161 if (ac_quoted->curses_color)
162 {
163 ac_quoted->curses_color->ref_count++;
164 curses_color_dump(cc, "curses rc++");
165 }
166 }
167
168 struct EventColor ev_c = { cid, ac };
170
172
173 *rc = MUTT_CMD_SUCCESS;
174 return true;
175}
void attr_color_overwrite(struct AttrColor *ac_old, struct AttrColor *ac_new)
Update an AttrColor in-place.
Definition: attr.c:395
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:161
void get_colorid_name(unsigned int cid, struct Buffer *buf)
Get the name of a color id.
Definition: command.c:128
struct Notify * ColorsNotify
Notifications: ColorId, EventColor.
Definition: notify.c:36
struct AttrColor * simple_color_get(enum ColorId cid)
Get the colour of an object by its ID.
Definition: simple.c:95
@ MT_COLOR_QUOTED
Pager: quoted text.
Definition: color.h:59
@ MUTT_CMD_SUCCESS
Success: Command worked.
Definition: command.h:39
void curses_color_free(struct CursesColor **ptr)
Free a CursesColor.
Definition: curses.c:120
void curses_color_dump(struct CursesColor *cc, const char *prefix)
Log one Curses colour.
Definition: debug.c:122
void curses_colors_dump(struct Buffer *buf)
Dump all the Curses colours.
Definition: debug.c:144
#define _(a)
Definition: message.h:28
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition: notify.c:173
@ NT_COLOR_SET
Color has been set.
Definition: notify2.h:43
@ NT_COLOR
Colour has changed, NotifyColor, EventColor.
Definition: notify_type.h:41
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:82
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:96
static int find_highest_used(void)
Find the highest-numbered quotedN in use.
Definition: quoted.c:106
#define COLOR_QUOTED(cid)
Definition: quoted.h:39
short ref_count
Number of users.
Definition: attr.h:71
struct CursesColor * curses_color
Underlying Curses colour.
Definition: attr.h:70
String manipulation buffer.
Definition: buffer.h:36
char * data
Pointer to data.
Definition: buffer.h:37
Colour in the ncurses palette.
Definition: curses2.h:41
short ref_count
Number of users.
Definition: curses2.h:45
An Event that happened to a Colour.
Definition: notify2.h:55
enum ColorId cid
Colour ID that has changed.
Definition: notify2.h:56
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ quoted_colors_parse_uncolor()

enum CommandResult quoted_colors_parse_uncolor ( enum ColorId  cid,
int  q_level,
struct Buffer err 
)

Parse the 'uncolor quoted' command.

Parameters
cidColour Id, should be MT_COLOR_QUOTED
q_levelQuoting depth level
errBuffer for error messages
Return values
enumCommandResult, e.g. MUTT_CMD_SUCCESS

Definition at line 184 of file quoted.c.

186{
187 color_debug(LL_DEBUG5, "unquoted %d\n", q_level);
188
189 struct AttrColor *ac = &QuotedColors[q_level];
191
193
194 struct EventColor ev_c = { cid, ac };
196
197 return MUTT_CMD_SUCCESS;
198}
@ NT_COLOR_RESET
Color has been reset/removed.
Definition: notify2.h:44
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ QuotedColors

struct AttrColor QuotedColors[]
extern

Array of colours for quoted email text.

Definition at line 43 of file quoted.c.