NeoMutt  2023-05-17-33-gce4425
Teaching an old dog new tricks
DOXYGEN
mutt_curses.c File Reference

Define wrapper functions around Curses. More...

#include "config.h"
#include <stddef.h>
#include "mutt_curses.h"
#include "color/lib.h"
+ Include dependency graph for mutt_curses.c:

Go to the source code of this file.

Functions

void mutt_curses_set_color (struct AttrColor *ac)
 Set the colour and attributes for text. More...
 
struct AttrColormutt_curses_set_normal_backed_color_by_id (enum ColorId cid)
 Set the colour and attributes by the colour id. More...
 
struct AttrColormutt_curses_set_color_by_id (enum ColorId cid)
 Set the colour and attributes by the colour id. More...
 
enum MuttCursorState mutt_curses_set_cursor (enum MuttCursorState state)
 Set the cursor state. More...
 

Detailed Description

Define wrapper functions around Curses.

Authors
  • Michael R. Elkins
  • g10 Code GmbH
  • 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 mutt_curses.c.

Function Documentation

◆ mutt_curses_set_color()

void mutt_curses_set_color ( struct AttrColor ac)

Set the colour and attributes for text.

Parameters
acColour and Attributes to set

Definition at line 40 of file mutt_curses.c.

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}
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
+ Here is the caller graph for this function:

◆ mutt_curses_set_normal_backed_color_by_id()

struct AttrColor * mutt_curses_set_normal_backed_color_by_id ( enum ColorId  cid)

Set the colour and attributes by the colour id.

Parameters
cidColour Id, e.g. MT_COLOR_WARNING
Return values
ptrColour set
Note
Colour will be merged over MT_COLOR_NORMAL

Definition at line 65 of file mutt_curses.c.

66{
67 struct AttrColor *ac_normal = simple_color_get(MT_COLOR_NORMAL);
68 struct AttrColor *ac_color = simple_color_get(cid);
69
70 struct AttrColor *ac_merge = merged_color_overlay(ac_normal, ac_color);
71
72 mutt_curses_set_color(ac_merge);
73 return ac_merge;
74}
struct AttrColor * simple_color_get(enum ColorId cid)
Get the colour of an object by its ID.
Definition: simple.c:74
@ MT_COLOR_NORMAL
Plain text.
Definition: color.h:57
struct AttrColor * merged_color_overlay(struct AttrColor *base, struct AttrColor *over)
Combine two colours.
Definition: merged.c:109
void mutt_curses_set_color(struct AttrColor *ac)
Set the colour and attributes for text.
Definition: mutt_curses.c:40
A curses colour and its attributes.
Definition: attr.h:35
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_curses_set_color_by_id()

struct AttrColor * mutt_curses_set_color_by_id ( enum ColorId  cid)

Set the colour and attributes by the colour id.

Parameters
cidColour Id, e.g. MT_COLOR_TREE
Return values
ptrColour set

Definition at line 81 of file mutt_curses.c.

82{
83 struct AttrColor *ac = simple_color_get(cid);
84 if (!attr_color_is_set(ac))
86
88 return ac;
89}
bool attr_color_is_set(struct AttrColor *ac)
Is the object coloured?
Definition: attr.c:160
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_curses_set_cursor()

enum MuttCursorState mutt_curses_set_cursor ( enum MuttCursorState  state)

Set the cursor state.

Parameters
stateState to set, e.g. MUTT_CURSOR_INVISIBLE
Return values
enumOld state, e.g. MUTT_CURSOR_VISIBLE

Definition at line 96 of file mutt_curses.c.

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}
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
+ Here is the caller graph for this function: