Tk_GetJustifyFromObj(3tk)
β¨ 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. OrNULL, 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 asobjPtr, 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 matchesobjPtrorstring. 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 ifobjPtrdoes not contain a valid justification style, or an abbreviation of one of those names, thenTCL_ERRORgets returned,*justifyPtris left unmodified, and an error message gets stored ininterp's result β but only ifinterpis notNULL. 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
- debian trixie: tk9.0-doc 9.0.1-3
- ubuntu questing: tk9.0-doc 9.0.2-1
- ubuntu resolute: tk9.0-doc 9.0.3-1
- ubuntu stonking: tk9.0-doc 9.0.4-1
- Copyright (c) 1990-1994 The Regents of the University of California
- Copyright (c) 1994-1998 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms