NeoMutt  2024-11-14-34-g5aaf0d
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 A_ITALIC   0
 
#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
  • 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.h.

Macro Definition Documentation

◆ A_ITALIC

#define A_ITALIC   0

Definition at line 49 of file mutt_curses.h.

◆ ctrl

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

Definition at line 52 of file mutt_curses.h.

◆ key_is_return

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

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

64{
68};
@ MUTT_CURSOR_INVISIBLE
Hide the cursor.
Definition: mutt_curses.h:65
@ 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

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_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
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
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_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
+ 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}
const struct AttrColor * merged_color_overlay(const struct AttrColor *base, const struct AttrColor *over)
Combine two colours.
Definition: merged.c:107
+ 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 76 of file resize.c.

77{
78 struct winsize w = mutt_get_winsize();
79
80 int screenrows = w.ws_row;
81 int screencols = w.ws_col;
82
83 if (screenrows <= 0)
84 {
85 const char *cp = mutt_str_getenv("LINES");
86 if (cp && !mutt_str_atoi_full(cp, &screenrows))
87 screenrows = 24;
88 }
89
90 if (screencols <= 0)
91 {
92 const char *cp = mutt_str_getenv("COLUMNS");
93 if (cp && !mutt_str_atoi_full(cp, &screencols))
94 screencols = 80;
95 }
96
97 resizeterm(screenrows, screencols);
98 rootwin_set_size(screencols, screenrows);
100}
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition: string.c:726
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:56
void rootwin_set_size(int cols, int rows)
Set the dimensions of the Root Window.
Definition: rootwin.c:253
+ Here is the call graph for this function:
+ Here is the caller graph for this function: