TclXInit(TCL)

πŸ“¦ version 8.4.0, in fedora 43, fedora 44

πŸ’… TclXInit β€” Extended Tcl initialization πŸ’…

okay bestie, so this is the manual page for TclXInit(TCL) β€” yeah, it lives in the TCL manual section. Sit down, grab a boba, we're learning how Extended Tcl boots up. 🧚✨


🌸 NAME 🌸

Tclx_Init, Tclxcmd_Init, TclX_Main, Tkx_Init, TkX_Main β€” Extended Tcl initialization. that's the whole vibe, that's the assignment. πŸ’–


✨ SYNOPSIS ✨

-ltclx -ltcl

#include "tclExtend.h"

int
Tclx_Init (Tcl_Interp *interp);

int
Tclxcmd_Init (Tcl_Interp *interp);

int
void
TclX_Main (int               argc,
           char            **argv,
           Tcl_AppInitProc  *appInitProc);

int
Tkx_Init (Tcl_Interp *interp);

void
TkX_Main (int               argc,
          char            **argv,
          Tcl_AppInitProc  *appInitProc);

void
TclX_SetAppInfo (int   defaultValues,
                 char *appName,
                 char *appLongName,
                 char *appVersion,
                 int   appPatchlevel);

πŸ‘‘ DESCRIPTION πŸ‘‘

so these functions are literally the whole "how do I turn on Extended Tcl" situation, plus how you build an entire app on top of Extended Tcl. this page also gets into the ~lore~ of how you'd wedge TclX into some other application. ngl it's a lot. let's go. 🫢

πŸŽ€ Tclx_Init

boots up Extended Tcl and drops the extended command set right into the interpreter. this gets called from Tcl_AppInit. heads up bestie: this one must be called after the Tcl_Init function. it's giving "order matters."

and not just the standard command set either β€” it also switches on use of tlib packages libraries and makes the standard TclX library available. slay. πŸ’…

Parameters

  • interp β€” a pointer to the interpreter to add the commands to.

Returns:

  • TCL_OK if all is ok, TCL_ERROR if an error occurred.

πŸŽ€ Tclxcmd_Init

adds the TclX command set to the interpreter β€” but with the exception of the TclX library management commands. so like, everything except that one part. this is normally called by Tclx_Init, and you should really only reach for it yourself if you do not want the TclX library handling. ikykyk. πŸ™ˆ

Parameters

  • interp β€” a pointer to the interpreter to add the commands to.

Returns:

  • TCL_OK if all is ok, TCL_ERROR if an error occurred.

πŸŽ€ TclX_Main

this one parses the command line according to the TclX shell specification (that's the Unix-shell-compatible one, bestie, so your muscle memory still works). it creates an interpreter, then calls the function you handed it β€” appInitProc β€” to initialize any application-specific commands.

after that? it either evaluates the command or script you specified on the command line, or it drops you into an interactive command loop. cute.

⚠️ this procedure never returns β€” it exits the process when it's done. no coming back, no "see you later," it just leaves. πŸ’€

bonus: using the TclX shell also gives you SIGINT handling in interactive shells. that's the little treat. πŸ”₯

πŸŽ€ Tkx_Init

initializes the Extended Tcl Tk environment. this gets called from Tcl_AppInit, after the Tk_Init function. again: order. matters. πŸŽ€

Parameters

  • interp β€” a pointer to the interpreter to add the commands to.

Returns:

  • TCL_OK if all is ok, TCL_ERROR if an error occurred.

πŸŽ€ TkX_Main

parses the command line according to the wish shell specification. creates an interpreter, calls the function you gave it β€” appInitProc β€” to initialize any application-specific commands, and then either evaluates the command or script from the command line, or enters an interactive command loop.

⚠️ same deal as its sibling: this procedure never returns. it exits the process when it's done. periodt.

using the TclX wish shell gets you SIGINT handling in interactive shells β€” and other than that, it is identical to standard wish. no notes. ⭐

πŸŽ€ TclX_SetAppInfo

stores the application information that infox returns. πŸ“

Parameters

  • defaultValues β€” if true, then the values are assigned only if they are not already defined (defaulted). if false, the values are always set.
  • appName β€” application symbolic name.
  • appLongName β€” long, natural language application name.
  • appVersion β€” version number of the application.
  • appPatchlevel β€” patch level of the application. if less than zero, don't change it.
πŸ’€ bestie, listen: string pointers are saved without copying β€” so don't release that memory, fr fr. and if the arguments are NULL, don't change the values. that's it, that's the rule.

πŸ¦‹ DYNAMIC LOADING OF TCLX πŸ¦‹

TclX can be dynamically loaded on systems that support shared libraries and the load command. you can do this with either load or the package require commands, your call. ✨

if you're going the package require route, a pkgIndex,tcl must be constructed. important: pkg_mkIndex does not generate a pkgIndex.tcl file that works with TclX. nope. not it.

instead, a command similar to this one

package ifneeded Tclx 7.5.0 "load $dir/libtclx.so"

should be placed in the directory containing the TclX shared library. πŸ’…

a prototype pkgIndex,tcl file is build by TclX and is installed in the run time directory under the name pkgIndex,proto. this file can't be used as-is β€” you gotta rename and copy it, or combine it with an existing pkgIndex,tcl in the directory containing the shared library. πŸŽ€

and bestie? there is no need to dynamically load libtkx.so, since it only contains support for wishx. save yourself the trouble. πŸ’–


🌈 INTEGRATING TCLX WITH OTHER EXTENSIONS AND APPLICATIONS 🌈

the main aspects to integrating TclX with into an application is to decide if the application is based on the standard Tcl/Tk shells or the TclX shells. that's the fork in the road, the vibe check, the whole thing. 🧚

if you want the standard shells? easy. all that is necessary is to call Tclx_Init after Tcl_Init and Tkx_Init after Tk_Init. this functionality may also be dynamically loaded. done and dusted. ✨

to get the TclX shell in a Tcl-only application, with the tcl command functionality, call TclX_Main from the main function instead of Tcl_Main. this shell has arguments conforming to other Unix shells, plus SIGINT signal handling when interactive. 🫢

to get the Tclx shell in a Tk application, with the wishx command functionality, call TkX_Main from the main function instead of Tk_Main. this shell has SIGINT signal handling when interactive. and that's the tea. β˜•


πŸ’Œ okay that's the whole page!! this came to you from the Tcl manual, and it's the TclXInit(TCL) page β€” no date on it, she's timeless like that. mwah, go write something iconic bestie πŸ’…πŸ’–βœ¨
πŸ“¦ where this page comes from