81 char buf[1024] = { 0 };
83 int w = (percent * win->
state.
cols) / 100;
87 vsnprintf(buf,
sizeof(buf), fmt, ap);
114 char ch =
buf_at(buf2, off);
115 buf2->
data[off] =
'\0';
118 buf2->
data[off] = ch;
137 if (!win || !win->
wdata)
165 if (wdata->
msg[0] ==
'\0')
168 if (wdata->
size == 0)
245 const unsigned shift = wdata->
is_bytes ? 10 : 0;
312 size_t time_inc,
bool is_bytes)
353 vsnprintf(wdata->
msg,
sizeof(wdata->
msg), fmt, ap);
char buf_at(const struct Buffer *buf, size_t offset)
Return the character at the given offset.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Color and attribute parsing.
bool simple_color_is_set(enum ColorId cid)
Is the object coloured?
@ MT_COLOR_PROGRESS
Progress bar.
@ MT_COLOR_NORMAL
Plain text.
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.
size_t mutt_strwidth(const char *s)
Measure a string's width in screen cells.
static int progress_window_recalc(struct MuttWindow *win)
Recalculate the Progress Bar - Implements MuttWindow::recalc() -.
static int progress_window_repaint(struct MuttWindow *win)
Repaint the Progress Bar - Implements MuttWindow::repaint() -.
void progress_wdata_free(struct MuttWindow *win, void **ptr)
Free Progress Bar Window data - Implements MuttWindow::wdata_free() -.
Convenience wrapper for the gui headers.
uint64_t mutt_date_now_ms(void)
Return the number of milliseconds since the Unix epoch.
Convenience wrapper for the library headers.
const struct AttrColor * mutt_curses_set_normal_backed_color_by_id(enum ColorId cid)
Set the colour and attributes by the colour id.
const struct AttrColor * mutt_curses_set_color_by_id(enum ColorId cid)
Set the colour and attributes by the colour id.
struct MuttWindow * mutt_window_new(enum WindowType type, enum MuttWindowOrientation orient, enum MuttWindowSize size, int cols, int rows)
Create a new Window.
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
int mutt_window_addstr(struct MuttWindow *win, const char *str)
Write a 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.
#define WA_RECALC
Recalculate the contents of the Window.
@ WT_STATUS_BAR
Status Bar containing extra info about the Index/Pager/etc.
@ MUTT_WIN_ORIENT_VERTICAL
Window uses all available vertical space.
#define WA_REPAINT
Redraw the contents of the Window.
#define MUTT_WIN_SIZE_UNLIMITED
Use as much space as possible.
@ MUTT_WIN_SIZE_FIXED
Window has a fixed size.
void mutt_str_pretty_size(char *buf, size_t buflen, size_t num)
Display an abbreviated size, like 3.4K.
Some miscellaneous 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.
struct ProgressWindowData * progress_wdata_new(void)
Create new Progress Bar Window Data.
Progress Bar Window Data.
void progress_window_set_size(struct MuttWindow *win, size_t size)
Set the progress size.
static bool percent_needs_update(const struct ProgressWindowData *wdata, int percent)
Do we need to update, given the current percentage?
bool progress_window_update(struct MuttWindow *win, size_t pos, int percent)
Update the Progress Bar Window.
void progress_window_set_message(struct MuttWindow *win, const char *fmt, va_list ap)
Set the progress message.
static void message_bar(struct MuttWindow *win, int percent, const char *fmt,...)
Draw a colourful progress bar.
static bool time_needs_update(const struct ProgressWindowData *wdata, size_t now)
Do we need to update, given the current time?
static bool pos_needs_update(const struct ProgressWindowData *wdata, long pos)
Do we need to update, given the current pos?
struct MuttWindow * progress_window_new(size_t size, size_t size_inc, size_t time_inc, bool is_bytes)
Create a new Progress Bar Window.
String manipulation buffer.
size_t dsize
Length of data.
char * data
Pointer to data.
int(* repaint)(struct MuttWindow *win)
struct WindowState state
Current state of the Window.
void * wdata
Private data.
int(* recalc)(struct MuttWindow *win)
void(* wdata_free)(struct MuttWindow *win, void **ptr)
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
enum MuttWindowSize size
Type of Window, e.g. MUTT_WIN_SIZE_FIXED.
Progress Bar Window Data.
int update_percent
Updated percentage complete.
char msg[1024]
Message to display.
size_t size
Total expected size.
char pretty_pos[24]
Pretty string for the position.
size_t time_inc
Time increment.
uint64_t update_time
Time of last update.
int display_percent
Displayed percentage complete.
size_t display_pos
Displayed position.
size_t size_inc
Size increment.
bool is_bytes
true if measuring bytes
size_t update_pos
Updated position.
struct MuttWindow * win
Window to draw on.
uint64_t display_time
Time of last display.
char pretty_size[24]
Pretty string for size.
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.