Konstruct / GAR colors
Brian M Hunt <[email protected]> Sat, 28 Feb 2004 11:08:39 -0500
| Newsgroups | gmane.linux.bbc.devel |
|---|---|
| Message-ID | <[email protected]> |
I've submitted a patch to Konstruct to add colors, similar to GAR's. The
method I've used is a bit cleaner and safer, and thought you all might want
to have a look at it.
You can have a look at Konstruct at:
http://bugs.kde.org/show_bug.cgi?id=75812
First, it uses tput and the TERM variable to form valid colors on ANSI and
non-ANSI terminals, ala terminfo. It'll work on color, and non-color
machines, as well as support other fancy things like bold, underline, etc.,
if they are available.
Second, it can use $(call COLOR,statement) to colorize, so you don't need an
end-of-line delimiter. For example:
TERM_RST =$(shell tput sgr0) # resets terminal (on ANSI: \E[0;0m)
TERM_BOLD =$(shell tput bold) # bold. duh.
TERM_RED =$(shell tput setaf 1)
# call function for "actions"
TMSG_ACTION =$(TERM_BOLD)$(TERM_RED)$1$(TERM_RST)
Second, instead of:
@echo 'The $(TERM_RED)$(TERM_BOLD)action$(TERM_RST) terminated
successfully'
You can write:
@echo The $(call TMG_ACTION,action) terminated successfully.
Finally, this seems cleaner to me. The implicit, rather than explicit,
delimiter is less likely to end up bleeding from a mistake or typo, as
well, I'd think.
You may be interested in adopting this or a variation thereof, maybe not,
but I thought I'd pass it along just in case. :)
Cheers,
Brian M Hunt