aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorJan Engelhardt <jengelh@linux01.gwdg.de>2007-05-08 03:38:04 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:27 -0400
commitfa6ce9ab5fbcb4c276c48861584b70d387e787b3 (patch)
tree71b6295410513d17226a57be542f0a761db97841 /drivers/char
parent1c2bbe6a11ec7d1de114acfc8a6bf2821b0224a5 (diff)
vt: add color support to the "underline" and "italic" attributes
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> Acked-by: "Antonino A. Daplas" <adaplas@pol.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/vt.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 4ef9a286a230..4818327180ac 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -348,10 +348,12 @@ void update_region(struct vc_data *vc, unsigned long start, int count)
348 348
349/* Structure of attributes is hardware-dependent */ 349/* Structure of attributes is hardware-dependent */
350 350
351static u8 build_attr(struct vc_data *vc, u8 _color, u8 _intensity, u8 _blink, u8 _underline, u8 _reverse) 351static u8 build_attr(struct vc_data *vc, u8 _color, u8 _intensity, u8 _blink,
352 u8 _underline, u8 _reverse, u8 _italic)
352{ 353{
353 if (vc->vc_sw->con_build_attr) 354 if (vc->vc_sw->con_build_attr)
354 return vc->vc_sw->con_build_attr(vc, _color, _intensity, _blink, _underline, _reverse); 355 return vc->vc_sw->con_build_attr(vc, _color, _intensity,
356 _blink, _underline, _reverse, _italic);
355 357
356#ifndef VT_BUF_VRAM_ONLY 358#ifndef VT_BUF_VRAM_ONLY
357/* 359/*
@@ -368,10 +370,13 @@ static u8 build_attr(struct vc_data *vc, u8 _color, u8 _intensity, u8 _blink, u8
368 u8 a = vc->vc_color; 370 u8 a = vc->vc_color;
369 if (!vc->vc_can_do_color) 371 if (!vc->vc_can_do_color)
370 return _intensity | 372 return _intensity |
373 (_italic ? 2 : 0) |
371 (_underline ? 4 : 0) | 374 (_underline ? 4 : 0) |
372 (_reverse ? 8 : 0) | 375 (_reverse ? 8 : 0) |
373 (_blink ? 0x80 : 0); 376 (_blink ? 0x80 : 0);
374 if (_underline) 377 if (_italic)
378 a = (a & 0xF0) | vc->vc_itcolor;
379 else if (_underline)
375 a = (a & 0xf0) | vc->vc_ulcolor; 380 a = (a & 0xf0) | vc->vc_ulcolor;
376 else if (_intensity == 0) 381 else if (_intensity == 0)
377 a = (a & 0xf0) | vc->vc_ulcolor; 382 a = (a & 0xf0) | vc->vc_ulcolor;
@@ -392,8 +397,10 @@ static u8 build_attr(struct vc_data *vc, u8 _color, u8 _intensity, u8 _blink, u8
392 397
393static void update_attr(struct vc_data *vc) 398static void update_attr(struct vc_data *vc)
394{ 399{
395 vc->vc_attr = build_attr(vc, vc->vc_color, vc->vc_intensity, vc->vc_blink, vc->vc_underline, vc->vc_reverse ^ vc->vc_decscnm); 400 vc->vc_attr = build_attr(vc, vc->vc_color, vc->vc_intensity,
396 vc->vc_video_erase_char = (build_attr(vc, vc->vc_color, 1, vc->vc_blink, 0, vc->vc_decscnm) << 8) | ' '; 401 vc->vc_blink, vc->vc_underline,
402 vc->vc_reverse ^ vc->vc_decscnm, vc->vc_italic);
403 vc->vc_video_erase_char = (build_attr(vc, vc->vc_color, 1, vc->vc_blink, 0, vc->vc_decscnm, 0) << 8) | ' ';
397} 404}
398 405
399/* Note: inverting the screen twice should revert to the original state */ 406/* Note: inverting the screen twice should revert to the original state */
@@ -1136,6 +1143,7 @@ static void csi_X(struct vc_data *vc, int vpar) /* erase the following vpar posi
1136static void default_attr(struct vc_data *vc) 1143static void default_attr(struct vc_data *vc)
1137{ 1144{
1138 vc->vc_intensity = 1; 1145 vc->vc_intensity = 1;
1146 vc->vc_italic = 0;
1139 vc->vc_underline = 0; 1147 vc->vc_underline = 0;
1140 vc->vc_reverse = 0; 1148 vc->vc_reverse = 0;
1141 vc->vc_blink = 0; 1149 vc->vc_blink = 0;
@@ -1158,6 +1166,9 @@ static void csi_m(struct vc_data *vc)
1158 case 2: 1166 case 2:
1159 vc->vc_intensity = 0; 1167 vc->vc_intensity = 0;
1160 break; 1168 break;
1169 case 3:
1170 vc->vc_italic = 1;
1171 break;
1161 case 4: 1172 case 4:
1162 vc->vc_underline = 1; 1173 vc->vc_underline = 1;
1163 break; 1174 break;
@@ -1198,6 +1209,9 @@ static void csi_m(struct vc_data *vc)
1198 case 22: 1209 case 22:
1199 vc->vc_intensity = 1; 1210 vc->vc_intensity = 1;
1200 break; 1211 break;
1212 case 23:
1213 vc->vc_italic = 0;
1214 break;
1201 case 24: 1215 case 24:
1202 vc->vc_underline = 0; 1216 vc->vc_underline = 0;
1203 break; 1217 break;
@@ -1458,6 +1472,7 @@ static void save_cur(struct vc_data *vc)
1458 vc->vc_saved_x = vc->vc_x; 1472 vc->vc_saved_x = vc->vc_x;
1459 vc->vc_saved_y = vc->vc_y; 1473 vc->vc_saved_y = vc->vc_y;
1460 vc->vc_s_intensity = vc->vc_intensity; 1474 vc->vc_s_intensity = vc->vc_intensity;
1475 vc->vc_s_italic = vc->vc_italic;
1461 vc->vc_s_underline = vc->vc_underline; 1476 vc->vc_s_underline = vc->vc_underline;
1462 vc->vc_s_blink = vc->vc_blink; 1477 vc->vc_s_blink = vc->vc_blink;
1463 vc->vc_s_reverse = vc->vc_reverse; 1478 vc->vc_s_reverse = vc->vc_reverse;
@@ -1472,6 +1487,7 @@ static void restore_cur(struct vc_data *vc)
1472{ 1487{
1473 gotoxy(vc, vc->vc_saved_x, vc->vc_saved_y); 1488 gotoxy(vc, vc->vc_saved_x, vc->vc_saved_y);
1474 vc->vc_intensity = vc->vc_s_intensity; 1489 vc->vc_intensity = vc->vc_s_intensity;
1490 vc->vc_italic = vc->vc_s_italic;
1475 vc->vc_underline = vc->vc_s_underline; 1491 vc->vc_underline = vc->vc_s_underline;
1476 vc->vc_blink = vc->vc_s_blink; 1492 vc->vc_blink = vc->vc_s_blink;
1477 vc->vc_reverse = vc->vc_s_reverse; 1493 vc->vc_reverse = vc->vc_s_reverse;
@@ -2686,6 +2702,11 @@ static void con_close(struct tty_struct *tty, struct file *filp)
2686 mutex_unlock(&tty_mutex); 2702 mutex_unlock(&tty_mutex);
2687} 2703}
2688 2704
2705static int default_italic_color = 2; // green (ASCII)
2706static int default_underline_color = 3; // cyan (ASCII)
2707module_param_named(italic, default_italic_color, int, S_IRUGO | S_IWUSR);
2708module_param_named(underline, default_underline_color, int, S_IRUGO | S_IWUSR);
2709
2689static void vc_init(struct vc_data *vc, unsigned int rows, 2710static void vc_init(struct vc_data *vc, unsigned int rows,
2690 unsigned int cols, int do_clear) 2711 unsigned int cols, int do_clear)
2691{ 2712{
@@ -2705,7 +2726,8 @@ static void vc_init(struct vc_data *vc, unsigned int rows,
2705 vc->vc_palette[k++] = default_blu[j] ; 2726 vc->vc_palette[k++] = default_blu[j] ;
2706 } 2727 }
2707 vc->vc_def_color = 0x07; /* white */ 2728 vc->vc_def_color = 0x07; /* white */
2708 vc->vc_ulcolor = 0x0f; /* bold white */ 2729 vc->vc_ulcolor = default_underline_color;
2730 vc->vc_itcolor = default_italic_color;
2709 vc->vc_halfcolor = 0x08; /* grey */ 2731 vc->vc_halfcolor = 0x08; /* grey */
2710 init_waitqueue_head(&vc->paste_wait); 2732 init_waitqueue_head(&vc->paste_wait);
2711 reset_terminal(vc, do_clear); 2733 reset_terminal(vc, do_clear);