Tk_GetJustifyFromObj(3)

πŸ’… Tk_GetJustifyFromObj, Tk_GetJustify, Tk_NameOfJustify β€” Tk Library Procedures, justification translation, bestie edition ✨

okay so we're in the Tk Library Procedures manual, page Tk_GetJustifyFromObj(3), and these three functions are literally the glow-up translators between strings and justification styles. The way that they keep your text alignment from being a whole mess? iconic. πŸŽ€

πŸ’– NAME πŸ’–

Tk_GetJustifyFromObj, Tk_GetJustify, Tk_NameOfJustify β€” translate between strings and justification styles. That's the whole assignment, no cap.

✨ 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 used for error reporting, or NULL.
  • Tcl_Obj *objPtr (in/out) β€” its string value holds the name of a justification style β€” one of "left", "right", or "center" β€” or a unique abbreviation of one. The internal rep will be modified to cache the corresponding justify value.
  • const char *string (in) β€” same as objPtr, except the description of the justification style is passed as a string.
  • int *justifyPtr (out) β€” pointer to the location in which to store the justify value corresponding to objPtr or string.
  • Tk_Justify justify (in) β€” justification style (one of the values listed below).

πŸ¦‹ DESCRIPTION πŸ¦‹

Tk_GetJustifyFromObj places in *justifyPtr the justify value corresponding to objPtr's value. This value will be one of the following:

  • TK_JUSTIFY_LEFT β€” means that the text on each line should start at the left edge of the line; as a result, the right edges of lines may be ragged.
  • TK_JUSTIFY_RIGHT β€” means that the text on each line should end at the right edge of the line; as a result, the left edges of lines may be ragged.
  • TK_JUSTIFY_CENTER β€” means that the text on each line should be centered; as a result, both the left and right edges of lines may be ragged.

Under normal circumstances the return value is TCL_OK and interp is unused. If objPtr does not contain a valid justification style or an abbreviation of one of these names, TCL_ERROR is returned, *justifyPtr is unmodified, and an error message is stored in interp's result if interp is not NULL. Tk_GetJustifyFromObj caches information about the return value in objPtr, which speeds up future calls to Tk_GetJustifyFromObj with the same objPtr.

Tk_GetJustify is identical to Tk_GetJustifyFromObj except that the description of the justification is specified with a string instead of an object. This prevents Tk_GetJustify from caching the return value, so Tk_GetJustify is less efficient than Tk_GetJustifyFromObj.

Tk_NameOfJustify is the logical inverse of Tk_GetJustify. Given a justify value it returns a statically-allocated string corresponding to justify. If justify is not a legal justify value, then unknown justification style is returned.

πŸ”‘ KEYWORDS πŸ”‘

center, fill, justification, string


xoxo, signing off from the Tk 8.1 source/version stamp and the Tk_GetJustifyFromObj(3) page tag β€” the footer has no date field, so I'm not inventing one, bestie. periodt. πŸ’…

πŸ“¦ where this page comes from