UNPKG

2.25 kBtext/coffeescriptView Raw
1
2TRM = require './main'
3rpr = ( require 'util' ).inspect
4log = console.log
5
6
7show_color_gamut = ->
8 _esc = "\x1b" # ESCape
9 _csi = _esc + "[" # Command Sequence Initializer
10 _sgr = "m" # Select Graphic Rendition
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
24log rpr TRM.red 'helo world', ( TRM.olive 'abc' ), [ 1, 2, 3, ]
25log TRM.red 'helo world', ( TRM.olive 'abc' ), ( TRM.olive TRM.underline [ 1, 2, 3, ] ), 'ooops'
26
27
28# log "A", @constants[ 'red' ], "B", @constants[ 'reset' ], "C"
29# log "A", @constants[ 'red' ], "B", @constants[ 'olive' ], "C", @constants[ 'red' ], "C"
30
31# log @constants[ 'reset' ]
32
33
34# show_color_gamut()
35log "helo"
36process.stdout.write ( TRM.goto 10, 1 ) + 'ABCD'
37process.stdout.write ( TRM.right 5 ) + "X" + TRM.up( 3 ) + '---'
38process.stdout.write ( TRM.goto_column 50 ) + 'HERE'
39process.stdout.write ( TRM.move 2, 3 ) + 'THERE'
40process.stdout.write TRM.clear_above
41# process.stdout.write TRM.clear_to_bottom
42log TRM.underline 'lore', ( TRM.blue 'ipsum' ), 'dolores'
43log TRM.orange 'lore', ( TRM.green TRM.underline 'ipsum' ), 'dolores'
44process.stdout.write ( TRM.down 15 )
45show_color_gamut()
46log()
47log()
48log()
49
50
51colortext = TRM.pen 'foo', ( TRM.steel 'helo', 42 ), 'bar', ( TRM.pink 'baz' )
52console.log colortext
53# color_matcher = /\x1b\[(38);(05);([0-9]{1,3})m([^\x1b]*)\x1b\[(?:0m|K)/
54# console.log rpr colortext.match color_matcher
55
56# info rpr TRM.pen ( TRM.pink 'helo' ), 'foo', ( TRM.gold 'oops' )
57
58colortext = '\x1b[38;05;199mhelo\x1b[0m foo \x1b[38;05;214moops\x1b[0m'
59colortext = '\x1b[38;05;199mhelo\x1b[0m foo \x1b[38;05;214moops'
60
61console.log TRM.analyze colortext
62console.log TRM.as_html colortext
63console.log TRM.as_html colortext, 'css-prefix': 'xxxx', 'close-spans': yes
64# console.log TRM.get_css_source()
65