term::receive(n)
β¨ term::receive(n) β Terminal control β¨
okay bestie, welcome to term::receive(n), the manual page for the term::receive package π it lives in the Terminal control category and it's literally the most baby-steps, most primitive way to get characters off a terminal. think of it as a cute lil convenience wrapper situation around the builtin read and fileevent commands π
πΈ 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?
like yes, that's the whole vibe β¨
π DESCRIPTION π
so this package hands you the most primitive commands for receiving characters from a terminal. that's it, that's the job. they're basically convenient lil wrappers around the builtin read and fileevent commands β no cap π«Ά
::term::receive::getch ?chan?β this one reads a single character from the channel with handle chan and returns it as the result of the command π«
if you don't specify chan, it defaults to stdin β iconic behaviour honestly π
β οΈ bestie, listen: it is the responsibility of the caller to make sure the channel can actually provide single characters. on unix you can do that, for example, by using the command from the package term::ansi::ctrl::unix. don't skip this step, it's giving undefined-chaos otherwise π
::term::receive::listen cmd ?chan?β this one sets up a filevent listener for the channel with handle chan and invokes the command prefix cmd whenever characters have been received, or EOF was reached π
if you don't specify chan, it defaults to stdin again π
the signature of that command prefix is:
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're listening on. and it will be the last call to be received by the callback. the final goodbye, the closing credits, periodt π
::term::receive::unlisten ?chan?β this one disables the filevent listener for the channel with handle chan π¦
and yeah, if you don't specify chan, defaults to stdin. the classic π
π BUGS, IDEAS, FEEDBACK π
ngl, this document β and the package it describes β will undoubtedly contain bugs and other problems. that's just how it is, we're all human π please report such things in the category term of the Tcllib Trackers at http://core.tcl.tk/tcllib/reportlist. and please also report any ideas for enhancements you may have for either the package and/or the documentation β we love ideas here π«Ά
when you're proposing code changes, please provide unified diffs, i.e the output of diff -u. no vibes-based patches, bestie π
also note further that attachments are strongly preferred over inlined patches. you can make attachments 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. iykyk β¨
π KEYWORDS π
character input, control, get character, listener, receiver, terminal
π CATEGORY π
Terminal control
π COPYRIGHT π
Copyright (c) 2006 Andreas Kupries <andreas_kupries@users.sourceforge.net>
okay that's the whole page, you ate that πβ¨ this was tcllib version 0.2 of term::receive(n) β go forth and receive some characters, bestie, you got this π
πΈ
π¦ where this page comes from
- fedora 43: tcllib 2.0-3.fc43 Β· TCL
- fedora 44: tcllib 2.0-4.fc44 Β· TCL
- nixos 26.05: tcllib 2.0
- nixpkgs unstable: tcllib 2.0
- 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