Compare commits

...

5 commits

Author SHA1 Message Date
Heinz N. Gies
2bcf00402d Fix hiding truecolor 2017-06-14 21:57:32 +02:00
Heinz N. Gies
5d1a3c6783 Merge branch 'master' of github.com:project-fifo/cf 2017-06-14 21:44:51 +02:00
Heinz N. Gies
03c34c8e9a Add truecolor 2017-06-14 21:44:42 +02:00
Heinz N. Gies
52f39d9be0 Merge pull request #2 from binarin/erlang-mk-workaround
Add `compile` target to Makefile
2017-03-22 18:48:27 +01:00
Alexey Lebedeff
2ea1755cf2 Add compile target to Makefile
To make it usable with stock version of `erlang.mk`.

I'm trying to use `cf` from withing erlang.mk-based project, but it
fails to properly autopatch it. erlang.mk magic works properly when
Makefile contains some references to `rebar`.

Proper fix will be available within
https://github.com/ninenines/erlang.mk/issues/586

But currently it's far more easier to add single target to this project,
than to delve into shell script/make spaghetti =)
2016-08-02 14:06:37 +03:00
4 changed files with 48 additions and 5 deletions

View file

@ -1,5 +1,8 @@
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
./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.clean ] && rm termtypes.master.clean || true
compile:
rebar3 compile
termtypes.master.clean: termtypes.master
cat termtypes.master | grep -v '^#' | grep -v '^\s*$$' > termtypes.master.clean

View file

@ -1,2 +1,8 @@
{erl_opts, [debug_info]}.
{deps, []}.
{profiles, [
{shell, [
{deps, [sync]}
]}
]}.

View file

@ -1,6 +1,6 @@
{application,cf,
[{description,"Terminal colour helper"},
{vsn,"0.2.2"},
{vsn, git},
{registered,[]},
{applications,[kernel,stdlib]},
{env,[]},

View file

@ -38,6 +38,11 @@
%% c,C - cyan
%% 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
%% @end
print(Fmt, Args) ->
@ -113,6 +118,11 @@ cfmt(S) ->
cfmt(S, Enabled) ->
lists:flatten(cfmt_(S, Enabled)).
cfmt_([$~, $!, $#, _R1, _R2, _G1, _G2, _B1, _B2 | S], false) ->
cfmt_(S, false);
cfmt_([$~, $#, $#, _R1, _R2, _G1, _G2, _B1, _B2 | S], false) ->
cfmt_(S, false);
cfmt_([$~, $!, $_, _C | S], false) ->
cfmt_(S, false);
cfmt_([$~, $#, _C | S], false) ->
@ -120,12 +130,33 @@ cfmt_([$~,$#, _C | 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) ->
[?U |cfmt_(S, Enabled)];
cfmt_([$~,$!, $^ | S], Enabled) ->
[?B | cfmt_(S, Enabled)];
cfmt_([$~,$!, $_, $^ | S], Enabled) ->
[?U, ?B | cfmt_(S, Enabled)];
?CFMT($!, ?R);
?CFMT($x, ?NX);
?CFMT($X, ?BX);