Compare commits
5 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
2bcf00402d | ||
![]() |
5d1a3c6783 | ||
![]() |
03c34c8e9a | ||
![]() |
52f39d9be0 | ||
![]() |
2ea1755cf2 |
4 changed files with 48 additions and 5 deletions
6
Makefile
6
Makefile
|
@ -1,5 +1,8 @@
|
||||||
TERMCAP_FILE=http://code.metager.de/source/raw/OpenBSD/src/share/termtypes/termtypes.master
|
TERMCAP_FILE=http://code.metager.de/source/raw/OpenBSD/src/share/termtypes/termtypes.master
|
||||||
|
|
||||||
|
all: src/termcap.erl
|
||||||
|
rebar3 compile
|
||||||
|
|
||||||
src/termcap.erl: termtypes.master.clean mk-termcap.escript termcap.erl
|
src/termcap.erl: termtypes.master.clean mk-termcap.escript termcap.erl
|
||||||
./mk-termcap.escript termtypes.master.clean > src/cf_term.erl
|
./mk-termcap.escript termtypes.master.clean > src/cf_term.erl
|
||||||
|
|
||||||
|
@ -11,6 +14,9 @@ clean:
|
||||||
[ -f termtypes.master ] && rm termtypes.master || true
|
[ -f termtypes.master ] && rm termtypes.master || true
|
||||||
[ -f termtypes.master.clean ] && rm termtypes.master.clean || true
|
[ -f termtypes.master.clean ] && rm termtypes.master.clean || true
|
||||||
|
|
||||||
|
compile:
|
||||||
|
rebar3 compile
|
||||||
|
|
||||||
termtypes.master.clean: termtypes.master
|
termtypes.master.clean: termtypes.master
|
||||||
cat termtypes.master | grep -v '^#' | grep -v '^\s*$$' > termtypes.master.clean
|
cat termtypes.master | grep -v '^#' | grep -v '^\s*$$' > termtypes.master.clean
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,8 @@
|
||||||
{erl_opts, [debug_info]}.
|
{erl_opts, [debug_info]}.
|
||||||
{deps, []}.
|
{deps, []}.
|
||||||
|
|
||||||
|
{profiles, [
|
||||||
|
{shell, [
|
||||||
|
{deps, [sync]}
|
||||||
|
]}
|
||||||
|
]}.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{application,cf,
|
{application,cf,
|
||||||
[{description,"Terminal colour helper"},
|
[{description,"Terminal colour helper"},
|
||||||
{vsn,"0.2.2"},
|
{vsn, git},
|
||||||
{registered,[]},
|
{registered,[]},
|
||||||
{applications,[kernel,stdlib]},
|
{applications,[kernel,stdlib]},
|
||||||
{env,[]},
|
{env,[]},
|
||||||
|
|
37
src/cf.erl
37
src/cf.erl
|
@ -38,6 +38,11 @@
|
||||||
%% c,C - cyan
|
%% c,C - cyan
|
||||||
%% w,W - white
|
%% w,W - white
|
||||||
%%
|
%%
|
||||||
|
%% true color is supported by using
|
||||||
|
%% ~!#<rr><gg><bb> as each as hex values so ~!#ff6402
|
||||||
|
%%
|
||||||
|
%% the same can be done for the background by yusign ~##
|
||||||
|
%%
|
||||||
%% The function will disable colours on non x term termials
|
%% The function will disable colours on non x term termials
|
||||||
%% @end
|
%% @end
|
||||||
print(Fmt, Args) ->
|
print(Fmt, Args) ->
|
||||||
|
@ -113,12 +118,37 @@ cfmt(S) ->
|
||||||
cfmt(S, Enabled) ->
|
cfmt(S, Enabled) ->
|
||||||
lists:flatten(cfmt_(S, Enabled)).
|
lists:flatten(cfmt_(S, Enabled)).
|
||||||
|
|
||||||
cfmt_([$~,$!, $_, _C | S], false) ->
|
cfmt_([$~, $!, $#, _R1, _R2, _G1, _G2, _B1, _B2 | S], false) ->
|
||||||
cfmt_(S, false);
|
cfmt_(S, false);
|
||||||
cfmt_([$~,$#, _C | S], false) ->
|
cfmt_([$~, $#, $#, _R1, _R2, _G1, _G2, _B1, _B2 | S], false) ->
|
||||||
cfmt_(S, false);
|
cfmt_(S, false);
|
||||||
cfmt_([$~,$!, _C | S], false) ->
|
|
||||||
|
cfmt_([$~, $!, $_, _C | S], false) ->
|
||||||
cfmt_(S, false);
|
cfmt_(S, false);
|
||||||
|
cfmt_([$~, $#, _C | S], false) ->
|
||||||
|
cfmt_(S, false);
|
||||||
|
cfmt_([$~, $!, _C | S], false) ->
|
||||||
|
cfmt_(S, false);
|
||||||
|
|
||||||
|
cfmt_([$~, $!, $#, R1, R2, G1, G2, B1, B2 | S], Enabled) ->
|
||||||
|
R = list_to_integer([R1, R2], 16),
|
||||||
|
G = list_to_integer([G1, G2], 16),
|
||||||
|
B = list_to_integer([B1, B2], 16),
|
||||||
|
["\033[38;2;",
|
||||||
|
integer_to_list(R), $;,
|
||||||
|
integer_to_list(G), $;,
|
||||||
|
integer_to_list(B), $m |
|
||||||
|
cfmt_(S, Enabled)];
|
||||||
|
|
||||||
|
cfmt_([$~, $#, $#, R1, R2, G1, G2, B1, B2 | S], Enabled) ->
|
||||||
|
R = list_to_integer([R1, R2], 16),
|
||||||
|
G = list_to_integer([G1, G2], 16),
|
||||||
|
B = list_to_integer([B1, B2], 16),
|
||||||
|
["\033[48;2;",
|
||||||
|
integer_to_list(R), $;,
|
||||||
|
integer_to_list(G), $;,
|
||||||
|
integer_to_list(B), $m |
|
||||||
|
cfmt_(S, Enabled)];
|
||||||
|
|
||||||
cfmt_([$~, $!, $_, $_ | S], Enabled) ->
|
cfmt_([$~, $!, $_, $_ | S], Enabled) ->
|
||||||
[?U |cfmt_(S, Enabled)];
|
[?U |cfmt_(S, Enabled)];
|
||||||
|
@ -126,6 +156,7 @@ cfmt_([$~,$!, $^ | S], Enabled) ->
|
||||||
[?B | cfmt_(S, Enabled)];
|
[?B | cfmt_(S, Enabled)];
|
||||||
cfmt_([$~,$!, $_, $^ | S], Enabled) ->
|
cfmt_([$~,$!, $_, $^ | S], Enabled) ->
|
||||||
[?U, ?B | cfmt_(S, Enabled)];
|
[?U, ?B | cfmt_(S, Enabled)];
|
||||||
|
|
||||||
?CFMT($!, ?R);
|
?CFMT($!, ?R);
|
||||||
?CFMT($x, ?NX);
|
?CFMT($x, ?NX);
|
||||||
?CFMT($X, ?BX);
|
?CFMT($X, ?BX);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue