---
name: "ansi_cctrl"
section: "3tcl"
platform: "linux"
package: "tcllib"
version: "2.0+dfsg-4"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/ansi_cctrl"
---

# ansi\_cctrl(3tcl)

ANSI control sequences

```

```

## NAME

term::ansi::code::ctrl - ANSI control sequences

## SYNOPSIS

package require **Tcl 8.5 9**

package require **term::ansi::code ?0.2?**

package require **term::ansi::code::ctrl ?0.3?**

**::term::ansi::code::ctrl::names**

**::term::ansi::code::ctrl::import** ?*ns*? ?*arg*...?

**::term::ansi::code::ctrl::eeol**

**::term::ansi::code::ctrl::esol**

**::term::ansi::code::ctrl::el**

**::term::ansi::code::ctrl::ed**

**::term::ansi::code::ctrl::eu**

**::term::ansi::code::ctrl::es**

**::term::ansi::code::ctrl::sd**

**::term::ansi::code::ctrl::su**

**::term::ansi::code::ctrl::ch**

**::term::ansi::code::ctrl::sc**

**::term::ansi::code::ctrl::rc**

**::term::ansi::code::ctrl::sca**

**::term::ansi::code::ctrl::rca**

**::term::ansi::code::ctrl::st**

**::term::ansi::code::ctrl::ct**

**::term::ansi::code::ctrl::cat**

**::term::ansi::code::ctrl::qdc**

**::term::ansi::code::ctrl::qds**

**::term::ansi::code::ctrl::qcp**

**::term::ansi::code::ctrl::rd**

**::term::ansi::code::ctrl::elw**

**::term::ansi::code::ctrl::dlw**

**::term::ansi::code::ctrl::eg**

**::term::ansi::code::ctrl::lg**

**::term::ansi::code::ctrl::scs0** *tag*

**::term::ansi::code::ctrl::scs1** *tag*

**::term::ansi::code::ctrl::sda** *arg*...

**::term::ansi::code::ctrl::sda\_fgblack**

**::term::ansi::code::ctrl::sda\_fgred**

**::term::ansi::code::ctrl::sda\_fggreen**

**::term::ansi::code::ctrl::sda\_fgyellow**

**::term::ansi::code::ctrl::sda\_fgblue**

**::term::ansi::code::ctrl::sda\_fgmagenta**

**::term::ansi::code::ctrl::sda\_fgcyan**

**::term::ansi::code::ctrl::sda\_fgwhite**

**::term::ansi::code::ctrl::sda\_fgdefault**

**::term::ansi::code::ctrl::sda\_bgblack**

**::term::ansi::code::ctrl::sda\_bgred**

**::term::ansi::code::ctrl::sda\_bggreen**

**::term::ansi::code::ctrl::sda\_bgyellow**

**::term::ansi::code::ctrl::sda\_bgblue**

**::term::ansi::code::ctrl::sda\_bgmagenta**

**::term::ansi::code::ctrl::sda\_bgcyan**

**::term::ansi::code::ctrl::sda\_bgwhite**

**::term::ansi::code::ctrl::sda\_bgdefault**

**::term::ansi::code::ctrl::sda\_bold**

**::term::ansi::code::ctrl::sda\_dim**

**::term::ansi::code::ctrl::sda\_italic**

**::term::ansi::code::ctrl::sda\_underline**

**::term::ansi::code::ctrl::sda\_blink**

**::term::ansi::code::ctrl::sda\_revers**

**::term::ansi::code::ctrl::sda\_hidden**

**::term::ansi::code::ctrl::sda\_strike**

**::term::ansi::code::ctrl::sda\_nobold**

**::term::ansi::code::ctrl::sda\_noitalic**

**::term::ansi::code::ctrl::sda\_nounderline**

**::term::ansi::code::ctrl::sda\_noblink**

**::term::ansi::code::ctrl::sda\_norevers**

**::term::ansi::code::ctrl::sda\_nohidden**

**::term::ansi::code::ctrl::sda\_nostrike**

**::term::ansi::code::ctrl::sda\_reset**

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

**::term::ansi::code::ctrl::cu** ?*n*?

**::term::ansi::code::ctrl::cd** ?*n*?

**::term::ansi::code::ctrl::cf** ?*n*?

**::term::ansi::code::ctrl::cb** ?*n*?

**::term::ansi::code::ctrl::ss** ?*s* *e*?

**::term::ansi::code::ctrl::skd** *code* *str*

**::term::ansi::code::ctrl::title** *str*

**::term::ansi::code::ctrl::gron**

**::term::ansi::code::ctrl::groff**

**::term::ansi::code::ctrl::tlc**

**::term::ansi::code::ctrl::trc**

**::term::ansi::code::ctrl::brc**

**::term::ansi::code::ctrl::blc**

**::term::ansi::code::ctrl::ltj**

**::term::ansi::code::ctrl::ttj**

**::term::ansi::code::ctrl::rtj**

**::term::ansi::code::ctrl::btj**

**::term::ansi::code::ctrl::fwj**

**::term::ansi::code::ctrl::hl**

**::term::ansi::code::ctrl::vl**

**::term::ansi::code::ctrl::groptim** *str*

**::term::ansi::code::ctrl::clear**

**::term::ansi::code::ctrl::init**

**::term::ansi::code::ctrl::showat** *row* *col* *text*

```

```

## DESCRIPTION

This package provides symbolic names for the ANSI control sequences. For each sequence a single command is provided which returns the sequence as its result. None of the commands of this package write to a channel; that is handled by higher level packages, like **term::ansi::send**.

## API

### INTROSPECTION

- **::term::ansi::code::ctrl::names**

  This command is for introspection. It returns as its result a list containing the names of all attribute commands.

- **::term::ansi::code::ctrl::import** ?*ns*? ?*arg*...?

  This command imports some or all attribute commands into the namespace *ns*. This is by default the namespace *ctrl*. Note that this is relative namespace name, placing the imported command into a child of the current namespace. By default all commands are imported, this can howver be restricted by listing the names of the wanted commands after the namespace argument.

### SEQUENCES

- **::term::ansi::code::ctrl::eeol**

  Erase (to) End Of Line

- **::term::ansi::code::ctrl::esol**

  Erase (to) Start Of Line

- **::term::ansi::code::ctrl::el**

  Erase (current) Line

- **::term::ansi::code::ctrl::ed**

  Erase Down (to bottom)

- **::term::ansi::code::ctrl::eu**

  Erase Up (to top)

- **::term::ansi::code::ctrl::es**

  Erase Screen

- **::term::ansi::code::ctrl::sd**

  Scroll Down

- **::term::ansi::code::ctrl::su**

  Scroll Up

- **::term::ansi::code::ctrl::ch**

  Cursor Home

- **::term::ansi::code::ctrl::sc**

  Save Cursor

- **::term::ansi::code::ctrl::rc**

  Restore Cursor (Unsave)

- **::term::ansi::code::ctrl::sca**

  Save Cursor + Attributes

- **::term::ansi::code::ctrl::rca**

  Restore Cursor + Attributes

- **::term::ansi::code::ctrl::st**

  Set Tab (@ current position)

- **::term::ansi::code::ctrl::ct**

  Clear Tab (@ current position)

- **::term::ansi::code::ctrl::cat**

  Clear All Tabs

- **::term::ansi::code::ctrl::qdc**

  Query Device Code

- **::term::ansi::code::ctrl::qds**

  Query Device Status

- **::term::ansi::code::ctrl::qcp**

  Query Cursor Position

- **::term::ansi::code::ctrl::rd**

  Reset Device

- **::term::ansi::code::ctrl::elw**

  Enable Line Wrap

- **::term::ansi::code::ctrl::dlw**

  Disable Line Wrap

- **::term::ansi::code::ctrl::eg**

  Enter Graphics Mode

- **::term::ansi::code::ctrl::lg**

  Exit Graphics Mode

- **::term::ansi::code::ctrl::scs0** *tag*

  Set default character set

- **::term::ansi::code::ctrl::scs1** *tag*

  Set alternate character set Select Character Set.

  Choose which character set is used for either default (scs0) or alternate font (scs1). This does not change whether default or alternate font are used, only their definition.

  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

- **::term::ansi::code::ctrl::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.

- **::term::ansi::code::ctrl::sda\_fgblack**

  Set text color to *Black*.

- **::term::ansi::code::ctrl::sda\_fgred**

  Set text color to *Red*.

- **::term::ansi::code::ctrl::sda\_fggreen**

  Set text color to *Green*.

- **::term::ansi::code::ctrl::sda\_fgyellow**

  Set text color to *Yellow*.

- **::term::ansi::code::ctrl::sda\_fgblue**

  Set text color to *Blue*.

- **::term::ansi::code::ctrl::sda\_fgmagenta**

  Set text color to *Magenta*.

- **::term::ansi::code::ctrl::sda\_fgcyan**

  Set text color to *Cyan*.

- **::term::ansi::code::ctrl::sda\_fgwhite**

  Set text color to *White*.

- **::term::ansi::code::ctrl::sda\_fgdefault**

  Set default text color (*Black*).

- **::term::ansi::code::ctrl::sda\_bgblack**

  Set background to *Black*.

- **::term::ansi::code::ctrl::sda\_bgred**

  Set background to *Red*.

- **::term::ansi::code::ctrl::sda\_bggreen**

  Set background to *Green*.

- **::term::ansi::code::ctrl::sda\_bgyellow**

  Set background to *Yellow*.

- **::term::ansi::code::ctrl::sda\_bgblue**

  Set background to *Blue*.

- **::term::ansi::code::ctrl::sda\_bgmagenta**

  Set background to *Magenta*.

- **::term::ansi::code::ctrl::sda\_bgcyan**

  Set background to *Cyan*.

- **::term::ansi::code::ctrl::sda\_bgwhite**

  Set background to *White*.

- **::term::ansi::code::ctrl::sda\_bgdefault**

  Set default background (Transparent).

- **::term::ansi::code::ctrl::sda\_bold**

  Bold on.

- **::term::ansi::code::ctrl::sda\_dim**

  Dim on.

- **::term::ansi::code::ctrl::sda\_italic**

  Italics on.

- **::term::ansi::code::ctrl::sda\_underline**

  Underscore on.

- **::term::ansi::code::ctrl::sda\_blink**

  Blink on.

- **::term::ansi::code::ctrl::sda\_revers**

  Reverse on.

- **::term::ansi::code::ctrl::sda\_hidden**

  Hidden on.

- **::term::ansi::code::ctrl::sda\_strike**

  Strike-through on.

- **::term::ansi::code::ctrl::sda\_nobold**

  Bold off.

- **::term::ansi::code::ctrl::sda\_noitalic**

  Italics off.

- **::term::ansi::code::ctrl::sda\_nounderline**

  Underscore off.

- **::term::ansi::code::ctrl::sda\_noblink**

  Blink off.

- **::term::ansi::code::ctrl::sda\_norevers**

  Reverse off.

- **::term::ansi::code::ctrl::sda\_nohidden**

  Hidden off.

- **::term::ansi::code::ctrl::sda\_nostrike**

  Strike-through off.

- **::term::ansi::code::ctrl::sda\_reset**

  Reset all attributes to their default values.

- **::term::ansi::send::fcp** *row* *col*

  Force Cursor Position (aka Go To).

- **::term::ansi::code::ctrl::cu** ?*n*?

  Cursor Up. *n* defaults to 1.

- **::term::ansi::code::ctrl::cd** ?*n*?

  Cursor Down. *n* defaults to 1.

- **::term::ansi::code::ctrl::cf** ?*n*?

  Cursor Forward. *n* defaults to 1.

- **::term::ansi::code::ctrl::cb** ?*n*?

  Cursor Backward. *n* defaults to 1.

- **::term::ansi::code::ctrl::ss** ?*s* *e*?

  Scroll Screen (entire display, or between rows start end, inclusive).

- **::term::ansi::code::ctrl::skd** *code* *str*

  Set Key Definition.

- **::term::ansi::code::ctrl::title** *str*

  Set the terminal title.

- **::term::ansi::code::ctrl::gron**

  Switch to character/box graphics. I.e. switch to the alternate font.

- **::term::ansi::code::ctrl::groff**

  Switch to regular characters. I.e. switch to the default font.

- **::term::ansi::code::ctrl::tlc**

  Character graphics, Top Left Corner.

- **::term::ansi::code::ctrl::trc**

  Character graphics, Top Right Corner.

- **::term::ansi::code::ctrl::brc**

  Character graphics, Bottom Right Corner.

- **::term::ansi::code::ctrl::blc**

  Character graphics, Bottom Left Corner.

- **::term::ansi::code::ctrl::ltj**

  Character graphics, Left T Junction.

- **::term::ansi::code::ctrl::ttj**

  Character graphics, Top T Junction.

- **::term::ansi::code::ctrl::rtj**

  Character graphics, Right T Junction.

- **::term::ansi::code::ctrl::btj**

  Character graphics, Bottom T Junction.

- **::term::ansi::code::ctrl::fwj**

  Character graphics, Four-Way Junction.

- **::term::ansi::code::ctrl::hl**

  Character graphics, Horizontal Line.

- **::term::ansi::code::ctrl::vl**

  Character graphics, Vertical Line.

- **::term::ansi::code::ctrl::groptim** *str*

  Optimize character graphics. The generator commands above create way to many superfluous commands shifting into and out of the graphics mode. 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.

- **::term::ansi::code::ctrl::clear**

  Clear screen. In essence a sequence of CursorHome + EraseDown.

- **::term::ansi::code::ctrl::init**

  Initialize default and alternate fonts to ASCII and box graphics.

- **::term::ansi::code::ctrl::showat** *row* *col* *text*

  Format the block of text for display at the specified location.

## BUGS, IDEAS, FEEDBACK

This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category *term* of the *Tcllib Trackers* \[http://core.tcl.tk/tcllib/reportlist\]. Please also report any ideas for enhancements you may have for either package and/or documentation.

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.

## KEYWORDS

ansi, attribute control, color control, control, terminal

## CATEGORY

Terminal control

## COPYRIGHT

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