[pacman-dev] Pacman color output
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I don't know if you have discussed this before, any chance to see color support to pacman's output? i really loved the way pacman does the download when adding "ilovecandy" to /etc/pacman.conf :D, so I tried to add some colors but since the string length is checked in pm_fprintf function, it may break the message, I tried doing it in another way (by simply adding an extra char *color to pm_fprintf function) but I am not a C++ programer so i failed specially about adding strings together (color + str + CLEAR) to fprintf, anyone interresting in doing it ? Regards, Wael Nasreddine -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) iD8DBQFEgsaFVWU5RcjdGKIRApalAJ0btdXfcN25YSWz7y8YCXYnJpVYvgCgvWF4 sK/TTvg3yz8T2y6TboCqDv0= =DoAW -----END PGP SIGNATURE-----
On Sun, Jun 04, 2006 at 01:39:50PM +0200, Wael Nasreddine <wael@siemens-mobiles.org> wrote:
I don't know if you have discussed this before, any chance to see color support to pacman's output? i really loved the way pacman does the download when adding "ilovecandy" to /etc/pacman.conf :D, so I
if you have ilovecandy in pacman.conf, then why not? probably it should be disabled by default, it can cause problems on some weird terminals
tried to add some colors but since the string length is checked in pm_fprintf function, it may break the message, I tried doing it in
you mean the 9 chars limit? see this: http://www.archlinux.org/pipermail/pacman-dev/2006-May/000313.html if that's the problem, then just use the patch, and it'll go away :)
another way (by simply adding an extra char *color to pm_fprintf function) but I am not a C++ programer so i failed specially about
pacman is written in C, not in C++
adding strings together (color + str + CLEAR) to fprintf, anyone interresting in doing it ?
the coding part, yes. but i don't want to figure out what colors looks nice :) ok, probably red for errors, but the others.. example: $ LANG= LC_ALL= sudo pacman -Sy :: Synchronizing package databases... then you can say echo -e "\e[01;36m::\e[0m \e[01mSynchronizing package databases...\e[0m" would be nicer. that way you don't have to do any coding and i don't have to figure out the colors :) udv / greetings, VMiklos -- Developer of Frugalware Linux, to make things frugal - http://frugalware.org
VMiklos wrote:
On Sun, Jun 04, 2006 at 01:39:50PM +0200, Wael Nasreddine <wael@siemens-mobiles.org> wrote:
I don't know if you have discussed this before, any chance to see color support to pacman's output? i really loved the way pacman does the download when adding "ilovecandy" to /etc/pacman.conf :D, so I
if you have ilovecandy in pacman.conf, then why not? probably it should be disabled by default, it can cause problems on some weird terminals
Yes it is disabled by default actually and i didn't even know about it, i just saw it inside the code..
tried to add some colors but since the string length is checked in pm_fprintf function, it may break the message, I tried doing it in
you mean the 9 chars limit?
see this: http://www.archlinux.org/pipermail/pacman-dev/2006-May/000313.html
if that's the problem, then just use the patch, and it'll go away :)
it is already applied, i'll see how many chars i can print
another way (by simply adding an extra char *color to pm_fprintf function) but I am not a C++ programer so i failed specially about
pacman is written in C, not in C++
:$
adding strings together (color + str + CLEAR) to fprintf, anyone interresting in doing it ?
the coding part, yes. but i don't want to figure out what colors looks nice :) ok, probably red for errors, but the others..
example:
$ LANG= LC_ALL= sudo pacman -Sy :: Synchronizing package databases...
then you can say
echo -e "\e[01;36m::\e[0m \e[01mSynchronizing package databases...\e[0m"
would be nicer. that way you don't have to do any coding and i don't have to figure out the colors :)
Actually what i did, in src/pacman/log.h i added something like /* colors */ #define GREEN "\033[1;32m" #define RED "\033[1;31m" #define YELLOW "\033[1;33m" #define BLUE "\033[1;36m" #define CLEAR "\033[m" maybe add them in the config instead but anyway this would be make things easier, i also added config->color (use_color directive) which probably be better, though there's too much messages to edit, anyway i'll try the above instead of GREEN etc.. i'll call them INFO WARN ERROR CLEAR so it'll be open, and if it's ok i'll send a patch (base code is urs from frugalware) ..
udv / greetings, VMiklos
Regards, Wael Nasreddine
On Sun, Jun 04, 2006 at 02:09:20PM +0200, Wael Nasreddine <wael@siemens-mobiles.org> wrote:
Yes it is disabled by default actually and i didn't even know about it, i just saw it inside the code..
probably you know the definitio of the easter egg ;)
it is already applied, i'll see how many chars i can print
$ grep LOG_STR_LEN *.h log.h:#define LOG_STR_LEN 256
Actually what i did, in src/pacman/log.h i added something like /* colors */ #define GREEN "\033[1;32m" #define RED "\033[1;31m" #define YELLOW "\033[1;33m" #define BLUE "\033[1;36m" #define CLEAR "\033[m"
maybe add them in the config instead
huh? #defines are correct imho, we don't want a theme-able pacman, do we? :)
but anyway this would be make things easier, i also added config->color (use_color directive) which probably be better
imo separating this from the ilovecandy is a good idea
though there's too much messages to edit
you can handle the libalpm messages at once. in pacman itself, what about modifying only the MSG, WARN and ERR macros in log.h? (an extra parameter to pm_fprintf then it could hanele the color or so)
i'll try the above instead of GREEN etc.. i'll call them INFO WARN ERROR CLEAR so it'll be open
i would suggest using the already existing names (see above)
and if it's ok i'll send a patch (base code is urs from frugalware) ..
sure, feel free to came up with a patch :) udv / greetings, VMiklos -- Developer of Frugalware Linux, to make things frugal - http://frugalware.org
participants (2)
-
VMiklos
-
Wael Nasreddine