- NAME
- term - tcl interface to the curses library
- SYNOPSIS
- term option ?arg arg ...?
- DESCRIPTION
- term attr attribute fg bg
- attribute
- fg,bg
- term banner ?-italic? ?-dblsize? ?-char val? ?-samechar? string
- term beep ?visual?
- term can_scroll
- term clear
- term clreol
- term cols or term rows
- term corner
- term curr_col or term curr_row
- term enter
- term exit
- term flush
- term getchar
- term gets ?scrollsize?
- term init ?raw?
- term move row column
- term newinput row column width historysz attr fg bg
- term puts text
- term screensize
- term scroll ?top? ?bottom? ?number?
- INPUT WINDOW
- handle addhistory string
- handle addmacro name value
- handle clear
- handle insert text
- handle movecursor
- handle process char variable
- 0
- 1
- 2
- handle reposition raw column width
- handle redraw
- PORTABILITY ISSUES
- Unix
- EXAMPLES
- SEE ALSO
- KEYWORDS
term - tcl interface to the curses library
term option ?arg arg ...?
This command provides several operations on a unix terminal used
for creating curses layouts. Option indicates what to do with
the terminal. Any unique abbreviation for option is acceptable.
The valid options are:
- term attr attribute fg bg
-
- attribute
-
bold, underline, inverse, all append 'off' to turn them off
- fg,bg
-
red, green, blue, black, cyan, magenta, yellow, white, default
- term banner ?-italic? ?-dblsize? ?-char val? ?-samechar? string
-
return a list as a result of converting string into large letters. the tcl code:
puts [join [term banner hello] \n]
returns
*** *** ***
** ** **
** ** **** ** ** ****
*** ** ** ** ** ** ** **
** ** ****** ** ** ** **
** ** ** ** ** ** **
*** ** **** **** **** ****
- term beep ?visual?
-
beep, visually if allowed
- term can_scroll
-
returns 1 if terminal can scroll, 0 if not
- term clear
-
clear screen
- term clreol
-
clear to end of line
- term cols or term rows
-
get the number of columns or rows of the whole terminal
- term corner
-
flush buffer and move cursor to lower right
- term curr_col or term curr_row
-
get current cursor column or row
- term enter
-
use upon returning from suspension
- term exit
-
revert terminal to original state, disable all attributes
and set colors to default
- term flush
-
flush buffer
- term getchar
-
get one character
- term gets ?scrollsize?
-
get string, with optional scrollsize
- term init ?raw?
-
initilizes terminal
- term move row column
-
move cursor to position
- term newinput row column width historysz attr fg bg
-
create a new input window at the position row and column using width as text field
size. The historysz argument will define the size of the history list. The attributes of the window
are set using the attr, fg and bg arguments. newinput will create a new Tcl command
and return the handle of this command. To delete the new Tcl command use the rename Tcl command.
Please read at INPUT WINDOW for more details
- term puts text
-
put string starting at the current cursor position
- term screensize
-
reconfig after sigwinch
- term scroll ?top? ?bottom? ?number?
-
scroll by number rows, number can be negative.
top and bottom restrict the region to a subwindow
The term newinput ... command creates a new Tcl command whose name is handle.
This command may be used to invoke various operations on the input window.
It has the following general form:
handle option ?arg arg ...?
Option and the args determine the exact behavior of the command.
The following commands are possible for input window:
- handle addhistory string
-
add string to the history buffer of the input window
- handle addmacro name value
-
bind a input window command to a key. the following example will
set the input window to the value 'redraw' using the CTRL-L key:
$in addmacro "^L" "redraw"
- handle clear
-
clear the input window
- handle insert text
-
insert the text into the input window
- handle movecursor
-
move the curser into the input window
- handle process char variable
-
this command will exactly add one single character to the input window.
This character is typical the return value from a term getchar command.
The second argument variable is used to return the entire
value of the input window. Macro expasion is performed as defined
in the addmacro option. The return value of this command is:
- 0
-
just a normal character
- 1
-
got a ENTER, input finished
- 2
-
fond a macro
- handle reposition raw column width
-
move the input window to a new place using raw and column
coordinates and width size
- handle redraw
-
redraw the input window
- Unix
-
These command is only available on unix like system's
This is the famous 'hello world' printed in the middle of the screen:
package require TclTerm
term init
term enter
term clear
term move [expr {[term rows]/2}] [expr {[term cols]/2-4}]
term puts "hello world"
term exit
The next example is using an input window to get data from the user:
set in [term newinput [term curr_row] [term curr_col] 15 0 bold red blue]
$in movecursor
$in redraw
while 1 {
set c [term getchar]
set ret [$in process $c str]
if {$ret == 1} {
term attr alloff default default
term move 16 0
term puts "String typed: $str"
term flush
break;
}
if {$ret == 2} {
term attr alloff default default
term move 16 0
term puts "Macro hit: $str"
term clreol
$in movecursor
term flush
}
}
ncurses
terminal, curses, tcl