diff options
| author | Toomas Soome <tsoome@me.com> | 2017-02-01 08:56:36 +0200 |
|---|---|---|
| committer | Toomas Soome <tsoome@me.com> | 2019-02-12 23:11:45 +0200 |
| commit | cbc8e155c29643fa0d62159c2d3dee078ed6cc91 (patch) | |
| tree | 81b5ea5a1d03f8c0057352e982d52bd5011eb39e /usr/src/uts/common/io/tem_safe.c | |
| parent | c9aaca5d3825256aa6c09cc34e4ce5640630341b (diff) | |
| download | illumos-joyent-cbc8e155c29643fa0d62159c2d3dee078ed6cc91.tar.gz | |
10355 uts: new-font project. Use terminus Unicode fonts for console.
Reviewed by: John Levon <john.levon@joyent.com>
Reviewed by: Gergő Doma <domag02@gmail.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src/uts/common/io/tem_safe.c')
| -rw-r--r-- | usr/src/uts/common/io/tem_safe.c | 406 |
1 files changed, 165 insertions, 241 deletions
diff --git a/usr/src/uts/common/io/tem_safe.c b/usr/src/uts/common/io/tem_safe.c index 7055568c29..bd9f493921 100644 --- a/usr/src/uts/common/io/tem_safe.c +++ b/usr/src/uts/common/io/tem_safe.c @@ -87,7 +87,6 @@ tem_safe_callbacks_t tem_safe_pix_callbacks = { &tem_safe_pix_cls }; - static void tem_safe_control(struct tem_vt_state *, tem_char_t, cred_t *, enum called_from); static void tem_safe_setparam(struct tem_vt_state *, int, int); @@ -137,12 +136,12 @@ static void tem_safe_bell(struct tem_vt_state *tem, enum called_from called_from); static void tem_safe_pix_clear_prom_output(struct tem_vt_state *tem, cred_t *credp, enum called_from called_from); +static void tem_safe_get_color(text_color_t *, text_color_t *, term_char_t); static void tem_safe_virtual_cls(struct tem_vt_state *, int, screen_pos_t, screen_pos_t); static void tem_safe_virtual_display(struct tem_vt_state *, - tem_char_t *, int, screen_pos_t, screen_pos_t, - text_color_t, text_color_t); + term_char_t *, int, screen_pos_t, screen_pos_t); static void tem_safe_virtual_copy(struct tem_vt_state *, screen_pos_t, screen_pos_t, screen_pos_t, screen_pos_t, screen_pos_t, screen_pos_t); @@ -158,23 +157,6 @@ static void bit_to_pix24(struct tem_vt_state *tem, tem_char_t c, static void bit_to_pix32(struct tem_vt_state *tem, tem_char_t c, text_color_t fg_color, text_color_t bg_color); -/* BEGIN CSTYLED */ -/* Bk Rd Gr Br Bl Mg Cy Wh */ -static text_color_t dim_xlate[] = { 1, 5, 3, 7, 2, 6, 4, 8 }; -static text_color_t brt_xlate[] = { 9, 13, 11, 15, 10, 14, 12, 0 }; -/* END CSTYLED */ - - -text_cmap_t cmap4_to_24 = { -/* BEGIN CSTYLED */ -/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 - Wh+ Bk Bl Gr Cy Rd Mg Br Wh Bk+ Bl+ Gr+ Cy+ Rd+ Mg+ Yw */ - 0xff,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x40,0x00,0x00,0x00,0xff,0xff,0xff, - 0xff,0x00,0x00,0x80,0x80,0x00,0x00,0x80,0x80,0x40,0x00,0xff,0xff,0x00,0x00,0xff, - 0xff,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x40,0xff,0x00,0xff,0x00,0xff,0x00 -/* END CSTYLED */ -}; - #define PIX4TO32(pix4) (uint32_t)( \ cmap4_to_24.red[pix4] << 16 | \ cmap4_to_24.green[pix4] << 8 | \ @@ -186,9 +168,9 @@ text_cmap_t cmap4_to_24 = { #define tem_safe_callback_copy (*tems.ts_callbacks->tsc_copy) #define tem_safe_callback_cursor (*tems.ts_callbacks->tsc_cursor) #define tem_safe_callback_cls (*tems.ts_callbacks->tsc_cls) -#define tem_safe_callback_bit2pix(tem, c, fg, bg) { \ +#define tem_safe_callback_bit2pix(tem, c) { \ ASSERT(tems.ts_callbacks->tsc_bit2pix != NULL); \ - (void) (*tems.ts_callbacks->tsc_bit2pix)((tem), (c), (fg), (bg));\ + (void) (*tems.ts_callbacks->tsc_bit2pix)((tem), (c));\ } void @@ -254,7 +236,7 @@ static void tem_safe_input_partial(struct tem_vt_state *tem, cred_t *credp, enum called_from called_from) { - int i; + unsigned i; uint8_t c; if (tem->tvs_utf8_left == 0) @@ -567,6 +549,9 @@ tem_safe_selgraph(struct tem_vt_state *tem) tem->tvs_flags &= ~TEM_ATTR_BOLD; break; + case 4: /* Underline */ + tem->tvs_flags |= TEM_ATTR_UNDERLINE; + break; case 5: /* Blink */ tem->tvs_flags |= TEM_ATTR_BLINK; break; @@ -579,6 +564,26 @@ tem_safe_selgraph(struct tem_vt_state *tem) } break; + case 22: /* Remove Bold */ + tem->tvs_flags &= ~TEM_ATTR_BOLD; + break; + + case 24: /* Remove Underline */ + tem->tvs_flags &= ~TEM_ATTR_UNDERLINE; + break; + + case 25: /* Remove Blink */ + tem->tvs_flags &= ~TEM_ATTR_BLINK; + break; + + case 27: /* Remove Reverse */ + if (tem->tvs_flags & TEM_ATTR_SCREEN_REVERSE) { + tem->tvs_flags |= TEM_ATTR_REVERSE; + } else { + tem->tvs_flags &= ~TEM_ATTR_REVERSE; + } + break; + case 30: /* black (grey) foreground */ case 31: /* red (light red) foreground */ case 32: /* green (light green) foreground */ @@ -971,13 +976,19 @@ static void tem_safe_outch(struct tem_vt_state *tem, tem_char_t ch, cred_t *credp, enum called_from called_from) { + text_color_t fg; + text_color_t bg; + text_attr_t attr; ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) || called_from == CALLED_FROM_STANDALONE); /* buffer up the character until later */ - - tem->tvs_outbuf[tem->tvs_outindex++] = ch; + tem_safe_get_attr(tem, &fg, &bg, &attr, TEM_ATTR_REVERSE); + tem->tvs_outbuf[tem->tvs_outindex].tc_char = ch | TEM_ATTR(attr); + tem->tvs_outbuf[tem->tvs_outindex].tc_fg_color = fg; + tem->tvs_outbuf[tem->tvs_outindex].tc_bg_color = bg; + tem->tvs_outindex++; tem->tvs_c_cursor.col++; if (tem->tvs_c_cursor.col >= tems.ts_c_dimension.width) { tem_safe_send_data(tem, credp, called_from); @@ -1056,9 +1067,6 @@ static void tem_safe_send_data(struct tem_vt_state *tem, cred_t *credp, enum called_from called_from) { - text_color_t fg_color; - text_color_t bg_color; - ASSERT((called_from == CALLED_FROM_STANDALONE) || MUTEX_HELD(&tem->tvs_lock)); @@ -1067,11 +1075,9 @@ tem_safe_send_data(struct tem_vt_state *tem, cred_t *credp, return; } - tem_safe_get_color(tem, &fg_color, &bg_color, TEM_ATTR_REVERSE); tem_safe_virtual_display(tem, tem->tvs_outbuf, tem->tvs_outindex, - tem->tvs_s_cursor.row, tem->tvs_s_cursor.col, - fg_color, bg_color); + tem->tvs_s_cursor.row, tem->tvs_s_cursor.col); if (tem->tvs_isactive) { /* @@ -1080,7 +1086,6 @@ tem_safe_send_data(struct tem_vt_state *tem, cred_t *credp, tem_safe_callback_display(tem, tem->tvs_outbuf, tem->tvs_outindex, tem->tvs_s_cursor.row, tem->tvs_s_cursor.col, - fg_color, bg_color, credp, called_from); } @@ -1399,32 +1404,25 @@ tem_safe_clear_chars(struct tem_vt_state *tem, int count, screen_pos_t row, /*ARGSUSED*/ void -tem_safe_text_display(struct tem_vt_state *tem, tem_char_t *string, +tem_safe_text_display(struct tem_vt_state *tem, term_char_t *string, int count, screen_pos_t row, screen_pos_t col, - text_color_t fg_color, text_color_t bg_color, cred_t *credp, enum called_from called_from) { struct vis_consdisplay da; int i; - uint8_t c; + tem_char_t c; ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) || called_from == CALLED_FROM_STANDALONE); - da.data = &c; + da.data = (uint8_t *)&c; da.width = 1; da.row = row; da.col = col; - da.fg_color = fg_color; - da.bg_color = bg_color; - for (i = 0; i < count; i++) { - /* VGATEXT can only display single byte chars. */ - if (string[i] > 0xff) - c = '?'; - else - c = (uint8_t)string[i]; + tem_safe_get_color(&da.fg_color, &da.bg_color, string[i]); + c = TEM_CHAR(string[i].tc_char); tems_safe_display(&da, credp, called_from); da.col++; } @@ -1463,7 +1461,6 @@ tem_safe_image_display(struct tem_vt_state *tem, uchar_t *image, mutex_exit(&tems.ts_lock); } - /*ARGSUSED*/ void tem_safe_text_copy(struct tem_vt_state *tem, @@ -1492,26 +1489,32 @@ tem_safe_text_cls(struct tem_vt_state *tem, int count, screen_pos_t row, screen_pos_t col, cred_t *credp, enum called_from called_from) { - struct vis_consdisplay da; + text_attr_t attr; + term_char_t c; + int i; ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) || called_from == CALLED_FROM_STANDALONE); - da.data = (unsigned char *)tems.ts_blank_line; - da.width = (screen_size_t)count; - da.row = row; - da.col = col; - - tem_safe_get_color(tem, &da.fg_color, &da.bg_color, + tem_safe_get_attr(tem, &c.tc_fg_color, &c.tc_bg_color, &attr, TEM_ATTR_SCREEN_REVERSE); - tems_safe_display(&da, credp, called_from); + c.tc_char = TEM_ATTR(attr & ~TEM_ATTR_UNDERLINE) | ' '; + + if (count > tems.ts_c_dimension.width || + col + count > tems.ts_c_dimension.width) + count = tems.ts_c_dimension.width - col; + + for (i = 0; i < count; i++) + tems.ts_blank_line[i] = c; + + tem_safe_text_display(tem, tems.ts_blank_line, count, row, col, + credp, called_from); } void tem_safe_pix_display(struct tem_vt_state *tem, - tem_char_t *string, int count, + term_char_t *string, int count, screen_pos_t row, screen_pos_t col, - text_color_t fg_color, text_color_t bg_color, cred_t *credp, enum called_from called_from) { struct vis_consdisplay da; @@ -1521,13 +1524,13 @@ tem_safe_pix_display(struct tem_vt_state *tem, called_from == CALLED_FROM_STANDALONE); da.data = (uchar_t *)tem->tvs_pix_data; - da.width = tems.ts_font.width; - da.height = tems.ts_font.height; + da.width = (screen_size_t)tems.ts_font.vf_width; + da.height = (screen_size_t)tems.ts_font.vf_height; da.row = (row * da.height) + tems.ts_p_offset.y; da.col = (col * da.width) + tems.ts_p_offset.x; for (i = 0; i < count; i++) { - tem_safe_callback_bit2pix(tem, string[i], fg_color, bg_color); + tem_safe_callback_bit2pix(tem, string[i]); tems_safe_display(&da, credp, called_from); da.col += da.width; } @@ -1560,9 +1563,10 @@ tem_safe_pix_copy(struct tem_vt_state *tem, } need_clear = B_FALSE; - ma.s_row = s_row * tems.ts_font.height + tems.ts_p_offset.y; - ma.e_row = (e_row + 1) * tems.ts_font.height + tems.ts_p_offset.y - 1; - ma.t_row = t_row * tems.ts_font.height + tems.ts_p_offset.y; + ma.s_row = s_row * tems.ts_font.vf_height + tems.ts_p_offset.y; + ma.e_row = (e_row + 1) * tems.ts_font.vf_height + + tems.ts_p_offset.y - 1; + ma.t_row = t_row * tems.ts_font.vf_height + tems.ts_p_offset.y; /* * Check if we're in process of clearing OBP's columns area, @@ -1574,15 +1578,15 @@ tem_safe_pix_copy(struct tem_vt_state *tem, * We need to clear OBP's columns area outside our kernel * console term. So that we set ma.e_col to entire row here. */ - ma.s_col = s_col * tems.ts_font.width; + ma.s_col = s_col * tems.ts_font.vf_width; ma.e_col = tems.ts_p_dimension.width - 1; - ma.t_col = t_col * tems.ts_font.width; + ma.t_col = t_col * tems.ts_font.vf_width; } else { - ma.s_col = s_col * tems.ts_font.width + tems.ts_p_offset.x; - ma.e_col = (e_col + 1) * tems.ts_font.width + + ma.s_col = s_col * tems.ts_font.vf_width + tems.ts_p_offset.x; + ma.e_col = (e_col + 1) * tems.ts_font.vf_width + tems.ts_p_offset.x - 1; - ma.t_col = t_col * tems.ts_font.width + tems.ts_p_offset.x; + ma.t_col = t_col * tems.ts_font.vf_width + tems.ts_p_offset.x; } tems_safe_copy(&ma, credp, called_from); @@ -1599,12 +1603,13 @@ tem_safe_pix_copy(struct tem_vt_state *tem, } void -tem_safe_pix_bit2pix(struct tem_vt_state *tem, tem_char_t c, - unsigned char fg, unsigned char bg) +tem_safe_pix_bit2pix(struct tem_vt_state *tem, term_char_t c) { + text_color_t fg, bg; void (*fp)(struct tem_vt_state *, tem_char_t, unsigned char, unsigned char); + tem_safe_get_color(&fg, &bg, c); switch (tems.ts_pdepth) { case 4: fp = bit_to_pix4; @@ -1626,7 +1631,7 @@ tem_safe_pix_bit2pix(struct tem_vt_state *tem, tem_char_t c, return; } - fp(tem, c, fg, bg); + fp(tem, c.tc_char, fg, bg); } @@ -1677,8 +1682,8 @@ tem_safe_pix_clear_prom_output(struct tem_vt_state *tem, cred_t *credp, ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) || called_from == CALLED_FROM_STANDALONE); - width = tems.ts_font.width; - height = tems.ts_font.height; + width = tems.ts_font.vf_width; + height = tems.ts_font.vf_height; offset = tems.ts_p_offset.y % height; nrows = tems.ts_p_offset.y / height; @@ -1700,19 +1705,25 @@ tem_safe_pix_clear_entire_screen(struct tem_vt_state *tem, cred_t *credp, struct vis_consclear cl; text_color_t fg_color; text_color_t bg_color; - int nrows, ncols, width, height; + text_attr_t attr; + term_char_t c; + int nrows, ncols, width, height; ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) || called_from == CALLED_FROM_STANDALONE); /* call driver first, if error, clear terminal area */ - tem_safe_get_color(tem, &fg_color, &bg_color, TEM_ATTR_SCREEN_REVERSE); + tem_safe_get_attr(tem, &c.tc_fg_color, &c.tc_bg_color, &attr, + TEM_ATTR_SCREEN_REVERSE); + c.tc_char = TEM_ATTR(attr); + + tem_safe_get_color(&fg_color, &bg_color, c); cl.bg_color = bg_color; if (tems_cls_layered(&cl, credp) == 0) return; - width = tems.ts_font.width; - height = tems.ts_font.height; + width = tems.ts_font.vf_width; + height = tems.ts_font.vf_height; nrows = (tems.ts_p_dimension.height + (height - 1))/ height; ncols = (tems.ts_p_dimension.width + (width - 1))/ width; @@ -2038,18 +2049,24 @@ tem_safe_pix_cursor(struct tem_vt_state *tem, short action, struct vis_conscursor ca; uint32_t color; text_color_t fg, bg; + term_char_t c; + text_attr_t attr; ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) || called_from == CALLED_FROM_STANDALONE); - ca.row = tem->tvs_c_cursor.row * tems.ts_font.height + + ca.row = tem->tvs_c_cursor.row * tems.ts_font.vf_height + tems.ts_p_offset.y; - ca.col = tem->tvs_c_cursor.col * tems.ts_font.width + + ca.col = tem->tvs_c_cursor.col * tems.ts_font.vf_width + tems.ts_p_offset.x; - ca.width = tems.ts_font.width; - ca.height = tems.ts_font.height; + ca.width = (screen_size_t)tems.ts_font.vf_width; + ca.height = (screen_size_t)tems.ts_font.vf_height; - tem_safe_get_color(tem, &fg, &bg, TEM_ATTR_REVERSE); + tem_safe_get_attr(tem, &c.tc_fg_color, &c.tc_bg_color, &attr, + TEM_ATTR_REVERSE); + c.tc_char = TEM_ATTR(attr); + + tem_safe_get_color(&fg, &bg, c); switch (tems.ts_pdepth) { case 4: @@ -2105,10 +2122,17 @@ tem_safe_pix_cursor(struct tem_vt_state *tem, short action, tems_safe_cursor(&ca, credp, called_from); if (action == VIS_GET_CURSOR) { - tem->tvs_c_cursor.row = (ca.row - tems.ts_p_offset.y) / - tems.ts_font.height; - tem->tvs_c_cursor.col = (ca.col - tems.ts_p_offset.x) / - tems.ts_font.width; + tem->tvs_c_cursor.row = 0; + tem->tvs_c_cursor.col = 0; + + if (ca.row != 0) { + tem->tvs_c_cursor.row = (ca.row - tems.ts_p_offset.y) / + tems.ts_font.vf_height; + } + if (ca.col != 0) { + tem->tvs_c_cursor.col = (ca.col - tems.ts_p_offset.x) / + tems.ts_font.vf_width; + } } } @@ -2185,44 +2209,39 @@ bit_to_pix32(struct tem_vt_state *tem, tem_char_t c, text_color_t fg_color4, font_bit_to_pix32(&tems.ts_font, dest, c, fg_color32, bg_color32); } -static text_color_t -ansi_bg_to_solaris(struct tem_vt_state *tem, int ansi) -{ - if (tem->tvs_flags & TEM_ATTR_BRIGHT_BG) - return (brt_xlate[ansi]); - else - return (dim_xlate[ansi]); -} - -static text_color_t -ansi_fg_to_solaris(struct tem_vt_state *tem, int ansi) -{ - if (tem->tvs_flags & TEM_ATTR_BRIGHT_FG || - tem->tvs_flags & TEM_ATTR_BOLD) { - return (brt_xlate[ansi]); - } else { - return (dim_xlate[ansi]); - } -} - /* * flag: TEM_ATTR_SCREEN_REVERSE or TEM_ATTR_REVERSE */ void -tem_safe_get_color(struct tem_vt_state *tem, text_color_t *fg, - text_color_t *bg, uint8_t flag) +tem_safe_get_attr(struct tem_vt_state *tem, text_color_t *fg, + text_color_t *bg, text_attr_t *attr, uint8_t flag) { if (tem->tvs_flags & flag) { - *fg = ansi_fg_to_solaris(tem, - tem->tvs_bg_color); - *bg = ansi_bg_to_solaris(tem, - tem->tvs_fg_color); + *fg = tem->tvs_bg_color; + *bg = tem->tvs_fg_color; } else { - *fg = ansi_fg_to_solaris(tem, - tem->tvs_fg_color); - *bg = ansi_bg_to_solaris(tem, - tem->tvs_bg_color); + *fg = tem->tvs_fg_color; + *bg = tem->tvs_bg_color; } + + if (attr == NULL) + return; + + *attr = tem->tvs_flags; +} + +static void +tem_safe_get_color(text_color_t *fg, text_color_t *bg, term_char_t c) +{ + if (TEM_ATTR_ISSET(c.tc_char, TEM_ATTR_BRIGHT_FG | TEM_ATTR_BOLD)) + *fg = brt_xlate[c.tc_fg_color]; + else + *fg = dim_xlate[c.tc_fg_color]; + + if (TEM_ATTR_ISSET(c.tc_char, TEM_ATTR_BRIGHT_BG)) + *bg = brt_xlate[c.tc_bg_color]; + else + *bg = dim_xlate[c.tc_bg_color]; } /* @@ -2248,8 +2267,8 @@ tem_safe_pix_cls_range(struct tem_vt_state *tem, struct vis_consdisplay da; int i, j; int row_add = 0; - text_color_t fg_color; - text_color_t bg_color; + term_char_t c; + text_attr_t attr; ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) || called_from == CALLED_FROM_STANDALONE); @@ -2257,12 +2276,15 @@ tem_safe_pix_cls_range(struct tem_vt_state *tem, if (sroll_up) row_add = tems.ts_c_dimension.height - 1; - da.width = tems.ts_font.width; - da.height = tems.ts_font.height; + da.width = (screen_size_t)tems.ts_font.vf_width; + da.height = (screen_size_t)tems.ts_font.vf_height; - tem_safe_get_color(tem, &fg_color, &bg_color, TEM_ATTR_SCREEN_REVERSE); + tem_safe_get_attr(tem, &c.tc_fg_color, &c.tc_bg_color, &attr, + TEM_ATTR_SCREEN_REVERSE); + /* Make sure we will not draw underlines */ + c.tc_char = TEM_ATTR(attr & ~TEM_ATTR_UNDERLINE) | ' '; - tem_safe_callback_bit2pix(tem, ' ', fg_color, bg_color); + tem_safe_callback_bit2pix(tem, c); da.data = (uchar_t *)tem->tvs_pix_data; for (i = 0; i < nrows; i++, row++) { @@ -2279,14 +2301,11 @@ tem_safe_pix_cls_range(struct tem_vt_state *tem, * virtual screen operations */ static void -tem_safe_virtual_display(struct tem_vt_state *tem, tem_char_t *string, - int count, screen_pos_t row, screen_pos_t col, - text_color_t fg_color, text_color_t bg_color) +tem_safe_virtual_display(struct tem_vt_state *tem, term_char_t *string, + int count, screen_pos_t row, screen_pos_t col) { int i, width; - tem_char_t *addr; - text_color_t *pfgcolor; - text_color_t *pbgcolor; + term_char_t *addr; if (row < 0 || row >= tems.ts_c_dimension.height || col < 0 || col >= tems.ts_c_dimension.width || @@ -2294,77 +2313,24 @@ tem_safe_virtual_display(struct tem_vt_state *tem, tem_char_t *string, return; width = tems.ts_c_dimension.width; - addr = tem->tvs_screen_buf + (row * width + col); - pfgcolor = tem->tvs_fg_buf + (row * width + col); - pbgcolor = tem->tvs_bg_buf + (row * width + col); + addr = tem->tvs_screen_buf + (row * width + col); for (i = 0; i < count; i++) { *addr++ = string[i]; - *pfgcolor++ = fg_color; - *pbgcolor++ = bg_color; } } static void -i_virtual_copy_tem_chars(tem_char_t *base, +i_virtual_copy_tem_chars(term_char_t *base, screen_pos_t s_col, screen_pos_t s_row, screen_pos_t e_col, screen_pos_t e_row, screen_pos_t t_col, screen_pos_t t_row) { - tem_char_t *from; - tem_char_t *to; + term_char_t *from; + term_char_t *to; int cnt; screen_size_t chars_per_row; - tem_char_t *to_row_start; - tem_char_t *from_row_start; - screen_size_t rows_to_move; - int cols = tems.ts_c_dimension.width; - - chars_per_row = e_col - s_col + 1; - rows_to_move = e_row - s_row + 1; - - to_row_start = base + ((t_row * cols) + t_col); - from_row_start = base + ((s_row * cols) + s_col); - - if (to_row_start < from_row_start) { - while (rows_to_move-- > 0) { - to = to_row_start; - from = from_row_start; - to_row_start += cols; - from_row_start += cols; - for (cnt = chars_per_row; cnt-- > 0; ) - *to++ = *from++; - } - } else { - /* - * Offset to the end of the region and copy backwards. - */ - cnt = rows_to_move * cols + chars_per_row; - to_row_start += cnt; - from_row_start += cnt; - - while (rows_to_move-- > 0) { - to_row_start -= cols; - from_row_start -= cols; - to = to_row_start; - from = from_row_start; - for (cnt = chars_per_row; cnt-- > 0; ) - *--to = *--from; - } - } -} - -static void -i_virtual_copy_colors(text_color_t *base, - screen_pos_t s_col, screen_pos_t s_row, - screen_pos_t e_col, screen_pos_t e_row, - screen_pos_t t_col, screen_pos_t t_row) -{ - text_color_t *from; - text_color_t *to; - int cnt; - screen_size_t chars_per_row; - text_color_t *to_row_start; - text_color_t *from_row_start; + term_char_t *to_row_start; + term_char_t *from_row_start; screen_size_t rows_to_move; int cols = tems.ts_c_dimension.width; @@ -2433,23 +2399,24 @@ tem_safe_virtual_copy(struct tem_vt_state *tem, i_virtual_copy_tem_chars(tem->tvs_screen_buf, s_col, s_row, e_col, e_row, t_col, t_row); - - i_virtual_copy_colors(tem->tvs_fg_buf, - s_col, s_row, e_col, e_row, t_col, t_row); - i_virtual_copy_colors(tem->tvs_bg_buf, - s_col, s_row, e_col, e_row, t_col, t_row); } static void tem_safe_virtual_cls(struct tem_vt_state *tem, int count, screen_pos_t row, screen_pos_t col) { - text_color_t fg_color; - text_color_t bg_color; + int i; + text_attr_t attr; + term_char_t c; + + tem_safe_get_attr(tem, &c.tc_fg_color, &c.tc_bg_color, &attr, + TEM_ATTR_SCREEN_REVERSE); + c.tc_char = TEM_ATTR(attr & ~TEM_ATTR_UNDERLINE) | ' '; - tem_safe_get_color(tem, &fg_color, &bg_color, TEM_ATTR_SCREEN_REVERSE); - tem_safe_virtual_display(tem, tems.ts_blank_line, count, row, col, - fg_color, bg_color); + for (i = 0; i < tems.ts_c_dimension.width; i++) + tems.ts_blank_line[i] = c; + + tem_safe_virtual_display(tem, tems.ts_blank_line, count, row, col); } /* @@ -2483,12 +2450,7 @@ void tem_safe_unblank_screen(struct tem_vt_state *tem, cred_t *credp, enum called_from called_from) { - text_color_t fg_color, fg_last; - text_color_t bg_color, bg_last; - size_t tc_size = sizeof (text_color_t); - int row, col, count, col_start; - int width; - tem_char_t *buf; + int row; ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) || called_from == CALLED_FROM_STANDALONE); @@ -2498,8 +2460,6 @@ tem_safe_unblank_screen(struct tem_vt_state *tem, cred_t *credp, tem_safe_callback_cursor(tem, VIS_HIDE_CURSOR, credp, called_from); - width = tems.ts_c_dimension.width; - /* * Display data in tvs_screen_buf to the actual framebuffer in a * row by row way. @@ -2507,44 +2467,8 @@ tem_safe_unblank_screen(struct tem_vt_state *tem, cred_t *credp, * and background color all together. */ for (row = 0; row < tems.ts_c_dimension.height; row++) { - buf = tem->tvs_screen_buf + (row * width); - count = col_start = 0; - for (col = 0; col < width; col++) { - fg_color = - tem->tvs_fg_buf[(row * width + col) * tc_size]; - bg_color = - tem->tvs_bg_buf[(row * width + col) * tc_size]; - if (col == 0) { - fg_last = fg_color; - bg_last = bg_color; - } - - if ((fg_color != fg_last) || (bg_color != bg_last)) { - /* - * Call the primitive to render this data. - */ - tem_safe_callback_display(tem, - buf, count, row, col_start, - fg_last, bg_last, credp, called_from); - buf += count; - count = 1; - col_start = col; - fg_last = fg_color; - bg_last = bg_color; - } else { - count++; - } - } - - if (col_start == (width - 1)) - continue; - - /* - * Call the primitive to render this data. - */ - tem_safe_callback_display(tem, - buf, count, row, col_start, - fg_last, bg_last, credp, called_from); + tem_safe_callback_display(tem, tem->tvs_screen_rows[row], + tems.ts_c_dimension.width, row, 0, credp, called_from); } tem_safe_callback_cursor(tem, VIS_DISPLAY_CURSOR, credp, called_from); |
