aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--drivers/char/vt.c34
-rw-r--r--drivers/video/console/mdacon.c3
-rw-r--r--drivers/video/console/promcon.c3
-rw-r--r--drivers/video/console/sticon.c2
-rw-r--r--drivers/video/console/vgacon.c12
-rw-r--r--include/linux/console.h2
-rw-r--r--include/linux/console_struct.h3
7 files changed, 45 insertions, 14 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);
diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c
index 124ecbe6f88c..bd8d995fe25d 100644
--- a/drivers/video/console/mdacon.c
+++ b/drivers/video/console/mdacon.c
@@ -384,7 +384,7 @@ static inline u16 mda_convert_attr(u16 ch)
384} 384}
385 385
386static u8 mdacon_build_attr(struct vc_data *c, u8 color, u8 intensity, 386static u8 mdacon_build_attr(struct vc_data *c, u8 color, u8 intensity,
387 u8 blink, u8 underline, u8 reverse) 387 u8 blink, u8 underline, u8 reverse, u8 italic)
388{ 388{
389 /* The attribute is just a bit vector: 389 /* The attribute is just a bit vector:
390 * 390 *
@@ -397,6 +397,7 @@ static u8 mdacon_build_attr(struct vc_data *c, u8 color, u8 intensity,
397 return (intensity & 3) | 397 return (intensity & 3) |
398 ((underline & 1) << 2) | 398 ((underline & 1) << 2) |
399 ((reverse & 1) << 3) | 399 ((reverse & 1) << 3) |
400 (!!italic << 4) |
400 ((blink & 1) << 7); 401 ((blink & 1) << 7);
401} 402}
402 403
diff --git a/drivers/video/console/promcon.c b/drivers/video/console/promcon.c
index b78eac63459f..ae02e4eb18e7 100644
--- a/drivers/video/console/promcon.c
+++ b/drivers/video/console/promcon.c
@@ -548,7 +548,8 @@ promcon_scroll(struct vc_data *conp, int t, int b, int dir, int count)
548} 548}
549 549
550#if !(PROMCON_COLOR) 550#if !(PROMCON_COLOR)
551static u8 promcon_build_attr(struct vc_data *conp, u8 _color, u8 _intensity, u8 _blink, u8 _underline, u8 _reverse) 551static u8 promcon_build_attr(struct vc_data *conp, u8 _color, u8 _intensity,
552 u8 _blink, u8 _underline, u8 _reverse, u8 _italic)
552{ 553{
553 return (_reverse) ? 0xf : 0x7; 554 return (_reverse) ? 0xf : 0x7;
554} 555}
diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c
index 57b21e533036..67a682d6cc7b 100644
--- a/drivers/video/console/sticon.c
+++ b/drivers/video/console/sticon.c
@@ -314,7 +314,7 @@ static unsigned long sticon_getxy(struct vc_data *conp, unsigned long pos,
314} 314}
315 315
316static u8 sticon_build_attr(struct vc_data *conp, u8 color, u8 intens, 316static u8 sticon_build_attr(struct vc_data *conp, u8 color, u8 intens,
317 u8 blink, u8 underline, u8 reverse) 317 u8 blink, u8 underline, u8 reverse, u8 italic)
318{ 318{
319 u8 attr = ((color & 0x70) >> 1) | ((color & 7)); 319 u8 attr = ((color & 0x70) >> 1) | ((color & 7));
320 320
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index 3e67c34df9a5..53c22197b631 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -87,7 +87,7 @@ static void vgacon_save_screen(struct vc_data *c);
87static int vgacon_scroll(struct vc_data *c, int t, int b, int dir, 87static int vgacon_scroll(struct vc_data *c, int t, int b, int dir,
88 int lines); 88 int lines);
89static u8 vgacon_build_attr(struct vc_data *c, u8 color, u8 intensity, 89static u8 vgacon_build_attr(struct vc_data *c, u8 color, u8 intensity,
90 u8 blink, u8 underline, u8 reverse); 90 u8 blink, u8 underline, u8 reverse, u8);
91static void vgacon_invert_region(struct vc_data *c, u16 * p, int count); 91static void vgacon_invert_region(struct vc_data *c, u16 * p, int count);
92static unsigned long vgacon_uni_pagedir[2]; 92static unsigned long vgacon_uni_pagedir[2];
93 93
@@ -578,12 +578,14 @@ static void vgacon_deinit(struct vc_data *c)
578} 578}
579 579
580static u8 vgacon_build_attr(struct vc_data *c, u8 color, u8 intensity, 580static u8 vgacon_build_attr(struct vc_data *c, u8 color, u8 intensity,
581 u8 blink, u8 underline, u8 reverse) 581 u8 blink, u8 underline, u8 reverse, u8 italic)
582{ 582{
583 u8 attr = color; 583 u8 attr = color;
584 584
585 if (vga_can_do_color) { 585 if (vga_can_do_color) {
586 if (underline) 586 if (italic)
587 attr = (attr & 0xF0) | c->vc_itcolor;
588 else if (underline)
587 attr = (attr & 0xf0) | c->vc_ulcolor; 589 attr = (attr & 0xf0) | c->vc_ulcolor;
588 else if (intensity == 0) 590 else if (intensity == 0)
589 attr = (attr & 0xf0) | c->vc_halfcolor; 591 attr = (attr & 0xf0) | c->vc_halfcolor;
@@ -597,7 +599,9 @@ static u8 vgacon_build_attr(struct vc_data *c, u8 color, u8 intensity,
597 if (intensity == 2) 599 if (intensity == 2)
598 attr ^= 0x08; 600 attr ^= 0x08;
599 if (!vga_can_do_color) { 601 if (!vga_can_do_color) {
600 if (underline) 602 if (italic)
603 attr = (attr & 0xF8) | 0x02;
604 else if (underline)
601 attr = (attr & 0xf8) | 0x01; 605 attr = (attr & 0xf8) | 0x01;
602 else if (intensity == 0) 606 else if (intensity == 0)
603 attr = (attr & 0xf0) | 0x08; 607 attr = (attr & 0xf0) | 0x08;
diff --git a/include/linux/console.h b/include/linux/console.h
index fcc18e012e45..62ef6e11d0d2 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -51,7 +51,7 @@ struct consw {
51 int (*con_scrolldelta)(struct vc_data *, int); 51 int (*con_scrolldelta)(struct vc_data *, int);
52 int (*con_set_origin)(struct vc_data *); 52 int (*con_set_origin)(struct vc_data *);
53 void (*con_save_screen)(struct vc_data *); 53 void (*con_save_screen)(struct vc_data *);
54 u8 (*con_build_attr)(struct vc_data *, u8, u8, u8, u8, u8); 54 u8 (*con_build_attr)(struct vc_data *, u8, u8, u8, u8, u8, u8);
55 void (*con_invert_region)(struct vc_data *, u16 *, int); 55 void (*con_invert_region)(struct vc_data *, u16 *, int);
56 u16 *(*con_screen_pos)(struct vc_data *, int); 56 u16 *(*con_screen_pos)(struct vc_data *, int);
57 unsigned long (*con_getxy)(struct vc_data *, unsigned long, int *, int *); 57 unsigned long (*con_getxy)(struct vc_data *, unsigned long, int *, int *);
diff --git a/include/linux/console_struct.h b/include/linux/console_struct.h
index a86162b26c0d..a461f76fb004 100644
--- a/include/linux/console_struct.h
+++ b/include/linux/console_struct.h
@@ -37,6 +37,7 @@ struct vc_data {
37 unsigned char vc_color; /* Foreground & background */ 37 unsigned char vc_color; /* Foreground & background */
38 unsigned char vc_s_color; /* Saved foreground & background */ 38 unsigned char vc_s_color; /* Saved foreground & background */
39 unsigned char vc_ulcolor; /* Color for underline mode */ 39 unsigned char vc_ulcolor; /* Color for underline mode */
40 unsigned char vc_itcolor;
40 unsigned char vc_halfcolor; /* Color for half intensity mode */ 41 unsigned char vc_halfcolor; /* Color for half intensity mode */
41 /* cursor */ 42 /* cursor */
42 unsigned int vc_cursor_type; 43 unsigned int vc_cursor_type;
@@ -71,10 +72,12 @@ struct vc_data {
71 unsigned int vc_deccolm : 1; /* 80/132 Column Mode */ 72 unsigned int vc_deccolm : 1; /* 80/132 Column Mode */
72 /* attribute flags */ 73 /* attribute flags */
73 unsigned int vc_intensity : 2; /* 0=half-bright, 1=normal, 2=bold */ 74 unsigned int vc_intensity : 2; /* 0=half-bright, 1=normal, 2=bold */
75 unsigned int vc_italic:1;
74 unsigned int vc_underline : 1; 76 unsigned int vc_underline : 1;
75 unsigned int vc_blink : 1; 77 unsigned int vc_blink : 1;
76 unsigned int vc_reverse : 1; 78 unsigned int vc_reverse : 1;
77 unsigned int vc_s_intensity : 2; /* saved rendition */ 79 unsigned int vc_s_intensity : 2; /* saved rendition */
80 unsigned int vc_s_italic:1;
78 unsigned int vc_s_underline : 1; 81 unsigned int vc_s_underline : 1;
79 unsigned int vc_s_blink : 1; 82 unsigned int vc_s_blink : 1;
80 unsigned int vc_s_reverse : 1; 83 unsigned int vc_s_reverse : 1;