head	1.2;
access;
symbols
	tcllib-1-13:1.2
	tcllib-1-12:1.2
	tklib-0-5:1.2
	tcllib-1-11-1:1.2
	tcllib-1-11:1.2
	tcllib-1-10:1.2
	tcllib-1-9:1.2;
locks; strict;
comment	@# @;


1.2
date	2006.08.09.19.11.15;	author andreas_kupries;	state Exp;
branches;
next	1.1;

1.1
date	2006.07.24.03.32.06;	author andreas_kupries;	state Exp;
branches;
next	;


desc
@@


1.2
log
@
	* ../../examples/term/menu2: Updated to changes in the
	  package term::receive::bind.
	* term_bind.man: Updated documentation as well.
@
text
@#!/bin/sh
# -*- tcl -*- \
exec tclsh "$0" ${1+"$@@"}
lappend auto_path [file join [file dirname [file dirname [file dirname [info script]]]] modules]

package require term::ansi::send
package require term::ansi::code::macros
package require term::receive::bind
package require term::ansi::ctrl::unix
package require term::ansi::code::ctrl

term::ansi::send::import         vt
term::ansi::code::ctrl::import ctrl

set menu {Hello World {How  } {Are  } {You  }}
set max  [llength $menu]
set at   0

proc Up {args} {
    global at
    if {$at == 0} return
    incr at -1
    Show
    return
}
proc Down {args} {
    global at max
    if {$at >= ($max - 1)} return
    incr at
    Show
    return
}
proc Do {args} {
    term::ansi::ctrl::unix::cooked
    vt::clear
    exit
}
proc Default {string} {
    return
}

proc Show {} {
    global at menu
    set i 0
    set str ""
    foreach m $menu {
	if {$i != $at} {
	    append str $m
	} else {
	    append str [ctrl::sda_revers]
	    append str $m
	    append str [ctrl::sda_reset]
	}
	append str \n
	incr i
    }
    vt::showat 5 5 [string trimright $str \n]
    return  
}

term::receive::bind B
B map [ctrl::cu] Up
B map [ctrl::cd] Down
B map \r Do
B map \n Do
B default Default

term::ansi::ctrl::unix::raw
vt::init
vt::clear

Show
#term::ansi::ctrl::unix::cooked
B listen
vwait forever
term::ansi::ctrl::unix::cooked
exit
@


1.1
log
@
	* receive.tcl: New file, package. Basic receiver functionality
	* receive.man: (getting chars, event listener). Documentation.

	* bind.tcl:      New file, package. Recognition of character
	* term_bind.man: sequences in the input, execution of
	  actions. Dispatcher. A 'bind' for character sequences.

	* pkgIndex.tcl: New packages registered.

	* ../../examples/term/menu2: Example for receive and bind.

	* ansi_code.man: Typos.
	* ansi_send.man:
	* term.man:
	* term_send.man:
@
text
@d19 1
a19 1
proc Up {} {
d26 1
a26 1
proc Down {} {
d33 1
a33 1
proc Do {} {
d38 4
d66 1
@

