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