tkcon(1)

๐Ÿ’– tkcon(1) โ€” the Tk console glow-up ๐Ÿ’–

okay bestie, so this is tkcon, from the General Commands Manual section (that's section 1, iykyk โ€” the one for actual runnable commands ๐Ÿ‘‘). buckle up, she's a long one and she's iconic.


โœจ NAME โœจ

tkcon โ€” a Tk console replacement ๐ŸŽ€


๐ŸŒธ SYNOPSIS ๐ŸŒธ

tkcon [{option value | tcl_script} ...]

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

okay so, TkCon? she's a replacement for the standard console that ships with Tk. like, on Windows/Mac that default console exists, but also she works on Unix too, no cap. and honestly? the console itself gives you so many more features than the standard one, it's not even a comparison ๐Ÿ’….

TkCon works on every platform where Tcl/Tk is available โ€” literally all of them. and her whole purpose in life? she's meant primarily to help you out when you're working with all the little teeny tiny details inside Tcl and Tk. the way that Unix users finally get the GUI console that Mac and Windows Tk just... hands you by default? yeah. that's the vibe. main character energy fr fr ๐Ÿซถ

tkcon [{option value | tcl_script} ...]

๐Ÿ’… OPTIONS ๐Ÿ’…

so here's the thing bestie, with one exception: command line arguments get handled after the TkCon resource file is sourced, but before the slave interpreter or the TkCon user interface is initialized. so like, timing matters, noted ๐Ÿ“

the one exception is -rcfile โ€” she gets handled right before she would be sourced, so you can specify any alternate file you want. queen behavior honestly ๐Ÿ‘‘

and lowkey important: command line arguments get passed to each new console and will be evaluated by each one of them. like, every single one. so if you don't want that happening, you have to say:

tkcon main set argv {}; tkcon main set argc 0

and for all these options? any unique substring is allowed. abbreviate away bestie โœจ

  • -argv (also --) โ€” makes TkCon stop evaluating arguments and set the remaining args to be argv/argc (with -- prepended). and this carries over for any further consoles. this one is meant only for wrapping TkCon around programs that require their own arguments. niche but essential ๐ŸŽ€
  • -color-<color> color โ€” sets the requested color type to the specified color for tkcon. for the recognized <color> names, go peek at tkconrc(5) ๐ŸŒˆ
  • -eval tcl_script (also -main or -e) โ€” a Tcl script to eval in each main interpreter. this gets evaluated after the resource file is loaded and the slave interpreter is created. and yes, multiple -eval switches will be recognized, in order ๐Ÿ‘‘
  • -exec slavename โ€” sets the named slave that tkcon operates in. in general this is only useful if you set it to "" (empty), which tells tkcon to avoid the multi-interpreter model entirely and just operate in the main environment. when it's empty, any further arguments will only be used in the first tkcon console and not passed onto further new consoles. super useful when you're using tkcon as a console for extended wish executables that don't load their commands into slave interpreters ๐Ÿซถ
  • -font font โ€” sets the font that tkcon uses for its text windows. and if this isn't a fixed width font? tkcon will override it. she has standards ๐Ÿ’…
  • -nontcl TCL_BOOLEAN โ€” sets ::tkcon::OPT(nontcl) to TCL_BOOLEAN (see tkconrc(5)). you need this when attaching to non-Tcl interpreters ๐Ÿ‘€
  • -package package_name (also -load) โ€” packages to automatically load into the slave interpreters (i.e. "Tk") ๐Ÿ“
  • -rcfile filename โ€” specify an alternate tkcon resource file name ๐ŸŒธ
  • -root widgetname โ€” makes the named widget the root name of all consoles (i.e. .tkcon) ๐Ÿ‘‘
  • -slave tcl_script โ€” a Tcl script to eval in each slave interpreter. this will append the one specified in the tkcon resource file, if any ๐Ÿ“Ž

๐ŸŽ€ KEY BINDINGS ๐ŸŽ€

okay so most of these bindings are the same as for the text widget, periodt. but some have been modified to make sure the integrity of the console is maintained (she's protective of herself, respect it ๐Ÿ’…). others got added just to make the console more useful. only the modified or new bindings are listed here, so don't come for me about the ones that aren't mentioned ๐Ÿ™ˆ

  • Control-x or Cut (on Sparc5 keyboards) โ€” Cut โœ‚๏ธ
  • Control-c or Copy (on Sparc5 keyboards) โ€” Copy ๐Ÿ“‹
  • Control-v or Paste (on Sparc5 keyboards) โ€” Paste ๐Ÿ“ฅ
  • Insert โ€” Insert. (duh.) ๐Ÿ™„
  • Up โ€” goes up one level in the commands line history when the cursor is on the prompt line, otherwise it moves through the buffer โฌ†๏ธ
  • Down โ€” goes down one level in the commands line history when the cursor is on the last line of the buffer, otherwise it moves through the buffer โฌ‡๏ธ
  • Control-p โ€” goes up one level in the commands line history ๐Ÿ”ผ
  • Control-n โ€” goes down one level in the commands line history ๐Ÿ”ฝ
  • Tab โ€” tries to expand file path names, then variable names, then proc names. she's thorough ๐Ÿ’…
  • Escape โ€” tries to expand file path names ๐Ÿ“
  • Control-P โ€” tries to expand procedure names. the procedure names will be those that are actually in the attached interpreter (unless nontcl is specified, in which case it always does the lookup in the default slave interpreter) ๐Ÿ‘‘
  • Control-V โ€” tries to expand variable names (those returned by [info vars]). its search behavior is like that for procedure names ๐Ÿ”
  • Return or Enter โ€” evaluates the current command line if it's a complete command, otherwise it just goes to a new line. she's not gonna run your half-finished nonsense bestie ๐Ÿ’€
  • Control-a โ€” go to the beginning of the current command line โฎ๏ธ
  • Control-l โ€” clear the entire console buffer ๐Ÿงน
  • Control-r โ€” searches backwards in the history for any command that contains the string in the current command line. repeatable to search farther back. and the matching substring of the found command will blink โœจ
  • Control-s โ€” as above, but searches forward (only useful if you searched too far back, oops ๐Ÿ™ˆ)
  • Control-t โ€” transposes characters ๐Ÿ”„
  • Control-u โ€” clears the current command line ๐Ÿงผ
  • Control-z โ€” saves the current command line in a buffer that can be retrieved with another Control-z. if the current command line is empty, then any saved command is retrieved without being overwritten. otherwise? the current contents get swapped with what's in the saved command buffer. it's giving clipboard but make it mysterious ๐ŸŽ€
  • Control-Key-1 โ€” attaches console to the console's slave interpreter 1๏ธโƒฃ
  • Control-Key-2 โ€” attaches console to the console's master interpreter 2๏ธโƒฃ
  • Control-Key-3 โ€” attaches console to main TkCon interpreter 3๏ธโƒฃ
  • Control-A โ€” pops up the "About" dialog ๐Ÿซถ
  • Control-N โ€” creates a new console. each console has separate state, including its own widget hierarchy (it's a slave interpreter) ๐Ÿ‘‘
  • Control-q โ€” close the current console OR quit the program (depends on the value of ::tkcon::TKCON(slaveexit)) ๐Ÿค”
  • Control-w โ€” closes the current console. closing the main console will exit the program (something has to control all the slaves...) ๐Ÿ’€

TkCon also has electric bracing (similar to that in emacs, bestie, we love a crossover). she'll highlight matching pairs of {}'s, []'s, ()'s and ""'s โœจ

for the first three โ€” if there's no matching left element for the right, then it blinks the entire current command line. for the double quote? if there's no proper match then it just blinks the current double quote character. and yes she does properly recognize most escaping (except escaped escapes ๐Ÿ˜ญ), but she does not look for commenting. and honestly? why would you interactively put comments in? exactly. no notes ๐Ÿ’…

๐Ÿ’ซ COMMANDS ๐Ÿ’ซ

ok bestie so TkCon introduces a bunch of brand-new procedures to make you more productive and/or to bring back functionality that you're used to from native environments but that Tcl lowkey lost. There are also a few redefined procedures in the mix. Here's a non-comprehensive list โ€” meaning it's giving highlights, not the whole syllabus:

  • alias ?sourceCmd targetCmd ?arg arg ...?? โ€” the simple alias mechanism, fr fr. Heads up: it will overwrite existing commands, no hesitation, no apology ๐Ÿ’€. Call it with no args and it hands you the current aliases. Also note that TkCon makes some aliases for you (in slaves) โ€” do not delete those ones, bestie, they're load-bearing.
  • clear ?percentage? โ€” clears the text widget. Same energy as the <Control-l> binding, except this one lets you pass a percentage of the buffer to clear (1-100, and 100 is the default). Partial clear, iconic behavior โœจ
  • dir ?-all? ?-full? ?-long? ?pattern pattern ...? โ€” the cheap-and-cheerful way to get directory listings. Uses glob style pattern matching. No cap.
  • dump type ?-nocomplain? ?-filter pattern? ?--? pattern ?pattern ...? โ€” lets you spit out state information about the interpreter in a form that's both Tcl readable and human readable. Obsessed. See dump(3tk) for the details.
  • echo ?arg arg ...? โ€” concatenates the args and spits the result straight to the console (stdout). Simple. Clean. Slays.
  • edit ?-type type? ?-find str? ?-attach interp? arg โ€” opens an editor with the data from arg. The optional type argument can be one of: proc, var or file. For proc or var, arg may be a pattern. Chef's kiss ๐ŸŽ€
  • idebug command ?args? โ€” interactive debugging command. See idebug(3tk) for details.
  • lremove ?-all? ?-regexp -glob? list items โ€” removes one or more items from a list and returns the new list. Specify -all and it removes all instances of each item in the list. Specify -regexp or -glob and it interprets each item in the items list as a regexp or glob pattern to match against. Pattern matching? We love to see it ๐Ÿ’…
  • less โ€” aliased to edit.
  • ls โ€” aliased to dir -full.
  • more โ€” aliased to edit.
  • observe type ?args? โ€” gives you passive runtime debugging output for variables and commands. See observe(3tk) for details.
  • puts (same options as always) โ€” redefined so the output goes into TkCon instead. Same options as always, bestie, no surprises there.
  • tkcon method ?args? โ€” the multi-purpose command. See tkcon(3tk) for details.
  • tclindex โ€” convenience proc to update the "tclIndex" file (controlled by the -index switch) and/or the "pkgIndex.tcl" file (controlled by the -package switch) in the named directories, based on the given pattern for files. Full signature:
tclindex ?-extensions patternlist? ?-index TCL_BOOLEAN? ?-package TCL_BOOLEAN? ?dir1 dir2 ...?

It defaults to creating the "tclIndex" but not the "pkgIndex.tcl" file, with the directory defaulting to [pwd]. The extension defaults to *.tcl, with *.[info sharelibextension] added when -package is true.

  • unalias cmd โ€” unaliases command. Bye bestie ๐Ÿ‘‹
  • what string โ€” the what command identifies the word given in string in the Tcl environment and returns a list of types that it was recognized as. Possible types are: alias, procedure, command, array variable, scalar variable, directory, file, widget, and executable. It's used by the procedures dump and which. Detective energy ๐Ÿ”
  • which command โ€” like the which command of Unix shells, this tells you if a particular command is known, and if so, whether it's internal or external to the interpreter. If it's an internal command and there's a slot in auto_index for it, it tells you the file that auto_index would load. Now, this does not necessarily mean that that's where the file came from โ€” but if it weren't in the interpreter previously, then that's where the command was found. Semantics matter, iykyk.

There are also several procedures that I use as helpers that some of you may find helpful in your coding (i.e. expanding pathnames). Feel free to lift them from the code โ€” but do assign proper attribution, please and thank you ๐Ÿซถ


๐ŸŒˆ EXAMLPES ๐ŸŒˆ

(yes that's the spelling, we keep it, it's part of the lore ๐Ÿ’€)

Some examples of tkcon command line startup situations, because a vibe check in code form is helpful:

megawish /usr/bin/tkcon -exec "" -root .tkcon mainfile.tcl

Use tkcon as a console for your megawish application. You can avoid starting the line with megawish if that is the default wish that TkCon would use. The -root ensures that tkcon will not conflict with the application root window.

tkcon -font "Courier 12" -load Tk

Use the courier font for TkCon and always load Tk in slave interpreters at startup.

tkcon -rcfile ~/.wishrc -color-bg white

Use the ~/.wishrc file as the resource file, and a white background for TkCon's text widgets.


๐Ÿ“ FILES ๐Ÿ“

TkCon will search for a resource file in "~/.tkconrc".

TkCon never sources the "~/.wishrc" file. Periodt.

The resource file is sourced by each new instance of the console. An example resource file is provided in tkconrc(5).


๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

dump(3tk), idebug(3tk), observe(3tk), text(3tk), tkcon(3tk), tkconrc(5)


๐Ÿ”‘ KEYWORDS ๐Ÿ”‘

Tk, console


Copyright (c) Jeffrey Hobbs (jeff at hobbs.org)


and that's a wrap, bestie ๐Ÿ’– that was TkCon, version 2.5, section tkcon(1) โ€” go forth and console responsibly, you absolute icon ๐Ÿฆ‹โœจ

๐Ÿ“ฆ where this page comes from