Re: VT100 Terminal library

From: Erik Buchmann (buchmann_at_iti.cs.uni-magdeburg.de)
Date: 10/14/03


Date: Tue, 14 Oct 2003 15:16:31 +0200

Hi Googie,

Googie wrote:
> Well, package can be downloaded from:
> ftp://scripts.one.pl/libterm-1.0.tar.gz

i've seen it, but it seems to be unnecessary complex.
The code below does roughly the same and adds full cursor control. I
wrote it some months ago as part of my library, but thought it wasnt
ready for publishing ;-)

CU, Erik

###########################################################################
# Constants for using with textAttr

set ::ansiTerm::AllOff 0
set ::ansiTerm::Bold 1
set ::ansiTerm::Underscore 4
set ::ansiTerm::Blink 5
set ::ansiTerm::Reverse 7
set ::ansiTerm::Concealed 8
set ::ansiTerm::BlackForeground 30
set ::ansiTerm::RedForeground 31
set ::ansiTerm::GreenForeground 32
set ::ansiTerm::YellowForeground 33
set ::ansiTerm::BlueForeground 34
set ::ansiTerm::MagentaForeground 35
set ::ansiTerm::CyanForeground 36
set ::ansiTerm::WhiteForeground 37
set ::ansiTerm::BlackBackground 40
set ::ansiTerm::RedBackground 41
set ::ansiTerm::GreenBackground 42
set ::ansiTerm::YellowBackground 43
set ::ansiTerm::BlueBackground 44
set ::ansiTerm::MagentaBackground 45
set ::ansiTerm::CyanBackground 46
set ::ansiTerm::WhiteBackground 47

###########################################################################
# ANSI Primitives

# Set the current text attribute. See constants or terminal
documentation for available values
proc ::ansiTerm::textAttr {m} {puts -nonewline [format
"\033\[%im" $m]}

# Clear terminal and reset all values to default.
proc ::ansiTerm::clearTerminal {} {puts -nonewline [format
"\033\[2J\033\[1;1H\033\[0m"]}

# Change Cursor position to absolute values
proc ::ansiTerm::cursorPosition {x y} {puts -nonewline [format
"\033\[%i;%iH" $y $x]}

# Move Cursor up by n lines
proc ::ansiTerm::cursorUp {l} {puts -nonewline [format
"\033\[%iA" $l]}

# Move Cursor down by n lines
proc ::ansiTerm::cursorDown {l} {puts -nonewline [format
"\033\[%iB" $l]}

# Move Cursor right by n columns
proc ::ansiTerm::cursorRight {l} {puts -nonewline [format
"\033\[%iC" $l]}

# Move Cursor left by n columns
proc ::ansiTerm::cursorLeft {l} {puts -nonewline [format
"\033\[%iD" $l]}

# Save current Cursor position
proc ::ansiTerm::cursorSave {} {puts -nonewline [format "\033\[s"]}

# Restore current Cursor position
proc ::ansiTerm::cursorRestore {} {puts -nonewline [format "\033\[u"]}



Relevant Pages

  • Re: position cursor in body
    ... code does not affect cursor position. ... I'm using Outlook 2000 and your ... Dim objitem As Object ...
    (microsoft.public.outlook.program_vba)
  • Re: OT: Why is C so popular?
    ... if (<cursor placed here) { ... <later cursor position> ... there's nothing to hate about brackets. ... You can get my public key from any of the ...
    (Debian-User)
  • Re: Wrong Cell
    ... The initial cursor position is the position of the cursor when you save ... You can press Ctrl+to put the cursor to the last cell either before you ... Free Excel-Based Data Processing Tool is Available for Download ...
    (microsoft.public.excel.misc)
  • Re: [Xnews] Editor window opens full screen.
    ... encourages snipping rather than top posting IMHO. ... But one doesn't usually have to snip if one selects the wanted ... Since the change to the initial cursor position was made, ...
    (news.software.readers)
  • Re: VT100 Terminal library
    ... Googie wrote: ... > There is also procedure 'mv' which moves cursor position from current by ... set of cursor commands that is quite capable of managing the whole ...
    (comp.lang.tcl)