[PATCH 3/16] vt-underline-color.diff

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Linux Kernel Mailing List <linux-kernel@...>
Cc: Andrew Morton <akpm@...>
Date: Sunday, April 1, 2007 - 2:14 pm

Add color support to the "underline" and "italic" attributes as in
OpenBSD/NetBSD-style (vt220) and xterm.

Signed-off-by: Jan Engelhardt <jengelh@gmx.de>

 drivers/char/vt.c               |   34 ++++++++++++++++++++++++++++------
 drivers/video/console/mdacon.c  |    3 ++-
 drivers/video/console/promcon.c |    3 ++-
 drivers/video/console/sticon.c  |    2 +-
 drivers/video/console/vgacon.c  |   12 ++++++++----
 include/linux/console.h         |    2 +-
 include/linux/console_struct.h  |    3 +++
 7 files changed, 45 insertions(+), 14 deletions(-)

Index: linux-2.6.21-rc5/drivers/char/vt.c
===================================================================
--- linux-2.6.21-rc5.orig/drivers/char/vt.c
+++ linux-2.6.21-rc5/drivers/char/vt.c
@@ -348,10 +348,12 @@ void update_region(struct vc_data *vc, u
 
 /* Structure of attributes is hardware-dependent */
 
-static u8 build_attr(struct vc_data *vc, u8 _color, u8 _intensity, u8 _blink, u8 _underline, u8 _reverse)
+static u8 build_attr(struct vc_data *vc, u8 _color, u8 _intensity, u8 _blink,
+    u8 _underline, u8 _reverse, u8 _italic)
 {
 	if (vc->vc_sw->con_build_attr)
-		return vc->vc_sw->con_build_attr(vc, _color, _intensity, _blink, _underline, _reverse);
+		return vc->vc_sw->con_build_attr(vc, _color, _intensity,
+		       _blink, _underline, _reverse, _italic);
 
 #ifndef VT_BUF_VRAM_ONLY
 /*
@@ -368,10 +370,13 @@ static u8 build_attr(struct vc_data *vc,
 	u8 a = vc->vc_color;
 	if (!vc->vc_can_do_color)
 		return _intensity |
+		       (_italic ? 2 : 0) |
 		       (_underline ? 4 : 0) |
 		       (_reverse ? 8 : 0) |
 		       (_blink ? 0x80 : 0);
-	if (_underline)
+	if (_italic)
+		a = (a & 0xF0) | vc->vc_itcolor;
+	else if (_underline)
 		a = (a & 0xf0) | vc->vc_ulcolor;
 	else if (_intensity == 0)
 		a = (a & 0xf0) | vc->vc_ulcolor;
@@ -392,8 +397,10 @@ static u8 build_attr(struct vc_data *vc,
 
 static void update_attr(struct vc_data *vc)
 {
-	vc->vc_attr = build_attr(vc, vc->vc_color, vc->vc_intensity, vc->vc_blink, vc->vc_underline, vc->vc_reverse ^ vc->vc_decscnm);
-	vc->vc_video_erase_char = (build_attr(vc, vc->vc_color, 1, vc->vc_blink, 0, vc->vc_decscnm) << 8) | ' ';
+	vc->vc_attr = build_attr(vc, vc->vc_color, vc->vc_intensity,
+	              vc->vc_blink, vc->vc_underline,
+	              vc->vc_reverse ^ vc->vc_decscnm, vc->vc_italic);
+	vc->vc_video_erase_char = (build_attr(vc, vc->vc_color, 1, vc->vc_blink, 0, vc->vc_decscnm, 0) << 8) | ' ';
 }
 
 /* Note: inverting the screen twice should revert to the original state */
@@ -1136,6 +1143,7 @@ static void csi_X(struct vc_data *vc, in
 static void default_attr(struct vc_data *vc)
 {
 	vc->vc_intensity = 1;
+	vc->vc_italic = 0;
 	vc->vc_underline = 0;
 	vc->vc_reverse = 0;
 	vc->vc_blink = 0;
@@ -1158,6 +1166,9 @@ static void csi_m(struct vc_data *vc)
 			case 2:
 				vc->vc_intensity = 0;
 				break;
+			case 3:
+				vc->vc_italic = 1;
+				break;
 			case 4:
 				vc->vc_underline = 1;
 				break;
@@ -1198,6 +1209,9 @@ static void csi_m(struct vc_data *vc)
 			case 22:
 				vc->vc_intensity = 1;
 				break;
+			case 23:
+				vc->vc_italic = 0;
+				break;
 			case 24:
 				vc->vc_underline = 0;
 				break;
@@ -1458,6 +1472,7 @@ static void save_cur(struct vc_data *vc)
 	vc->vc_saved_x		= vc->vc_x;
 	vc->vc_saved_y		= vc->vc_y;
 	vc->vc_s_intensity	= vc->vc_intensity;
+	vc->vc_s_italic         = vc->vc_italic;
 	vc->vc_s_underline	= vc->vc_underline;
 	vc->vc_s_blink		= vc->vc_blink;
 	vc->vc_s_reverse	= vc->vc_reverse;
@@ -1472,6 +1487,7 @@ static void restore_cur(struct vc_data *
 {
 	gotoxy(vc, vc->vc_saved_x, vc->vc_saved_y);
 	vc->vc_intensity	= vc->vc_s_intensity;
+	vc->vc_italic		= vc->vc_s_italic;
 	vc->vc_underline	= vc->vc_s_underline;
 	vc->vc_blink		= vc->vc_s_blink;
 	vc->vc_reverse		= vc->vc_s_reverse;
@@ -2585,6 +2601,11 @@ static void con_close(struct tty_struct 
 	mutex_unlock(&tty_mutex);
 }
 
+static int default_italic_color    = 2; // green (ASCII)
+static int default_underline_color = 3; // cyan (ASCII)
+module_param_named(italic, default_italic_color, int, S_IRUGO | S_IWUSR);
+module_param_named(underline, default_underline_color, int, S_IRUGO | S_IWUSR);
+
 static void vc_init(struct vc_data *vc, unsigned int rows,
 		    unsigned int cols, int do_clear)
 {
@@ -2604,7 +2625,8 @@ static void vc_init(struct vc_data *vc, 
 		vc->vc_palette[k++] = default_blu[j] ;
 	}
 	vc->vc_def_color       = 0x07;   /* white */
-	vc->vc_ulcolor		= 0x0f;   /* bold white */
+	vc->vc_ulcolor         = default_underline_color;
+	vc->vc_itcolor         = default_italic_color;
 	vc->vc_halfcolor       = 0x08;   /* grey */
 	init_waitqueue_head(&vc->paste_wait);
 	reset_terminal(vc, do_clear);
Index: linux-2.6.21-rc5/drivers/video/console/mdacon.c
===================================================================
--- linux-2.6.21-rc5.orig/drivers/video/console/mdacon.c
+++ linux-2.6.21-rc5/drivers/video/console/mdacon.c
@@ -384,7 +384,7 @@ static inline u16 mda_convert_attr(u16 c
 }
 
 static u8 mdacon_build_attr(struct vc_data *c, u8 color, u8 intensity, 
-			    u8 blink, u8 underline, u8 reverse)
+			    u8 blink, u8 underline, u8 reverse, u8 italic)
 {
 	/* The attribute is just a bit vector:
 	 *
@@ -397,6 +397,7 @@ static u8 mdacon_build_attr(struct vc_da
 	return (intensity & 3) |
 		((underline & 1) << 2) |
 		((reverse   & 1) << 3) |
+		(!!italic << 4) |
 		((blink     & 1) << 7);
 }
 
Index: linux-2.6.21-rc5/drivers/video/console/promcon.c
===================================================================
--- linux-2.6.21-rc5.orig/drivers/video/console/promcon.c
+++ linux-2.6.21-rc5/drivers/video/console/promcon.c
@@ -548,7 +548,8 @@ promcon_scroll(struct vc_data *conp, int
 }
 
 #if !(PROMCON_COLOR)
-static u8 promcon_build_attr(struct vc_data *conp, u8 _color, u8 _intensity, u8 _blink, u8 _underline, u8 _reverse)
+static u8 promcon_build_attr(struct vc_data *conp, u8 _color, u8 _intensity,
+    u8 _blink, u8 _underline, u8 _reverse, u8 _italic)
 {
 	return (_reverse) ? 0xf : 0x7;
 }
Index: linux-2.6.21-rc5/drivers/video/console/sticon.c
===================================================================
--- linux-2.6.21-rc5.orig/drivers/video/console/sticon.c
+++ linux-2.6.21-rc5/drivers/video/console/sticon.c
@@ -314,7 +314,7 @@ static unsigned long sticon_getxy(struct
 }
 
 static u8 sticon_build_attr(struct vc_data *conp, u8 color, u8 intens,
-			    u8 blink, u8 underline, u8 reverse)
+			    u8 blink, u8 underline, u8 reverse, u8 italic)
 {
     u8 attr = ((color & 0x70) >> 1) | ((color & 7));
 
Index: linux-2.6.21-rc5/drivers/video/console/vgacon.c
===================================================================
--- linux-2.6.21-rc5.orig/drivers/video/console/vgacon.c
+++ linux-2.6.21-rc5/drivers/video/console/vgacon.c
@@ -87,7 +87,7 @@ static void vgacon_save_screen(struct vc
 static int vgacon_scroll(struct vc_data *c, int t, int b, int dir,
 			 int lines);
 static u8 vgacon_build_attr(struct vc_data *c, u8 color, u8 intensity,
-			    u8 blink, u8 underline, u8 reverse);
+			    u8 blink, u8 underline, u8 reverse, u8);
 static void vgacon_invert_region(struct vc_data *c, u16 * p, int count);
 static unsigned long vgacon_uni_pagedir[2];
 
@@ -577,12 +577,14 @@ static void vgacon_deinit(struct vc_data
 }
 
 static u8 vgacon_build_attr(struct vc_data *c, u8 color, u8 intensity,
-			    u8 blink, u8 underline, u8 reverse)
+			    u8 blink, u8 underline, u8 reverse, u8 italic)
 {
 	u8 attr = color;
 
 	if (vga_can_do_color) {
-		if (underline)
+		if (italic)
+			attr = (attr & 0xF0) | c->vc_itcolor;
+		else if (underline)
 			attr = (attr & 0xf0) | c->vc_ulcolor;
 		else if (intensity == 0)
 			attr = (attr & 0xf0) | c->vc_halfcolor;
@@ -596,7 +598,9 @@ static u8 vgacon_build_attr(struct vc_da
 	if (intensity == 2)
 		attr ^= 0x08;
 	if (!vga_can_do_color) {
-		if (underline)
+		if (italic)
+			attr = (attr & 0xF8) | 0x02;
+		else if (underline)
 			attr = (attr & 0xf8) | 0x01;
 		else if (intensity == 0)
 			attr = (attr & 0xf0) | 0x08;
Index: linux-2.6.21-rc5/include/linux/console.h
===================================================================
--- linux-2.6.21-rc5.orig/include/linux/console.h
+++ linux-2.6.21-rc5/include/linux/console.h
@@ -51,7 +51,7 @@ struct consw {
 	int	(*con_scrolldelta)(struct vc_data *, int);
 	int	(*con_set_origin)(struct vc_data *);
 	void	(*con_save_screen)(struct vc_data *);
-	u8	(*con_build_attr)(struct vc_data *, u8, u8, u8, u8, u8);
+	u8	(*con_build_attr)(struct vc_data *, u8, u8, u8, u8, u8, u8);
 	void	(*con_invert_region)(struct vc_data *, u16 *, int);
 	u16    *(*con_screen_pos)(struct vc_data *, int);
 	unsigned long (*con_getxy)(struct vc_data *, unsigned long, int *, int *);
Index: linux-2.6.21-rc5/include/linux/console_struct.h
===================================================================
--- linux-2.6.21-rc5.orig/include/linux/console_struct.h
+++ linux-2.6.21-rc5/include/linux/console_struct.h
@@ -37,6 +37,7 @@ struct vc_data {
 	unsigned char	vc_color;		/* Foreground & background */
 	unsigned char	vc_s_color;		/* Saved foreground & background */
 	unsigned char	vc_ulcolor;		/* Color for underline mode */
+	unsigned char   vc_itcolor;
 	unsigned char	vc_halfcolor;		/* Color for half intensity mode */
 	/* cursor */
 	unsigned int	vc_cursor_type;
@@ -71,10 +72,12 @@ struct vc_data {
 	unsigned int	vc_deccolm	: 1;	/* 80/132 Column Mode */
 	/* attribute flags */
 	unsigned int	vc_intensity	: 2;	/* 0=half-bright, 1=normal, 2=bold */
+	unsigned int    vc_italic:1;
 	unsigned int	vc_underline	: 1;
 	unsigned int	vc_blink	: 1;
 	unsigned int	vc_reverse	: 1;
 	unsigned int	vc_s_intensity	: 2;	/* saved rendition */
+	unsigned int    vc_s_italic:1;
 	unsigned int	vc_s_underline	: 1;
 	unsigned int	vc_s_blink	: 1;
 	unsigned int	vc_s_reverse	: 1;
#<EOF>

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/16] Assorted patches, Jan Engelhardt, (Sun Apr 1, 2:13 pm)
[PATCH 16/16] warn-on-kthread-name-truncation.diff, Jan Engelhardt, (Sun Apr 1, 2:18 pm)
Re: [PATCH 16/16] warn-on-kthread-name-truncation.diff, Andrew Morton, (Mon Apr 2, 2:00 am)
Re: [PATCH 16/16] warn-on-kthread-name-truncation.diff, Jan Engelhardt, (Mon Apr 2, 2:51 am)
[PATCH 15/16] use-regular-eth-suffix.diff, Jan Engelhardt, (Sun Apr 1, 2:18 pm)
Re: [PATCH 15/16] use-regular-eth-suffix.diff, Kyle Moffett, (Sun Apr 1, 2:42 pm)
Re: [PATCH 15/16] use-regular-eth-suffix.diff, Jouni Malinen, (Sun Apr 1, 9:40 pm)
[PATCH 14/16] kconfig-allow-override.diff, Jan Engelhardt, (Sun Apr 1, 2:17 pm)
Re: [PATCH 14/16] kconfig-allow-override.diff, Sam Ravnborg, (Sun Apr 1, 2:44 pm)
Re: [PATCH 14/16] kconfig-allow-override.diff, Randy Dunlap, (Sun Apr 1, 3:09 pm)
[PATCH 13/16] show-pipesize-in-stat.diff, Jan Engelhardt, (Sun Apr 1, 2:17 pm)
Re: [PATCH 13/16] show-pipesize-in-stat.diff, Eric Dumazet, (Mon Apr 2, 6:41 am)
Re: [PATCH 13/16] show-pipesize-in-stat.diff, Jan Engelhardt, (Tue Apr 3, 8:48 pm)
Re: [PATCH 13/16] show-pipesize-in-stat.diff, Eric Dumazet, (Wed Apr 4, 1:03 am)
Re: [PATCH 13/16] show-pipesize-in-stat.diff, Jan Engelhardt, (Tue Apr 17, 4:05 am)
Re: [PATCH 13/16] show-pipesize-in-stat.diff, Andrew Morton, (Mon Apr 2, 1:58 am)
Re: [PATCH 13/16] show-pipesize-in-stat.diff, Jan Engelhardt, (Mon Apr 2, 2:48 am)
[PATCH 12/16] cifs-use-mutex.diff, Jan Engelhardt, (Sun Apr 1, 2:16 pm)
Re: [PATCH 12/16] cifs-use-mutex.diff, Roland Dreier, (Mon Apr 2, 1:36 am)
[PATCH 11/16] samba-eintr-fix.diff, Jan Engelhardt, (Sun Apr 1, 2:16 pm)
Re: [PATCH 11/16] samba-eintr-fix.diff, Andrew Morton, (Mon Apr 2, 1:53 am)
Re: [PATCH 11/16] samba-eintr-fix.diff, Dave Jones, (Sun Apr 1, 3:09 pm)
Re: [PATCH 11/16] samba-eintr-fix.diff, Jan Engelhardt, (Sun Apr 1, 3:28 pm)
Re: [PATCH 11/16] samba-eintr-fix.diff, Dave Jones, (Sun Apr 1, 3:42 pm)
[PATCH 10/16] show-partitions-on-mount-error.diff, Jan Engelhardt, (Sun Apr 1, 2:15 pm)
Re: [PATCH 10/16] show-partitions-on-mount-error.diff, Pavel Machek, (Mon Apr 2, 2:59 pm)
Re: [PATCH 10/16] show-partitions-on-mount-error.diff, Jan Engelhardt, (Tue Apr 3, 8:42 pm)
Re: [PATCH 10/16] show-partitions-on-mount-error.diff, Andrew Morton, (Mon Apr 2, 1:48 am)
Re: [PATCH 10/16] show partitions on mount error, Jan Engelhardt, (Mon Apr 2, 3:01 am)
Re: [PATCH 10/16] show-partitions-on-mount-error.diff, Andrew Morton, (Mon Apr 2, 1:47 am)
[PATCH 09/16] zlib-decompression-status.diff, Jan Engelhardt, (Sun Apr 1, 2:15 pm)
Re: [PATCH 09/16] zlib-decompression-status.diff, Jan Engelhardt, (Mon Apr 2, 2:50 pm)
[PATCH 08/16] console-printk-level.diff, Jan Engelhardt, (Sun Apr 1, 2:15 pm)
Re: [PATCH 08/16] console-printk-level.diff, Randy Dunlap, (Sun Apr 1, 3:07 pm)
[PATCH 07/16] kconfig-dynamic-frequency.diff, Jan Engelhardt, (Sun Apr 1, 2:15 pm)
Re: [PATCH 07/16] kconfig-dynamic-frequency.diff, Kyle Moffett, (Sun Apr 1, 2:39 pm)
Re: [PATCH 07/16] kconfig-dynamic-frequency.diff, Jan Engelhardt, (Sun Apr 1, 2:42 pm)
Re: [PATCH 07/16] kconfig-dynamic-frequency.diff, Kyle Moffett, (Sun Apr 1, 2:52 pm)
Re: [PATCH 07/16] kconfig-dynamic-frequency.diff, Robert P. J. Day, (Sun Apr 1, 4:22 pm)
Re: [PATCH 07/16] kconfig-dynamic-frequency.diff, Jan Engelhardt, (Sun Apr 1, 3:01 pm)
[PATCH], Kyle Moffett, (Sun Apr 1, 3:42 pm)
Re: [PATCH], Jan Engelhardt, (Sun Apr 1, 3:47 pm)
Re: [PATCH], Kyle Moffett, (Sun Apr 1, 4:07 pm)
Re: [PATCH], Andi Kleen, (Sun Apr 1, 7:03 pm)
[PATCH 06/16] isofs-add-write-bit.diff, Jan Engelhardt, (Sun Apr 1, 2:15 pm)
[PATCH 5/16] fix-kthread-niceness.diff, Jan Engelhardt, (Sun Apr 1, 2:14 pm)
Re: [PATCH 5/16] fix-kthread-niceness.diff, Andrew Morton, (Mon Apr 2, 1:39 am)
[PATCH 4/16] vt-printk-color.diff, Jan Engelhardt, (Sun Apr 1, 2:14 pm)
[PATCH 3/16] vt-underline-color.diff, Jan Engelhardt, (Sun Apr 1, 2:14 pm)
Re: [PATCH 3/16] vt-underline-color.diff, Andrew Morton, (Mon Apr 2, 1:37 am)
Re: [PATCH 3/16] vt-underline-color.diff, Antonino A. Daplas, (Mon Apr 2, 2:57 am)
[PATCH 2/16] vt-pure-colors.diff, Jan Engelhardt, (Sun Apr 1, 2:14 pm)
Re: [PATCH 2/16] vt-pure-colors.diff, James Bruce, (Sun Apr 1, 2:39 pm)
Re: [PATCH 2/16] vt-pure-colors.diff, Antonino A. Daplas, (Mon Apr 2, 2:49 am)
Re: [PATCH 2/16] vt-pure-colors.diff, Jan Engelhardt, (Mon Apr 2, 3:04 am)
Re: [PATCH 2/16] vt-pure-colors.diff, Antonino A. Daplas, (Mon Apr 2, 3:50 am)
Re: [PATCH 2/16] vt-pure-colors.diff, Jan Engelhardt, (Mon Apr 2, 4:01 am)
[PATCH 1/16] vt-sysfs-for-colors.diff, Jan Engelhardt, (Sun Apr 1, 2:13 pm)
Re: [PATCH 1/16] vt-sysfs-for-colors.diff, Antonino A. Daplas, (Mon Apr 2, 2:49 am)
[PATCH 17/16] Do not reset UTF8 on terminal reset, Jan Engelhardt, (Mon Apr 2, 3:31 am)
Re: [PATCH 17/16] Do not reset UTF8 on terminal reset, Pavel Machek, (Mon Apr 2, 2:50 pm)
Re: [PATCH 17/16] Do not reset UTF8 on terminal reset, Paul LeoNerd Evans, (Mon Apr 2, 7:26 am)
Re: [PATCH 17/16] Do not reset UTF8 on terminal reset, Antonino A. Daplas, (Mon Apr 2, 7:44 am)
Re: [PATCH 17/16] Do not reset UTF8 on terminal reset, Paul LeoNerd Evans, (Mon Apr 2, 7:54 am)
Re: [PATCH 17/16] Do not reset UTF8 on terminal reset, Antonino A. Daplas, (Mon Apr 2, 8:47 am)
Re: [PATCH 17/16] Do not reset UTF8 on terminal reset, Jan Engelhardt, (Mon Apr 2, 9:34 am)
Re: [PATCH 17/16] Do not reset UTF8 on terminal reset, Paul LeoNerd Evans, (Mon Apr 2, 9:20 am)
Re: [PATCH 17/16] Do not reset UTF8 on terminal reset, Antonino A. Daplas, (Mon Apr 2, 5:30 am)