Skip to content

Commit

Permalink
* mu-script: add color support (disable with --nocolor)
Browse files Browse the repository at this point in the history
  • Loading branch information
djcb committed Oct 24, 2012
1 parent 3bc3424 commit 25f367c
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions mu/mu-cmd-script.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/

/*
Expand Down Expand Up @@ -38,24 +37,27 @@
#define MU_GUILE_EXT ".scm"
#define MU_GUILE_DESCR_PREFIX ";; INFO: "

#define COL(C) ((color)?C:"")

static void
print_script (const char *name, const char *oneline, const char *descr,
gboolean verbose)
gboolean color, gboolean verbose)
{
g_print ("%s%s%s%s",
g_print ("%s%s%s%s%s%s%s%s",
verbose ? "\n" : " * ",
name,
COL(MU_COLOR_GREEN),name,COL(MU_COLOR_DEFAULT),
oneline ? ": " : "",
oneline ? oneline :"");
COL(MU_COLOR_BLUE),oneline ? oneline :"",MU_COLOR_DEFAULT);

if (verbose && descr)
g_print ("%s", descr);
g_print ("%s%s%s",
COL(MU_COLOR_MAGENTA),descr,COL(MU_COLOR_DEFAULT));
}


static gboolean
print_scripts (GSList *scripts, gboolean verbose, const char *rxstr,
GError **err)
print_scripts (GSList *scripts, gboolean color,
gboolean verbose, const char *rxstr, GError **err)
{
GSList *cur;

Expand Down Expand Up @@ -86,7 +88,7 @@ print_scripts (GSList *scripts, gboolean verbose, const char *rxstr,
continue;
}

print_script (name, oneline, descr, verbose);
print_script (name, oneline, descr, color, verbose);
}

return TRUE;
Expand Down Expand Up @@ -167,7 +169,7 @@ mu_cmd_script (MuConfig *opts, GError **err)
goto leave;

if (!opts->script) {
print_scripts (scripts, opts->verbose,
print_scripts (scripts, !opts->nocolor, opts->verbose,
opts->params[1], err);
goto leave;
}
Expand Down

0 comments on commit 25f367c

Please sign in to comment.