version bump
This commit is contained in:
parent
16dcc2b2a0
commit
3e7a95d8af
2 changed files with 20 additions and 6 deletions
|
@ -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,[]}]}.
|
||||
|
|
20
src/cf.erl
20
src/cf.erl
|
@ -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)];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue