Compare commits
No commits in common. "master" and "0.2.2" have entirely different histories.
4 changed files with 5 additions and 48 deletions
6
Makefile
6
Makefile
|
@ -1,8 +1,5 @@
|
||||||
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
|
||||||
|
|
||||||
|
@ -14,9 +11,6 @@ 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,8 +1,2 @@
|
||||||
{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, git},
|
{vsn,"0.2.2"},
|
||||||
{registered,[]},
|
{registered,[]},
|
||||||
{applications,[kernel,stdlib]},
|
{applications,[kernel,stdlib]},
|
||||||
{env,[]},
|
{env,[]},
|
||||||
|
|
37
src/cf.erl
37
src/cf.erl
|
@ -38,11 +38,6 @@
|
||||||
%% 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) ->
|
||||||
|
@ -118,37 +113,12 @@ cfmt(S) ->
|
||||||
cfmt(S, Enabled) ->
|
cfmt(S, Enabled) ->
|
||||||
lists:flatten(cfmt_(S, Enabled)).
|
lists:flatten(cfmt_(S, Enabled)).
|
||||||
|
|
||||||
cfmt_([$~, $!, $#, _R1, _R2, _G1, _G2, _B1, _B2 | S], false) ->
|
cfmt_([$~,$!, $_, _C | S], false) ->
|
||||||
cfmt_(S, false);
|
cfmt_(S, false);
|
||||||
cfmt_([$~, $#, $#, _R1, _R2, _G1, _G2, _B1, _B2 | S], false) ->
|
cfmt_([$~,$#, _C | 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)];
|
||||||
|
@ -156,7 +126,6 @@ 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