version bump

This commit is contained in:
Heinz N. Gies 2015-10-18 21:31:17 +02:00
parent 16dcc2b2a0
commit 3e7a95d8af
2 changed files with 20 additions and 6 deletions

View file

@ -1,10 +1,10 @@
{application,cf,
[{description,"Terminal colour helper"},
{vsn,"0.1.2"},
{vsn,"0.1.3"},
{registered,[]},
{applications,[kernel,stdlib]},
{env,[]},
{modules,[]},
{contributors,["Heinz N. Gies <heinz@project-fifo.net>"]},
{maintainers,["Heinz N. Gies <heinz@project-fifo.net>"]},
{licenses,["MIT"]},
{links,[]}]}.

View file

@ -96,19 +96,33 @@ format(Fmt) ->
-define(CFMT_U(Char, Colour),
cfmt_([$~, $_, Char | S], Enabled) -> [Colour | cfmt_(S, Enabled)]).
colour_term() ->
case application:get_env(cf, colour_term) of
{ok, V} ->
V;
undefined ->
V = case os:getenv("TERM") of
"xterm" ++ _ ->
true;
_ ->
false
end,
application:set_env(cf, colour_term, V),
V
end.
cfmt(S) ->
cfmt(S, os:getenv("TERM") =:= "xterm").
cfmt(S, colour_term()).
cfmt(S, Enabled) ->
lists:flatten(cfmt_(S, Enabled)).
cfmt_([$~,$!, _C | S], false) ->
cfmt_(S, false);
cfmt_([$~,$!, $_, _C | S], false) ->
cfmt_(S, false);
cfmt_([$~,$#, _C | S], false) ->
cfmt_(S, false);
cfmt_([$~,$!, _C | S], false) ->
cfmt_(S, false);
cfmt_([$~, $!, $_, $_ | S], Enabled) ->
[?U |cfmt_(S, Enabled)];