Changeset 32e7411 in mainline


Ignore:
Timestamp:
2010-05-04T15:48:49Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5e16832f
Parents:
53e197f
Message:

more serial console fixes

  • better attributes in monochrome mode
  • better colors for styles in color mode
  • fix errors on redrawing areas
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/fb/serial_console.c

    r53e197f r32e7411  
    8484        SGR_RESET       = 0,
    8585        SGR_BOLD        = 1,
     86        SGR_UNDERLINE   = 4,
    8687        SGR_BLINK       = 5,
    8788        SGR_REVERSE     = 7,
    88         SGR_NORMAL_INT  = 22,
    89         SGR_BLINK_OFF   = 25,
    90         SGR_REVERSE_OFF = 27,
    9189        SGR_FGCOLOR     = 30,
    9290        SGR_BGCOLOR     = 40
     
    153151        switch (style) {
    154152        case STYLE_EMPHASIS:
     153                serial_sgr(SGR_RESET);
    155154                if (color) {
    156                         serial_sgr(SGR_RESET);
    157155                        serial_sgr(SGR_FGCOLOR + CI_RED);
    158156                        serial_sgr(SGR_BGCOLOR + CI_WHITE);
     
    161159                break;
    162160        case STYLE_INVERTED:
     161                serial_sgr(SGR_RESET);
    163162                if (color) {
    164                         serial_sgr(SGR_RESET);
    165163                        serial_sgr(SGR_FGCOLOR + CI_WHITE);
    166164                        serial_sgr(SGR_BGCOLOR + CI_BLACK);
    167                         serial_sgr(SGR_NORMAL_INT);
    168165                } else
    169166                        serial_sgr(SGR_REVERSE);
    170167                break;
    171168        case STYLE_SELECTED:
     169                serial_sgr(SGR_RESET);
    172170                if (color) {
    173                         serial_sgr(SGR_RESET);
    174171                        serial_sgr(SGR_FGCOLOR + CI_WHITE);
    175172                        serial_sgr(SGR_BGCOLOR + CI_RED);
    176                         serial_sgr(SGR_NORMAL_INT);
    177                 } else {
    178                         serial_sgr(SGR_BOLD);
    179                         serial_sgr(SGR_REVERSE);
    180                 }
     173                } else
     174                        serial_sgr(SGR_UNDERLINE);
    181175                break;
    182176        default:
     177                serial_sgr(SGR_RESET);
    183178                if (color) {
    184                         serial_sgr(SGR_RESET);
    185179                        serial_sgr(SGR_FGCOLOR + CI_BLACK);
    186180                        serial_sgr(SGR_BGCOLOR + CI_WHITE);
    187181                }
    188                 serial_sgr(SGR_NORMAL_INT);
    189182        }
    190183}
     
    193186    uint8_t flags)
    194187{
     188        serial_sgr(SGR_RESET);
    195189        if (color) {
    196                 serial_sgr(SGR_RESET);
    197                 serial_sgr(SGR_FGCOLOR + color_map[fgcolor]);
    198                 serial_sgr(SGR_BGCOLOR + color_map[bgcolor]);
     190                serial_sgr(SGR_FGCOLOR + color_map[fgcolor & 7]);
     191                serial_sgr(SGR_BGCOLOR + color_map[bgcolor & 7]);
     192                if (flags & CATTR_BRIGHT)
     193                        serial_sgr(SGR_BOLD);
    199194        } else {
    200                 if (fgcolor < bgcolor)
    201                         serial_sgr(SGR_RESET);
    202                 else
     195                if (fgcolor >= bgcolor)
    203196                        serial_sgr(SGR_REVERSE);
    204         }       
     197        }
    205198}
    206199
     
    209202        serial_sgr(SGR_RESET);
    210203       
    211         if (fgcolor < bgcolor)
    212                 serial_sgr(SGR_REVERSE_OFF);
    213         else
     204        if (fgcolor >= bgcolor)
    214205                serial_sgr(SGR_REVERSE);
    215206}
     
    283274}
    284275
    285 
    286 
    287276/** Draw text data to viewport.
    288277 *
    289  * @param vport Viewport id
    290  * @param data  Text data.
    291  * @param x     Leftmost column of the area.
    292  * @param y     Topmost row of the area.
    293  * @param w     Number of rows.
    294  * @param h    Number of columns.
     278 * @param vport  Viewport id
     279 * @param data   Text data.
     280 * @param x0     Leftmost column of the area.
     281 * @param y0     Topmost row of the area.
     282 * @param width  Number of rows.
     283 * @param height Number of columns.
    295284 *
    296285 */
    297 static void draw_text_data(keyfield_t *data, ipcarg_t x, ipcarg_t y,
    298     ipcarg_t w, ipcarg_t h)
    299 {
    300         serial_goto(x, y);
    301         ipcarg_t i;
    302         ipcarg_t j;
    303        
     286static void draw_text_data(keyfield_t *data, ipcarg_t x0, ipcarg_t y0,
     287    ipcarg_t width, ipcarg_t height)
     288{
    304289        attrs_t *a0 = &data[0].attrs;
    305        
    306         for (j = 0; j < h; j++) {
    307                 if ((j > 0) && (w != scr_width))
    308                         serial_goto(x, j);
     290        serial_set_attrs(a0);
     291       
     292        ipcarg_t y;
     293        for (y = 0; y < height; y++) {
     294                serial_goto(x0, y0 + y);
    309295               
    310                 for (i = 0; i < w; i++) {
    311                         attrs_t *a1 = &data[j * w + i].attrs;
    312                        
    313                         if (!attrs_same(*a0, *a1)) {
    314                                 serial_set_attrs(a1);
    315                                 a0 = a1;
     296                ipcarg_t x;
     297                for (x = 0; x < width; x++) {
     298                        attrs_t *attr = &data[y * width + x].attrs;
     299                       
     300                        if (!attrs_same(*a0, *attr)) {
     301                                serial_set_attrs(attr);
     302                                a0 = attr;
    316303                        }
    317304                       
    318                         serial_putchar(data[j * w + i].character);
     305                        serial_putchar(data[y * width + x].character);
    319306                }
    320307        }
Note: See TracChangeset for help on using the changeset viewer.