term::receive(n)

πŸ“¦
version 2.0 Β· 2 versions
, in fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

✨ 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 (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