term::receive(3tcl)
π term::receive β the manual page, but make it cute π
okay bestie, so this is term::receive from the Terminal control corner of the tcllib universe, and it's literally the most primitive way to get characters off a terminal. no cap. sit down, hydrate, let's go π
β¨ NAME β¨
term::receive β general input from terminals π
πΈ SYNOPSIS πΈ
package require Tcl 8.5 9
package require term::receive ?0.2?
::term::receive::getch ?chan?
::term::receive::listen cmd ?chan?
cmd process string
cmd eof
::term::receive::unlisten ?chan?
π¦ DESCRIPTION π¦
so this package hands you the most primitive commands for receiving characters from a terminal. that's the whole vibe. and honestly? they're basically just convenient little wrappers around the builtin commands read and fileevent. nothing more, nothing less, and that's on periodt π
::term::receive::getch ?chan?β bestie this one reads a single character off the channel with handle chan and returns it as the result of the command. π«Ά
if you don't specify chan, it defaults to stdin. easy.
heads up queen: it is the responsibility of the caller to make sure the channel can actually provide single characters. on unix you can make that happen, for example, by using the command from the package term::ansi::ctrl::unix. don't skip that step, i'm begging π
::term::receive::listen cmd ?chan?β this one sets up a filevent listener for the channel with handle chan, and it invokes the command prefix cmd whenever characters have been received, or when EOF was reached. iconic behaviour fr fr β¨
if you don't specify chan, it defaults to stdin. again, easy.
the signature of the command prefix is literally this, memorise it iykyk:
cmd process string
- this method gets invoked when characters were received, and string holds them for processing. π
cmd eof
- this method gets invoked when EOF was reached on the channel we listen on. it will be the last call your callback ever receives. last one, no encore π
::term::receive::unlisten ?chan?β this one disables the filevent listener for the channel with handle chan. bye bye listener π
if you don't specify chan, it defaults to stdin. yes, same deal as always.
π BUGS, IDEAS, FEEDBACK π
ngl, this document and the package it describes will undoubtedly contain bugs and other problems. like, obviously. please report those in the category term of the Tcllib Trackers at http://core.tcl.tk/tcllib/reportlist. and if you've got ideas for enhancements for either the package and/or the documentation? send those too, we want them π
when you're proposing code changes, please provide unified diffs, i.e. the output of diff -u. don't be mysterious about it β¨
also note further that attachments are strongly preferred over inlined patches. you can make an attachment by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. slay π
β KEYWORDS β
character input, control, get character, listener, receiver, terminal
π CATEGORY π
Terminal control
π COPYRIGHT π
Copyright (c) 2006 Andreas Kupries <andreas_kupries@users.sourceforge.net>
and that's the whole page bestie, we ate and left no crumbs π the source is tcllib, version 0.2, and this whole vibe is dated term::receive(3tcl). mwah, go write some terminal code π¦β¨
π¦ where this page comes from
- debian trixie: tcllib 2.0+dfsg-4 Β· Tcl
- ubuntu questing: tcllib 2.0+dfsg-4
- ubuntu resolute: tcllib 2.0+dfsg-5 Β· Tcl
- ubuntu stonking: tcllib 2.0+dfsg-6 Β· Tcl
- Copyright (c) 2006 Andreas Kupries <andreas_kupries@users\&.sourceforge\&.net>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms