Draw a colourful progress bar.
76{
77 if (!fmt || !win || !win->
wdata)
78 return;
79
80 va_list ap;
81 char buf[1024] = { 0 };
83 int w = (percent * win->
state.
cols) / 100;
84 size_t l;
85
86 va_start(ap, fmt);
87 vsnprintf(buf, sizeof(buf), fmt, ap);
89 va_end(ap);
90
92
94
96 {
97 if (l < w)
98 {
99
102 w -= l;
103 while (w-- > 0)
104 {
106 }
108 }
109 else
110 {
111
113
114 char ch =
buf_at(buf2, off);
115 buf2->
data[off] =
'\0';
118 buf2->
data[off] = ch;
121 }
122 }
123 else
124 {
126 }
127
130}
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".
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.
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.
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.
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.
String manipulation buffer.
size_t dsize
Length of data.
char * data
Pointer to data.
struct WindowState state
Current state of the Window.
void * wdata
Private data.
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.