Changeset 25a76ab8 in mainline for uspace/srv/hid/fb/serial_console.c


Ignore:
Timestamp:
2010-05-08T07:53:23Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
051bc69a
Parents:
6c39a907 (diff), 1317380 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

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

    r6c39a907 r25a76ab8  
    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        }
     
    352339                ipcarg_t w;
    353340                ipcarg_t h;
    354                 attrs_t attr;
    355341                ssize_t rows;
    356342               
     
    430416                        break;
    431417                case FB_SET_STYLE:
    432                         attr.t = at_style;
    433                         attr.a.s.style = IPC_GET_ARG1(call);
     418                        cur_attr.t = at_style;
     419                        cur_attr.a.s.style = IPC_GET_ARG1(call);
    434420                        serial_set_attrs(&cur_attr);
    435421                        retval = 0;
    436422                        break;
    437423                case FB_SET_COLOR:
    438                         attr.t = at_idx;
    439                         attr.a.i.fg_color = IPC_GET_ARG1(call);
    440                         attr.a.i.bg_color = IPC_GET_ARG2(call);
    441                         attr.a.i.flags = IPC_GET_ARG3(call);
     424                        cur_attr.t = at_idx;
     425                        cur_attr.a.i.fg_color = IPC_GET_ARG1(call);
     426                        cur_attr.a.i.bg_color = IPC_GET_ARG2(call);
     427                        cur_attr.a.i.flags = IPC_GET_ARG3(call);
    442428                        serial_set_attrs(&cur_attr);
    443429                        retval = 0;
    444430                        break;
    445431                case FB_SET_RGB_COLOR:
    446                         attr.t = at_rgb;
    447                         attr.a.r.fg_color = IPC_GET_ARG1(call);
    448                         attr.a.r.bg_color = IPC_GET_ARG2(call);
     432                        cur_attr.t = at_rgb;
     433                        cur_attr.a.r.fg_color = IPC_GET_ARG1(call);
     434                        cur_attr.a.r.bg_color = IPC_GET_ARG2(call);
    449435                        serial_set_attrs(&cur_attr);
    450436                        retval = 0;
Note: See TracChangeset for help on using the changeset viewer.