term::ansi::send(n)

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

πŸŽ€ term::ansi::send(n) β€” Terminal control πŸŽ€

okay bestie, come CLOSE. this is the manual page for term::ansi::send, which lives in the Terminal control section of the Tcl man pages. it's a Tcl package that yeets ANSI control sequences at your terminal, and honestly? it's giving keyboard wizard energy. πŸ’…

we're doing this in parts because it's LONG long, and this is part one. buckle up. πŸ¦‹


✨ NAME ✨

term::ansi::send β€” Output of ANSI control sequences to terminals

like. that's it. that's the whole job description. it sends ANSI control sequences to terminals. no cap. πŸ”₯


✨ SYNOPSIS ✨

first things first, the requirements, because you can't just walk in here without them:

package require Tcl 8.5 9

package require term::ansi::send ?0.2?

so you need Tcl 8.5 or 9, and the package itself, and the version is optional (?0.2? β€” the ?s mean "this bit is optional", not that it's confused, ok 😭).

then the actual commands. and there are a LOT of them. like, a concerning amount. let's go. 🫢

the import + the little guys

::term::ansi::send::import ?ns? ...

::term::ansi::send::eeol

::term::ansi::send::esol

::term::ansi::send::el

::term::ansi::send::ed

::term::ansi::send::eu

::term::ansi::send::es

::term::ansi::send::sd

::term::ansi::send::su

::term::ansi::send::ch

::term::ansi::send::sc

::term::ansi::send::rc

::term::ansi::send::sca

::term::ansi::send::rca

::term::ansi::send::st

::term::ansi::send::ct

::term::ansi::send::cat

::term::ansi::send::qdc

::term::ansi::send::qds

::term::ansi::send::qcp

::term::ansi::send::rd

::term::ansi::send::elw

::term::ansi::send::dlw

::term::ansi::send::eg

::term::ansi::send::lg

look at all those little two-and-three letter icons ✨ they're short, they're punchy, they're doing the most with the least. main character energy fr fr.

the tag + sda crew

::term::ansi::send::scs0 tag

::term::ansi::send::scs1 tag

::term::ansi::send::sda arg...

scs0 and scs1 both take a tag, and sda takes an arg... (that's a variable number of args, bestie, it's flexible like that πŸ’œ).

the sda_ family (yes, all of them, i counted)

::term::ansi::send::sda_fgblack

::term::ansi::send::sda_fgred

::term::ansi::send::sda_fggreen

::term::ansi::send::sda_fgyellow

::term::ansi::send::sda_fgblue

::term::ansi::send::sda_fgmagenta

::term::ansi::send::sda_fgcyan

::term::ansi::send::sda_fgwhite

::term::ansi::send::sda_fgdefault

::term::ansi::send::sda_bgblack

::term::ansi::send::sda_bgred

::term::ansi::send::sda_bggreen

::term::ansi::send::sda_bgyellow

::term::ansi::send::sda_bgblue

::term::ansi::send::sda_bgmagenta

::term::ansi::send::sda_bgcyan

::term::ansi::send::sda_bgwhite

::term::ansi::send::sda_bgdefault

::term::ansi::send::sda_bold

::term::ansi::send::sda_dim

::term::ansi::send::sda_italic

::term::ansi::send::sda_underline

::term::ansi::send::sda_blink

::term::ansi::send::sda_revers

::term::ansi::send::sda_hidden

::term::ansi::send::sda_strike

::term::ansi::send::sda_nobold

::term::ansi::send::sda_noitalic

::term::ansi::send::sda_nounderline

::term::ansi::send::sda_noblink

::term::ansi::send::sda_norevers

::term::ansi::send::sda_nohidden

::term::ansi::send::sda_nostrike

::term::ansi::send::sda_reset

foreground, background, bold, dim, italic, underline, blink, revers, hidden, strike β€” and then a whole set of no-versions to undo them, plus sda_reset. the way that this list just keeps going. πŸ’€ obsessed. note that it's revers, not reverse β€” that's not a typo, that's the actual name, don't @ me.

positioning + text + titles

::term::ansi::send::fcp row col

::term::ansi::send::cu ?n?

::term::ansi::send::cd ?n?

::term::ansi::send::cf ?n?

::term::ansi::send::cb ?n?

::term::ansi::send::ss ?s e?

::term::ansi::send::skd code str

::term::ansi::send::title str

fcp wants a row and a col. cu, cd, cf and cb all take an optional n. ss takes optional s and e. skd wants a code and a str. title takes a str. πŸ“

the rest of the roster

::term::ansi::send::gron

::term::ansi::send::groff

::term::ansi::send::tlc

::term::ansi::send::trc

::term::ansi::send::brc

::term::ansi::send::blc

::term::ansi::send::ltj

::term::ansi::send::ttj

::term::ansi::send::rtj

::term::ansi::send::btj

::term::ansi::send::fwj

::term::ansi::send::hl

::term::ansi::send::vl

::term::ansi::send::groptim str

::term::ansi::send::clear

::term::ansi::send::init

::term::ansi::send::showat row col text

and that's the full synopsis, every single command, nothing skipped, nothing merged, nothing invented. groptim takes a str, and showat takes row col text. the corner ones (tlc, trc, brc, blc) and the justify ones (ltj, ttj, rtj, btj, fwj) are all here too. ✨


okay that's part one, the synopsis. part two is where we get into what all of these actually DO, and bestie, there's a lot of tea to spill. πŸ«– stay tuned πŸ’–

✨ DESCRIPTION ✨

Okay bestie, listen UP, because this package is literally the glow-up your terminal has been waiting for. πŸ’…

This package provides commands to send ANSI terminal control sequences to a terminal. That's the whole vibe. All commands come in two variants:

  • one for sending to any channel
  • one for sending to stdout (the main character, obviously)

The commands are defined using the control sequences provided by the package term::ansi::code::ctrl. They have the same arguments as the commands they're based on β€” with one exception, the variant for sending to any channel. That variant's first argument is always a channel handle, then followed by the original arguments. 🫢

Below we list only the variant sending to stdout. (The channel one is just this, but with your channel handle up front, iykyk.)


🌸 The Commands 🌸

  • ::term::ansi::send::import ?ns? ... β€” Imports the commands of this package into the namespace ns. If not specified it defaults to send. Heads up though: this default is a relative namespace name, i.e. the actual namespace will be created under the current namespace. By default all commands will be imported, but you can restrict it to specific commands by listing them after the namespace to import them into. ✨

🧹 Erasing Things

  • ::term::ansi::send::eeol β€” Erase (to) End Of Line.
  • ::term::ansi::send::esol β€” Erase (to) Start Of Line.
  • ::term::ansi::send::el β€” Erase (current) Line.
  • ::term::ansi::send::ed β€” Erase Down (to bottom).
  • ::term::ansi::send::eu β€” Erase Up (to top).
  • ::term::ansi::send::es β€” Erase Screen.

πŸ“œ Scrolling

  • ::term::ansi::send::sd β€” Scroll Down.
  • ::term::ansi::send::su β€” Scroll Up.

🎯 Cursor Basics

  • ::term::ansi::send::ch β€” Cursor Home.
  • ::term::ansi::send::sc β€” Save Cursor. Note: Only one saved position can be handled. This is no unlimited stack. Saving before restoring will overwrite the saved data. 😭
  • ::term::ansi::send::rc β€” Restore Cursor (Unsave).
  • ::term::ansi::send::sca β€” Save Cursor + Attributes.
  • ::term::ansi::send::rca β€” Restore Cursor + Attributes.

πŸ“‘ Tabs

  • ::term::ansi::send::st β€” Set Tab (@ current position).
  • ::term::ansi::send::ct β€” Clear Tab (@ current position).
  • ::term::ansi::send::cat β€” Clear All Tabs.

πŸ” Queries & Device Stuff

  • ::term::ansi::send::qdc β€” Query Device Code.
  • ::term::ansi::send::qds β€” Query Device Status.
  • ::term::ansi::send::qcp β€” Query Cursor Position.
  • ::term::ansi::send::rd β€” Reset Device.
  • ::term::ansi::send::elw β€” Enable Line Wrap.
  • ::term::ansi::send::dlw β€” Disable Line Wrap.

🎨 Graphics Mode & Character Sets

  • ::term::ansi::send::eg β€” Enter Graphics Mode.
  • ::term::ansi::send::lg β€” Exit Graphics Mode.
  • ::term::ansi::send::scs0 tag
  • ::term::ansi::send::scs1 tag β€” Select Character Set.

Choose which character set is used for default (scs0) and alternate font (scs1). This does not change whether default or alternate font are used, just their definitions. πŸ‘‘

The legal tags, and their meanings, are:

  • A β€” United Kingdom Set
  • B β€” ASCII Set
  • 0 β€” Special Graphics
  • 1 β€” Alternate Character ROM Standard Character Set
  • 2 β€” Alternate Character ROM Special Graphics

πŸ’– Display Attributes

  • ::term::ansi::send::sda arg... β€” Set Display Attributes. The arguments are the code sequences for the possible attributes, as provided by the package term::ansi::code::attr. For convenience this package also provides additional commands, each setting a single specific attribute. πŸŽ€

🌈 Foreground Colours

  • ::term::ansi::send::sda_fgblack β€” Set text color to Black.
  • ::term::ansi::send::sda_fgred β€” Set text color to Red.
  • ::term::ansi::send::sda_fggreen β€” Set text color to Green.
  • ::term::ansi::send::sda_fgyellow β€” Set text color to Yellow.
  • ::term::ansi::send::sda_fgblue β€” Set text color to Blue.
  • ::term::ansi::send::sda_fgmagenta β€” Set text color to Magenta.
  • ::term::ansi::send::sda_fgcyan β€” Set text color to Cyan.
  • ::term::ansi::send::sda_fgwhite β€” Set text color to White.
  • ::term::ansi::send::sda_fgdefault β€” Set default text color (Black).

πŸ¦‹ Background Colours

  • ::term::ansi::send::sda_bgblack β€” Set background to Black.
  • ::term::ansi::send::sda_bgred β€” Set background to Red.
  • ::term::ansi::send::sda_bggreen β€” Set background to Green.
  • ::term::ansi::send::sda_bgyellow β€” Set background to Yellow.
  • ::term::ansi::send::sda_bgblue β€” Set background to Blue.
  • ::term::ansi::send::sda_bgmagenta β€” Set background to Magenta.
  • ::term::ansi::send::sda_bgcyan β€” Set background to Cyan.
  • ::term::ansi::send::sda_bgwhite β€” Set background to White.
  • ::term::ansi::send::sda_bgdefault β€” Set default background (Transparent).

✨ On & Off

  • ::term::ansi::send::sda_bold β€” Bold on.
  • ::term::ansi::send::sda_dim β€” Dim on.
  • ::term::ansi::send::sda_italic β€” Italics on.
  • ::term::ansi::send::sda_underline β€” Underscore on.
  • ::term::ansi::send::sda_blink β€” Blink on.
  • ::term::ansi::send::sda_revers β€” Reverse on.
  • ::term::ansi::send::sda_hidden β€” Hidden on.
  • ::term::ansi::send::sda_strike β€” Strike-through on.
  • ::term::ansi::send::sda_nobold β€” Bold off.
  • ::term::ansi::send::sda_noitalic β€” Italics off.
  • ::term::ansi::send::sda_nounderline β€” Underscore off.
  • ::term::ansi::send::sda_noblink β€” Blink off.
  • ::term::ansi::send::sda_norevers β€” Reverse off.
  • ::term::ansi::send::sda_nohidden β€” Hidden off.
  • ::term::ansi::send::sda_nostrike β€” Strike-through off.
  • ::term::ansi::send::sda_reset β€” Reset all attributes to their default values.

🧭 Moving The Cursor

  • ::term::ansi::send::fcp row col β€” Force Cursor Position (aka Go To).
  • ::term::ansi::send::cu ?n? β€” Cursor Up. n defaults to 1.
  • ::term::ansi::send::cd ?n? β€” Cursor Down. n defaults to 1.
  • ::term::ansi::send::cf ?n? β€” Cursor Forward. n defaults to 1.
  • ::term::ansi::send::cb ?n? β€” Cursor Backward. n defaults to 1.

πŸ–₯️ Screen & Keys

  • ::term::ansi::send::ss ?s e? β€” Scroll Screen (entire display, or between rows start end, inclusive).
  • ::term::ansi::send::skd code str β€” Set Key Definition.
  • ::term::ansi::send::title str β€” Set the terminal title.

πŸ“¦ Box Graphics, The Moment You've All Been Waiting For πŸ“¦

  • ::term::ansi::send::gron β€” Switch to character/box graphics. I.e. switch to the alternate font.
  • ::term::ansi::send::groff β€” Switch to regular characters. I.e. switch to the default font.
  • ::term::ansi::send::tlc β€” Character graphics, Top Left Corner.
  • ::term::ansi::send::trc β€” Character graphics, Top Right Corner.
  • ::term::ansi::send::brc β€” Character graphics, Bottom Right Corner.
  • ::term::ansi::send::blc β€” Character graphics, Bottom Left Corner.
  • ::term::ansi::send::ltj β€” Character graphics, Left T Junction.
  • ::term::ansi::send::ttj β€” Character graphics, Top T Junction.
  • ::term::ansi::send::rtj β€” Character graphics, Right T Junction.
  • ::term::ansi::send::btj β€” Character graphics, Bottom T Junction.
  • ::term::ansi::send::fwj β€” Character graphics, Four-Way Junction.
  • ::term::ansi::send::hl β€” Character graphics, Horizontal Line.
  • ::term::ansi::send::vl β€” Character graphics, Vertical Line.
  • ::term::ansi::send::groptim str β€” Optimize character graphics. The generator commands above create way too many superfluous commands shifting into and out of the graphics mode. (Not me calling them out 😭.) This command removes all shifts which are not needed. To this end it also knows which characters will look the same in both modes, to handle strings created outside of this package. 🧚

🏁 Odds & Ends

  • ::term::ansi::send::clear β€” Clear screen. In essence a sequence of CursorHome + EraseDown.
  • ::term::ansi::send::init β€” Initialize default and alternate fonts to ASCII and box graphics.
  • ::term::ansi::send::showat row col text β€” Show the block of text at the specified location.

πŸ’€ BUGS, IDEAS, FEEDBACK πŸ’€

This document, and the package it describes, will undoubtedly contain bugs and other problems. Like, obviously. πŸ™ˆ Please report such in the category term of the Tcllib Trackers at http://core.tcl.tk/tcllib/reportlist. Please also report any ideas for enhancements you may have for either package and/or documentation β€” we love ideas here. 🫢

When proposing code changes, please provide unified diffs, i.e the output of diff -u.

Note further that attachments are strongly preferred over inlined patches. Attachments can be made 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. No cap. ✨

πŸ”‘ KEYWORDS πŸ”‘

character output, control, terminal


πŸ—‚οΈ CATEGORY πŸ—‚οΈ

Terminal control


Copyright (c) 2006 Andreas Kupries <andreas_kupries@users.sourceforge.net>


And that's a wrap bestie!! πŸŽ€ This page is term::ansi::send(n) from tcllib, version 0.2 β€” go forth and make your terminal absolutely serve. Slay. πŸ’…βœ¨πŸŒˆ

πŸ“¦ where this page comes from