TBUF(3pub)
β¨ TBUF(3pub) β¨
okay bestie, welcome to TBUF(3pub) β the manual page for manipulating text editor buffers π it's from the publib family and it's lowkey iconic, so let's get into it π
πΈ NAME πΈ
tbuf_create, tbuf_destroy, tbuf_copy, tbuf_cat, tbuf_length, tbuf_chars β manipulate text editor buffer π
π¦ SYNOPSIS π¦
#include <publib.h>
Tbuf *tbuf_create(const char *chars, size_t len);
void tbuf_destroy(Tbuf *tbuf);
Tbuf *tbuf_copy(Tbuf *tbuf, size_t offset, size_tlen);
Tbuf *tbuf_cat(Tbuf *tbuf, Tbuf * tbuf);
size_t tbuf_length(Tbuf *tbuf);
void tbuf_chars(char *chars, Tbuf *tbuf, size_t offset, size_t len);
π DESCRIPTION π
okay so these routines create and manipulate simple text editor buffers, which honestly you can also just think of as arbitrarily large text strings π«Ά the buffers are one-dimensional (i.e., not automatically divided into lines), and they're indexed with character offsets. they are 8-bit and binary clean β i.e., they may contain any 8-bit characters, including the zero byte ('\0') πβ¨ yes bestie, the null byte, she's allowed here.
tbuf_create creates a buffer from a C character array, and tbuf_destroy destroys it π once it's created, a buffer may not be modified. instead, a new buffer needs to be created, using tbuf_cat and tbuf_copy. and here's the slay part: they create the new buffer so that it shares as much memory as possible with the old buffer, so the immutability does not necessarily waste memory much π
the way that never changing a buffer makes undo and redo so simple?? π you only need to keep a list of buffers and display the suitable one to the user. literally main character energy. the caller should remember to call tbuf_destroy for unnecessary buffers, of course π
tbuf_length returns the number of characters in the buffer. tbuf_copy copies part of a buffer into a C character array. > heads up babes: the array is not zero-terminated β the caller must do it himself π
β RETURN VALUE β
tbuf_create,tbuf_copy, andtbuf_catreturn a pointer to the new buffer, orNULLif the operation failed πtbuf_lengthreturns the number of characters in the buffer π₯tbuf_destroyandtbuf_charsreturn nothing and cannot fail β queen behaviour, no notes π
π SEE ALSO π
publib(3), sbuf(3)
π AUTHOR π
Lars Wirzenius, liw@iki.fi.
and that's the whole vibe, bestie π¦ this was TBUF(3pub), aka the publib page, and yeah β that footer really do say TBUF(3pub) π go forth and buffer responsibly, no cap β¨π
π¦ where this page comes from
- debian bookworm: publib-dev 0.40-3+b1 Β· BSD-2-Clause
- debian trixie: publib-dev 0.40-4 Β· BSD-2-Clause
- ubuntu jammy: publib-dev 0.40-3build1 Β· BSD-2-Clause
- ubuntu noble: publib-dev 0.40-3build1 Β· BSD-2-Clause
- ubuntu questing: publib-dev 0.40-4
- ubuntu resolute: publib-dev 0.40-4build1 Β· BSD-2-Clause
- ubuntu stonking: publib-dev 0.40-4build1 Β· BSD-2-Clause
- Copyright (c) 1994-2006 Lars Wirzenius. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms