]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fdisk: support colors customization
authorKarel Zak <kzak@redhat.com>
Mon, 12 May 2014 08:22:09 +0000 (10:22 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 13 May 2014 10:13:02 +0000 (12:13 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/fdisk-menu.c
disk-utils/fdisk.8
disk-utils/fdisk.c

index 4e44f0b854e3ed91720b205795be795be3b565c6..c688fdfef6a6fd6646e76d4b61aadcd28102530f 100644 (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
index d542da9b4168977e672ab291c12451072c566cf9..94081efa1f2dfbf1487f986caf06f2ad9624e485 100644 (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
index 8762a7ac8bfd3f974ca8e1859a9a91c04d364746..7df6b899dd97223f08a495d7f4c4d817adcb5eed 100644 (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"