#include <stddef.h>
#include <stdbool.h>
#include <wchar.h>
#include "config/lib.h"
#include "mutt.h"
#include "browser.h"
#include "keymap.h"
#include "pager/lib.h"
Go to the source code of this file.
Enumerations | |
enum | FormatJustify { JUSTIFY_LEFT = -1, JUSTIFY_CENTER = 0, JUSTIFY_RIGHT = 1 } |
Alignment for mutt_simple_format() More... | |
Functions | |
int | mutt_addwch (wchar_t wc) |
addwch would be provided by an up-to-date curses library More... | |
int | mutt_any_key_to_continue (const char *s) |
Prompt the user to 'press any key' and wait. More... | |
void | mutt_beep (bool force) |
Irritate the user. More... | |
int | mutt_buffer_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. More... | |
int | mutt_buffer_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. More... | |
int | mutt_do_pager (const char *banner, const char *tempfile, PagerFlags do_color, struct Pager *info) |
Display some page-able text to the user. More... | |
void | mutt_edit_file (const char *editor, const char *file) |
Let the user edit a file. More... | |
void | mutt_endwin (void) |
Shutdown curses/slang. More... | |
void | mutt_flushinp (void) |
Empty all the keyboard buffers. More... | |
void | mutt_flush_macro_to_endcond (void) |
Drop a macro from the input buffer. More... | |
void | mutt_flush_unget_to_endcond (void) |
Clear entries from UngetKeyEvents. More... | |
void | mutt_format_s (char *buf, size_t buflen, const char *prec, const char *s) |
Format a simple string. More... | |
void | mutt_format_s_tree (char *buf, size_t buflen, const char *prec, const char *s) |
Format a simple string with tree characters. More... | |
void | mutt_format_s_x (char *buf, size_t buflen, const char *prec, const char *s, bool arboreal) |
Format a string like snprintf() More... | |
void | mutt_getch_timeout (int delay) |
Set the getch() timeout. More... | |
struct KeyEvent | mutt_getch (void) |
Read a character from the input buffer. More... | |
int | mutt_get_field (const char *field, char *buf, size_t buflen, CompletionFlags complete, bool multiple, char ***files, int *numfiles) |
Ask the user for a string. More... | |
int | mutt_get_field_unbuffered (const char *msg, char *buf, size_t buflen, CompletionFlags flags) |
Ask the user for a string (ignoring macro buffer) More... | |
int | mutt_multi_choice (const char *prompt, const char *letters) |
Offer the user a multiple choice question. More... | |
void | mutt_need_hard_redraw (void) |
Force a hard refresh. More... | |
void | mutt_paddstr (int n, const char *s) |
Display a string on screen, padded if necessary. More... | |
void | mutt_perror_debug (const char *s) |
Show the user an 'errno' message. More... | |
void | mutt_push_macro_event (int ch, int op) |
Add the character/operation to the macro buffer. More... | |
void | mutt_query_exit (void) |
Ask the user if they want to leave NeoMutt. More... | |
void | mutt_refresh (void) |
Force a refresh of the screen. More... | |
void | mutt_show_error (void) |
Show the user an error message. More... | |
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() More... | |
int | mutt_strwidth (const char *s) |
Measure a string's width in screen cells. More... | |
int | mutt_strnwidth (const char *s, size_t len) |
Measure a string's width in screen cells. More... | |
void | mutt_unget_event (int ch, int op) |
Return a keystroke to the input buffer. More... | |
void | mutt_unget_string (const char *s) |
Return a string to the input buffer. More... | |
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. More... | |
enum QuadOption | mutt_yesorno (const char *msg, enum QuadOption def) |
Ask the user a Yes/No question. More... | |
enum QuadOption | query_quadoption (enum QuadOption opt, const char *prompt) |
Ask the user a quad-question. More... | |
Variables | |
bool | C_MetaKey |
interpret ALT-x as ESC-x More... | |
int | MuttGetchTimeout |
Timeout in ms for mutt_getch() More... | |
GUI miscellaneous curses (window drawing) routines
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 curs_lib.h.
enum FormatJustify |
Alignment for mutt_simple_format()
Enumerator | |
---|---|
JUSTIFY_LEFT | Left justify the text. |
JUSTIFY_CENTER | Centre the text. |
JUSTIFY_RIGHT | Right justify the text. |
Definition at line 46 of file curs_lib.h.
int mutt_addwch | ( | wchar_t | wc | ) |
addwch would be provided by an up-to-date curses library
wc | Wide char to display |
0 | Success |
-1 | Error |
Definition at line 1063 of file curs_lib.c.
int mutt_any_key_to_continue | ( | const char * | s | ) |
Prompt the user to 'press any key' and wait.
s | Message prompt |
num | Key pressed |
EOF | Error, or prompt aborted |
Definition at line 605 of file curs_lib.c.
void mutt_beep | ( | bool | force | ) |
Irritate the user.
force | If true, ignore the "$beep" config variable |
Definition at line 99 of file curs_lib.c.
int mutt_buffer_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.
[in] | prompt | Prompt |
[in] | fname | Buffer for the result |
[in] | mailbox | If true, select mailboxes |
[in] | multiple | Allow multiple selections |
[in] | m | Mailbox |
[out] | files | List of files selected |
[out] | numfiles | Number of files selected |
[in] | flags | Flags, see SelectFileFlags |
0 | Success |
-1 | Error |
Definition at line 772 of file curs_lib.c.
int mutt_buffer_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.
[in] | field | Prompt |
[in] | buf | Buffer for the result |
[in] | complete | Flags, see CompletionFlags |
[in] | multiple | Allow multiple selections |
[in] | m | Mailbox |
[out] | files | List of files selected |
[out] | numfiles | Number of files selected |
1 | Redraw the screen and call the function again |
0 | Selection made |
-1 | Aborted |
Definition at line 260 of file curs_lib.c.
int mutt_do_pager | ( | const char * | banner, |
const char * | tempfile, | ||
PagerFlags | do_color, | ||
struct Pager * | info | ||
) |
Display some page-able text to the user.
banner | Message for status bar |
tempfile | File to display |
do_color | Flags, see PagerFlags |
info | Info about current mailbox (OPTIONAL) |
0 | Success |
-1 | Error |
Definition at line 691 of file curs_lib.c.
void mutt_edit_file | ( | const char * | editor, |
const char * | file | ||
) |
Let the user edit a file.
editor | User's editor config |
file | File to edit |
Definition at line 356 of file curs_lib.c.
void mutt_endwin | ( | void | ) |
Shutdown curses/slang.
Definition at line 572 of file curs_lib.c.
void mutt_flushinp | ( | void | ) |
Empty all the keyboard buffers.
Definition at line 923 of file curs_lib.c.
void mutt_flush_macro_to_endcond | ( | void | ) |
Drop a macro from the input buffer.
All the macro text is deleted until an OP_END_COND command, or the buffer is empty.
Definition at line 894 of file curs_lib.c.
void mutt_flush_unget_to_endcond | ( | void | ) |
Clear entries from UngetKeyEvents.
Normally, OP_END_COND should only be in the MacroEvent buffer. km_error_key() (ab)uses OP_END_COND as a barrier in the unget buffer, and calls this function to flush.
Definition at line 911 of file curs_lib.c.
void mutt_format_s | ( | char * | buf, |
size_t | buflen, | ||
const char * | prec, | ||
const char * | s | ||
) |
Format a simple string.
[out] | buf | Buffer in which to save string |
[in] | buflen | Buffer length |
[in] | prec | Field precision, e.g. "-3.4" |
[in] | s | String to format |
Definition at line 1248 of file curs_lib.c.
void mutt_format_s_tree | ( | char * | buf, |
size_t | buflen, | ||
const char * | prec, | ||
const char * | s | ||
) |
Format a simple string with tree characters.
[out] | buf | Buffer in which to save string |
[in] | buflen | Buffer length |
[in] | prec | Field precision, e.g. "-3.4" |
[in] | s | String to format |
Definition at line 1260 of file curs_lib.c.
void mutt_format_s_x | ( | char * | buf, |
size_t | buflen, | ||
const char * | prec, | ||
const char * | s, | ||
bool | arboreal | ||
) |
Format a string like snprintf()
[out] | buf | Buffer in which to save string |
[in] | buflen | Buffer length |
[in] | prec | Field precision, e.g. "-3.4" |
[in] | s | String to format |
[in] | arboreal | If true, string contains graphical tree characters |
This formats a string rather like:
Definition at line 1211 of file curs_lib.c.
void mutt_getch_timeout | ( | int | delay | ) |
Set the getch() timeout.
delay | Timeout delay in ms |
delay is just like for timeout() or poll(): the number of milliseconds mutt_getch() should block for input.
Definition at line 146 of file curs_lib.c.
struct KeyEvent mutt_getch | ( | void | ) |
Read a character from the input buffer.
obj | KeyEvent to process |
The priority for reading events is:
This function can return:
{ -1, OP_NULL }
{ -2, OP_NULL }
Definition at line 189 of file curs_lib.c.
int mutt_get_field | ( | const char * | field, |
char * | buf, | ||
size_t | buflen, | ||
CompletionFlags | complete, | ||
bool | multiple, | ||
char *** | files, | ||
int * | numfiles | ||
) |
Ask the user for a string.
[in] | field | Prompt |
[in] | buf | Buffer for the result |
[in] | buflen | Length of buffer |
[in] | complete | Flags, see CompletionFlags |
[in] | multiple | Allow multiple selections |
[out] | files | List of files selected |
[out] | numfiles | Number of files selected |
1 | Redraw the screen and call the function again |
0 | Selection made |
-1 | Aborted |
Definition at line 311 of file curs_lib.c.
int mutt_get_field_unbuffered | ( | const char * | msg, |
char * | buf, | ||
size_t | buflen, | ||
CompletionFlags | flags | ||
) |
Ask the user for a string (ignoring macro buffer)
msg | Prompt |
buf | Buffer for the result |
buflen | Length of buffer |
flags | Flags, see CompletionFlags |
1 | Redraw the screen and call the function again |
0 | Selection made |
-1 | Aborted |
Definition at line 335 of file curs_lib.c.
int mutt_multi_choice | ( | const char * | prompt, |
const char * | letters | ||
) |
Offer the user a multiple choice question.
prompt | Message prompt |
letters | Allowable selection keys |
>=0 | 0-based user selection |
-1 | Selection aborted |
Definition at line 937 of file curs_lib.c.
void mutt_need_hard_redraw | ( | void | ) |
Force a hard refresh.
Make sure that the next refresh does a full refresh. This could be optimized by not doing it at all if DISPLAY is set as this might indicate that a GUI based pinentry was used. Having an option to customize this is of course the NeoMutt way.
Definition at line 130 of file curs_lib.c.
void mutt_paddstr | ( | int | n, |
const char * | s | ||
) |
Display a string on screen, padded if necessary.
n | Final width of field |
s | String to display |
Definition at line 1270 of file curs_lib.c.
void mutt_perror_debug | ( | const char * | s | ) |
Show the user an 'errno' message.
s | Additional text to show |
Definition at line 591 of file curs_lib.c.
void mutt_push_macro_event | ( | int | ch, |
int | op | ||
) |
Add the character/operation to the macro buffer.
ch | Character to add |
op | Operation to add |
Adds the ch/op to the macro buffer. This should be used for macros, push, and exec commands only.
Definition at line 875 of file curs_lib.c.
void mutt_query_exit | ( | void | ) |
Ask the user if they want to leave NeoMutt.
This function is called when the user presses the abort key.
Definition at line 540 of file curs_lib.c.
void mutt_refresh | ( | void | ) |
Force a refresh of the screen.
Definition at line 108 of file curs_lib.c.
void mutt_show_error | ( | void | ) |
Show the user an error message.
Definition at line 558 of file curs_lib.c.
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()
[out] | buf | Buffer in which to save string |
[in] | buflen | Buffer length |
[in] | min_width | Minimum width |
[in] | max_width | Maximum width |
[in] | justify | Justification, e.g. JUSTIFY_RIGHT |
[in] | pad_char | Padding character |
[in] | s | String to format |
[in] | n | Number of bytes of string to format |
[in] | arboreal | If true, string contains graphical tree characters |
This formats a string, a bit like snprintf(buf, buflen, "%-*.*s", min_width, max_width, s), except that the widths refer to the number of character cells when printed.
Definition at line 1097 of file curs_lib.c.
int mutt_strwidth | ( | const char * | s | ) |
Measure a string's width in screen cells.
s | String to be measured |
num | Screen cells string would use |
Definition at line 1363 of file curs_lib.c.
int mutt_strnwidth | ( | const char * | s, |
size_t | n | ||
) |
Measure a string's width in screen cells.
s | String to be measured |
n | Length of string to be measured |
num | Screen cells string would use |
Definition at line 1376 of file curs_lib.c.
void mutt_unget_event | ( | int | ch, |
int | op | ||
) |
Return a keystroke to the input buffer.
ch | Key press |
op | Operation, e.g. OP_DELETE |
This puts events into the UngetKeyEvents
buffer
Definition at line 838 of file curs_lib.c.
void mutt_unget_string | ( | const char * | s | ) |
Return a string to the input buffer.
s | String to return |
This puts events into the UngetKeyEvents
buffer
Definition at line 857 of file curs_lib.c.
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.
[in] | src | String to measure |
[in] | maxlen | Maximum length of string in bytes |
[in] | maxwid | Maximum width in screen columns |
[out] | width | Save the truncated screen column width |
num | Bytes to use |
See how many bytes to copy from string so it's at most maxlen bytes long and maxwid columns wide
Definition at line 1313 of file curs_lib.c.
enum QuadOption mutt_yesorno | ( | const char * | msg, |
enum QuadOption | def | ||
) |
Ask the user a Yes/No question.
msg | Prompt |
def | Default answer, MUTT_YES or MUTT_NO (see QuadOption) |
num | Selection made, see QuadOption |
Definition at line 380 of file curs_lib.c.
enum QuadOption query_quadoption | ( | enum QuadOption | opt, |
const char * | prompt | ||
) |
Ask the user a quad-question.
opt | Option to use |
prompt | Message to show to the user |
QuadOption | Result, e.g. MUTT_NO |
Definition at line 518 of file curs_lib.c.
bool C_MetaKey |
int MuttGetchTimeout |
Timeout in ms for mutt_getch()
Definition at line 93 of file curs_lib.c.