Encapsulate a curses function to reduce dependencies.
void mutt_query_exit(void)
{
mutt_flushinp();
- curs_set(1);
+ mutt_curses_set_cursor(MUTT_CURSOR_VISIBLE);
if (C_Timeout)
mutt_getch_timeout(-1); /* restore blocking operation */
if (mutt_yesorno(_("Exit NeoMutt?"), MUTT_YES) == MUTT_YES)
mutt_exit(1);
}
mutt_clear_error();
- mutt_curs_set(-1);
+ mutt_curses_set_cursor(MUTT_CURSOR_RESTORE_LAST);
SigInt = 0;
}
flushinp();
}
-#if (defined(USE_SLANG_CURSES) || defined(HAVE_CURS_SET))
-/**
- * mutt_curs_set - Set the cursor position
- * @param cursor
- * * -1: restore the value of the last call
- * * 0: make the cursor invisible
- * * 1: make the cursor visible
- */
-void mutt_curs_set(int cursor)
-{
- static int SavedCursor = 1;
-
- if (cursor < 0)
- cursor = SavedCursor;
- else
- SavedCursor = cursor;
-
- if (curs_set(cursor) == ERR)
- {
- if (cursor == 1) /* cnorm */
- curs_set(2); /* cvvis */
- }
-}
-#endif
-
/**
* mutt_multi_choice - Offer the user a multiple choice question
* @param prompt Message prompt
}
if (op >= 0)
- mutt_curs_set(0);
+ mutt_curses_set_cursor(MUTT_CURSOR_INVISIBLE);
if (menu->type == MENU_MAIN)
{
continue;
}
- mutt_curs_set(1);
+ mutt_curses_set_cursor(MUTT_CURSOR_VISIBLE);
/* special handling for the tag-prefix function */
if ((op == OP_TAG_PREFIX) || (op == OP_TAG_PREFIX_COND))
else
menu->oldcurrent = -1;
- mutt_curs_set(1); /* fallback from the pager */
+ mutt_curses_set_cursor(MUTT_CURSOR_VISIBLE); /* fallback from the pager */
}
#ifdef USE_NNTP
if (menu->tagprefix && (i != OP_TAG_PREFIX) && (i != OP_TAG_PREFIX_COND) && (i != -2))
menu->tagprefix = false;
- mutt_curs_set(0);
+ mutt_curses_set_cursor(MUTT_CURSOR_INVISIBLE);
if (menu_redraw(menu) == OP_REDRAW)
return OP_REDRAW;
else if (menu->tagged && C_AutoTag)
menu->tagprefix = true;
- mutt_curs_set(1);
+ mutt_curses_set_cursor(MUTT_CURSOR_VISIBLE);
if (SigWinch)
{
attrset(ColorDefs[MT_COLOR_NORMAL]);
#endif
}
+
+/**
+ * mutt_curses_set_cursor - Set the cursor state
+ * @param state State to set, e.g. #MUTT_CURSOR_INVISIBLE
+ */
+void mutt_curses_set_cursor(enum MuttCursorState state)
+{
+#if (defined(USE_SLANG_CURSES) || defined(HAVE_CURS_SET))
+ static int SavedCursor = MUTT_CURSOR_VISIBLE;
+
+ if (state == MUTT_CURSOR_RESTORE_LAST)
+ state = SavedCursor;
+ else
+ SavedCursor = state;
+
+ if (curs_set(state) == ERR)
+ {
+ if (state == MUTT_CURSOR_VISIBLE)
+ curs_set(MUTT_CURSOR_VERY_VISIBLE);
+ }
+#endif
+}
beep(); \
} while (false)
-#if !(defined(USE_SLANG_CURSES) || defined(HAVE_CURS_SET))
-#define curs_set(x)
-#endif
-
-#if (defined(USE_SLANG_CURSES) || defined(HAVE_CURS_SET))
-void mutt_curs_set(int cursor);
-#else
-#define mutt_curs_set(x)
-#endif
-
#define ctrl(ch) ((ch) - '@')
#ifdef KEY_ENTER
#define CI_is_return(ch) (((ch) == '\r') || ((ch) == '\n'))
#endif
+/**
+ * enum MuttCursorState - Cursor states for mutt_curses_set_cursor()
+ */
+enum MuttCursorState
+{
+ MUTT_CURSOR_RESTORE_LAST = -1, ///< Restore the previous cursor state
+ MUTT_CURSOR_INVISIBLE = 0, ///< Hide the cursor
+ MUTT_CURSOR_VISIBLE = 1, ///< Display a normal cursor
+ MUTT_CURSOR_VERY_VISIBLE = 2, ///< Display a very visible cursor
+};
+
void mutt_curses_set_attr(int attr);
void mutt_curses_set_color(enum ColorId color);
+void mutt_curses_set_cursor(enum MuttCursorState state);
void mutt_resize_screen(void);
#endif /* MUTT_MUTT_CURSES_H */
if (!C_Suspend)
break;
IsEndwin = isendwin();
- curs_set(1);
+ mutt_curses_set_cursor(MUTT_CURSOR_VISIBLE);
if (!IsEndwin)
endwin();
kill(0, SIGSTOP);
case SIGCONT:
if (!IsEndwin)
refresh();
- mutt_curs_set(-1);
+ mutt_curses_set_cursor(MUTT_CURSOR_RESTORE_LAST);
/* We don't receive SIGWINCH when suspended; however, no harm is done by
* just assuming we received one, and triggering the 'resize' anyway. */
SigWinch = 1;
*/
static void curses_exit_handler(int sig)
{
- curs_set(1);
+ mutt_curses_set_cursor(MUTT_CURSOR_VISIBLE);
endwin(); /* just to be safe */
mutt_unlink_temp_attachments();
mutt_sig_exit_handler(sig); /* DOES NOT RETURN */
*/
static void curses_segv_handler(int sig)
{
- curs_set(1);
+ mutt_curses_set_cursor(MUTT_CURSOR_VISIBLE);
endwin(); /* just to be safe */
#ifdef HAVE_LIBUNWIND
show_backtrace();
while (ch != -1)
{
- mutt_curs_set(0);
+ mutt_curses_set_cursor(MUTT_CURSOR_INVISIBLE);
pager_custom_redraw(pager_menu);
{
mutt_clear_error();
}
- mutt_curs_set(1);
+ mutt_curses_set_cursor(MUTT_CURSOR_VISIBLE);
bool do_new_mail = false;