fdisk: support colors customization

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2014-05-12 10:22:09 +02:00
parent 052e512a64
commit 496c979a09
3 changed files with 24 additions and 13 deletions

View File

@ -359,7 +359,7 @@ static int print_fdisk_menu(struct fdisk_context *cxt)
if (IS_MENU_SEP(e) && (!e->title || !*e->title))
printf("\n");
else if (IS_MENU_SEP(e)) {
color_enable(UL_COLOR_BOLD);
color_scheme_enable("help-title", UL_COLOR_BOLD);
printf("\n %s\n", _(e->title));
color_disable();
} else

View File

@ -245,16 +245,27 @@ For best results, you should always use an OS-specific partition table
program. For example, you should make DOS partitions with the DOS FDISK
program and Linux partitions with the Linux fdisk or Linux cfdisk programs.
.SH COLORS
Implicit coloring can be disabled as follows:
.RS
Implicit coloring can be disabled by an empty file \fI/etc/terminal-colors.d/fdisk.disable\fR.
.br
.BI "touch /etc/terminal-colors.d/fdisk.disable"
.br
See
.BR terminal-colors.d (5)
for more details about colorization configuration. The logical color names
supported by
.B fdisk
are:
.TP
.B header
The header of the output tables.
.TP
.B help-title
The help section titles.
.TP
.B warn
The warning messages.
.TP
.B welcome
The welcome message.
.RE
For more details see
.BR terminal-colors.d (5).
.SH AUTHORS
.MT kzak@redhat.com
Karel Zak

View File

@ -338,13 +338,13 @@ int ask_callback(struct fdisk_context *cxt, struct fdisk_ask *ask,
fputs_info(ask, stdout);
break;
case FDISK_ASKTYPE_WARNX:
color_fenable(UL_COLOR_RED, stderr);
color_scheme_fenable("warn", UL_COLOR_RED, stderr);
fputs(fdisk_ask_print_get_mesg(ask), stderr);
color_fdisable(stderr);
fputc('\n', stderr);
break;
case FDISK_ASKTYPE_WARN:
color_fenable(UL_COLOR_RED, stderr);
color_scheme_fenable("warn", UL_COLOR_RED, stderr);
fputs(fdisk_ask_print_get_mesg(ask), stderr);
errno = fdisk_ask_print_get_errno(ask);
fprintf(stderr, ": %m\n");
@ -579,7 +579,7 @@ void list_disklabel(struct fdisk_context *cxt)
char *next = strchr(str, '\n');
if (next && colors_wanted()) {
*next = '\0';
color_enable(UL_COLOR_BOLD);
color_scheme_enable("header", UL_COLOR_BOLD);
fputs(p, stdout);
color_disable();
fputc('\n', stdout);
@ -902,7 +902,7 @@ int main(int argc, char **argv)
usage(stderr);
/* Here starts interactive mode, use fdisk_{warn,info,..} functions */
color_enable(UL_COLOR_GREEN);
color_scheme_enable("welcome", UL_COLOR_GREEN);
fdisk_info(cxt, _("Welcome to fdisk (%s)."), PACKAGE_STRING);
color_disable();
fdisk_info(cxt, _("Changes will remain in memory only, until you decide to write them.\n"