NeoMutt  2022-04-29-247-gc6aae8
Teaching an old dog new tricks
DOXYGEN
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 CI_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 (struct AttrColor *ac)
 Set the colour and attributes for text. 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...
 
struct AttrColormutt_curses_set_normal_backed_color_by_id (enum ColorId cid)
 Set the colour and attributes by the colour id. More...
 
void mutt_resize_screen (void)
 Update NeoMutt's opinion about the window size (CURSES) More...
 

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 40 of file mutt_curses.h.

◆ CI_is_return

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

Definition at line 45 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 51 of file mutt_curses.h.

52{
56};
@ MUTT_CURSOR_INVISIBLE
Hide the cursor.
Definition: mutt_curses.h:53
@ MUTT_CURSOR_VISIBLE
Display a normal cursor.
Definition: mutt_curses.h:54
@ MUTT_CURSOR_VERY_VISIBLE
Display a very visible cursor.
Definition: mutt_curses.h:55

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_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
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:54
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_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:52
+ 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 * merged_color_overlay(struct AttrColor *base, 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 (CURSES)

Definition at line 73 of file resize.c.

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