]> granicus.if.org Git - neomutt/blob - mutt_curses.c
Fix mutt_write_mime_body() application/pgp-encrypted handling
[neomutt] / mutt_curses.c
1 /**
2  * @file
3  * Define wrapper functions around Curses/Slang
4  *
5  * @authors
6  * Copyright (C) 1996-2000,2012 Michael R. Elkins <me@mutt.org>
7  * Copyright (C) 2004 g10 Code GmbH
8  * Copyright (C) 2019 Richard Russon <rich@flatcap.org>
9  *
10  * @copyright
11  * This program is free software: you can redistribute it and/or modify it under
12  * the terms of the GNU General Public License as published by the Free Software
13  * Foundation, either version 2 of the License, or (at your option) any later
14  * version.
15  *
16  * This program is distributed in the hope that it will be useful, but WITHOUT
17  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
19  * details.
20  *
21  * You should have received a copy of the GNU General Public License along with
22  * this program.  If not, see <http://www.gnu.org/licenses/>.
23  */
24
25 #include "config.h"
26 #include "mutt_curses.h"
27 #include "color.h"
28
29 /**
30  * mutt_curses_set_attr - Set the attributes for text
31  * @param attr Attributes to set, e.g. A_UNDERLINE
32  */
33 void mutt_curses_set_attr(int attr)
34 {
35 #ifdef HAVE_BKGDSET
36   bkgdset(attr | ' ');
37 #endif
38 }
39
40 /**
41  * mutt_curses_set_color - Set the current colour for text
42  * @param color Colour to set, e.g. #MT_COLOR_HEADER
43  *
44  * If the system has bkgdset() use it rather than attrset() so that the clr*()
45  * functions will properly set the background attributes all the way to the
46  * right column.
47  */
48 void mutt_curses_set_color(enum ColorId color)
49 {
50 #ifdef HAVE_BKGDSET
51   if (ColorDefs[color] != 0)
52     bkgdset(ColorDefs[color] | ' ');
53   else
54     bkgdset(ColorDefs[MT_COLOR_NORMAL] | ' ');
55 #else
56   if (ColorDefs[color] != 0)
57     attrset(ColorDefs[color]);
58   else
59     attrset(ColorDefs[MT_COLOR_NORMAL]);
60 #endif
61 }
62
63 /**
64  * mutt_curses_set_cursor - Set the cursor state
65  * @param state State to set, e.g. #MUTT_CURSOR_INVISIBLE
66  */
67 void mutt_curses_set_cursor(enum MuttCursorState state)
68 {
69 #if (defined(USE_SLANG_CURSES) || defined(HAVE_CURS_SET))
70   static int SavedCursor = MUTT_CURSOR_VISIBLE;
71
72   if (state == MUTT_CURSOR_RESTORE_LAST)
73     state = SavedCursor;
74   else
75     SavedCursor = state;
76
77   if (curs_set(state) == ERR)
78   {
79     if (state == MUTT_CURSOR_VISIBLE)
80       curs_set(MUTT_CURSOR_VERY_VISIBLE);
81   }
82 #endif
83 }