:: Re: [DNG] Does dunst require dbus?
Kezdőlap
Delete this message
Reply to this message
Szerző: Hendrik Boom
Dátum:  
Címzett: dng
Tárgy: Re: [DNG] Does dunst require dbus?
On Sun, Jan 24, 2016 at 02:30:15PM +0100, Didier Kryn wrote:
>
>     Thanks for the links. Actually I think I derived my PS1 settings
> from an example found in some default .bashrc. I found the colors by
> try and fail, or maybe I looked at what ncurses was producing. Of
> course you don't want to use ncurses here since you want to keep a
> scrolling terminal. I eventually wrote a simple C programs which
> changes the color. It understands color names in english and french
> - easy to change to your prefered language.

>
>     Steve can see the use I make of indentation and curly braces
> placement is non-standard, but it makes blocks more visible :-)


Really, not al lthat standard. It resembles the formatting that the FSF
recommends. Or once recommended, if I recall correctly.

It's my preferred formatting, too.

There's a longstanding dispute whether to use this one or the one
used in examples in the old K&R book. THe dispute will probaby never
be resolved.

--- hendrik

>
> #include <stdio.h>
> #include <curses.h>
> #include <term.h>
> #include <string.h>
>
> static int myputc(int c)
> {
> return fputc(c, stdout);
> }
>
> #define defcolor max_colors+1
> #define SETCOLOR(C) tputs(tparm(set_foreground, C), 1, myputc)
>
> int main(int argc, char **argv)
> {
> const char * const couleurs[] =
> {"noir", "bleu", "vert", "cyan", "rouge", "magenta", "jaune", "gris"};
> const char * const colours[] =
> {"black", "blue", "green", "cyan", "red", "magenta", "yellow", "grey"};
>
> int c;
> char choix[8];
>
> if(isatty(1)) setupterm(NULL, 1, NULL);
> else return 0;
>
>   if(argc>1)
>     {
>       for(c=0; argv[1][c] && c<8; c++) choix[c] = tolower(argv[1][c]);
>       choix[c] = '\0';
>       for(c=0; c<8; c++)
>         {
>           if(!strncmp(couleurs[c], choix, strlen(couleurs[c]))) break;
>           if(!strncmp(colours[c], choix, strlen(couleurs[c]))) break;
>         }
>     }
>   else c = defcolor;

>
> SETCOLOR(c);
> fflush(stdout);
> return 0;
> }