NeoMutt  2020-11-20
Teaching an old dog new tricks
DOXYGEN
mutt_curses.h File Reference

Define wrapper functions around Curses/Slang. More...

#include "config.h"
#include "color.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_RESTORE_LAST = -1, 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_attr (int attr)
 Set the attributes for text. More...
 
void mutt_curses_set_color (enum ColorId color)
 Set the current colour for text. More...
 
void mutt_curses_set_cursor (enum MuttCursorState state)
 Set the cursor state. More...
 
void mutt_resize_screen (void)
 Update NeoMutt's opinion about the window size (CURSES) More...
 

Detailed Description

Define wrapper functions around Curses/Slang.

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

◆ CI_is_return

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

Definition at line 71 of file mutt_curses.h.

Enumeration Type Documentation

◆ MuttCursorState

Cursor states for mutt_curses_set_cursor()

Enumerator
MUTT_CURSOR_RESTORE_LAST 

Restore the previous cursor state.

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

78 {
83 };
Display a very visible cursor.
Definition: mutt_curses.h:82
Display a normal cursor.
Definition: mutt_curses.h:81
Restore the previous cursor state.
Definition: mutt_curses.h:79
Hide the cursor.
Definition: mutt_curses.h:80

Function Documentation

◆ mutt_curses_set_attr()

void mutt_curses_set_attr ( int  attr)

Set the attributes for text.

Parameters
attrAttributes to set, e.g. A_UNDERLINE

Definition at line 40 of file mutt_curses.c.

41 {
42 #ifdef HAVE_BKGDSET
43  bkgdset(attr | ' ');
44 #else
45  attrset(attr);
46 #endif
47 }
+ Here is the caller graph for this function:

◆ mutt_curses_set_color()

void mutt_curses_set_color ( enum ColorId  color)

Set the current colour for text.

Parameters
colorColour to set, e.g. MT_COLOR_HEADER

If the system has bkgdset() use it rather than attrset() so that the clr*() functions will properly set the background attributes all the way to the right column.

Definition at line 57 of file mutt_curses.c.

58 {
59  if (!Colors)
60  return;
61 #ifdef HAVE_BKGDSET
62  if (Colors->defs[color] != 0)
63  bkgdset(Colors->defs[color] | ' ');
64  else
65  bkgdset(Colors->defs[MT_COLOR_NORMAL] | ' ');
66 #else
67  if (Colors->defs[color] != 0)
68  attrset(Colors->defs[color]);
69  else
70  attrset(Colors->defs[MT_COLOR_NORMAL]);
71 #endif
72 }
int * defs
Array of all fixed colours, see enum ColorId.
Definition: color.h:131
Plain text.
Definition: color.h:77
Definition: color.h:129
+ Here is the caller graph for this function:

◆ mutt_curses_set_cursor()

void mutt_curses_set_cursor ( enum MuttCursorState  state)

Set the cursor state.

Parameters
stateState to set, e.g. MUTT_CURSOR_INVISIBLE

Definition at line 78 of file mutt_curses.c.

79 {
80 #if (defined(USE_SLANG_CURSES) || defined(HAVE_CURS_SET))
81  static int SavedCursor = MUTT_CURSOR_VISIBLE;
82 
83  if (state == MUTT_CURSOR_RESTORE_LAST)
84  state = SavedCursor;
85  else
86  SavedCursor = state;
87 
88  if (curs_set(state) == ERR)
89  {
90  if (state == MUTT_CURSOR_VISIBLE)
91  curs_set(MUTT_CURSOR_VERY_VISIBLE);
92  }
93 #endif
94 }
Display a very visible cursor.
Definition: mutt_curses.h:82
Display a normal cursor.
Definition: mutt_curses.h:81
Restore the previous cursor state.
Definition: mutt_curses.h:79
+ 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 101 of file resize.c.

102 {
103  struct winsize w = mutt_get_winsize();
104 
105  int screenrows = w.ws_row;
106  int screencols = w.ws_col;
107 
108  if (screenrows <= 0)
109  {
110  const char *cp = mutt_str_getenv("LINES");
111  if (cp && (mutt_str_atoi(cp, &screenrows) < 0))
112  screenrows = 24;
113  }
114 
115  if (screencols <= 0)
116  {
117  const char *cp = mutt_str_getenv("COLUMNS");
118  if (cp && (mutt_str_atoi(cp, &screencols) < 0))
119  screencols = 80;
120  }
121 
122  resizeterm(screenrows, screencols);
123  mutt_window_set_root(screencols, screenrows);
124  window_notify_all(NULL);
125 }
int mutt_str_atoi(const char *str, int *dst)
Convert ASCII string to an integer.
Definition: string.c:252
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition: string.c:991
static struct winsize mutt_get_winsize(void)
Use an ioctl to get the window size.
Definition: resize.c:51
void mutt_window_set_root(int cols, int rows)
Set the dimensions of the Root Window.
Definition: mutt_window.c:624
void window_notify_all(struct MuttWindow *win)
Notify observers of changes to a Window and its children.
Definition: mutt_window.c:129
+ Here is the call graph for this function:
+ Here is the caller graph for this function: