Revision 5fafdf24 console.c

b/console.c
1 1
/*
2 2
 * QEMU graphical console
3
 * 
3
 *
4 4
 * Copyright (c) 2004 Fabrice Bellard
5
 * 
5
 *
6 6
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 7
 * of this software and associated documentation files (the "Software"), to deal
8 8
 * in the Software without restriction, including without limitation the rights
......
180 180
        r = (rgba >> 16) & 0xff;
181 181
        g = (rgba >> 8) & 0xff;
182 182
        b = (rgba) & 0xff;
183
        color = (rgb_to_index[r] * 6 * 6) + 
184
            (rgb_to_index[g] * 6) + 
183
        color = (rgb_to_index[r] * 6 * 6) +
184
            (rgb_to_index[g] * 6) +
185 185
            (rgb_to_index[b]);
186 186
        break;
187 187
#endif
......
205 205
    return color;
206 206
}
207 207

  
208
static void vga_fill_rect (DisplayState *ds, 
208
static void vga_fill_rect (DisplayState *ds,
209 209
                           int posx, int posy, int width, int height, uint32_t color)
210 210
{
211 211
    uint8_t *d, *d1;
212 212
    int x, y, bpp;
213
    
213
   
214 214
    bpp = (ds->depth + 7) >> 3;
215
    d1 = ds->data + 
215
    d1 = ds->data +
216 216
        ds->linesize * posy + bpp * posx;
217 217
    for (y = 0; y < height; y++) {
218 218
        d = d1;
......
250 250
    bpp = (ds->depth + 7) >> 3;
251 251
    wb = w * bpp;
252 252
    if (yd <= ys) {
253
        s = ds->data + 
253
        s = ds->data +
254 254
            ds->linesize * ys + bpp * xs;
255
        d = ds->data + 
255
        d = ds->data +
256 256
            ds->linesize * yd + bpp * xd;
257 257
        for (y = 0; y < h; y++) {
258 258
            memmove(d, s, wb);
......
260 260
            s += ds->linesize;
261 261
        }
262 262
    } else {
263
        s = ds->data + 
263
        s = ds->data +
264 264
            ds->linesize * (ys + h - 1) + bpp * xs;
265
        d = ds->data + 
265
        d = ds->data +
266 266
            ds->linesize * (yd + h - 1) + bpp * xd;
267 267
       for (y = 0; y < h; y++) {
268 268
            memmove(d, s, wb);
......
405 405
}
406 406
#endif
407 407

  
408
static void vga_putcharxy(DisplayState *ds, int x, int y, int ch, 
408
static void vga_putcharxy(DisplayState *ds, int x, int y, int ch,
409 409
                          TextAttributes *t_attrib)
410 410
{
411 411
    uint8_t *d;
......
428 428
    }
429 429

  
430 430
    bpp = (ds->depth + 7) >> 3;
431
    d = ds->data + 
431
    d = ds->data +
432 432
        ds->linesize * y * FONT_HEIGHT + bpp * x * FONT_WIDTH;
433 433
    linesize = ds->linesize;
434 434
    font_ptr = vgafont16 + FONT_HEIGHT * ch;
......
525 525
            y2 += s->total_height;
526 526
        if (y2 < s->height) {
527 527
            c = &s->cells[y1 * s->width + x];
528
            vga_putcharxy(s->ds, x, y2, c->ch, 
528
            vga_putcharxy(s->ds, x, y2, c->ch,
529 529
                          &(c->t_attrib));
530
            dpy_update(s->ds, x * FONT_WIDTH, y2 * FONT_HEIGHT, 
530
            dpy_update(s->ds, x * FONT_WIDTH, y2 * FONT_HEIGHT,
531 531
                       FONT_WIDTH, FONT_HEIGHT);
532 532
        }
533 533
    }
......
556 556
            } else {
557 557
                vga_putcharxy(s->ds, x, y, c->ch, &(c->t_attrib));
558 558
            }
559
            dpy_update(s->ds, x * FONT_WIDTH, y * FONT_HEIGHT, 
559
            dpy_update(s->ds, x * FONT_WIDTH, y * FONT_HEIGHT,
560 560
                       FONT_WIDTH, FONT_HEIGHT);
561 561
        }
562 562
    }
......
567 567
    TextCell *c;
568 568
    int x, y, y1;
569 569

  
570
    if (s != active_console) 
570
    if (s != active_console)
571 571
        return;
572 572

  
573 573
    vga_fill_rect(s->ds, 0, 0, s->ds->width, s->ds->height,
......
576 576
    for(y = 0; y < s->height; y++) {
577 577
        c = s->cells + y1 * s->width;
578 578
        for(x = 0; x < s->width; x++) {
579
            vga_putcharxy(s->ds, x, y, c->ch, 
579
            vga_putcharxy(s->ds, x, y, c->ch,
580 580
                          &(c->t_attrib));
581 581
            c++;
582 582
        }
......
591 591
{
592 592
    TextConsole *s;
593 593
    int i, y1;
594
    
594
   
595 595
    s = active_console;
596 596
    if (!s || (s->console_type == GRAPHIC_CONSOLE))
597 597
        return;
......
646 646
            c++;
647 647
        }
648 648
        if (s == active_console && s->y_displayed == s->y_base) {
649
            vga_bitblt(s->ds, 0, FONT_HEIGHT, 0, 0, 
650
                       s->width * FONT_WIDTH, 
649
            vga_bitblt(s->ds, 0, FONT_HEIGHT, 0, 0,
650
                       s->width * FONT_WIDTH,
651 651
                       (s->height - 1) * FONT_HEIGHT);
652 652
            vga_fill_rect(s->ds, 0, (s->height - 1) * FONT_HEIGHT,
653
                          s->width * FONT_WIDTH, FONT_HEIGHT, 
653
                          s->width * FONT_WIDTH, FONT_HEIGHT,
654 654
                          color_table[0][s->t_attrib_default.bgcol]);
655
            dpy_update(s->ds, 0, 0, 
655
            dpy_update(s->ds, 0, 0,
656 656
                       s->width * FONT_WIDTH, s->height * FONT_HEIGHT);
657 657
        }
658 658
    }
......
781 781
            console_put_lf(s);
782 782
            break;
783 783
        case '\b':  /* backspace */
784
            if (s->x > 0) 
784
            if (s->x > 0)
785 785
                s->x--;
786 786
            break;
787 787
        case '\t':  /* tabspace */
......
832 832
    case TTY_STATE_CSI: /* handle escape sequence parameters */
833 833
        if (ch >= '0' && ch <= '9') {
834 834
            if (s->nb_esc_params < MAX_ESC_PARAMS) {
835
                s->esc_params[s->nb_esc_params] = 
835
                s->esc_params[s->nb_esc_params] =
836 836
                    s->esc_params[s->nb_esc_params] * 10 + ch - '0';
837 837
            }
838 838
        } else {
......
1047 1047
    TextConsole *s = opaque;
1048 1048
    int len;
1049 1049
    uint8_t buf[16];
1050
    
1050
   
1051 1051
    len = qemu_chr_can_read(s->chr);
1052 1052
    if (len > s->out_fifo.count)
1053 1053
        len = s->out_fifo.count;
......
1192 1192
    s->out_fifo.buf = s->out_fifo_buf;
1193 1193
    s->out_fifo.buf_size = sizeof(s->out_fifo_buf);
1194 1194
    s->kbd_timer = qemu_new_timer(rt_clock, kbd_send_chars, s);
1195
    
1195
   
1196 1196
    if (!color_inited) {
1197 1197
        color_inited = 1;
1198 1198
        for(j = 0; j < 2; j++) {
1199 1199
            for(i = 0; i < 8; i++) {
1200
                color_table[j][i] = col_expand(s->ds, 
1200
                color_table[j][i] = col_expand(s->ds,
1201 1201
                        vga_get_color(s->ds, color_table_rgb[j][i]));
1202 1202
            }
1203 1203
        }

Also available in: Unified diff