[pacman-dev] coloured pacman
Hi all, this patch add coloured output in to pacman-3.0.0 diff is here: http://www.fi.muni.cz/~xgondz/pacman3-color/pacman3-color.diff vogo
On 2/6/07, Vojtěch Gondžala <vogo@seznam.cz> wrote:
Hi all,
this patch add coloured output in to pacman-3.0.0
diff is here: http://www.fi.muni.cz/~xgondz/pacman3-color/pacman3-color.diff
I think the general consensus is that coloring pacman output is bad, but I really have no technical opinion. Two things, about your patch: a) Could you set this up to include a pacman.conf setting (maybe UseColor) and only output color when that is true. b) Could you please send the patch in unified diff format, it makes it easier for us to see the changes you made and comment on them (see submitting-patches at the top of pacman CVS's root). Thanks for the patch! Does anyone have strong opinions either way about color? I for one don't care that much, as long as I can shut it off.
2007/2/6, Aaron Griffin <aaronmgriffin@gmail.com>:
On 2/6/07, Vojtěch Gondžala <vogo@seznam.cz> wrote:
Hi all,
this patch add coloured output in to pacman-3.0.0
diff is here: http://www.fi.muni.cz/~xgondz/pacman3-color/pacman3-color.diff
I think the general consensus is that coloring pacman output is bad, but I really have no technical opinion.
Two things, about your patch: a) Could you set this up to include a pacman.conf setting (maybe UseColor) and only output color when that is true.
b) Could you please send the patch in unified diff format, it makes it easier for us to see the changes you made and comment on them (see submitting-patches at the top of pacman CVS's root).
Thanks for the patch!
Does anyone have strong opinions either way about color? I for one don't care that much, as long as I can shut it off.
I don't mind about color. Anyway makepkg and initscripts do use colored messages, so why not pacman? Of course it can be customizable (I would prefer common way of doing this in makepkg, initscripts and pacman) and optional (UseColor in pacman.conf), and of course it shouldn't add complexity to code. This patch is hard to read (because it's not unified diff) but as I see it would be better to do not change MSG(NL, ...) to MSG(NL, color(...)), but instead change MSG itself - this would be much cleaner way, IMO. -- Roman Kyrylych (Роман Кирилич)
2007/2/6, Roman Kyrylych <roman.kyrylych@gmail.com>:
I don't mind about color. Anyway makepkg and initscripts do use colored messages, so why not pacman? Of course it can be customizable (I would prefer common way of doing this in makepkg, initscripts and pacman) and optional (UseColor in pacman.conf), and of course it shouldn't add complexity to code. This patch is hard to read (because it's not unified diff) but as I see it would be better to do not change MSG(NL, ...) to MSG(NL, color(...)), but instead change MSG itself - this would be much cleaner way, IMO.
Forgot to add: IMO it would be better to chage printf(color(...)) to function too. P.S.: what's the principal difference between printf'ing and MSG'ing? -- Roman Kyrylych (Роман Кирилич)
On 2/6/07, Roman Kyrylych <roman.kyrylych@gmail.com> wrote:
P.S.: what's the principal difference between printf'ing and MSG'ing?
It's complicated, and one of the things Dan and I plan on addressing in the 3.1 release. MSG() is a macro around the pm_fprintf function call. Same with ERR().
On 2/6/07, Aaron Griffin <aaronmgriffin@gmail.com> wrote:
On 2/6/07, Vojtěch Gondžala <vogo@seznam.cz> wrote:
Hi all,
this patch add coloured output in to pacman-3.0.0
diff is here: http://www.fi.muni.cz/~xgondz/pacman3-color/pacman3-color.diff
I think the general consensus is that coloring pacman output is bad, but I really have no technical opinion.
My opinion on color is this- it seems to make more sense in bash scripting than C programming. However, it is something often asked for, so I don't want to say it isn't something that should be considered. I guess I would say this...perhaps we should wait for pacman 3.1 when we try to refine the output system a bit. Right now, pm_fprintf, MSG, and ERR just make a lot of trouble it seems, and we need to fix those up a bit. I'd like to see the kind of color that this patch provides to see what direction we should go with changing the output functions. -Dan
On 2/6/07, Dan McGee <dpmcgee@gmail.com> wrote:
I'd like to see the kind of color that this patch provides to see what direction we should go with changing the output functions.
It seems there's a forum thread: http://bbs.archlinux.org/viewtopic.php?id=29624
On Tue, Feb 06, 2007 at 10:49:40AM -0600, Aaron Griffin wrote:
On 2/6/07, Vojtěch Gondžala <vogo@seznam.cz> wrote:
Hi all,
this patch add coloured output in to pacman-3.0.0
diff is here: http://www.fi.muni.cz/~xgondz/pacman3-color/pacman3-color.diff
I think the general consensus is that coloring pacman output is bad, but I really have no technical opinion.
Two things, about your patch: a) Could you set this up to include a pacman.conf setting (maybe UseColor) and only output color when that is true.
b) Could you please send the patch in unified diff format, it makes it easier for us to see the changes you made and comment on them (see submitting-patches at the top of pacman CVS's root).
Thanks for the patch!
Does anyone have strong opinions either way about color? I for one don't care that much, as long as I can shut it off.
Its not easy to display colored text in a portable way. An easy, but wrong way is using ANSI escape sequences directly because you make assumption about the tty. A much more portable way is querying the database of terminal capabilities (termcap/terminfo). Jürgen
On 2/6/07, Jürgen Hötzel <juergen@hoetzel.info> wrote:
Its not easy to display colored text in a portable way. An easy, but wrong way is using ANSI escape sequences directly because you make assumption about the tty.
A much more portable way is querying the database of terminal capabilities (termcap/terminfo).
Jürgen
Much better put than my point about hardcoding the escape sequences in C code. Although not necessarily good in a bash script, the code can be edited if necessary quite easily to fix escape sequences. However, Jürgen makes the excellent point that these escape sequences cannot always be assumed to be portable. -Dan
On 2/6/07, Dan McGee <dpmcgee@gmail.com> wrote:
On 2/6/07, Jürgen Hötzel <juergen@hoetzel.info> wrote:
Its not easy to display colored text in a portable way. An easy, but wrong way is using ANSI escape sequences directly because you make assumption about the tty.
A much more portable way is querying the database of terminal capabilities (termcap/terminfo).
Jürgen
Much better put than my point about hardcoding the escape sequences in C code. Although not necessarily good in a bash script, the code can be edited if necessary quite easily to fix escape sequences. However, Jürgen makes the excellent point that these escape sequences cannot always be assumed to be portable.
And, one of the things I said the last time (6 months ago?) about this topic, was that, it'd be nice to support bold/underline or whatever on mono terminals too, in the absence of color. That'd be real fancy.
On Tue, Feb 06, 2007 at 02:37:04PM -0600, Aaron Griffin wrote:
On 2/6/07, Dan McGee <dpmcgee@gmail.com> wrote:
On 2/6/07, Jürgen Hötzel <juergen@hoetzel.info> wrote:
Its not easy to display colored text in a portable way. An easy, but wrong way is using ANSI escape sequences directly because you make assumption about the tty.
A much more portable way is querying the database of terminal capabilities (termcap/terminfo).
Jürgen
Much better put than my point about hardcoding the escape sequences in C code. Although not necessarily good in a bash script, the code can be edited if necessary quite easily to fix escape sequences. However, Jürgen makes the excellent point that these escape sequences cannot always be assumed to be portable.
And, one of the things I said the last time (6 months ago?) about this topic, was that, it'd be nice to support bold/underline or whatever on mono terminals too, in the absence of color. That'd be real fancy. _______________________________________________
Possible by querying the terminfo database. In Shell: if ! tput setf 4; then # try red tput bold; # else bold fi Jürgen
On Tue, Feb 06, 2007 at 03:11:06PM -0500, Dan McGee wrote:
On 2/6/07, Jürgen Hötzel <juergen@hoetzel.info> wrote:
Its not easy to display colored text in a portable way. An easy, but wrong way is using ANSI escape sequences directly because you make assumption about the tty.
A much more portable way is querying the database of terminal capabilities (termcap/terminfo).
Jürgen
Much better put than my point about hardcoding the escape sequences in C code. Although not necessarily good in a bash script, the code can be edited if necessary quite easily to fix escape sequences. However, Jürgen makes the excellent point that these escape sequences cannot always be assumed to be portable.
You can also query the terminfo database in shellscripts by using ncurses tput utility. For example: $ echo `tput setf 4`RED Jürgen
OK, i make new diff(http://www.fi.muni.cz/~xgondz/pacman3-color/pacman3-color.diff), I hope that is correct. The function color is colouring a string only when descriptor is a tty, it's querying via function isatty. I thing, when a string will be colouring in function pm_fprintf must be overlay function fprintf and that isn't a trifle. I can keep this patch out of pacman, when you think that color output in console isn't good idea, it isn't problem ;-).
On 2/6/07, Vojtěch Gondžala <vogo@seznam.cz> wrote:
OK, i make new diff(http://www.fi.muni.cz/~xgondz/pacman3-color/pacman3-color.diff), I hope that is correct.
The function color is colouring a string only when descriptor is a tty, it's querying via function isatty.
I thing, when a string will be colouring in function pm_fprintf must be overlay function fprintf and that isn't a trifle.
I can keep this patch out of pacman, when you think that color output in console isn't good idea, it isn't problem ;-).
The idea definitely has promise. We just have to make sure if we implement it, we do it in a way that doesn't break the way a lot of people may use pacman. Thanks for the diff though- you are the first person to actually follow through with a feature request this big and patch it. -Dan
2007/2/6, Vojtěch Gondžala <vogo@seznam.cz>:
OK, i make new diff(http://www.fi.muni.cz/~xgondz/pacman3-color/pacman3-color.diff), I hope that is correct.
The function color is colouring a string only when descriptor is a tty, it's querying via function isatty.
I thing, when a string will be colouring in function pm_fprintf must be overlay function fprintf and that isn't a trifle.
I can keep this patch out of pacman, when you think that color output in console isn't good idea, it isn't problem ;-).
Unified diffs look much better. :) My thoughts: snprintf(tr, LOG_STR_LEN, color(2, . . .)) fprintf(color(2, . . .)) MSG(NL, color(1, . . .)) ERR(NL, color(2, . . .)) looks not very good, I hope in 3.1 this can be cleaned, so calling color function could be integrated in some new unified msg function. Then C_WHITE, C_DEFAULT could be eliminated too - coloring should be set per message type (class), not per each message. With improved messages output in 3.1 your patch will be much smaller then. -- Roman Kyrylych (Роман Кирилич)
participants (5)
-
Aaron Griffin
-
Dan McGee
-
Jürgen Hötzel
-
Roman Kyrylych
-
Vojtěch Gondžala