All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Engelhardt <jengelh@linux01.gwdg.de>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: Andrew Morton <akpm@osdl.org>
Subject: [PATCH 3/16] vt-underline-color.diff
Date: Sun, 1 Apr 2007 20:14:14 +0200 (MEST)	[thread overview]
Message-ID: <Pine.LNX.4.61.0704012002570.12316@yvahk01.tjqt.qr> (raw)
In-Reply-To: <Pine.LNX.4.61.0704011900470.8018@yvahk01.tjqt.qr>


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>


  parent reply	other threads:[~2007-04-01 18:14 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-01 18:13 [PATCH 0/16] Assorted patches Jan Engelhardt
2007-04-01 18:13 ` [PATCH 1/16] vt-sysfs-for-colors.diff Jan Engelhardt
2007-04-02  6:49   ` Antonino A. Daplas
2007-04-02  7:31     ` [PATCH 17/16] Do not reset UTF8 on terminal reset Jan Engelhardt
2007-04-02  9:30       ` Antonino A. Daplas
2007-04-02 11:26       ` Paul LeoNerd Evans
2007-04-02 11:44         ` Antonino A. Daplas
2007-04-02 11:54           ` Paul LeoNerd Evans
2007-04-02 12:47             ` Antonino A. Daplas
2007-04-02 13:20               ` Paul LeoNerd Evans
2007-04-02 13:34               ` Jan Engelhardt
2007-04-02 18:50       ` Pavel Machek
2007-04-01 18:14 ` [PATCH 2/16] vt-pure-colors.diff Jan Engelhardt
2007-04-01 18:39   ` James Bruce
2007-04-02  6:49   ` Antonino A. Daplas
2007-04-02  7:04     ` Jan Engelhardt
2007-04-02  7:50       ` Antonino A. Daplas
2007-04-02  8:01         ` Jan Engelhardt
2007-04-01 18:14 ` Jan Engelhardt [this message]
2007-04-02  5:37   ` [PATCH 3/16] vt-underline-color.diff Andrew Morton
2007-04-02  6:57   ` Antonino A. Daplas
2007-04-01 18:14 ` [PATCH 4/16] vt-printk-color.diff Jan Engelhardt
2007-04-01 18:14 ` [PATCH 5/16] fix-kthread-niceness.diff Jan Engelhardt
2007-04-02  5:39   ` Andrew Morton
2007-04-01 18:15 ` [PATCH 06/16] isofs-add-write-bit.diff Jan Engelhardt
2007-04-01 18:15 ` [PATCH 07/16] kconfig-dynamic-frequency.diff Jan Engelhardt
2007-04-01 18:39   ` Kyle Moffett
2007-04-01 18:42     ` Jan Engelhardt
2007-04-01 18:52       ` Kyle Moffett
2007-04-01 19:01         ` Jan Engelhardt
2007-04-01 19:42           ` [PATCH] Kyle Moffett
2007-04-01 19:47             ` [PATCH] Jan Engelhardt
2007-04-01 20:07               ` [PATCH] Kyle Moffett
2007-04-01 19:50             ` [PATCH] Add a CONFIG_I_KNOW_WHAT_THE_HELL_I_AM_DOING variable Kyle Moffett
2007-04-01 23:03             ` [PATCH] Andi Kleen
2007-04-01 20:22         ` [PATCH 07/16] kconfig-dynamic-frequency.diff Robert P. J. Day
2007-04-01 18:15 ` [PATCH 08/16] console-printk-level.diff Jan Engelhardt
2007-04-01 19:07   ` Randy Dunlap
2007-04-01 18:15 ` [PATCH 09/16] zlib-decompression-status.diff Jan Engelhardt
2007-04-02 17:48   ` Jörn Engel
2007-04-02 18:50     ` Jan Engelhardt
2007-04-01 18:15 ` [PATCH 10/16] show-partitions-on-mount-error.diff Jan Engelhardt
2007-04-02  5:47   ` Andrew Morton
2007-04-02  5:48   ` Andrew Morton
2007-04-02  7:01     ` [PATCH 10/16] show partitions on mount error Jan Engelhardt
2007-04-02 18:59   ` [PATCH 10/16] show-partitions-on-mount-error.diff Pavel Machek
2007-04-04  0:42     ` Jan Engelhardt
2007-04-01 18:16 ` [PATCH 11/16] samba-eintr-fix.diff Jan Engelhardt
2007-04-01 19:09   ` Dave Jones
2007-04-01 19:28     ` Jan Engelhardt
2007-04-01 19:42       ` Dave Jones
2007-04-02  5:53   ` Andrew Morton
2007-04-01 18:16 ` [PATCH 12/16] cifs-use-mutex.diff Jan Engelhardt
2007-04-02  5:36   ` Roland Dreier
2007-04-01 18:17 ` [PATCH 13/16] show-pipesize-in-stat.diff Jan Engelhardt
2007-04-02  5:58   ` Andrew Morton
2007-04-02  6:48     ` Jan Engelhardt
2007-04-02 10:41   ` Eric Dumazet
2007-04-04  0:48     ` Jan Engelhardt
2007-04-04  5:03       ` Eric Dumazet
2007-04-17  8:05         ` Jan Engelhardt
2007-04-01 18:17 ` [PATCH 14/16] kconfig-allow-override.diff Jan Engelhardt
2007-04-01 18:44   ` Sam Ravnborg
2007-04-01 19:09     ` Randy Dunlap
2007-04-01 18:18 ` [PATCH 15/16] use-regular-eth-suffix.diff Jan Engelhardt
2007-04-01 18:42   ` Kyle Moffett
2007-04-02  1:40   ` Jouni Malinen
2007-04-01 18:18 ` [PATCH 16/16] warn-on-kthread-name-truncation.diff Jan Engelhardt
2007-04-02  6:00   ` Andrew Morton
2007-04-02  6:51     ` Jan Engelhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.61.0704012002570.12316@yvahk01.tjqt.qr \
    --to=jengelh@linux01.gwdg.de \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.