winmsg_esc_ex(WinArgv, Window *win) { if (!win || !win->w_cmdargs[0]) return; wmbc_printf(wmbc, "%s", win->w_cmdargs[0]); wmbc_fastfw0(wmbc); if (**src == WINESC_CMD_ARGS) { int i; for (i = 1; win->w_cmdargs[i]; i++) { wmbc_printf(wmbc, " %s", win->w_cmdargs[i]); wmbc_fastfw0(wmbc); } } }
winmsg_esc_ex(WinNames, const bool hide_cur, Window *win) { Window *oldfore = 0; size_t max = wmbc_bytesleft(wmbc); if (display) { oldfore = D_fore; D_fore = win; } /* TODO: no need to enforce a limit here */ AddWindows(wmbc, max - 1, hide_cur | (esc->flags.lng ? 0 : 2) | (esc->flags.plus ? 4 : 0) | (esc->flags.minus ? 8 : 0), win ? win->w_number : -1); if (display) D_fore = oldfore; if (*wmbc->p) wmc_set(cond); wmbc_fastfw0(wmbc); }
/* Write data to the buffer using a printf-style format string. If needed, the * buffer will be automatically expanded to accomodate the resulting string and * is therefore protected against overflows. */ int wmbc_printf(WinMsgBufContext *wmbc, const char *fmt, ...) { va_list ap; size_t n, max; /* to prevent buffer overflows, cap the number of bytes to the remaining * buffer size */ va_start(ap, fmt); max = wmbc_bytesleft(wmbc); n = vsnprintf(wmbc->p, max, fmt, ap); va_end(ap); /* more space is needed if vsnprintf returns a larger number than our max, * in which case we should accomodate by dynamically resizing the buffer and * trying again */ if (n > max) { if (!_wmbc_expand(wmbc, wmb_size(wmbc->buf) + n - max)) { /* failed to allocate additional memory; this will simply have to do */ wmbc_fastfw_end(wmbc); va_end(ap); return max; } va_start(ap, fmt); size_t m = vsnprintf(wmbc->p, n + 1, fmt, ap); assert(m == n); /* this should never fail */ va_end(ap); } wmbc_fastfw0(wmbc); return n; }
winmsg_esc_ex(Wflags, Window *win) { *wmbc->p = '\0'; if (win) AddWindowFlags(wmbc->p, wmbc_bytesleft(wmbc), win); if (*wmbc->p) wmc_set(cond); wmbc_fastfw0(wmbc); }