winmsg_esc_ex(TruncPos, uint8_t perc, bool ellip) { /* TODO: encapsulate */ wmbc->trunc.pos = wmbc_offset(wmbc); wmbc->trunc.perc = perc; wmbc->trunc.ellip = ellip; }
/* Attempts buffer expansion and updates context pointers appropriately. The * result is true if expansion succeeded, otherwise false. */ static bool _wmbc_expand(WinMsgBufContext *wmbc, size_t size) { size_t offset = wmbc_offset(wmbc); if (wmb_expand(wmbc->buf, size) < size) { return false; } /* the buffer address may have changed; re-calculate pointer address */ wmbc->p = wmbc->buf->buf + offset; return true; }
/* Merges the contents of another null-terminated buffer and its renditions. The * return value is a pointer to the first character of WMB's buffer. */ char *wmbc_mergewmb(WinMsgBufContext *wmbc, WinMsgBuf *wmb) { char *p; size_t offset = wmbc_offset(wmbc); int ri; /* import buffer contents into our own at our current position */ assert(wmb); p = wmbc_strcpy(wmbc, wmb->buf); /* merge renditions, adjusting them to reflect their new offset */ for (ri = 0; ri < wmb->numrend; ri++) { wmb_rendadd(wmbc->buf, wmb->rend[ri], offset + wmb->rendpos[ri]); } return p; }
/* Calculate the number of bytes remaining in the buffer relative to the current * position within the buffer */ size_t wmbc_bytesleft(WinMsgBufContext *wmbc) { return wmbc->buf->size - wmbc_offset(wmbc); }