mirror of https://github.com/djcb/mu.git
Merge pull request #354 from aecepoglu/master
* removed 'nocolor' option. Added 'color' option
This commit is contained in:
commit
f71ca983b9
13
man/mu.1
13
man/mu.1
|
@ -111,13 +111,14 @@ for extract MIME-parts (such as attachments) from messages. See
|
|||
|
||||
.SH COLORS
|
||||
|
||||
Some \fBmu\fR sub-commands support colorized output. If you don't want this,
|
||||
you can use the \fI--nocolor\fR/ option to disable it. Even then, colors will
|
||||
only be shown when output goes to a sufficiently capable terminal (this roughly
|
||||
mirrors the \fI--color=auto\fR of the GNU-version of the \fBls\fR-command).
|
||||
Some \fBmu\fR sub-commands support colorized output using the \fB--color\fR option. This option mimics the
|
||||
behaviour of same option in the GNU-version of \fBls\fR-command :
|
||||
With \fI"--color=auto"\fR, output is colorized only when stardard output is
|
||||
connected to a terminal.
|
||||
\fI--color=never\fR doesn't print colorized output in any case,
|
||||
and \fI--color=always\fR will always print colors.
|
||||
|
||||
Instead of the \fI--color\fR/, you can also set the \fBMU_NOCOLOR\fR
|
||||
environment variable to non-empty to disable colors.
|
||||
The default value is \fI--color=always\fR.
|
||||
|
||||
Currently, \fBmu find\fR, \fBmu view\fR, \fBmu cfind\fR and \fBmu extract\fR
|
||||
support colors.
|
||||
|
|
|
@ -76,14 +76,23 @@ set_group_mu_defaults (void)
|
|||
g_free(MU_CONFIG.muhome);
|
||||
MU_CONFIG.muhome = exp;
|
||||
}
|
||||
}
|
||||
|
||||
/* check for the MU_NOCOLOR env var; but in any case don't
|
||||
* use colors unless we're writing to a tty */
|
||||
if (g_getenv (MU_NOCOLOR) != NULL)
|
||||
MU_CONFIG.nocolor = TRUE;
|
||||
|
||||
if (!isatty(fileno(stdout)) || !isatty(fileno(stderr)))
|
||||
static gboolean
|
||||
config_options_set_color (const gchar *option_name,
|
||||
const gchar *value,
|
||||
gpointer data,
|
||||
GError **error)
|
||||
{
|
||||
if( g_strcmp0( value, "never") == 0)
|
||||
MU_CONFIG.nocolor = TRUE;
|
||||
else if( g_strcmp0( value, "auto") == 0)
|
||||
MU_CONFIG.nocolor = (!isatty(fileno(stdout)) || !isatty(fileno(stderr)));
|
||||
else if( g_strcmp0( value, "always") == 0)
|
||||
MU_CONFIG.nocolor = FALSE;
|
||||
else
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GOptionGroup*
|
||||
|
@ -101,8 +110,8 @@ config_options_group_mu (void)
|
|||
"specify an alternative mu directory", "<dir>"},
|
||||
{"log-stderr", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.log_stderr,
|
||||
"log to standard error (false)", NULL},
|
||||
{"nocolor", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.nocolor,
|
||||
"don't use ANSI-colors in output (false)", NULL},
|
||||
{"color", 0, 0, G_OPTION_ARG_CALLBACK, &config_options_set_color,
|
||||
"colorize output (never|auto|always)", "<mode>"},
|
||||
{"verbose", 'v', 0, G_OPTION_ARG_NONE, &MU_CONFIG.verbose,
|
||||
"verbose output (false)", NULL},
|
||||
|
||||
|
|
|
@ -102,8 +102,8 @@ struct _MuConfig {
|
|||
gboolean version; /* request mu version */
|
||||
gboolean log_stderr; /* log to stderr (not logfile) */
|
||||
gchar** params; /* parameters (for querying) */
|
||||
gboolean nocolor; /* don't use use ansi-colors
|
||||
* in some output */
|
||||
gboolean nocolor; /* don't use use ansi-colors
|
||||
* in some output */
|
||||
gboolean verbose; /* verbose output */
|
||||
|
||||
/* options for indexing */
|
||||
|
|
Loading…
Reference in New Issue