unibi_format(3)
β¨ NAME β¨
unibi_format, unibi_run β bestie, we're interpreting a terminfo format string π
So this is page unibi_format(3) from the unibilium manual, and it's about turning those cursed-looking format strings into actual output. Let's get into it π«Ά
πΈ SYNOPSIS πΈ
#include <unibilium.h>
void unibi_format(
unibi_var_t var_dyn[26],
unibi_var_t var_static[26],
const char *fmt,
unibi_var_t param[9],
void (*out)(void *, const char *, size_t),
void *ctx1,
void (*pad)(void *, size_t, int, int),
void *ctx2
);
size_t unibi_run(const char *fmt, unibi_var_t param[9], char *p, size_t n);
π DESCRIPTION π
unibi_format takes a format string fmt and, like, executes it. Slay. All the output happens through (possibly repeated) calls to out. And in those calls to out, the tea is:
- the first argument is always
ctx1 - the second argument is a pointer to a chunk of data
- the third argument is a count saying how big that chunk is, in bytes
Then there's pad, which gets used whenever the format string has "$<...>" padding instructions in it. In the calls to pad:
- the first argument is always
ctx2 - the second argument is the delay in tenths of milliseconds
- the third argument is a boolean flag for whether
"*"(proportional delay) was specified in the format string - the fourth argument is a boolean flag for whether
"/"(forced padding) was specified in the format string
So like, a format string of "$<5/>" would translate into "pad(ctx2, 50, 0, 1)". Iconic. β¨
You may pass a null pointer for pad β in that case padding instructions are silently skipped. No drama, no crash, they just don't happen.
The values of param are what get used for the format codes %p1 .. %p9. And the values of var_dyn and var_static are what get used for the so-called dynamic/static variables %Pa .. %Pz and %PA .. %PZ, respectively. Yes bestie, lowercase and uppercase are two whole separate vibes π
π¦ unibi_run β the wrapper π¦
unibi_run</purl> is a wrapper around unibi_format. Here's what it does:
- it passes two arrays (each initialized to 26 zeroes) as
var_dynandvar_static fmtandparamget passed on unchanged- it ignores padding
- it places all normal output in the buffer pointed to by
p nis the size of that buffer, so at mostnbytes will be written top
π RETURN VALUE π
unibi_run returns the number of bytes that would have been written if the buffer was big enough. So the number of valid bytes sitting in p after a call to unibi_run is the minimum of n and the return value of unibi_run. That's the whole trick, fr fr π
π SEE ALSO π
Okay that's the whole page, bestie, you ate that π This was unibilium-2.1.4, dated 2026-09-07 β go forth and interpret those format strings, main character energy only ππ¦
π¦ where this page comes from
- fedora 44: unibilium-devel 2.1.4-1.fc44 Β· LGPL-3.0-or-later
- fedora 44: unibilium-devel 2.1.4-1.fc44 Β· LGPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms