NeoMutt  2024-11-14-34-g5aaf0d
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
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 (const struct AttrColor *ac)
 Set the colour and attributes for text.
 
const struct AttrColormutt_curses_set_normal_backed_color_by_id (enum ColorId cid)
 Set the colour and attributes by the colour id.
 
const struct AttrColormutt_curses_set_color_by_id (enum ColorId cid)
 Set the colour and attributes by the colour id.
 
enum MuttCursorState mutt_curses_set_cursor (enum MuttCursorState state)
 Set the cursor state.
 

Detailed Description

Define wrapper functions around Curses.

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 mutt_curses.c.

Function Documentation

◆ mutt_curses_set_color()

void mutt_curses_set_color ( const struct AttrColor ac)

Set the colour and attributes for text.

Parameters
acColour and Attributes to set

Definition at line 38 of file mutt_curses.c.

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

◆ mutt_curses_set_normal_backed_color_by_id()

const 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 63 of file mutt_curses.c.

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}
struct AttrColor * simple_color_get(enum ColorId cid)
Get the colour of an object by its ID.
Definition: simple.c:88
@ 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
void mutt_curses_set_color(const struct AttrColor *ac)
Set the colour and attributes for text.
Definition: mutt_curses.c:38
A curses colour and its attributes.
Definition: attr.h:66
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_curses_set_color_by_id()

const 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 79 of file mutt_curses.c.

80{
81 struct AttrColor *ac = simple_color_get(cid);
82 if (!attr_color_is_set(ac))
84
86 return ac;
87}
bool attr_color_is_set(const struct AttrColor *ac)
Is the object coloured?
Definition: attr.c:179
+ 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 94 of file mutt_curses.c.

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