167 fputs(
"\033[?1049h", stdout);
169 keypad(stdscr,
true);
170 clearok(stdscr,
true);
266 while (
ch == KEY_RESIZE)
294 if ((
ch & 0x80) && c_meta_key)
299 return (
struct KeyEvent){ .ch =
'\033' , .op = OP_NULL };
325 keypad(stdscr,
true);
326 clearok(stdscr,
true);
376 char *p = strerror(errno);
379 mutt_error(
"%s: %s (errno = %d)", s, p ? p :
_(
"unknown error"), errno);
393 int fd = open(
"/dev/tty", O_RDONLY);
400 term.c_lflag &= ~(ICANON | ECHO);
402 term.c_cc[VTIME] = 255;
403 tcsetattr(fd, TCSANOW, &term);
408 fputs(
_(
"Press any key to continue..."), stdout);
413 while (read(fd, &ch, 1) == 0)
418 term.c_cc[VTIME] = 0;
419 tcsetattr(fd, TCSANOW, &term);
421 char buf[64] = { 0 };
422 while (read(fd, buf,
sizeof(buf)) > 0)
425 tcsetattr(fd, TCSANOW, &old);
428 fputs(
"\r\n", stdout);
430 return (ch >= 0) ? ch : EOF;
447 struct Mailbox *m,
bool multiple,
char ***files,
482 else if (ch.
ch ==
'?')
498 sprintf(pc,
"%s: ", prompt);
499 if (ch.
op == OP_NULL)
506 multiple, m, files, numfiles) != 0)
609 char buf[MB_LEN_MAX * 2];
610 mbstate_t mbstate = { 0 };
642 const char *s,
size_t n,
bool arboreal)
647 char scratch[MB_LEN_MAX] = { 0 };
648 mbstate_t mbstate1 = { 0 };
649 mbstate_t mbstate2 = { 0 };
650 bool escaped =
false;
654 for (; n && (k = mbrtowc(&wc, s, n, &mbstate1)); s += k, n -= k)
659 memset(&mbstate1, 0,
sizeof(mbstate1));
693 size_t k2 = wcrtomb(scratch, wc, &mbstate2);
699 strncpy(p, scratch, k2);
704 w = ((int) buflen < min_width) ? buflen : min_width;
720 int half = (w + 1) / 2;
735 buf[half] = pad_char;
759void mutt_format_s_x(
char *buf,
size_t buflen,
const char *prec,
const char *s,
bool arboreal)
764 int max_width = INT_MAX;
771 else if (*prec ==
'=')
776 min_width = strtol(prec, &p, 10);
780 max_width = strtol(prec, &p, 10);
796void mutt_format_s(
char *buf,
size_t buflen,
const char *prec,
const char *s)
824 mbstate_t mbstate = { 0 };
826 for (; len && (k = mbrtowc(&wc, s, len, &mbstate)); s += k, len -= k)
831 memset(&mbstate, 0,
sizeof(mbstate));
837 const int w = wcwidth(wc);
864 size_t n, w = 0, l = 0, cl;
866 mbstate_t mbstate = { 0 };
873 for (w = 0; n && (cl = mbrtowc(&wc, src, n, &mbstate)); src += cl, n -= cl)
878 memset(&mbstate, 0,
sizeof(mbstate));
890 else if ((cw < 0) && (cl == 1) && (src[0] !=
'\0') && (src[0] <
MUTT_TREE_MAX))
898 if ((cl + l > maxlen) || (cw + w > maxwid))
935 mbstate_t mbstate = { 0 };
937 for (w = 0; n && (k = mbrtowc(&wc, s, n, &mbstate)); s += k, n -= k)
949 memset(&mbstate, 0,
sizeof(mbstate));
#define ARRAY_SHRINK(head, num)
Mark a number of slots at the end of the array as unused.
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
#define ARRAY_LAST(head)
Convenience method to get the last element.
#define ARRAY_EMPTY(head)
Check if an array is empty.
#define ARRAY_SIZE(head)
The number of elements stored.
#define ARRAY_HEAD_INITIALIZER
Static initializer for arrays.
Select a Mailbox from a list.
#define MUTT_SEL_MAILBOX
Select a mailbox.
#define MUTT_SEL_FOLDER
Select a local directory.
#define MUTT_SEL_MULTI
Multi-selection is enabled.
#define MUTT_SEL_NO_FLAGS
No flags are set.
uint8_t SelectFileFlags
Flags for mutt_select_file(), e.g. MUTT_SEL_MAILBOX.
void buf_select_file(struct Buffer *file, SelectFileFlags flags, struct Mailbox *m, char ***files, int *numfiles)
Let the user select a file.
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
void buf_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Color and attribute parsing.
@ MT_COLOR_NORMAL
Plain text.
@ MT_COLOR_PROMPT
Question/user input.
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
void mutt_edit_file(const char *editor, const char *file)
Let the user edit a file.
size_t mutt_strnwidth(const char *s, size_t n)
Measure a string's width in screen cells.
static struct KeyEventArray MacroEvents
These are used for macros and exec/push commands.
struct KeyEvent mutt_getch_timeout(int delay)
Get an event with a timeout.
void mutt_flushinp(void)
Empty all the keyboard buffers.
static struct KeyEventArray UngetKeyEvents
These are used in all other "normal" situations, and are not ignored when setting OptIgnoreMacroEvent...
size_t mutt_wstr_trunc(const char *src, size_t maxlen, size_t maxwid, size_t *width)
Work out how to truncate a widechar string.
static void array_add(struct KeyEventArray *a, int ch, int op)
Add an event to the end of the array.
static void array_to_endcond(struct KeyEventArray *a)
Clear the array until an OP_END_COND.
struct KeyEvent mutt_getch(void)
Read a character from the input buffer.
void mutt_unget_string(const char *s)
Return a string to the input buffer.
void mutt_push_macro_event(int ch, int op)
Add the character/operation to the macro buffer.
static struct KeyEvent * array_pop(struct KeyEventArray *a)
Remove an event from the array.
void mutt_paddstr(struct MuttWindow *win, int n, const char *s)
Display a string on screen, padded if necessary.
void mutt_format_s_x(char *buf, size_t buflen, const char *prec, const char *s, bool arboreal)
Format a string like snprintf()
void mutt_unget_op(int op)
Return an operation to the input buffer.
void mutt_format_s_tree(char *buf, size_t buflen, const char *prec, const char *s)
Format a simple string with tree characters.
void mutt_refresh(void)
Force a refresh of the screen.
static void set_timeout(int delay)
Set the getch() timeout.
void mutt_flush_unget_to_endcond(void)
Clear entries from UngetKeyEvents.
int mutt_addwch(struct MuttWindow *win, wchar_t wc)
Addwch would be provided by an up-to-date curses library.
void mutt_flush_macro_to_endcond(void)
Drop a macro from the input buffer.
void mutt_simple_format(char *buf, size_t buflen, int min_width, int max_width, enum FormatJustify justify, char pad_char, const char *s, size_t n, bool arboreal)
Format a string, like snprintf()
int mutt_any_key_to_continue(const char *s)
Prompt the user to 'press any key' and wait.
void mutt_need_hard_redraw(void)
Force a hard refresh.
static int mutt_monitor_getch(void)
Get a character and poll the filesystem monitor.
void mutt_query_exit(void)
Ask the user if they want to leave NeoMutt.
ARRAY_HEAD(KeyEventArray, struct KeyEvent)
void mutt_endwin(void)
Shutdown curses.
void mutt_beep(bool force)
Irritate the user.
size_t mutt_strwidth(const char *s)
Measure a string's width in screen cells.
void mutt_unget_ch(int ch)
Return a keystroke to the input buffer.
void mutt_perror_debug(const char *s)
Show the user an 'errno' message.
void mutt_format_s(char *buf, size_t buflen, const char *prec, const char *s)
Format a simple string.
int MuttGetchTimeout
Timeout for getting a character from the user.
int buf_enter_fname(const char *prompt, struct Buffer *fname, bool mailbox, struct Mailbox *m, bool multiple, char ***files, int *numfiles, SelectFileFlags flags)
Ask the user to select a file.
GUI miscellaneous curses (window drawing) routines.
FormatJustify
Alignment for mutt_simple_format()
@ JUSTIFY_RIGHT
Right justify the text.
@ JUSTIFY_LEFT
Left justify the text.
@ JUSTIFY_CENTER
Centre the text.
int buf_get_field(const char *field, struct Buffer *buf, CompletionFlags complete, bool multiple, struct Mailbox *m, char ***files, int *numfiles)
Ask the user for a string.
void buf_file_expand_fmt_quote(struct Buffer *dest, const char *fmt, const char *src)
Replace s in a string with a filename.
bool OptKeepQuiet
(pseudo) shut up the message and refresh functions while we are executing an external program
bool OptNoCurses
(pseudo) when sending in batch mode
bool OptForceRefresh
(pseudo) refresh even during macros
SIG_ATOMIC_VOLATILE_T SigInt
true after SIGINT is received
bool OptIgnoreMacroEvents
(pseudo) don't process macro/push/exec events while set
#define mutt_debug(LEVEL,...)
keycode_t AbortKey
code of key to abort prompts, normally Ctrl-G
@ LL_DEBUG1
Log at debug level 1.
void mutt_exit(int code)
Leave NeoMutt NOW.
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
int mutt_monitor_poll(void)
Check for filesystem changes.
Monitor files for changes.
struct MuttWindow * msgwin_get_window(void)
Get the Message Window pointer.
wchar_t ReplacementChar
When a Unicode character can't be displayed, use this instead.
#define ICONV_BUF_TOO_SMALL
Error value for iconv() - Buffer too small.
#define ICONV_ILLEGAL_SEQ
Error value for iconv() - Illegal sequence.
Convenience wrapper for the library headers.
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Many unsorted constants and some structs.
#define MUTT_COMP_FILE
File completion (in browser)
#define MUTT_COMP_FILE_MBOX
File completion, plus incoming folders (in browser)
#define MUTT_COMP_CLEAR
Clear input if printable character is pressed.
enum MuttCursorState mutt_curses_set_cursor(enum MuttCursorState state)
Set the cursor state.
struct AttrColor * mutt_curses_set_normal_backed_color_by_id(enum ColorId cid)
Set the colour and attributes by the colour id.
struct AttrColor * mutt_curses_set_color_by_id(enum ColorId cid)
Set the colour and attributes by the colour id.
Define wrapper functions around Curses.
void mutt_resize_screen(void)
Update NeoMutt's opinion about the window size (CURSES)
MuttCursorState
Cursor states for mutt_curses_set_cursor()
@ MUTT_CURSOR_VISIBLE
Display a normal cursor.
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Create/manipulate threading in emails.
@ MUTT_SPECIAL_INDEX
Colour indicator.
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
struct MuttWindow * window_set_focus(struct MuttWindow *win)
Set the Window focus.
int mutt_window_mvaddstr(struct MuttWindow *win, int col, int row, const char *str)
Move the cursor and write a fixed string to a Window.
int mutt_window_addstr(struct MuttWindow *win, const char *str)
Write a string to a Window.
int mutt_window_addnstr(struct MuttWindow *win, const char *str, int num)
Write a partial string to a Window.
void mutt_window_clrtoeol(struct MuttWindow *win)
Clear to the end of the line.
int mutt_window_addch(struct MuttWindow *win, int ch)
Write one character to a Window.
All user-callable functions.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Prototypes for many functions.
int mutt_system(const char *cmd)
Run an external command.
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
enum QuadOption mutt_yesorno(const char *msg, enum QuadOption def)
Ask the user a Yes/No question.
void mutt_sig_allow_interrupt(bool allow)
Allow/disallow Ctrl-C (SIGINT)
String manipulation buffer.
An event such as a keypress.
int op
Function opcode, e.g. OP_HELP.
Container for Accounts, Notifications.
struct ConfigSubset * sub
Inherited config items.