X-Git-Url: https://git.proxmox.com/?p=vncterm.git;a=blobdiff_plain;f=vncterm.c;h=7fb424fb17ee2ea2d8db04f7baf92c58a1f19598;hp=baaa3797bed8cc3cea73026c7ead66e895942f87;hb=33a537dc6bc6c9e1912f624c263deabf57ba3ee3;hpb=f2c7aa6b087244e1596b4b294ccd7236e4cce991 diff --git a/vncterm.c b/vncterm.c index baaa379..7fb424f 100644 --- a/vncterm.c +++ b/vncterm.c @@ -50,6 +50,9 @@ char *auth_path = "/"; char *auth_perm = "Sys.Console"; +uint16_t screen_width = 744; +uint16_t screen_height = 400; + int use_x509 = 1; static char * @@ -1405,10 +1408,7 @@ vncterm_putchar (vncTerm *vt, unicode ch) if (vt->esc_buf[0] == 0) { vt->esc_buf[0] = 1; } - vt->cy -= vt->esc_buf[0]; - if (vt->cy < 0) { - vt->cy = 0; - } + vncterm_gotoxy (vt, vt->cx, vt->cy - vt->esc_buf[0]); break; case 'B': case 'e': @@ -1416,10 +1416,7 @@ vncterm_putchar (vncTerm *vt, unicode ch) if (vt->esc_buf[0] == 0) { vt->esc_buf[0] = 1; } - vt->cy += vt->esc_buf[0]; - if (vt->cy >= vt->height) { - vt->cy = vt->height - 1; - } + vncterm_gotoxy (vt, vt->cx, vt->cy + vt->esc_buf[0]); break; case 'C': case 'a': @@ -1427,20 +1424,14 @@ vncterm_putchar (vncTerm *vt, unicode ch) if (vt->esc_buf[0] == 0) { vt->esc_buf[0] = 1; } - vt->cx += vt->esc_buf[0]; - if (vt->cx >= vt->width) { - vt->cx = vt->width - 1; - } + vncterm_gotoxy (vt, vt->cx + vt->esc_buf[0], vt->cy); break; case 'D': /* move cursor left */ if (vt->esc_buf[0] == 0) { vt->esc_buf[0] = 1; } - vt->cx -= vt->esc_buf[0]; - if (vt->cx < 0) { - vt->cx = 0; - } + vncterm_gotoxy (vt, vt->cx - vt->esc_buf[0], vt->cy); break; case 'G': case '`': @@ -1790,7 +1781,11 @@ vncterm_puts (vncTerm *vt, const char *buf, int len) vt->utf_char = (vt->utf_char << 6) | (c & 0x3f); vt->utf_count--; if (vt->utf_count == 0) { - tc = vt->utf_char; + if (vt->utf_char <= USHRT_MAX) { + tc = vt->utf_char; + } else { + tc = 0; + } } else { continue; } @@ -2282,6 +2277,8 @@ main (int argc, char** argv) struct timeval tv, tv1; time_t elapsed, cur_time; struct winsize dimensions; + unsigned long width = 0; + unsigned long height = 0; if (gnutls_global_init () < 0) { fprintf(stderr, "gnutls_global_init failed\n"); @@ -2321,6 +2318,22 @@ main (int argc, char** argv) CHECK_ARGC (argc, argv, i); auth_perm = argv[i+1]; rfbPurgeArguments(&argc, &i, 2, argv); i--; + } else if (!strcmp (argv[i], "-width")) { + CHECK_ARGC (argc, argv, i); + errno = 0; + width = strtoul(argv[i+1], NULL, 10); + if (errno == 0 && width >= 16 && width < 0xFFFF) { + screen_width = width; + } + rfbPurgeArguments(&argc, &i, 2, argv); i--; + } else if (!strcmp (argv[i], "-height")) { + CHECK_ARGC (argc, argv, i); + errno = 0; + height = strtoul(argv[i+1], NULL, 10); + if (errno == 0 && height >= 32 && height < 0xFFFF) { + screen_height = height; + } + rfbPurgeArguments(&argc, &i, 2, argv); i--; } else if (!strcmp (argv[i], "-notls")) { rfbPurgeArguments(&argc, &i, 1, argv); i--; if ((vncticket = getenv("PVE_VNC_TICKET")) == NULL) { @@ -2340,7 +2353,7 @@ main (int argc, char** argv) rfbLogEnable (0); #endif - vncTerm *vt = create_vncterm (argc, argv, 745, 400); + vncTerm *vt = create_vncterm (argc, argv, screen_width, screen_height); setlocale(LC_ALL, ""); // set from environment