| 1 | # -*- tcl -*- |
|---|
| 2 | # ### ### ### ######### ######### ######### |
|---|
| 3 | ## Terminal packages - ANSI - Attribute codes |
|---|
| 4 | |
|---|
| 5 | # ### ### ### ######### ######### ######### |
|---|
| 6 | ## Requirements |
|---|
| 7 | |
|---|
| 8 | package require term::ansi::code ; # Constants |
|---|
| 9 | |
|---|
| 10 | namespace eval ::term::ansi::code::attr {} |
|---|
| 11 | |
|---|
| 12 | # ### ### ### ######### ######### ######### |
|---|
| 13 | ## API. Symbolic names. |
|---|
| 14 | |
|---|
| 15 | proc ::term::ansi::code::attr::names {} { |
|---|
| 16 | variable attr |
|---|
| 17 | return $attr |
|---|
| 18 | } |
|---|
| 19 | |
|---|
| 20 | proc ::term::ansi::code::attr::import {{ns attr} args} { |
|---|
| 21 | if {![llength $args]} {set args *} |
|---|
| 22 | set args ::term::ansi::code::attr::[join $args " ::term::ansi::code::attr::"] |
|---|
| 23 | uplevel 1 [list namespace eval ${ns} [linsert $args 0 namespace import]] |
|---|
| 24 | return |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | # ### ### ### ######### ######### ######### |
|---|
| 28 | ## Internal - Setup |
|---|
| 29 | |
|---|
| 30 | proc ::term::ansi::code::attr::DEF {name value} { |
|---|
| 31 | variable attr |
|---|
| 32 | const $name $value |
|---|
| 33 | lappend attr $name |
|---|
| 34 | namespace export $name |
|---|
| 35 | return |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | proc ::term::ansi::code::attr::INIT {} { |
|---|
| 39 | # ### ### ### ######### ######### ######### |
|---|
| 40 | ## |
|---|
| 41 | |
|---|
| 42 | # Colors. Foreground <=> Text |
|---|
| 43 | DEF fgblack 30 ; # Black |
|---|
| 44 | DEF fgred 31 ; # Red |
|---|
| 45 | DEF fggreen 32 ; # Green |
|---|
| 46 | DEF fgyellow 33 ; # Yellow |
|---|
| 47 | DEF fgblue 34 ; # Blue |
|---|
| 48 | DEF fgmagenta 35 ; # Magenta |
|---|
| 49 | DEF fgcyan 36 ; # Cyan |
|---|
| 50 | DEF fgwhite 37 ; # White |
|---|
| 51 | DEF fgdefault 39 ; # Default (Black) |
|---|
| 52 | |
|---|
| 53 | # Colors. Background. |
|---|
| 54 | DEF bgblack 40 ; # Black |
|---|
| 55 | DEF bgred 41 ; # Red |
|---|
| 56 | DEF bggreen 42 ; # Green |
|---|
| 57 | DEF bgyellow 43 ; # Yellow |
|---|
| 58 | DEF bgblue 44 ; # Blue |
|---|
| 59 | DEF bgmagenta 45 ; # Magenta |
|---|
| 60 | DEF bgcyan 46 ; # Cyan |
|---|
| 61 | DEF bgwhite 47 ; # White |
|---|
| 62 | DEF bgdefault 49 ; # Default (Transparent) |
|---|
| 63 | |
|---|
| 64 | # Non-color attributes. Activation. |
|---|
| 65 | DEF bold 1 ; # Bold |
|---|
| 66 | DEF dim 2 ; # Dim |
|---|
| 67 | DEF italic 3 ; # Italics |
|---|
| 68 | DEF underline 4 ; # Underscore |
|---|
| 69 | DEF blink 5 ; # Blink |
|---|
| 70 | DEF revers 7 ; # Reverse |
|---|
| 71 | DEF hidden 8 ; # Hidden |
|---|
| 72 | DEF strike 9 ; # StrikeThrough |
|---|
| 73 | |
|---|
| 74 | # Non-color attributes. Deactivation. |
|---|
| 75 | DEF nobold 22 ; # Bold |
|---|
| 76 | DEF nodim __ ; # Dim |
|---|
| 77 | DEF noitalic 23 ; # Italics |
|---|
| 78 | DEF nounderline 24 ; # Underscore |
|---|
| 79 | DEF noblink 25 ; # Blink |
|---|
| 80 | DEF norevers 27 ; # Reverse |
|---|
| 81 | DEF nohidden 28 ; # Hidden |
|---|
| 82 | DEF nostrike 29 ; # StrikeThrough |
|---|
| 83 | |
|---|
| 84 | # Remainder |
|---|
| 85 | DEF reset 0 ; # Reset |
|---|
| 86 | |
|---|
| 87 | ## |
|---|
| 88 | # ### ### ### ######### ######### ######### |
|---|
| 89 | return |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | # ### ### ### ######### ######### ######### |
|---|
| 93 | ## Data structures. |
|---|
| 94 | |
|---|
| 95 | namespace eval ::term::ansi::code::attr { |
|---|
| 96 | namespace import ::term::ansi::code::const |
|---|
| 97 | variable attr {} |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | ::term::ansi::code::attr::INIT |
|---|
| 101 | |
|---|
| 102 | # ### ### ### ######### ######### ######### |
|---|
| 103 | ## Ready |
|---|
| 104 | |
|---|
| 105 | package provide term::ansi::code::attr 0.1 |
|---|
| 106 | |
|---|
| 107 | ## |
|---|
| 108 | # ### ### ### ######### ######### ######### |
|---|