NeoMutt
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
mutt_curses.h File Reference

Define wrapper functions around Curses. More...

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

Go to the source code of this file.

Macros

#define ctrl(ch)   ((ch) - '@')
 
#define key_is_return(ch)   (((ch) == '\r') || ((ch) == '\n'))
 

Enumerations

enum  MuttCursorState { MUTT_CURSOR_INVISIBLE = 0 , MUTT_CURSOR_VISIBLE = 1 , MUTT_CURSOR_VERY_VISIBLE = 2 }
 Cursor states for mutt_curses_set_cursor() More...
 

Functions

void mutt_curses_set_color (const struct AttrColor *ac)
 Set the colour and attributes for text.
 
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.
 
const struct AttrColormutt_curses_set_normal_backed_color_by_id (enum ColorId cid)
 Set the colour and attributes by the colour id.
 
void mutt_resize_screen (void)
 Update NeoMutt's opinion about the window size.
 

Detailed Description

Define wrapper functions around Curses.

Authors
  • Michael R. Elkins
  • g10 Code GmbH

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.h.

Macro Definition Documentation

◆ ctrl

#define ctrl (   ch)    ((ch) - '@')

Definition at line 46 of file mutt_curses.h.

◆ key_is_return

#define key_is_return (   ch)    (((ch) == '\r') || ((ch) == '\n'))

Definition at line 51 of file mutt_curses.h.

Enumeration Type Documentation

◆ MuttCursorState

Cursor states for mutt_curses_set_cursor()

Enumerator
MUTT_CURSOR_INVISIBLE 

Hide the cursor.

MUTT_CURSOR_VISIBLE 

Display a normal cursor.

MUTT_CURSOR_VERY_VISIBLE 

Display a very visible cursor.

Definition at line 57 of file mutt_curses.h.

58{
62};
@ MUTT_CURSOR_INVISIBLE
Hide the cursor.
Definition: mutt_curses.h:59
@ 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

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 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_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 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(const struct AttrColor *ac)
Is the object coloured?
Definition: attr.c:160
struct AttrColor * simple_color_get(enum ColorId cid)
Get the colour of an object by its ID.
Definition: simple.c:81
@ MT_COLOR_NORMAL
Plain text.
Definition: color.h:57
void mutt_curses_set_color(const 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_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
+ 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 65 of file mutt_curses.c.

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}
const struct AttrColor * merged_color_overlay(const struct AttrColor *base, const struct AttrColor *over)
Combine two colours.
Definition: merged.c:109
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_resize_screen()

void mutt_resize_screen ( void  )

Update NeoMutt's opinion about the window size.

Definition at line 74 of file resize.c.

75{
76 struct winsize w = mutt_get_winsize();
77
78 int screenrows = w.ws_row;
79 int screencols = w.ws_col;
80
81 if (screenrows <= 0)
82 {
83 const char *cp = mutt_str_getenv("LINES");
84 if (cp && !mutt_str_atoi_full(cp, &screenrows))
85 screenrows = 24;
86 }
87
88 if (screencols <= 0)
89 {
90 const char *cp = mutt_str_getenv("COLUMNS");
91 if (cp && !mutt_str_atoi_full(cp, &screencols))
92 screencols = 80;
93 }
94
95 resizeterm(screenrows, screencols);
96 rootwin_set_size(screencols, screenrows);
98}
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition: string.c:918
void window_notify_all(struct MuttWindow *win)
Notify observers of changes to a Window and its children.
Definition: mutt_window.c:145
static struct winsize mutt_get_winsize(void)
Get the window size.
Definition: resize.c:54
void rootwin_set_size(int cols, int rows)
Set the dimensions of the Root Window.
Definition: rootwin.c:251
+ Here is the call graph for this function:
+ Here is the caller graph for this function: