File: attr.tcl

package info (click to toggle)
tcllib 1.20%2Bdfsg-1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 68,064 kB
  • sloc: tcl: 216,842; ansic: 14,250; sh: 2,846; xml: 1,766; yacc: 1,145; pascal: 881; makefile: 107; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (108 lines) | stat: -rw-r--r-- 2,832 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# -*- tcl -*-
# ### ### ### ######### ######### #########
## Terminal packages - ANSI - Attribute codes

# ### ### ### ######### ######### #########
## Requirements

package require  term::ansi::code ; # Constants

namespace eval ::term::ansi::code::attr {}

# ### ### ### ######### ######### #########
## API. Symbolic names.

proc ::term::ansi::code::attr::names {} {
    variable attr
    return  $attr
}

proc ::term::ansi::code::attr::import {{ns attr} args} {
    if {![llength $args]} {set args *}
    set args ::term::ansi::code::attr::[join $args " ::term::ansi::code::attr::"]
    uplevel 1 [list namespace eval ${ns} [linsert $args 0 namespace import]]
    return
}

# ### ### ### ######### ######### #########
## Internal - Setup

proc ::term::ansi::code::attr::DEF {name value} {
    variable  attr
    const            $name $value
    lappend   attr   $name
    namespace export $name
    return
}

proc ::term::ansi::code::attr::INIT {} {
    # ### ### ### ######### ######### #########
    ##

    # Colors. Foreground <=> Text
    DEF	fgblack   30	; # Black  
    DEF	fgred     31	; # Red    
    DEF	fggreen   32	; # Green  
    DEF	fgyellow  33	; # Yellow 
    DEF	fgblue    34	; # Blue   
    DEF	fgmagenta 35	; # Magenta
    DEF	fgcyan    36	; # Cyan   
    DEF	fgwhite   37	; # White  
    DEF	fgdefault 39    ; # Default (Black)

    # Colors. Background.
    DEF	bgblack   40	; # Black  
    DEF	bgred     41	; # Red    
    DEF	bggreen   42	; # Green  
    DEF	bgyellow  43	; # Yellow 
    DEF	bgblue    44	; # Blue   
    DEF	bgmagenta 45	; # Magenta
    DEF	bgcyan    46	; # Cyan   
    DEF	bgwhite   47	; # White  
    DEF	bgdefault 49    ; # Default (Transparent)

    # Non-color attributes. Activation.
    DEF	bold      1	; # Bold  
    DEF	dim       2	; # Dim
    DEF	italic    3     ; # Italics      
    DEF	underline 4	; # Underscore   
    DEF	blink     5	; # Blink
    DEF	revers    7	; # Reverse      
    DEF	hidden    8	; # Hidden
    DEF	strike    9     ; # StrikeThrough

    # Non-color attributes. Deactivation.
    DEF	nobold      22	; # Bold  
    DEF	nodim       __	; # Dim
    DEF	noitalic    23  ; # Italics      
    DEF	nounderline 24	; # Underscore   
    DEF	noblink     25	; # Blink
    DEF	norevers    27	; # Reverse      
    DEF	nohidden    28	; # Hidden
    DEF	nostrike    29  ; # StrikeThrough

    # Remainder
    DEF	reset       0   ; # Reset

    ##
    # ### ### ### ######### ######### #########
    return
}

# ### ### ### ######### ######### #########
## Data structures.

namespace eval ::term::ansi::code::attr {
    namespace import ::term::ansi::code::const
    variable attr {}
}

::term::ansi::code::attr::INIT

# ### ### ### ######### ######### #########
## Ready

package provide term::ansi::code::attr 0.1

##
# ### ### ### ######### ######### #########