code.tcl

Go to the documentation of this file.
00001 /*  -*- tcl -*-*/
00002 /*  ### ### ### ######### ######### #########*/
00003 /*  Terminal packages - ANSI*/
00004 /*  Generic commands to define commands for code sequences.*/
00005 
00006 /*  ### ### ### ######### ######### #########*/
00007 /*  Requirements*/
00008 
00009 namespace ::term::ansi::code {}
00010 
00011 /*  ### ### ### ######### ######### #########*/
00012 /*  API. Escape clauses, plain and bracket*/
00013 /*       Used by 'define'd commands.*/
00014 
00015 ret  ::term::ansi::code::esc  (type str) {return \033${str}}
00016 ret  ::term::ansi::code::escb (type str) {esc    \[${str}}
00017 
00018 /*  ### ### ### ######### ######### #########*/
00019 /*  API. Define command for named control code, or constant.*/
00020 /*       (Simple definitions without arguments)*/
00021 
00022 ret  ::term::ansi::code::define (type name , type escape , type code) {
00023     proc [Qualified $name] {} [list ::term::ansi::code::$escape $code]
00024 }
00025 
00026 ret  ::term::ansi::code::const (type name , type code) {
00027     proc [Qualified $name] {} [list return $code]
00028 }
00029 
00030 /*  ### ### ### ######### ######### #########*/
00031 /*  Internal helper to construct fully-qualified names.*/
00032 
00033 ret  ::term::ansi::code::Qualified (type name) {
00034     if {![string match "::*" $name]} {
00035         # Get the caller's namespace; append :: if it is not the
00036     # global namespace, for separation from the actual name.
00037         set ns [uplevel 2 [list namespace current]]
00038         if {![string equal "::" $ns]} {append ns "::"}
00039         set name "$ns$name"
00040     }
00041     return $name
00042 }
00043 
00044 /*  ### ### ### ######### ######### #########*/
00045 
00046 namespace ::term::ansi::code {
00047     namespace export esc escb define const
00048 }
00049 
00050 /*  ### ### ### ######### ######### #########*/
00051 /*  Ready*/
00052 
00053 package provide term::ansi::code 0.1
00054 
00055 /** 
00056  * ### ### ### ######### ######### #########
00057 

Generated on 21 Sep 2010 for Gui by  doxygen 1.6.1