1 |
|
2 | TRM = require './main'
|
3 | rpr = ( require 'util' ).inspect
|
4 | log = console.log
|
5 |
|
6 |
|
7 | show_color_gamut = ->
|
8 | _esc = "\x1b"
|
9 | _csi = _esc + "["
|
10 | _sgr = "m"
|
11 | reset = _csi + "0" + _sgr
|
12 |
|
13 | for green in [ 0 .. 5 ]
|
14 | for blue in [ 0 .. 5 ]
|
15 | R = []
|
16 | for red in [ 0 .. 5 ]
|
17 | color_code = red * 36 + green * 6 + blue + 16
|
18 | R.push "#{red} #{green} #{blue} #{color_code} #{_csi}38;05;#{color_code}#{_sgr}██████#{reset}"
|
19 | log R.join ' '
|
20 | for color_nr in [ 232 .. 255 ]
|
21 | log "#{_csi}38;05;#{color_nr}#{_sgr} #{color_nr}██████#{reset}"
|
22 |
|
23 |
|
24 | log rpr TRM.red 'helo world', ( TRM.olive 'abc' ), [ 1, 2, 3, ]
|
25 | log TRM.red 'helo world', ( TRM.olive 'abc' ), ( TRM.olive TRM.underline [ 1, 2, 3, ] ), 'ooops'
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | log "helo"
|
36 | process.stdout.write ( TRM.goto 10, 1 ) + 'ABCD'
|
37 | process.stdout.write ( TRM.right 5 ) + "X" + TRM.up( 3 ) + '---'
|
38 | process.stdout.write ( TRM.goto_column 50 ) + 'HERE'
|
39 | process.stdout.write ( TRM.move 2, 3 ) + 'THERE'
|
40 | process.stdout.write TRM.clear_above
|
41 |
|
42 | log TRM.underline 'lore', ( TRM.blue 'ipsum' ), 'dolores'
|
43 | log TRM.orange 'lore', ( TRM.green TRM.underline 'ipsum' ), 'dolores'
|
44 | process.stdout.write ( TRM.down 15 )
|
45 | show_color_gamut()
|
46 | log()
|
47 | log()
|
48 | log()
|
49 |
|
50 |
|
51 | colortext = TRM.pen 'foo', ( TRM.steel 'helo', 42 ), 'bar', ( TRM.pink 'baz' )
|
52 | console.log colortext
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 | colortext = '\x1b[38;05;199mhelo\x1b[0m foo \x1b[38;05;214moops\x1b[0m'
|
59 | colortext = '\x1b[38;05;199mhelo\x1b[0m foo \x1b[38;05;214moops'
|
60 |
|
61 | console.log TRM.analyze colortext
|
62 | console.log TRM.as_html colortext
|
63 | console.log TRM.as_html colortext, 'css-prefix': 'xxxx', 'close-spans': yes
|
64 |
|
65 |
|