NeoMutt  2024-10-02-7-gd3e66a
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
mutt_curses.c
Go to the documentation of this file.
1
29#include "config.h"
30#include <stddef.h>
31#include "mutt_curses.h"
32#include "color/lib.h"
33
38void mutt_curses_set_color(const struct AttrColor *ac)
39{
40 if (!ac)
41 return;
42
43 int index = ac->curses_color ? ac->curses_color->index : 0;
44
45#if defined(HAVE_SETCCHAR) && defined(HAVE_BKGRNDSET)
46 cchar_t cch = { 0 };
47 setcchar(&cch, L" ", ac->attrs, index, NULL);
48 bkgrndset(&cch);
49#elif defined(HAVE_BKGDSET)
50 bkgdset(COLOR_PAIR(index) | ac->attrs | ' ');
51#else
52 attrset(COLOR_PAIR(index) | ac->attrs);
53#endif
54}
55
64{
65 const struct AttrColor *ac_normal = simple_color_get(MT_COLOR_NORMAL);
66 const struct AttrColor *ac_color = simple_color_get(cid);
67
68 const struct AttrColor *ac_merge = merged_color_overlay(ac_normal, ac_color);
69
70 mutt_curses_set_color(ac_merge);
71 return ac_merge;
72}
73
80{
81 struct AttrColor *ac = simple_color_get(cid);
82 if (!attr_color_is_set(ac))
84
86 return ac;
87}
88
95{
96 static enum MuttCursorState SavedCursor = MUTT_CURSOR_VISIBLE;
97
98 enum MuttCursorState OldCursor = SavedCursor;
99 SavedCursor = state;
100
101 if (curs_set(state) == ERR)
102 {
103 if (state == MUTT_CURSOR_VISIBLE)
104 curs_set(MUTT_CURSOR_VERY_VISIBLE);
105 }
106
107 return OldCursor;
108}
bool attr_color_is_set(const struct AttrColor *ac)
Is the object coloured?
Definition: attr.c:179
Color and attribute parsing.
struct AttrColor * simple_color_get(enum ColorId cid)
Get the colour of an object by its ID.
Definition: simple.c:88
ColorId
List of all colored objects.
Definition: color.h:40
@ MT_COLOR_NORMAL
Plain text.
Definition: color.h:59
const struct AttrColor * merged_color_overlay(const struct AttrColor *base, const struct AttrColor *over)
Combine two colours.
Definition: merged.c:107
const struct AttrColor * mutt_curses_set_normal_backed_color_by_id(enum ColorId cid)
Set the colour and attributes by the colour id.
Definition: mutt_curses.c:63
enum MuttCursorState mutt_curses_set_cursor(enum MuttCursorState state)
Set the cursor state.
Definition: mutt_curses.c:94
const struct AttrColor * mutt_curses_set_color_by_id(enum ColorId cid)
Set the colour and attributes by the colour id.
Definition: mutt_curses.c:79
void mutt_curses_set_color(const struct AttrColor *ac)
Set the colour and attributes for text.
Definition: mutt_curses.c:38
Define wrapper functions around Curses.
MuttCursorState
Cursor states for mutt_curses_set_cursor()
Definition: mutt_curses.h:64
@ MUTT_CURSOR_VISIBLE
Display a normal cursor.
Definition: mutt_curses.h:66
@ MUTT_CURSOR_VERY_VISIBLE
Display a very visible cursor.
Definition: mutt_curses.h:67
A curses colour and its attributes.
Definition: attr.h:66
int attrs
Text attributes, e.g. A_BOLD.
Definition: attr.h:69
struct CursesColor * curses_color
Underlying Curses colour.
Definition: attr.h:70
short index
Index number.
Definition: curses2.h:44