Lines Matching +full:x +full:- +full:y

2  * SPDX-License-Identifier: MIT
14 #include "console-priv.h"
54 int x, y; member
124 return c->chr ? c->chr->label : NULL; in qemu_text_console_get_label()
132 .x = posx, .y = posy, .width = width, .height = height in qemu_console_fill_rect()
136 pixman_image_fill_rectangles(PIXMAN_OP_SRC, surface->image, in qemu_console_fill_rect()
148 surface->image, NULL, surface->image, in qemu_console_bitblt()
152 static void vga_putcharxy(QemuConsole *s, int x, int y, int ch, in vga_putcharxy() argument
160 if (t_attrib->invers) { in vga_putcharxy()
161 bgcol = color_table_rgb[t_attrib->bold][t_attrib->fgcol]; in vga_putcharxy()
162 fgcol = color_table_rgb[t_attrib->bold][t_attrib->bgcol]; in vga_putcharxy()
164 fgcol = color_table_rgb[t_attrib->bold][t_attrib->fgcol]; in vga_putcharxy()
165 bgcol = color_table_rgb[t_attrib->bold][t_attrib->bgcol]; in vga_putcharxy()
171 qemu_pixman_glyph_render(glyphs[ch], surface->image, in vga_putcharxy()
172 &fgcol, &bgcol, x, y, FONT_WIDTH, FONT_HEIGHT); in vga_putcharxy()
175 static void invalidate_xy(QemuTextConsole *s, int x, int y) in invalidate_xy() argument
180 if (s->update_x0 > x * FONT_WIDTH) in invalidate_xy()
181 s->update_x0 = x * FONT_WIDTH; in invalidate_xy()
182 if (s->update_y0 > y * FONT_HEIGHT) in invalidate_xy()
183 s->update_y0 = y * FONT_HEIGHT; in invalidate_xy()
184 if (s->update_x1 < (x + 1) * FONT_WIDTH) in invalidate_xy()
185 s->update_x1 = (x + 1) * FONT_WIDTH; in invalidate_xy()
186 if (s->update_y1 < (y + 1) * FONT_HEIGHT) in invalidate_xy()
187 s->update_y1 = (y + 1) * FONT_HEIGHT; in invalidate_xy()
193 int y, y1; in console_show_cursor() local
194 int x = s->x; in console_show_cursor() local
196 s->cursor_invalidate = 1; in console_show_cursor()
198 if (x >= s->width) { in console_show_cursor()
199 x = s->width - 1; in console_show_cursor()
201 y1 = (s->y_base + s->y) % s->total_height; in console_show_cursor()
202 y = y1 - s->y_displayed; in console_show_cursor()
203 if (y < 0) { in console_show_cursor()
204 y += s->total_height; in console_show_cursor()
206 if (y < s->height) { in console_show_cursor()
207 c = &s->cells[y1 * s->width + x]; in console_show_cursor()
211 vga_putcharxy(QEMU_CONSOLE(s), x, y, c->ch, &t_attrib); in console_show_cursor()
213 vga_putcharxy(QEMU_CONSOLE(s), x, y, c->ch, &(c->t_attrib)); in console_show_cursor()
215 invalidate_xy(s, x, y); in console_show_cursor()
223 int x, y, y1; in console_refresh() local
226 s->text_x[0] = 0; in console_refresh()
227 s->text_y[0] = 0; in console_refresh()
228 s->text_x[1] = s->width - 1; in console_refresh()
229 s->text_y[1] = s->height - 1; in console_refresh()
230 s->cursor_invalidate = 1; in console_refresh()
234 y1 = s->y_displayed; in console_refresh()
235 for (y = 0; y < s->height; y++) { in console_refresh()
236 c = s->cells + y1 * s->width; in console_refresh()
237 for (x = 0; x < s->width; x++) { in console_refresh()
238 vga_putcharxy(QEMU_CONSOLE(s), x, y, c->ch, in console_refresh()
239 &(c->t_attrib)); in console_refresh()
242 if (++y1 == s->total_height) { in console_refresh()
257 if (s->y_displayed == s->y_base) in console_scroll()
259 if (++s->y_displayed == s->total_height) in console_scroll()
260 s->y_displayed = 0; in console_scroll()
263 ydelta = -ydelta; in console_scroll()
264 i = s->backscroll_height; in console_scroll()
265 if (i > s->total_height - s->height) in console_scroll()
266 i = s->total_height - s->height; in console_scroll()
267 y1 = s->y_base - i; in console_scroll()
269 y1 += s->total_height; in console_scroll()
271 if (s->y_displayed == y1) in console_scroll()
273 if (--s->y_displayed < 0) in console_scroll()
274 s->y_displayed = s->total_height - 1; in console_scroll()
284 len = qemu_chr_be_can_write(s->chr); in kbd_send_chars()
285 avail = fifo8_num_used(&s->out_fifo); in kbd_send_chars()
290 buf = fifo8_pop_bufptr(&s->out_fifo, MIN(len, avail), &size); in kbd_send_chars()
291 qemu_chr_be_write(s->chr, buf, size); in kbd_send_chars()
292 len = qemu_chr_be_can_write(s->chr); in kbd_send_chars()
293 avail -= size; in kbd_send_chars()
306 console_scroll(s, -1); in qemu_text_console_handle_keysym()
312 console_scroll(s, -10); in qemu_text_console_handle_keysym()
323 c = keysym - 0xe100; in qemu_text_console_handle_keysym()
332 } else if (s->echo && (keysym == '\r' || keysym == '\n')) { in qemu_text_console_handle_keysym()
333 qemu_chr_write(s->chr, (uint8_t *)"\r", 1, true); in qemu_text_console_handle_keysym()
338 if (s->echo) { in qemu_text_console_handle_keysym()
339 qemu_chr_write(s->chr, buf, q - buf, true); in qemu_text_console_handle_keysym()
341 num_free = fifo8_num_free(&s->out_fifo); in qemu_text_console_handle_keysym()
342 fifo8_push_all(&s->out_fifo, buf, MIN(num_free, q - buf)); in qemu_text_console_handle_keysym()
353 if (s->text_x[0] <= s->text_x[1]) { in text_console_update()
354 src = (s->y_base + s->text_y[0]) * s->width; in text_console_update()
355 chardata += s->text_y[0] * s->width; in text_console_update()
356 for (i = s->text_y[0]; i <= s->text_y[1]; i ++) in text_console_update()
357 for (j = 0; j < s->width; j++, src++) { in text_console_update()
359 ATTR2CHTYPE(s->cells[src].ch, in text_console_update()
360 s->cells[src].t_attrib.fgcol, in text_console_update()
361 s->cells[src].t_attrib.bgcol, in text_console_update()
362 s->cells[src].t_attrib.bold)); in text_console_update()
364 dpy_text_update(QEMU_CONSOLE(s), s->text_x[0], s->text_y[0], in text_console_update()
365 s->text_x[1] - s->text_x[0], i - s->text_y[0]); in text_console_update()
366 s->text_x[0] = s->width; in text_console_update()
367 s->text_y[0] = s->height; in text_console_update()
368 s->text_x[1] = 0; in text_console_update()
369 s->text_y[1] = 0; in text_console_update()
371 if (s->cursor_invalidate) { in text_console_update()
372 dpy_text_cursor(QEMU_CONSOLE(s), s->x, s->y); in text_console_update()
373 s->cursor_invalidate = 0; in text_console_update()
381 int w1, x, y, last_width, w, h; in text_console_resize() local
383 assert(s->scanout.kind == SCANOUT_SURFACE); in text_console_resize()
385 w = surface_width(s->surface) / FONT_WIDTH; in text_console_resize()
386 h = surface_height(s->surface) / FONT_HEIGHT; in text_console_resize()
387 if (w == t->width && h == t->height) { in text_console_resize()
391 last_width = t->width; in text_console_resize()
392 t->width = w; in text_console_resize()
393 t->height = h; in text_console_resize()
395 w1 = MIN(t->width, last_width); in text_console_resize()
397 cells = g_new(TextCell, t->width * t->total_height + 1); in text_console_resize()
398 for (y = 0; y < t->total_height; y++) { in text_console_resize()
399 c = &cells[y * t->width]; in text_console_resize()
401 c1 = &t->cells[y * last_width]; in text_console_resize()
402 for (x = 0; x < w1; x++) { in text_console_resize()
406 for (x = w1; x < t->width; x++) { in text_console_resize()
407 c->ch = ' '; in text_console_resize()
408 c->t_attrib = TEXT_ATTRIBUTES_DEFAULT; in text_console_resize()
412 g_free(t->cells); in text_console_resize()
413 t->cells = cells; in text_console_resize()
418 QemuTextConsole *s = vc->console; in vc_put_lf()
420 int x, y1; in vc_put_lf() local
422 s->y++; in vc_put_lf()
423 if (s->y >= s->height) { in vc_put_lf()
424 s->y = s->height - 1; in vc_put_lf()
426 if (s->y_displayed == s->y_base) { in vc_put_lf()
427 if (++s->y_displayed == s->total_height) in vc_put_lf()
428 s->y_displayed = 0; in vc_put_lf()
430 if (++s->y_base == s->total_height) in vc_put_lf()
431 s->y_base = 0; in vc_put_lf()
432 if (s->backscroll_height < s->total_height) in vc_put_lf()
433 s->backscroll_height++; in vc_put_lf()
434 y1 = (s->y_base + s->height - 1) % s->total_height; in vc_put_lf()
435 c = &s->cells[y1 * s->width]; in vc_put_lf()
436 for(x = 0; x < s->width; x++) { in vc_put_lf()
437 c->ch = ' '; in vc_put_lf()
438 c->t_attrib = TEXT_ATTRIBUTES_DEFAULT; in vc_put_lf()
441 if (s->y_displayed == s->y_base) { in vc_put_lf()
442 s->text_x[0] = 0; in vc_put_lf()
443 s->text_y[0] = 0; in vc_put_lf()
444 s->text_x[1] = s->width - 1; in vc_put_lf()
445 s->text_y[1] = s->height - 1; in vc_put_lf()
448 s->width * FONT_WIDTH, in vc_put_lf()
449 (s->height - 1) * FONT_HEIGHT); in vc_put_lf()
450 qemu_console_fill_rect(QEMU_CONSOLE(s), 0, (s->height - 1) * FONT_HEIGHT, in vc_put_lf()
451 s->width * FONT_WIDTH, FONT_HEIGHT, in vc_put_lf()
453 s->update_x0 = 0; in vc_put_lf()
454 s->update_y0 = 0; in vc_put_lf()
455 s->update_x1 = s->width * FONT_WIDTH; in vc_put_lf()
456 s->update_y1 = s->height * FONT_HEIGHT; in vc_put_lf()
469 for (i = 0; i < vc->nb_esc_params; i++) { in vc_handle_escape()
470 switch (vc->esc_params[i]) { in vc_handle_escape()
472 vc->t_attrib = TEXT_ATTRIBUTES_DEFAULT; in vc_handle_escape()
475 vc->t_attrib.bold = 1; in vc_handle_escape()
478 vc->t_attrib.uline = 1; in vc_handle_escape()
481 vc->t_attrib.blink = 1; in vc_handle_escape()
484 vc->t_attrib.invers = 1; in vc_handle_escape()
487 vc->t_attrib.unvisible = 1; in vc_handle_escape()
490 vc->t_attrib.bold = 0; in vc_handle_escape()
493 vc->t_attrib.uline = 0; in vc_handle_escape()
496 vc->t_attrib.blink = 0; in vc_handle_escape()
499 vc->t_attrib.invers = 0; in vc_handle_escape()
502 vc->t_attrib.unvisible = 0; in vc_handle_escape()
506 vc->t_attrib.fgcol = QEMU_COLOR_BLACK; in vc_handle_escape()
509 vc->t_attrib.fgcol = QEMU_COLOR_RED; in vc_handle_escape()
512 vc->t_attrib.fgcol = QEMU_COLOR_GREEN; in vc_handle_escape()
515 vc->t_attrib.fgcol = QEMU_COLOR_YELLOW; in vc_handle_escape()
518 vc->t_attrib.fgcol = QEMU_COLOR_BLUE; in vc_handle_escape()
521 vc->t_attrib.fgcol = QEMU_COLOR_MAGENTA; in vc_handle_escape()
524 vc->t_attrib.fgcol = QEMU_COLOR_CYAN; in vc_handle_escape()
527 vc->t_attrib.fgcol = QEMU_COLOR_WHITE; in vc_handle_escape()
531 vc->t_attrib.bgcol = QEMU_COLOR_BLACK; in vc_handle_escape()
534 vc->t_attrib.bgcol = QEMU_COLOR_RED; in vc_handle_escape()
537 vc->t_attrib.bgcol = QEMU_COLOR_GREEN; in vc_handle_escape()
540 vc->t_attrib.bgcol = QEMU_COLOR_YELLOW; in vc_handle_escape()
543 vc->t_attrib.bgcol = QEMU_COLOR_BLUE; in vc_handle_escape()
546 vc->t_attrib.bgcol = QEMU_COLOR_MAGENTA; in vc_handle_escape()
549 vc->t_attrib.bgcol = QEMU_COLOR_CYAN; in vc_handle_escape()
552 vc->t_attrib.bgcol = QEMU_COLOR_WHITE; in vc_handle_escape()
558 static void vc_update_xy(VCChardev *vc, int x, int y) in vc_update_xy() argument
560 QemuTextConsole *s = vc->console; in vc_update_xy()
564 s->text_x[0] = MIN(s->text_x[0], x); in vc_update_xy()
565 s->text_x[1] = MAX(s->text_x[1], x); in vc_update_xy()
566 s->text_y[0] = MIN(s->text_y[0], y); in vc_update_xy()
567 s->text_y[1] = MAX(s->text_y[1], y); in vc_update_xy()
569 y1 = (s->y_base + y) % s->total_height; in vc_update_xy()
570 y2 = y1 - s->y_displayed; in vc_update_xy()
572 y2 += s->total_height; in vc_update_xy()
574 if (y2 < s->height) { in vc_update_xy()
575 if (x >= s->width) { in vc_update_xy()
576 x = s->width - 1; in vc_update_xy()
578 c = &s->cells[y1 * s->width + x]; in vc_update_xy()
579 vga_putcharxy(QEMU_CONSOLE(s), x, y2, c->ch, in vc_update_xy()
580 &(c->t_attrib)); in vc_update_xy()
581 invalidate_xy(s, x, y2); in vc_update_xy()
585 static void vc_clear_xy(VCChardev *vc, int x, int y) in vc_clear_xy() argument
587 QemuTextConsole *s = vc->console; in vc_clear_xy()
588 int y1 = (s->y_base + y) % s->total_height; in vc_clear_xy()
589 if (x >= s->width) { in vc_clear_xy()
590 x = s->width - 1; in vc_clear_xy()
592 TextCell *c = &s->cells[y1 * s->width + x]; in vc_clear_xy()
593 c->ch = ' '; in vc_clear_xy()
594 c->t_attrib = TEXT_ATTRIBUTES_DEFAULT; in vc_clear_xy()
595 vc_update_xy(vc, x, y); in vc_clear_xy()
600 QemuTextConsole *s = vc->console; in vc_put_one()
603 if (s->x >= s->width) { in vc_put_one()
605 s->x = 0; in vc_put_one()
608 y1 = (s->y_base + s->y) % s->total_height; in vc_put_one()
609 c = &s->cells[y1 * s->width + s->x]; in vc_put_one()
610 c->ch = ch; in vc_put_one()
611 c->t_attrib = vc->t_attrib; in vc_put_one()
612 vc_update_xy(vc, s->x, s->y); in vc_put_one()
613 s->x++; in vc_put_one()
625 static void vc_set_cursor(VCChardev *vc, int x, int y) in vc_set_cursor() argument
627 QemuTextConsole *s = vc->console; in vc_set_cursor()
629 if (x < 0) { in vc_set_cursor()
630 x = 0; in vc_set_cursor()
632 if (y < 0) { in vc_set_cursor()
633 y = 0; in vc_set_cursor()
635 if (y >= s->height) { in vc_set_cursor()
636 y = s->height - 1; in vc_set_cursor()
638 if (x >= s->width) { in vc_set_cursor()
639 x = s->width - 1; in vc_set_cursor()
642 s->x = x; in vc_set_cursor()
643 s->y = y; in vc_set_cursor()
648 QemuTextConsole *s = vc->console; in vc_putchar()
650 int x, y; in vc_putchar() local
653 switch(vc->state) { in vc_putchar()
657 s->x = 0; in vc_putchar()
663 if (s->x > 0) in vc_putchar()
664 s->x--; in vc_putchar()
667 if (s->x + (8 - (s->x % 8)) > s->width) { in vc_putchar()
668 s->x = 0; in vc_putchar()
671 s->x = s->x + (8 - (s->x % 8)); in vc_putchar()
684 vc->state = TTY_STATE_ESC; in vc_putchar()
694 vc->esc_params[i] = 0; in vc_putchar()
695 vc->nb_esc_params = 0; in vc_putchar()
696 vc->state = TTY_STATE_CSI; in vc_putchar()
698 vc->state = TTY_STATE_NORM; in vc_putchar()
703 if (vc->nb_esc_params < MAX_ESC_PARAMS) { in vc_putchar()
704 int *param = &vc->esc_params[vc->nb_esc_params]; in vc_putchar()
705 int digit = (ch - '0'); in vc_putchar()
707 *param = (*param <= (INT_MAX - digit) / 10) ? in vc_putchar()
711 if (vc->nb_esc_params < MAX_ESC_PARAMS) in vc_putchar()
712 vc->nb_esc_params++; in vc_putchar()
716 trace_console_putchar_csi(vc->esc_params[0], vc->esc_params[1], in vc_putchar()
717 ch, vc->nb_esc_params); in vc_putchar()
718 vc->state = TTY_STATE_NORM; in vc_putchar()
722 if (vc->esc_params[0] == 0) { in vc_putchar()
723 vc->esc_params[0] = 1; in vc_putchar()
725 vc_set_cursor(vc, s->x, s->y - vc->esc_params[0]); in vc_putchar()
729 if (vc->esc_params[0] == 0) { in vc_putchar()
730 vc->esc_params[0] = 1; in vc_putchar()
732 vc_set_cursor(vc, s->x, s->y + vc->esc_params[0]); in vc_putchar()
736 if (vc->esc_params[0] == 0) { in vc_putchar()
737 vc->esc_params[0] = 1; in vc_putchar()
739 vc_set_cursor(vc, s->x + vc->esc_params[0], s->y); in vc_putchar()
743 if (vc->esc_params[0] == 0) { in vc_putchar()
744 vc->esc_params[0] = 1; in vc_putchar()
746 vc_set_cursor(vc, s->x - vc->esc_params[0], s->y); in vc_putchar()
750 vc_set_cursor(vc, vc->esc_params[0] - 1, s->y); in vc_putchar()
755 vc_set_cursor(vc, vc->esc_params[1] - 1, vc->esc_params[0] - 1); in vc_putchar()
758 switch (vc->esc_params[0]) { in vc_putchar()
761 for (y = s->y; y < s->height; y++) { in vc_putchar()
762 for (x = 0; x < s->width; x++) { in vc_putchar()
763 if (y == s->y && x < s->x) { in vc_putchar()
766 vc_clear_xy(vc, x, y); in vc_putchar()
772 for (y = 0; y <= s->y; y++) { in vc_putchar()
773 for (x = 0; x < s->width; x++) { in vc_putchar()
774 if (y == s->y && x > s->x) { in vc_putchar()
777 vc_clear_xy(vc, x, y); in vc_putchar()
783 for (y = 0; y <= s->height; y++) { in vc_putchar()
784 for (x = 0; x < s->width; x++) { in vc_putchar()
785 vc_clear_xy(vc, x, y); in vc_putchar()
792 switch (vc->esc_params[0]) { in vc_putchar()
795 for(x = s->x; x < s->width; x++) { in vc_putchar()
796 vc_clear_xy(vc, x, s->y); in vc_putchar()
801 for (x = 0; x <= s->x && x < s->width; x++) { in vc_putchar()
802 vc_clear_xy(vc, x, s->y); in vc_putchar()
807 for(x = 0; x < s->width; x++) { in vc_putchar()
808 vc_clear_xy(vc, x, s->y); in vc_putchar()
817 switch (vc->esc_params[0]) { in vc_putchar()
825 (s->y_base + s->y) % s->total_height + 1, in vc_putchar()
826 s->x + 1); in vc_putchar()
833 vc->x_saved = s->x; in vc_putchar()
834 vc->y_saved = s->y; in vc_putchar()
838 s->x = vc->x_saved; in vc_putchar()
839 s->y = vc->y_saved; in vc_putchar()
850 #define TYPE_CHARDEV_VC "chardev-vc"
857 QemuTextConsole *s = drv->console; in DECLARE_INSTANCE_CHECKER()
860 s->update_x0 = s->width * FONT_WIDTH; in DECLARE_INSTANCE_CHECKER()
861 s->update_y0 = s->height * FONT_HEIGHT; in DECLARE_INSTANCE_CHECKER()
862 s->update_x1 = 0; in DECLARE_INSTANCE_CHECKER()
863 s->update_y1 = 0; in DECLARE_INSTANCE_CHECKER()
869 if (s->update_x0 < s->update_x1) { in DECLARE_INSTANCE_CHECKER()
870 dpy_gfx_update(QEMU_CONSOLE(s), s->update_x0, s->update_y0, in DECLARE_INSTANCE_CHECKER()
871 s->update_x1 - s->update_x0, in DECLARE_INSTANCE_CHECKER()
872 s->update_y1 - s->update_y0); in DECLARE_INSTANCE_CHECKER()
926 fifo8_create(&c->out_fifo, 16); in qemu_text_console_init()
927 c->total_height = DEFAULT_BACKSCROLL; in qemu_text_console_init()
928 QEMU_CONSOLE(c)->hw_ops = &text_console_ops; in qemu_text_console_init()
929 QEMU_CONSOLE(c)->hw = c; in qemu_text_console_init()
951 kbd_send_chars(drv->console); in vc_chr_accept_input()
958 drv->console->echo = echo; in vc_chr_set_echo()
963 dpy_text_resize(QEMU_CONSOLE(c), c->width, c->height); in qemu_text_console_update_size()
971 ChardevVC *vc = backend->u.vc.data; in vc_chr_open()
977 if (vc->has_width) { in vc_chr_open()
978 width = vc->width; in vc_chr_open()
979 } else if (vc->has_cols) { in vc_chr_open()
980 width = vc->cols * FONT_WIDTH; in vc_chr_open()
983 if (vc->has_height) { in vc_chr_open()
984 height = vc->height; in vc_chr_open()
985 } else if (vc->has_rows) { in vc_chr_open()
986 height = vc->rows * FONT_HEIGHT; in vc_chr_open()
1000 s->chr = chr; in vc_chr_open()
1001 drv->console = s; in vc_chr_open()
1004 drv->t_attrib = TEXT_ATTRIBUTES_DEFAULT; in vc_chr_open()
1007 if (chr->label) { in vc_chr_open()
1010 drv->t_attrib.bgcol = QEMU_COLOR_BLUE; in vc_chr_open()
1011 msg = g_strdup_printf("%s console\r\n", chr->label); in vc_chr_open()
1014 drv->t_attrib = TEXT_ATTRIBUTES_DEFAULT; in vc_chr_open()
1025 backend->type = CHARDEV_BACKEND_KIND_VC; in vc_chr_parse()
1026 vc = backend->u.vc.data = g_new0(ChardevVC, 1); in vc_chr_parse()
1031 vc->has_width = true; in vc_chr_parse()
1032 vc->width = val; in vc_chr_parse()
1037 vc->has_height = true; in vc_chr_parse()
1038 vc->height = val; in vc_chr_parse()
1043 vc->has_cols = true; in vc_chr_parse()
1044 vc->cols = val; in vc_chr_parse()
1049 vc->has_rows = true; in vc_chr_parse()
1050 vc->rows = val; in vc_chr_parse()
1058 cc->parse = vc_chr_parse; in char_vc_class_init()
1059 cc->open = vc_chr_open; in char_vc_class_init()
1060 cc->chr_write = vc_chr_write; in char_vc_class_init()
1061 cc->chr_accept_input = vc_chr_accept_input; in char_vc_class_init()
1062 cc->chr_set_echo = vc_chr_set_echo; in char_vc_class_init()