summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2014-05-12 10:22:09 +0200
committerKarel Zak2014-05-13 12:13:02 +0200
commit496c979a09899fac38b82e4b8d10bc4700407157 (patch)
tree31d286a746acf09b9463373efc28e058690244bf
parenthexdump: add --color to the man page (diff)
downloadkernel-qcow2-util-linux-496c979a09899fac38b82e4b8d10bc4700407157.tar.gz
kernel-qcow2-util-linux-496c979a09899fac38b82e4b8d10bc4700407157.tar.xz
kernel-qcow2-util-linux-496c979a09899fac38b82e4b8d10bc4700407157.zip
fdisk: support colors customization
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--disk-utils/fdisk-menu.c2
-rw-r--r--disk-utils/fdisk.827
-rw-r--r--disk-utils/fdisk.c8
3 files changed, 24 insertions, 13 deletions
diff --git a/disk-utils/fdisk-menu.c b/disk-utils/fdisk-menu.c
index 4e44f0b85..c688fdfef 100644
--- a/disk-utils/fdisk-menu.c
+++ b/disk-utils/fdisk-menu.c
@@ -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
diff --git a/disk-utils/fdisk.8 b/disk-utils/fdisk.8
index d542da9b4..94081efa1 100644
--- a/disk-utils/fdisk.8
+++ b/disk-utils/fdisk.8
@@ -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
diff --git a/disk-utils/fdisk.c b/disk-utils/fdisk.c
index 8762a7ac8..7df6b899d 100644
--- a/disk-utils/fdisk.c
+++ b/disk-utils/fdisk.c
@@ -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"