Tk_GetJustifyFromObj(3tk)

πŸ“¦
version 9.0.4 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ Tk_GetJustifyFromObj β€” translate between strings and justification styles ✨

okay bestie, welcome to the Tk_GetJustifyFromObj page πŸ’– this is a Tk Library Procedures situation, and it's all about turning strings into justification styles and back again. Three functions, one very specific job. Let's get into it πŸ¦‹


🌸 SYNOPSIS 🌸

#include <tk.h>

int
Tk_GetJustifyFromObj(interp, objPtr, justifyPtr)

int
Tk_GetJustify(interp, string, justifyPtr)

const char *
Tk_NameOfJustify(justify)

πŸŽ€ ARGUMENTS πŸŽ€

  • Tcl_Interp *interp (in) β€” the interpreter we use for error reporting. Or NULL, if you're feeling mysterious πŸ’…
  • Tcl_Obj *objPtr (in/out) β€” the string value inside it holds the name of a justification style β€” one of "left", "right", or "center" β€” or a unique abbreviation of one of those. The internal rep gets modified so it can cache the matching justify value. lowkey efficient, we love to see it ✨
  • const char *string (in) β€” literally the same thing as objPtr, except the justification style description comes in as a string instead. same vibe, different delivery πŸ“¦
  • int *justifyPtr (out) β€” a pointer to the spot where we're gonna stash the justify value that matches objPtr or string. that's the whole point, no cap 🎯
  • Tk_Justify justify (in) β€” a justification style. one of the values listed down below, bestie πŸ‘‡

πŸ’œ DESCRIPTION πŸ’œ

So Tk_GetJustifyFromObj places into *justifyPtr the justify value that corresponds to objPtr's value. And that value is gonna be one of these iconic three:

  • TK_JUSTIFY_LEFT β€” the text on each line starts at the left edge of the line. consequence? the right edges of lines may be ragged. it's giving chaotic right margin 😌
  • TK_JUSTIFY_RIGHT β€” the text on each line ends at the right edge of the line. consequence? the left edges of lines may be ragged. mirror image, still messy πŸ’…
  • TK_JUSTIFY_CENTER β€” the text on each line is centered. consequence? both the left and right edges of lines may be ragged. maximum chaos, maximum aesthetic πŸŽ€

Under normal circumstances the return value is TCL_OK and interp just sits there unused. iconic of it honestly πŸ™ˆ

but if objPtr does not contain a valid justification style, or an abbreviation of one of those names, then TCL_ERROR gets returned, *justifyPtr is left unmodified, and an error message gets stored in interp's result β€” but only if interp is not NULL. so like. don't be surprised when that happens, it's a whole thing 😭

Also Tk_GetJustifyFromObj caches information about the return value in objPtr, which speeds up future calls to Tk_GetJustifyFromObj with the same objPtr. it remembers. it's loyal 🫢

Tk_GetJustify is identical to Tk_GetJustifyFromObj, except the description of the justification is specified with a string instead of an object. the catch? this prevents Tk_GetJustify from caching the return value, so Tk_GetJustify is less efficient than Tk_GetJustifyFromObj. still works, just no cache glow-up πŸ’€

Tk_NameOfJustify is the logical inverse of Tk_GetJustify β€” the uno reverse card πŸ”„ Give it a justify value and it returns a statically-allocated string corresponding to justify. And if justify isn't a legal justify value? then "unknown justification style" comes back. that's the whole answer, periodt ✨


🌈 KEYWORDS 🌈

center, fill, justification, string


and that's the page bestie!! this was the Tk_GetJustifyFromObj(3tk) man page, from the Tk Library Procedures, sitting at version 8.1, brought to you by Tk itself πŸ’– go justify some text, you absolute main character πŸ‘‘πŸ¦‹

πŸ“¦ where this page comes from