mirror of
git://git.proxmox.com/git/spiceterm.git
synced 2025-01-25 06:03:53 +03:00
rename vncterm to spiceterm
This commit is contained in:
parent
8c22ae7f43
commit
d6a5f5a9fc
180
spiceterm.c
180
spiceterm.c
@ -76,7 +76,7 @@ static void
|
|||||||
print_usage (const char *msg)
|
print_usage (const char *msg)
|
||||||
{
|
{
|
||||||
if (msg) { fprintf (stderr, "ERROR: %s\n", msg); }
|
if (msg) { fprintf (stderr, "ERROR: %s\n", msg); }
|
||||||
fprintf (stderr, "USAGE: vncterm [vncopts] [-c command [args]]\n");
|
fprintf (stderr, "USAGE: spiceterm [spiceopts] [-c command [args]]\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert UCS2 to UTF8 sequence, trailing zero */
|
/* Convert UCS2 to UTF8 sequence, trailing zero */
|
||||||
@ -106,7 +106,7 @@ ucs2_to_utf8 (unicode c, char *out)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
draw_char_at (vncTerm *vt, int x, int y, unicode ch, TextAttributes attrib)
|
draw_char_at (spiceTerm *vt, int x, int y, unicode ch, TextAttributes attrib)
|
||||||
{
|
{
|
||||||
if (x < 0 || y < 0 || x >= vt->width || y >= vt->height) {
|
if (x < 0 || y < 0 || x >= vt->width || y >= vt->height) {
|
||||||
return;
|
return;
|
||||||
@ -116,7 +116,7 @@ draw_char_at (vncTerm *vt, int x, int y, unicode ch, TextAttributes attrib)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vncterm_update_xy (vncTerm *vt, int x, int y)
|
spiceterm_update_xy (spiceTerm *vt, int x, int y)
|
||||||
{
|
{
|
||||||
if (x < 0 || y < 0 || x >= vt->width || y >= vt->height) { return; }
|
if (x < 0 || y < 0 || x >= vt->width || y >= vt->height) { return; }
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ vncterm_update_xy (vncTerm *vt, int x, int y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vncterm_clear_xy (vncTerm *vt, int x, int y)
|
spiceterm_clear_xy (spiceTerm *vt, int x, int y)
|
||||||
{
|
{
|
||||||
if (x < 0 || y < 0 || x >= vt->width || y >= vt->height) { return; }
|
if (x < 0 || y < 0 || x >= vt->width || y >= vt->height) { return; }
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ vncterm_clear_xy (vncTerm *vt, int x, int y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vncterm_show_cursor (vncTerm *vt, int show)
|
spiceterm_show_cursor (spiceTerm *vt, int show)
|
||||||
{
|
{
|
||||||
int x = vt->cx;
|
int x = vt->cx;
|
||||||
if (x >= vt->width) {
|
if (x >= vt->width) {
|
||||||
@ -181,7 +181,7 @@ vncterm_show_cursor (vncTerm *vt, int show)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vncterm_refresh (vncTerm *vt)
|
spiceterm_refresh (spiceTerm *vt)
|
||||||
{
|
{
|
||||||
int x, y, y1;
|
int x, y, y1;
|
||||||
|
|
||||||
@ -199,11 +199,11 @@ vncterm_refresh (vncTerm *vt)
|
|||||||
}
|
}
|
||||||
//rfbMarkRectAsModified (vt->screen, 0, 0, vt->maxx, vt->maxy);
|
//rfbMarkRectAsModified (vt->screen, 0, 0, vt->maxx, vt->maxy);
|
||||||
|
|
||||||
vncterm_show_cursor (vt, 1);
|
spiceterm_show_cursor (vt, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vncterm_scroll_down (vncTerm *vt, int top, int bottom, int lines)
|
spiceterm_scroll_down (spiceTerm *vt, int top, int bottom, int lines)
|
||||||
{
|
{
|
||||||
if ((top + lines) >= bottom) {
|
if ((top + lines) >= bottom) {
|
||||||
lines = bottom - top -1;
|
lines = bottom - top -1;
|
||||||
@ -241,7 +241,7 @@ vncterm_scroll_down (vncTerm *vt, int top, int bottom, int lines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vncterm_scroll_up (vncTerm *vt, int top, int bottom, int lines, int moveattr)
|
spiceterm_scroll_up (spiceTerm *vt, int top, int bottom, int lines, int moveattr)
|
||||||
{
|
{
|
||||||
if ((top + lines) >= bottom) {
|
if ((top + lines) >= bottom) {
|
||||||
lines = bottom - top - 1;
|
lines = bottom - top - 1;
|
||||||
@ -286,7 +286,7 @@ vncterm_scroll_up (vncTerm *vt, int top, int bottom, int lines, int moveattr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vncterm_virtual_scroll (vncTerm *vt, int lines)
|
spiceterm_virtual_scroll (spiceTerm *vt, int lines)
|
||||||
{
|
{
|
||||||
if (vt->altbuf || lines == 0) return;
|
if (vt->altbuf || lines == 0) return;
|
||||||
|
|
||||||
@ -315,10 +315,10 @@ vncterm_virtual_scroll (vncTerm *vt, int lines)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vncterm_refresh (vt);
|
spiceterm_refresh (vt);
|
||||||
}
|
}
|
||||||
static void
|
static void
|
||||||
vncterm_respond_esc (vncTerm *vt, const char *esc)
|
spiceterm_respond_esc (spiceTerm *vt, const char *esc)
|
||||||
{
|
{
|
||||||
int len = strlen (esc);
|
int len = strlen (esc);
|
||||||
int i;
|
int i;
|
||||||
@ -332,17 +332,17 @@ vncterm_respond_esc (vncTerm *vt, const char *esc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vncterm_put_lf (vncTerm *vt)
|
spiceterm_put_lf (spiceTerm *vt)
|
||||||
{
|
{
|
||||||
if (vt->cy + 1 == vt->region_bottom) {
|
if (vt->cy + 1 == vt->region_bottom) {
|
||||||
|
|
||||||
if (vt->altbuf || vt->region_top != 0 || vt->region_bottom != vt->height) {
|
if (vt->altbuf || vt->region_top != 0 || vt->region_bottom != vt->height) {
|
||||||
vncterm_scroll_up (vt, vt->region_top, vt->region_bottom, 1, 1);
|
spiceterm_scroll_up (vt, vt->region_top, vt->region_bottom, 1, 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vt->y_displ == vt->y_base) {
|
if (vt->y_displ == vt->y_base) {
|
||||||
vncterm_scroll_up (vt, vt->region_top, vt->region_bottom, 1, 0);
|
spiceterm_scroll_up (vt, vt->region_top, vt->region_bottom, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vt->y_displ == vt->y_base) {
|
if (vt->y_displ == vt->y_base) {
|
||||||
@ -377,7 +377,7 @@ vncterm_put_lf (vncTerm *vt)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vncterm_csi_m (vncTerm *vt)
|
spiceterm_csi_m (spiceTerm *vt)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -475,7 +475,7 @@ vncterm_csi_m (vncTerm *vt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vncterm_save_cursor (vncTerm *vt)
|
spiceterm_save_cursor (spiceTerm *vt)
|
||||||
{
|
{
|
||||||
vt->cx_saved = vt->cx;
|
vt->cx_saved = vt->cx;
|
||||||
vt->cy_saved = vt->cy;
|
vt->cy_saved = vt->cy;
|
||||||
@ -487,7 +487,7 @@ vncterm_save_cursor (vncTerm *vt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vncterm_restore_cursor (vncTerm *vt)
|
spiceterm_restore_cursor (spiceTerm *vt)
|
||||||
{
|
{
|
||||||
vt->cx = vt->cx_saved;
|
vt->cx = vt->cx_saved;
|
||||||
vt->cy = vt->cy_saved;
|
vt->cy = vt->cy_saved;
|
||||||
@ -499,7 +499,7 @@ vncterm_restore_cursor (vncTerm *vt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vncterm_set_alternate_buffer (vncTerm *vt, int on_off)
|
spiceterm_set_alternate_buffer (spiceTerm *vt, int on_off)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
@ -513,7 +513,7 @@ vncterm_set_alternate_buffer (vncTerm *vt, int on_off)
|
|||||||
|
|
||||||
/* alternate buffer & cursor */
|
/* alternate buffer & cursor */
|
||||||
|
|
||||||
vncterm_save_cursor (vt);
|
spiceterm_save_cursor (vt);
|
||||||
/* save screen to altcels */
|
/* save screen to altcels */
|
||||||
for (y = 0; y < vt->height; y++) {
|
for (y = 0; y < vt->height; y++) {
|
||||||
int y1 = (vt->y_base + y) % vt->total_height;
|
int y1 = (vt->y_base + y) % vt->total_height;
|
||||||
@ -525,7 +525,7 @@ vncterm_set_alternate_buffer (vncTerm *vt, int on_off)
|
|||||||
/* clear screen */
|
/* clear screen */
|
||||||
for (y = 0; y <= vt->height; y++) {
|
for (y = 0; y <= vt->height; y++) {
|
||||||
for (x = 0; x < vt->width; x++) {
|
for (x = 0; x < vt->width; x++) {
|
||||||
vncterm_clear_xy (vt, x, y);
|
spiceterm_clear_xy (vt, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -543,14 +543,14 @@ vncterm_set_alternate_buffer (vncTerm *vt, int on_off)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vncterm_restore_cursor (vt);
|
spiceterm_restore_cursor (vt);
|
||||||
}
|
}
|
||||||
|
|
||||||
vncterm_refresh (vt);
|
spiceterm_refresh (vt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vncterm_set_mode (vncTerm *vt, int on_off)
|
spiceterm_set_mode (spiceTerm *vt, int on_off)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -562,7 +562,7 @@ vncterm_set_mode (vncTerm *vt, int on_off)
|
|||||||
vt->report_mouse = on_off;
|
vt->report_mouse = on_off;
|
||||||
break;
|
break;
|
||||||
case 1049: /* start/end special app mode (smcup/rmcup) */
|
case 1049: /* start/end special app mode (smcup/rmcup) */
|
||||||
vncterm_set_alternate_buffer (vt, on_off);
|
spiceterm_set_alternate_buffer (vt, on_off);
|
||||||
break;
|
break;
|
||||||
case 25: /* Cursor on/off */
|
case 25: /* Cursor on/off */
|
||||||
case 9: /* X10 mouse reporting on/off */
|
case 9: /* X10 mouse reporting on/off */
|
||||||
@ -580,7 +580,7 @@ vncterm_set_mode (vncTerm *vt, int on_off)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vncterm_gotoxy (vncTerm *vt, int x, int y)
|
spiceterm_gotoxy (spiceTerm *vt, int x, int y)
|
||||||
{
|
{
|
||||||
/* verify all boundaries */
|
/* verify all boundaries */
|
||||||
|
|
||||||
@ -610,7 +610,7 @@ enum { ESnormal, ESesc, ESsquare, ESgetpars, ESgotpars, ESfunckey,
|
|||||||
ESpalette, ESidquery, ESosc1, ESosc2};
|
ESpalette, ESidquery, ESosc1, ESosc2};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vncterm_putchar (vncTerm *vt, unicode ch)
|
spiceterm_putchar (spiceTerm *vt, unicode ch)
|
||||||
{
|
{
|
||||||
int x, y, i, c;
|
int x, y, i, c;
|
||||||
|
|
||||||
@ -633,10 +633,10 @@ vncterm_putchar (vncTerm *vt, unicode ch)
|
|||||||
vt->tty_state = ESpercent;
|
vt->tty_state = ESpercent;
|
||||||
break;
|
break;
|
||||||
case '7':
|
case '7':
|
||||||
vncterm_save_cursor (vt);
|
spiceterm_save_cursor (vt);
|
||||||
break;
|
break;
|
||||||
case '8':
|
case '8':
|
||||||
vncterm_restore_cursor (vt);
|
spiceterm_restore_cursor (vt);
|
||||||
break;
|
break;
|
||||||
case '(':
|
case '(':
|
||||||
vt->tty_state = ESsetG0; // SET G0
|
vt->tty_state = ESsetG0; // SET G0
|
||||||
@ -647,7 +647,7 @@ vncterm_putchar (vncTerm *vt, unicode ch)
|
|||||||
case 'M':
|
case 'M':
|
||||||
/* cursor up (ri) */
|
/* cursor up (ri) */
|
||||||
if (vt->cy == vt->region_top)
|
if (vt->cy == vt->region_top)
|
||||||
vncterm_scroll_down (vt, vt->region_top, vt->region_bottom, 1);
|
spiceterm_scroll_down (vt, vt->region_top, vt->region_bottom, 1);
|
||||||
else if (vt->cy > 0) {
|
else if (vt->cy > 0) {
|
||||||
vt->cy--;
|
vt->cy--;
|
||||||
}
|
}
|
||||||
@ -798,16 +798,16 @@ vncterm_putchar (vncTerm *vt, unicode ch)
|
|||||||
|
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'h':
|
case 'h':
|
||||||
vncterm_set_mode (vt, 1);
|
spiceterm_set_mode (vt, 1);
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
vncterm_set_mode (vt, 0);
|
spiceterm_set_mode (vt, 0);
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
if (!vt->esc_count) {
|
if (!vt->esc_count) {
|
||||||
vt->esc_count++; // default parameter 0
|
vt->esc_count++; // default parameter 0
|
||||||
}
|
}
|
||||||
vncterm_csi_m (vt);
|
spiceterm_csi_m (vt);
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
/* report cursor position */
|
/* report cursor position */
|
||||||
@ -858,16 +858,16 @@ vncterm_putchar (vncTerm *vt, unicode ch)
|
|||||||
case 'G':
|
case 'G':
|
||||||
case '`':
|
case '`':
|
||||||
/* move cursor to column */
|
/* move cursor to column */
|
||||||
vncterm_gotoxy (vt, vt->esc_buf[0] - 1, vt->cy);
|
spiceterm_gotoxy (vt, vt->esc_buf[0] - 1, vt->cy);
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
/* move cursor to row */
|
/* move cursor to row */
|
||||||
vncterm_gotoxy (vt, vt->cx , vt->esc_buf[0] - 1);
|
spiceterm_gotoxy (vt, vt->cx , vt->esc_buf[0] - 1);
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
case 'H':
|
case 'H':
|
||||||
/* move cursor to row, column */
|
/* move cursor to row, column */
|
||||||
vncterm_gotoxy (vt, vt->esc_buf[1] - 1, vt->esc_buf[0] - 1);
|
spiceterm_gotoxy (vt, vt->esc_buf[1] - 1, vt->esc_buf[0] - 1);
|
||||||
break;
|
break;
|
||||||
case 'J':
|
case 'J':
|
||||||
switch (vt->esc_buf[0]) {
|
switch (vt->esc_buf[0]) {
|
||||||
@ -878,7 +878,7 @@ vncterm_putchar (vncTerm *vt, unicode ch)
|
|||||||
if (y == vt->cy && x < vt->cx) {
|
if (y == vt->cy && x < vt->cx) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
vncterm_clear_xy (vt, x, y);
|
spiceterm_clear_xy (vt, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -889,7 +889,7 @@ vncterm_putchar (vncTerm *vt, unicode ch)
|
|||||||
if (y == vt->cy && x > vt->cx) {
|
if (y == vt->cy && x > vt->cx) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
vncterm_clear_xy (vt, x, y);
|
spiceterm_clear_xy (vt, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -897,7 +897,7 @@ vncterm_putchar (vncTerm *vt, unicode ch)
|
|||||||
/* clear entire screen */
|
/* clear entire screen */
|
||||||
for (y = 0; y <= vt->height; y++) {
|
for (y = 0; y <= vt->height; y++) {
|
||||||
for (x = 0; x < vt->width; x++) {
|
for (x = 0; x < vt->width; x++) {
|
||||||
vncterm_clear_xy (vt, x, y);
|
spiceterm_clear_xy (vt, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -908,19 +908,19 @@ vncterm_putchar (vncTerm *vt, unicode ch)
|
|||||||
case 0:
|
case 0:
|
||||||
/* clear to eol */
|
/* clear to eol */
|
||||||
for(x = vt->cx; x < vt->width; x++) {
|
for(x = vt->cx; x < vt->width; x++) {
|
||||||
vncterm_clear_xy (vt, x, vt->cy);
|
spiceterm_clear_xy (vt, x, vt->cy);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
/* clear from beginning of line */
|
/* clear from beginning of line */
|
||||||
for (x = 0; x <= vt->cx; x++) {
|
for (x = 0; x <= vt->cx; x++) {
|
||||||
vncterm_clear_xy (vt, x, vt->cy);
|
spiceterm_clear_xy (vt, x, vt->cy);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
/* clear entire line */
|
/* clear entire line */
|
||||||
for(x = 0; x < vt->width; x++) {
|
for(x = 0; x < vt->width; x++) {
|
||||||
vncterm_clear_xy (vt, x, vt->cy);
|
spiceterm_clear_xy (vt, x, vt->cy);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -934,7 +934,7 @@ vncterm_putchar (vncTerm *vt, unicode ch)
|
|||||||
else if (!c)
|
else if (!c)
|
||||||
c = 1;
|
c = 1;
|
||||||
|
|
||||||
vncterm_scroll_down (vt, vt->cy, vt->region_bottom, c);
|
spiceterm_scroll_down (vt, vt->cy, vt->region_bottom, c);
|
||||||
break;
|
break;
|
||||||
case 'M':
|
case 'M':
|
||||||
/* delete line */
|
/* delete line */
|
||||||
@ -945,19 +945,19 @@ vncterm_putchar (vncTerm *vt, unicode ch)
|
|||||||
else if (!c)
|
else if (!c)
|
||||||
c = 1;
|
c = 1;
|
||||||
|
|
||||||
vncterm_scroll_up (vt, vt->cy, vt->region_bottom, c, 1);
|
spiceterm_scroll_up (vt, vt->cy, vt->region_bottom, c, 1);
|
||||||
break;
|
break;
|
||||||
case 'T':
|
case 'T':
|
||||||
/* scroll down */
|
/* scroll down */
|
||||||
c = vt->esc_buf[0];
|
c = vt->esc_buf[0];
|
||||||
if (!c) c = 1;
|
if (!c) c = 1;
|
||||||
vncterm_scroll_down (vt, vt->region_top, vt->region_bottom, c);
|
spiceterm_scroll_down (vt, vt->region_top, vt->region_bottom, c);
|
||||||
break;
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
/* scroll up */
|
/* scroll up */
|
||||||
c = vt->esc_buf[0];
|
c = vt->esc_buf[0];
|
||||||
if (!c) c = 1;
|
if (!c) c = 1;
|
||||||
vncterm_scroll_up (vt, vt->region_top, vt->region_bottom, c, 1);
|
spiceterm_scroll_up (vt, vt->region_top, vt->region_bottom, c, 1);
|
||||||
break;
|
break;
|
||||||
case 'P':
|
case 'P':
|
||||||
/* delete c character */
|
/* delete c character */
|
||||||
@ -973,19 +973,19 @@ vncterm_putchar (vncTerm *vt, unicode ch)
|
|||||||
TextCell *dst = &vt->cells[y1 * vt->width + x];
|
TextCell *dst = &vt->cells[y1 * vt->width + x];
|
||||||
TextCell *src = dst + c;
|
TextCell *src = dst + c;
|
||||||
*dst = *src;
|
*dst = *src;
|
||||||
vncterm_update_xy (vt, x + c, vt->cy);
|
spiceterm_update_xy (vt, x + c, vt->cy);
|
||||||
src->ch = ' ';
|
src->ch = ' ';
|
||||||
src->attrib = vt->default_attrib;
|
src->attrib = vt->default_attrib;
|
||||||
vncterm_update_xy (vt, x, vt->cy);
|
spiceterm_update_xy (vt, x, vt->cy);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
/* save cursor position */
|
/* save cursor position */
|
||||||
vncterm_save_cursor (vt);
|
spiceterm_save_cursor (vt);
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
/* restore cursor position */
|
/* restore cursor position */
|
||||||
vncterm_restore_cursor (vt);
|
spiceterm_restore_cursor (vt);
|
||||||
break;
|
break;
|
||||||
case 'X':
|
case 'X':
|
||||||
/* erase c characters */
|
/* erase c characters */
|
||||||
@ -995,7 +995,7 @@ vncterm_putchar (vncTerm *vt, unicode ch)
|
|||||||
if (c > (vt->width - vt->cx)) c = vt->width - vt->cx;
|
if (c > (vt->width - vt->cx)) c = vt->width - vt->cx;
|
||||||
|
|
||||||
for(i = 0; i < c; i++) {
|
for(i = 0; i < c; i++) {
|
||||||
vncterm_clear_xy (vt, vt->cx + i, vt->cy);
|
spiceterm_clear_xy (vt, vt->cx + i, vt->cy);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '@':
|
case '@':
|
||||||
@ -1011,10 +1011,10 @@ vncterm_putchar (vncTerm *vt, unicode ch)
|
|||||||
TextCell *src = &vt->cells[y1 * vt->width + x];
|
TextCell *src = &vt->cells[y1 * vt->width + x];
|
||||||
TextCell *dst = src + c;
|
TextCell *dst = src + c;
|
||||||
*dst = *src;
|
*dst = *src;
|
||||||
vncterm_update_xy (vt, x + c, vt->cy);
|
spiceterm_update_xy (vt, x + c, vt->cy);
|
||||||
src->ch = ' ';
|
src->ch = ' ';
|
||||||
src->attrib = vt->cur_attrib;
|
src->attrib = vt->cur_attrib;
|
||||||
vncterm_update_xy (vt, x, vt->cy);
|
spiceterm_update_xy (vt, x, vt->cy);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -1095,7 +1095,7 @@ vncterm_putchar (vncTerm *vt, unicode ch)
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf (stderr, "ESC[>c Query term ID\n");
|
fprintf (stderr, "ESC[>c Query term ID\n");
|
||||||
#endif
|
#endif
|
||||||
vncterm_respond_esc (vt, TERMIDCODE);
|
spiceterm_respond_esc (vt, TERMIDCODE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ESpercent:
|
case ESpercent:
|
||||||
@ -1127,7 +1127,7 @@ vncterm_putchar (vncTerm *vt, unicode ch)
|
|||||||
case 9: /* tabspace */
|
case 9: /* tabspace */
|
||||||
if (vt->cx + (8 - (vt->cx % 8)) > vt->width) {
|
if (vt->cx + (8 - (vt->cx % 8)) > vt->width) {
|
||||||
vt->cx = 0;
|
vt->cx = 0;
|
||||||
vncterm_put_lf (vt);
|
spiceterm_put_lf (vt);
|
||||||
} else {
|
} else {
|
||||||
vt->cx = vt->cx + (8 - (vt->cx % 8));
|
vt->cx = vt->cx + (8 - (vt->cx % 8));
|
||||||
}
|
}
|
||||||
@ -1135,7 +1135,7 @@ vncterm_putchar (vncTerm *vt, unicode ch)
|
|||||||
case 10: /* LF,*/
|
case 10: /* LF,*/
|
||||||
case 11: /* VT */
|
case 11: /* VT */
|
||||||
case 12: /* FF */
|
case 12: /* FF */
|
||||||
vncterm_put_lf (vt);
|
spiceterm_put_lf (vt);
|
||||||
break;
|
break;
|
||||||
case 13: /* carriage return */
|
case 13: /* carriage return */
|
||||||
vt->cx = 0;
|
vt->cx = 0;
|
||||||
@ -1165,14 +1165,14 @@ vncterm_putchar (vncTerm *vt, unicode ch)
|
|||||||
if (vt->cx >= vt->width) {
|
if (vt->cx >= vt->width) {
|
||||||
/* line wrap */
|
/* line wrap */
|
||||||
vt->cx = 0;
|
vt->cx = 0;
|
||||||
vncterm_put_lf (vt);
|
spiceterm_put_lf (vt);
|
||||||
}
|
}
|
||||||
|
|
||||||
int y1 = (vt->y_base + vt->cy) % vt->total_height;
|
int y1 = (vt->y_base + vt->cy) % vt->total_height;
|
||||||
TextCell *c = &vt->cells[y1*vt->width + vt->cx];
|
TextCell *c = &vt->cells[y1*vt->width + vt->cx];
|
||||||
c->attrib = vt->cur_attrib;
|
c->attrib = vt->cur_attrib;
|
||||||
c->ch = ch;
|
c->ch = ch;
|
||||||
vncterm_update_xy (vt, vt->cx, vt->cy);
|
spiceterm_update_xy (vt, vt->cx, vt->cy);
|
||||||
vt->cx++;
|
vt->cx++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1181,11 +1181,11 @@ vncterm_putchar (vncTerm *vt, unicode ch)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
vncterm_puts (vncTerm *vt, const char *buf, int len)
|
spiceterm_puts (spiceTerm *vt, const char *buf, int len)
|
||||||
{
|
{
|
||||||
unicode tc;
|
unicode tc;
|
||||||
|
|
||||||
vncterm_show_cursor (vt, 0);
|
spiceterm_show_cursor (vt, 0);
|
||||||
|
|
||||||
while (len) {
|
while (len) {
|
||||||
unsigned char c = *buf;
|
unsigned char c = *buf;
|
||||||
@ -1245,19 +1245,19 @@ vncterm_puts (vncTerm *vt, const char *buf, int len)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vncterm_putchar (vt, tc);
|
spiceterm_putchar (vt, tc);
|
||||||
}
|
}
|
||||||
|
|
||||||
vncterm_show_cursor (vt, 1);
|
spiceterm_show_cursor (vt, 1);
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fixme:
|
/* fixme:
|
||||||
void
|
void
|
||||||
vncterm_set_xcut_text (char* str, int len, struct _rfbClientRec* cl)
|
spiceterm_set_xcut_text (char* str, int len, struct _rfbClientRec* cl)
|
||||||
{
|
{
|
||||||
vncTerm *vt =(vncTerm *)cl->screen->screenData;
|
spiceTerm *vt =(spiceTerm *)cl->screen->screenData;
|
||||||
|
|
||||||
// seems str is Latin-1 encoded
|
// seems str is Latin-1 encoded
|
||||||
if (vt->selection) free (vt->selection);
|
if (vt->selection) free (vt->selection);
|
||||||
@ -1271,19 +1271,19 @@ vncterm_set_xcut_text (char* str, int len, struct _rfbClientRec* cl)
|
|||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
static void
|
static void
|
||||||
mouse_report (vncTerm *vt, int butt, int mrx, int mry)
|
mouse_report (spiceTerm *vt, int butt, int mrx, int mry)
|
||||||
{
|
{
|
||||||
char buf[8];
|
char buf[8];
|
||||||
|
|
||||||
sprintf (buf, "[M%c%c%c", (char)(' ' + butt), (char)('!' + mrx),
|
sprintf (buf, "[M%c%c%c", (char)(' ' + butt), (char)('!' + mrx),
|
||||||
(char)('!' + mry));
|
(char)('!' + mry));
|
||||||
|
|
||||||
vncterm_respond_esc (vt, buf);
|
spiceterm_respond_esc (vt, buf);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
vncterm_toggle_marked_cell (vncTerm *vt, int pos)
|
spiceterm_toggle_marked_cell (spiceTerm *vt, int pos)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* fixme:
|
/* fixme:
|
||||||
@ -1307,10 +1307,10 @@ vncterm_toggle_marked_cell (vncTerm *vt, int pos)
|
|||||||
/* fixme:
|
/* fixme:
|
||||||
|
|
||||||
void
|
void
|
||||||
vncterm_pointer_event (int buttonMask, int x, int y, rfbClientPtr cl)
|
spiceterm_pointer_event (int buttonMask, int x, int y, rfbClientPtr cl)
|
||||||
{
|
{
|
||||||
|
|
||||||
vncTerm *vt =(vncTerm *)cl->screen->screenData;
|
spiceTerm *vt =(spiceTerm *)cl->screen->screenData;
|
||||||
static int button2_released = 1;
|
static int button2_released = 1;
|
||||||
static int last_mask = 0;
|
static int last_mask = 0;
|
||||||
static int sel_start_pos = 0;
|
static int sel_start_pos = 0;
|
||||||
@ -1355,7 +1355,7 @@ vncterm_pointer_event (int buttonMask, int x, int y, rfbClientPtr cl)
|
|||||||
}
|
}
|
||||||
if (vt->y_displ != vt->y_base) {
|
if (vt->y_displ != vt->y_base) {
|
||||||
vt->y_displ = vt->y_base;
|
vt->y_displ = vt->y_base;
|
||||||
vncterm_refresh (vt);
|
spiceterm_refresh (vt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
button2_released = 0;
|
button2_released = 0;
|
||||||
@ -1366,13 +1366,13 @@ vncterm_pointer_event (int buttonMask, int x, int y, rfbClientPtr cl)
|
|||||||
if (buttonMask & 1) {
|
if (buttonMask & 1) {
|
||||||
int pos = cy*vt->width + cx;
|
int pos = cy*vt->width + cx;
|
||||||
|
|
||||||
// code borrowed from libvncserver (VNConsole.c)
|
// code borrowed from libspiceserver (SPICEonsole.c)
|
||||||
|
|
||||||
if (!vt->mark_active) {
|
if (!vt->mark_active) {
|
||||||
|
|
||||||
vt->mark_active = 1;
|
vt->mark_active = 1;
|
||||||
sel_start_pos = sel_end_pos = pos;
|
sel_start_pos = sel_end_pos = pos;
|
||||||
vncterm_toggle_marked_cell (vt, pos);
|
spiceterm_toggle_marked_cell (vt, pos);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -1391,7 +1391,7 @@ vncterm_pointer_event (int buttonMask, int x, int y, rfbClientPtr cl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (cx <= cy) {
|
while (cx <= cy) {
|
||||||
vncterm_toggle_marked_cell (vt, cx);
|
spiceterm_toggle_marked_cell (vt, cx);
|
||||||
cx++;
|
cx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1429,7 +1429,7 @@ vncterm_pointer_event (int buttonMask, int x, int y, rfbClientPtr cl)
|
|||||||
free (sel_latin1);
|
free (sel_latin1);
|
||||||
|
|
||||||
while (sel_start_pos <= sel_end_pos) {
|
while (sel_start_pos <= sel_end_pos) {
|
||||||
vncterm_toggle_marked_cell (vt, sel_start_pos++);
|
spiceterm_toggle_marked_cell (vt, sel_start_pos++);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1441,7 +1441,7 @@ vncterm_pointer_event (int buttonMask, int x, int y, rfbClientPtr cl)
|
|||||||
|
|
||||||
static void my_kbd_push_key(SpiceKbdInstance *sin, uint8_t frag)
|
static void my_kbd_push_key(SpiceKbdInstance *sin, uint8_t frag)
|
||||||
{
|
{
|
||||||
// vncTerm *vt = SPICE_CONTAINEROF(sin, vncTerm, keyboard_sin);
|
// spiceTerm *vt = SPICE_CONTAINEROF(sin, spiceTerm, keyboard_sin);
|
||||||
|
|
||||||
/* we no not need this */
|
/* we no not need this */
|
||||||
|
|
||||||
@ -1450,7 +1450,7 @@ static void my_kbd_push_key(SpiceKbdInstance *sin, uint8_t frag)
|
|||||||
|
|
||||||
static void my_kbd_push_keyval(SpiceKbdInstance *sin, uint32_t keySym, int flags)
|
static void my_kbd_push_keyval(SpiceKbdInstance *sin, uint32_t keySym, int flags)
|
||||||
{
|
{
|
||||||
vncTerm *vt = SPICE_CONTAINEROF(sin, vncTerm, keyboard_sin);
|
spiceTerm *vt = SPICE_CONTAINEROF(sin, spiceTerm, keyboard_sin);
|
||||||
static int control = 0;
|
static int control = 0;
|
||||||
static int shift = 0;
|
static int shift = 0;
|
||||||
char *esc = NULL;
|
char *esc = NULL;
|
||||||
@ -1512,13 +1512,13 @@ static void my_kbd_push_keyval(SpiceKbdInstance *sin, uint32_t keySym, int flags
|
|||||||
esc = "OD";break;
|
esc = "OD";break;
|
||||||
case GDK_KEY_Page_Up:
|
case GDK_KEY_Page_Up:
|
||||||
if (shift) {
|
if (shift) {
|
||||||
vncterm_virtual_scroll (vt, -vt->height/2);
|
spiceterm_virtual_scroll (vt, -vt->height/2);
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
esc = "[5~";break;
|
esc = "[5~";break;
|
||||||
case GDK_KEY_Page_Down:
|
case GDK_KEY_Page_Down:
|
||||||
if (shift) {
|
if (shift) {
|
||||||
vncterm_virtual_scroll (vt, vt->height/2);
|
spiceterm_virtual_scroll (vt, vt->height/2);
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
esc = "[6~";break;
|
esc = "[6~";break;
|
||||||
@ -1560,11 +1560,11 @@ static void my_kbd_push_keyval(SpiceKbdInstance *sin, uint32_t keySym, int flags
|
|||||||
|
|
||||||
if (vt->y_displ != vt->y_base) {
|
if (vt->y_displ != vt->y_base) {
|
||||||
vt->y_displ = vt->y_base;
|
vt->y_displ = vt->y_base;
|
||||||
vncterm_refresh (vt);
|
spiceterm_refresh (vt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (esc) {
|
if (esc) {
|
||||||
vncterm_respond_esc(vt, esc);
|
spiceterm_respond_esc(vt, esc);
|
||||||
} else if (uc > 0) {
|
} else if (uc > 0) {
|
||||||
if (vt->utf8) {
|
if (vt->utf8) {
|
||||||
gchar buf[10];
|
gchar buf[10];
|
||||||
@ -1615,8 +1615,8 @@ static SpiceKbdInterface my_keyboard_sif = {
|
|||||||
.get_leds = my_kbd_get_leds,
|
.get_leds = my_kbd_get_leds,
|
||||||
};
|
};
|
||||||
|
|
||||||
vncTerm *
|
spiceTerm *
|
||||||
create_vncterm (int argc, char** argv, int maxx, int maxy)
|
create_spiceterm (int argc, char** argv, int maxx, int maxy)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -1628,7 +1628,7 @@ create_vncterm (int argc, char** argv, int maxx, int maxy)
|
|||||||
test_add_display_interface(test);
|
test_add_display_interface(test);
|
||||||
test_add_agent_interface(test->server);
|
test_add_agent_interface(test->server);
|
||||||
|
|
||||||
vncTerm *vt = (vncTerm *)calloc (sizeof(vncTerm), 1);
|
spiceTerm *vt = (spiceTerm *)calloc (sizeof(spiceTerm), 1);
|
||||||
|
|
||||||
vt->keyboard_sin.base.sif = &my_keyboard_sif.base;
|
vt->keyboard_sin.base.sif = &my_keyboard_sif.base;
|
||||||
spice_server_add_interface(test->server, &vt->keyboard_sin.base);
|
spice_server_add_interface(test->server, &vt->keyboard_sin.base);
|
||||||
@ -1645,13 +1645,13 @@ create_vncterm (int argc, char** argv, int maxx, int maxy)
|
|||||||
cmap->is16 = FALSE;
|
cmap->is16 = FALSE;
|
||||||
screen->serverFormat.trueColour = FALSE;
|
screen->serverFormat.trueColour = FALSE;
|
||||||
|
|
||||||
screen->kbdAddEvent = vncterm_kbd_event;
|
screen->kbdAddEvent = spiceterm_kbd_event;
|
||||||
|
|
||||||
screen->setXCutText = vncterm_set_xcut_text;
|
screen->setXCutText = spiceterm_set_xcut_text;
|
||||||
|
|
||||||
screen->ptrAddEvent = vncterm_pointer_event;
|
screen->ptrAddEvent = spiceterm_pointer_event;
|
||||||
|
|
||||||
screen->desktopName = "VNC Command Terminal";
|
screen->desktopName = "SPICE Command Terminal";
|
||||||
|
|
||||||
screen->newClientHook = new_client;
|
screen->newClientHook = new_client;
|
||||||
|
|
||||||
@ -1703,7 +1703,7 @@ create_vncterm (int argc, char** argv, int maxx, int maxy)
|
|||||||
|
|
||||||
static void master_watch(int master, int event, void *opaque)
|
static void master_watch(int master, int event, void *opaque)
|
||||||
{
|
{
|
||||||
vncTerm *vt = (vncTerm *)opaque;
|
spiceTerm *vt = (spiceTerm *)opaque;
|
||||||
|
|
||||||
printf("CHANNEL EVENT %d\n", event);
|
printf("CHANNEL EVENT %d\n", event);
|
||||||
|
|
||||||
@ -1718,7 +1718,7 @@ static void master_watch(int master, int event, void *opaque)
|
|||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
g_error("got read error"); // fixme
|
g_error("got read error"); // fixme
|
||||||
}
|
}
|
||||||
vncterm_puts (vt, buffer, c);
|
spiceterm_puts (vt, buffer, c);
|
||||||
} else {
|
} else {
|
||||||
if (vt->ibuf_count > 0) {
|
if (vt->ibuf_count > 0) {
|
||||||
printf ("DEBUG: WRITE %x %d\n", vt->ibuf[0], vt->ibuf_count);
|
printf ("DEBUG: WRITE %x %d\n", vt->ibuf[0], vt->ibuf_count);
|
||||||
@ -1754,7 +1754,7 @@ main (int argc, char** argv)
|
|||||||
|
|
||||||
if (0) print_usage(NULL); // fixme:
|
if (0) print_usage(NULL); // fixme:
|
||||||
|
|
||||||
vncTerm *vt = create_vncterm (argc, argv, 745, 400);
|
spiceTerm *vt = create_spiceterm (argc, argv, 745, 400);
|
||||||
|
|
||||||
setlocale(LC_ALL, ""); // set from environment
|
setlocale(LC_ALL, ""); // set from environment
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ typedef struct TextCell {
|
|||||||
TextAttributes attrib;
|
TextAttributes attrib;
|
||||||
} TextCell;
|
} TextCell;
|
||||||
|
|
||||||
typedef struct vncTerm {
|
typedef struct spiceTerm {
|
||||||
int maxx;
|
int maxx;
|
||||||
int maxy;
|
int maxy;
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ typedef struct vncTerm {
|
|||||||
|
|
||||||
unsigned int report_mouse:1;
|
unsigned int report_mouse:1;
|
||||||
|
|
||||||
} vncTerm;
|
} spiceTerm;
|
||||||
|
|
||||||
/* Unicode translations copied from kernel source consolemap.c */
|
/* Unicode translations copied from kernel source consolemap.c */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user