mirror of
git://git.proxmox.com/git/spiceterm.git
synced 2025-08-22 02:07:24 +00:00
fix coding style
This commit is contained in:
parent
7d75ff3d7c
commit
ea7edec46f
161
spiceterm.c
161
spiceterm.c
@ -87,7 +87,7 @@ print_usage(const char *msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
draw_char_at (spiceTerm *vt, int x, int y, gunichar2 ch, TextAttributes attrib)
|
draw_char_at(spiceTerm *vt, int x, int y, gunichar2 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;
|
||||||
@ -97,7 +97,7 @@ draw_char_at (spiceTerm *vt, int x, int y, gunichar2 ch, TextAttributes attrib)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
spiceterm_update_xy (spiceTerm *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; }
|
||||||
|
|
||||||
@ -108,12 +108,12 @@ spiceterm_update_xy (spiceTerm *vt, int x, int y)
|
|||||||
}
|
}
|
||||||
if (y2 < vt->height) {
|
if (y2 < vt->height) {
|
||||||
TextCell *c = &vt->cells[y1 * vt->width + x];
|
TextCell *c = &vt->cells[y1 * vt->width + x];
|
||||||
draw_char_at (vt, x, y2, c->ch, c->attrib);
|
draw_char_at(vt, x, y2, c->ch, c->attrib);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
spiceterm_clear_xy (spiceTerm *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; }
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ spiceterm_clear_xy (spiceTerm *vt, int x, int y)
|
|||||||
c->attrib.fgcol = vt->cur_attrib.fgcol;
|
c->attrib.fgcol = vt->cur_attrib.fgcol;
|
||||||
c->attrib.bgcol = vt->cur_attrib.bgcol;
|
c->attrib.bgcol = vt->cur_attrib.bgcol;
|
||||||
|
|
||||||
draw_char_at (vt, x, y, c->ch, c->attrib);
|
draw_char_at(vt, x, y, c->ch, c->attrib);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ spiceterm_toggle_marked_cell(spiceTerm *vt, int pos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
spiceterm_show_cursor (spiceTerm *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) {
|
||||||
@ -172,9 +172,9 @@ spiceterm_show_cursor (spiceTerm *vt, int show)
|
|||||||
if (show) {
|
if (show) {
|
||||||
TextAttributes attrib = vt->default_attrib;
|
TextAttributes attrib = vt->default_attrib;
|
||||||
attrib.invers = !(attrib.invers); /* invert fg and bg */
|
attrib.invers = !(attrib.invers); /* invert fg and bg */
|
||||||
draw_char_at (vt, x, y, c->ch, attrib);
|
draw_char_at(vt, x, y, c->ch, attrib);
|
||||||
} else {
|
} else {
|
||||||
draw_char_at (vt, x, y, c->ch, c->attrib);
|
draw_char_at(vt, x, y, c->ch, c->attrib);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -213,7 +213,7 @@ spiceterm_unselect_all(spiceTerm *vt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
spiceterm_scroll_down (spiceTerm *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;
|
||||||
@ -228,7 +228,7 @@ spiceterm_scroll_down (spiceTerm *vt, int top, int bottom, int lines)
|
|||||||
int src = ((vt->y_base + top + i) % vt->total_height)*vt->width;
|
int src = ((vt->y_base + top + i) % vt->total_height)*vt->width;
|
||||||
int dst = ((vt->y_base + top + lines + i) % vt->total_height)*vt->width;
|
int dst = ((vt->y_base + top + lines + i) % vt->total_height)*vt->width;
|
||||||
|
|
||||||
memmove(vt->cells + dst, vt->cells + src, vt->width*sizeof (TextCell));
|
memmove(vt->cells + dst, vt->cells + src, vt->width*sizeof(TextCell));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < lines; i++) {
|
for (i = 0; i < lines; i++) {
|
||||||
@ -251,7 +251,7 @@ spiceterm_scroll_down (spiceTerm *vt, int top, int bottom, int lines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
spiceterm_scroll_up (spiceTerm *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;
|
||||||
@ -281,7 +281,7 @@ spiceterm_scroll_up (spiceTerm *vt, int top, int bottom, int lines, int moveattr
|
|||||||
int dst = ((vt->y_base + top + i) % vt->total_height)*vt->width;
|
int dst = ((vt->y_base + top + i) % vt->total_height)*vt->width;
|
||||||
int src = ((vt->y_base + top + lines + i) % vt->total_height)*vt->width;
|
int src = ((vt->y_base + top + lines + i) % vt->total_height)*vt->width;
|
||||||
|
|
||||||
memmove(vt->cells + dst, vt->cells + src, vt->width*sizeof (TextCell));
|
memmove(vt->cells + dst, vt->cells + src, vt->width*sizeof(TextCell));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 1; i <= lines; i++) {
|
for (i = 1; i <= lines; i++) {
|
||||||
@ -296,7 +296,7 @@ spiceterm_scroll_up (spiceTerm *vt, int top, int bottom, int lines, int moveattr
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
spiceterm_virtual_scroll (spiceTerm *vt, int lines)
|
spiceterm_virtual_scroll(spiceTerm *vt, int lines)
|
||||||
{
|
{
|
||||||
if (vt->altbuf || lines == 0) return;
|
if (vt->altbuf || lines == 0) return;
|
||||||
|
|
||||||
@ -324,13 +324,13 @@ spiceterm_virtual_scroll (spiceTerm *vt, int lines)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spiceterm_refresh (vt);
|
spiceterm_refresh(vt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
spiceterm_respond_esc (spiceTerm *vt, const char *esc)
|
spiceterm_respond_esc(spiceTerm *vt, const char *esc)
|
||||||
{
|
{
|
||||||
int len = strlen (esc);
|
int len = strlen(esc);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (vt->ibuf_count < (IBUFSIZE - 1 - len)) {
|
if (vt->ibuf_count < (IBUFSIZE - 1 - len)) {
|
||||||
@ -342,17 +342,17 @@ spiceterm_respond_esc (spiceTerm *vt, const char *esc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
spiceterm_put_lf (spiceTerm *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) {
|
||||||
spiceterm_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) {
|
||||||
spiceterm_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) {
|
||||||
@ -386,7 +386,7 @@ spiceterm_put_lf (spiceTerm *vt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
spiceterm_csi_m (spiceTerm *vt)
|
spiceterm_csi_m(spiceTerm *vt)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -484,7 +484,7 @@ spiceterm_csi_m (spiceTerm *vt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
spiceterm_save_cursor (spiceTerm *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;
|
||||||
@ -496,7 +496,7 @@ spiceterm_save_cursor (spiceTerm *vt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
spiceterm_restore_cursor (spiceTerm *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;
|
||||||
@ -508,7 +508,7 @@ spiceterm_restore_cursor (spiceTerm *vt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
spiceterm_set_alternate_buffer (spiceTerm *vt, int on_off)
|
spiceterm_set_alternate_buffer(spiceTerm *vt, int on_off)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
@ -522,7 +522,7 @@ spiceterm_set_alternate_buffer (spiceTerm *vt, int on_off)
|
|||||||
|
|
||||||
/* alternate buffer & cursor */
|
/* alternate buffer & cursor */
|
||||||
|
|
||||||
spiceterm_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;
|
||||||
@ -534,7 +534,7 @@ spiceterm_set_alternate_buffer (spiceTerm *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++) {
|
||||||
spiceterm_clear_xy (vt, x, y);
|
spiceterm_clear_xy(vt, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -552,14 +552,14 @@ spiceterm_set_alternate_buffer (spiceTerm *vt, int on_off)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spiceterm_restore_cursor (vt);
|
spiceterm_restore_cursor(vt);
|
||||||
}
|
}
|
||||||
|
|
||||||
spiceterm_refresh (vt);
|
spiceterm_refresh(vt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
spiceterm_set_mode (spiceTerm *vt, int on_off)
|
spiceterm_set_mode(spiceTerm *vt, int on_off)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -592,7 +592,7 @@ spiceterm_set_mode (spiceTerm *vt, int on_off)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
spiceterm_gotoxy (spiceTerm *vt, int x, int y)
|
spiceterm_gotoxy(spiceTerm *vt, int x, int y)
|
||||||
{
|
{
|
||||||
/* verify all boundaries */
|
/* verify all boundaries */
|
||||||
|
|
||||||
@ -617,7 +617,7 @@ spiceterm_gotoxy (spiceTerm *vt, int x, int y)
|
|||||||
vt->cy = y;
|
vt->cy = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
debug_print_escape_buffer(spiceTerm *vt, const char *func, const char *prefix,
|
debug_print_escape_buffer(spiceTerm *vt, const char *func, const char *prefix,
|
||||||
const char *qes, gunichar2 ch)
|
const char *qes, gunichar2 ch)
|
||||||
{
|
{
|
||||||
@ -642,7 +642,7 @@ enum { ESnormal, ESesc, ESsquare, ESgetpars, ESgotpars, ESfunckey,
|
|||||||
ESpalette, ESidquery, ESosc1, ESosc2};
|
ESpalette, ESidquery, ESosc1, ESosc2};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
spiceterm_putchar (spiceTerm *vt, gunichar2 ch)
|
spiceterm_putchar(spiceTerm *vt, gunichar2 ch)
|
||||||
{
|
{
|
||||||
int x, y, i, c;
|
int x, y, i, c;
|
||||||
|
|
||||||
@ -665,10 +665,10 @@ spiceterm_putchar (spiceTerm *vt, gunichar2 ch)
|
|||||||
vt->tty_state = ESpercent;
|
vt->tty_state = ESpercent;
|
||||||
break;
|
break;
|
||||||
case '7':
|
case '7':
|
||||||
spiceterm_save_cursor (vt);
|
spiceterm_save_cursor(vt);
|
||||||
break;
|
break;
|
||||||
case '8':
|
case '8':
|
||||||
spiceterm_restore_cursor (vt);
|
spiceterm_restore_cursor(vt);
|
||||||
break;
|
break;
|
||||||
case '(':
|
case '(':
|
||||||
vt->tty_state = ESsetG0; // SET G0
|
vt->tty_state = ESsetG0; // SET G0
|
||||||
@ -679,7 +679,7 @@ spiceterm_putchar (spiceTerm *vt, gunichar2 ch)
|
|||||||
case 'M':
|
case 'M':
|
||||||
/* cursor up (ri) */
|
/* cursor up (ri) */
|
||||||
if (vt->cy == vt->region_top)
|
if (vt->cy == vt->region_top)
|
||||||
spiceterm_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--;
|
||||||
}
|
}
|
||||||
@ -821,7 +821,7 @@ spiceterm_putchar (spiceTerm *vt, gunichar2 ch)
|
|||||||
if (!vt->esc_count) {
|
if (!vt->esc_count) {
|
||||||
vt->esc_count++; // default parameter 0
|
vt->esc_count++; // default parameter 0
|
||||||
}
|
}
|
||||||
spiceterm_csi_m (vt);
|
spiceterm_csi_m(vt);
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
/* report cursor position */
|
/* report cursor position */
|
||||||
@ -872,16 +872,16 @@ spiceterm_putchar (spiceTerm *vt, gunichar2 ch)
|
|||||||
case 'G':
|
case 'G':
|
||||||
case '`':
|
case '`':
|
||||||
/* move cursor to column */
|
/* move cursor to column */
|
||||||
spiceterm_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 */
|
||||||
spiceterm_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 */
|
||||||
spiceterm_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]) {
|
||||||
@ -903,7 +903,7 @@ spiceterm_putchar (spiceTerm *vt, gunichar2 ch)
|
|||||||
if (y == vt->cy && x > vt->cx) {
|
if (y == vt->cy && x > vt->cx) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
spiceterm_clear_xy (vt, x, y);
|
spiceterm_clear_xy(vt, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -911,7 +911,7 @@ spiceterm_putchar (spiceTerm *vt, gunichar2 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++) {
|
||||||
spiceterm_clear_xy (vt, x, y);
|
spiceterm_clear_xy(vt, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -922,19 +922,19 @@ spiceterm_putchar (spiceTerm *vt, gunichar2 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++) {
|
||||||
spiceterm_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++) {
|
||||||
spiceterm_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++) {
|
||||||
spiceterm_clear_xy (vt, x, vt->cy);
|
spiceterm_clear_xy(vt, x, vt->cy);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -948,7 +948,7 @@ spiceterm_putchar (spiceTerm *vt, gunichar2 ch)
|
|||||||
else if (!c)
|
else if (!c)
|
||||||
c = 1;
|
c = 1;
|
||||||
|
|
||||||
spiceterm_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 */
|
||||||
@ -959,19 +959,19 @@ spiceterm_putchar (spiceTerm *vt, gunichar2 ch)
|
|||||||
else if (!c)
|
else if (!c)
|
||||||
c = 1;
|
c = 1;
|
||||||
|
|
||||||
spiceterm_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;
|
||||||
spiceterm_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;
|
||||||
spiceterm_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 */
|
||||||
@ -987,19 +987,19 @@ spiceterm_putchar (spiceTerm *vt, gunichar2 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;
|
||||||
spiceterm_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;
|
||||||
spiceterm_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 */
|
||||||
spiceterm_save_cursor (vt);
|
spiceterm_save_cursor(vt);
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
/* restore cursor position */
|
/* restore cursor position */
|
||||||
spiceterm_restore_cursor (vt);
|
spiceterm_restore_cursor(vt);
|
||||||
break;
|
break;
|
||||||
case 'X':
|
case 'X':
|
||||||
/* erase c characters */
|
/* erase c characters */
|
||||||
@ -1009,7 +1009,7 @@ spiceterm_putchar (spiceTerm *vt, gunichar2 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++) {
|
||||||
spiceterm_clear_xy (vt, vt->cx + i, vt->cy);
|
spiceterm_clear_xy(vt, vt->cx + i, vt->cy);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '@':
|
case '@':
|
||||||
@ -1028,7 +1028,7 @@ spiceterm_putchar (spiceTerm *vt, gunichar2 ch)
|
|||||||
spiceterm_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;
|
||||||
spiceterm_update_xy (vt, x, vt->cy);
|
spiceterm_update_xy(vt, x, vt->cy);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -1094,7 +1094,7 @@ spiceterm_putchar (spiceTerm *vt, gunichar2 ch)
|
|||||||
|
|
||||||
if (ch == 'c') {
|
if (ch == 'c') {
|
||||||
DPRINTF(1, "ESC[>c Query term ID");
|
DPRINTF(1, "ESC[>c Query term ID");
|
||||||
spiceterm_respond_esc (vt, TERMIDCODE);
|
spiceterm_respond_esc(vt, TERMIDCODE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ESpercent:
|
case ESpercent:
|
||||||
@ -1126,7 +1126,7 @@ spiceterm_putchar (spiceTerm *vt, gunichar2 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;
|
||||||
spiceterm_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));
|
||||||
}
|
}
|
||||||
@ -1134,7 +1134,7 @@ spiceterm_putchar (spiceTerm *vt, gunichar2 ch)
|
|||||||
case 10: /* LF,*/
|
case 10: /* LF,*/
|
||||||
case 11: /* VT */
|
case 11: /* VT */
|
||||||
case 12: /* FF */
|
case 12: /* FF */
|
||||||
spiceterm_put_lf (vt);
|
spiceterm_put_lf(vt);
|
||||||
break;
|
break;
|
||||||
case 13: /* carriage return */
|
case 13: /* carriage return */
|
||||||
vt->cx = 0;
|
vt->cx = 0;
|
||||||
@ -1164,14 +1164,14 @@ spiceterm_putchar (spiceTerm *vt, gunichar2 ch)
|
|||||||
if (vt->cx >= vt->width) {
|
if (vt->cx >= vt->width) {
|
||||||
/* line wrap */
|
/* line wrap */
|
||||||
vt->cx = 0;
|
vt->cx = 0;
|
||||||
spiceterm_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;
|
||||||
spiceterm_update_xy (vt, vt->cx, vt->cy);
|
spiceterm_update_xy(vt, vt->cx, vt->cy);
|
||||||
vt->cx++;
|
vt->cx++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1180,11 +1180,11 @@ spiceterm_putchar (spiceTerm *vt, gunichar2 ch)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
spiceterm_puts (spiceTerm *vt, const char *buf, int len)
|
spiceterm_puts(spiceTerm *vt, const char *buf, int len)
|
||||||
{
|
{
|
||||||
gunichar2 tc;
|
gunichar2 tc;
|
||||||
|
|
||||||
spiceterm_show_cursor (vt, 0);
|
spiceterm_show_cursor(vt, 0);
|
||||||
|
|
||||||
while (len) {
|
while (len) {
|
||||||
unsigned char c = *buf;
|
unsigned char c = *buf;
|
||||||
@ -1244,17 +1244,17 @@ spiceterm_puts (spiceTerm *vt, const char *buf, int len)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spiceterm_putchar (vt, tc);
|
spiceterm_putchar(vt, tc);
|
||||||
}
|
}
|
||||||
|
|
||||||
spiceterm_show_cursor (vt, 1);
|
spiceterm_show_cursor(vt, 1);
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fixme:
|
/* fixme:
|
||||||
void
|
void
|
||||||
spiceterm_set_xcut_text (char* str, int len, struct _rfbClientRec* cl)
|
spiceterm_set_xcut_text(char* str, int len, struct _rfbClientRec* cl)
|
||||||
{
|
{
|
||||||
spiceTerm *vt =(spiceTerm *)cl->screen->screenData;
|
spiceTerm *vt =(spiceTerm *)cl->screen->screenData;
|
||||||
|
|
||||||
@ -1288,7 +1288,7 @@ 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));
|
||||||
|
|
||||||
spiceterm_respond_esc(vt, buf);
|
spiceterm_respond_esc(vt, buf);
|
||||||
@ -1350,10 +1350,10 @@ spiceterm_motion_event(spiceTerm *vt, uint32_t x, uint32_t y, uint32_t buttons)
|
|||||||
mouse_report (vt, 1, cx, cy);
|
mouse_report (vt, 1, cx, cy);
|
||||||
}
|
}
|
||||||
if (buttons & 8) {
|
if (buttons & 8) {
|
||||||
mouse_report (vt, 2, cx, cy);
|
mouse_report(vt, 2, cx, cy);
|
||||||
}
|
}
|
||||||
if (!buttons) {
|
if(!buttons) {
|
||||||
mouse_report (vt, 3, cx, cy);
|
mouse_report(vt, 3, cx, cy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1390,7 +1390,6 @@ spiceterm_motion_event(spiceTerm *vt, uint32_t x, uint32_t y, uint32_t buttons)
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (pos != sel_end_pos) {
|
if (pos != sel_end_pos) {
|
||||||
|
|
||||||
if (pos > sel_end_pos) {
|
if (pos > sel_end_pos) {
|
||||||
cx = sel_end_pos; cy=pos;
|
cx = sel_end_pos; cy=pos;
|
||||||
} else {
|
} else {
|
||||||
@ -1443,7 +1442,7 @@ spiceterm_motion_event(spiceTerm *vt, uint32_t x, uint32_t y, uint32_t buttons)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
my_kbd_push_key(SpiceKbdInstance *sin, uint8_t frag)
|
my_kbd_push_key(SpiceKbdInstance *sin, uint8_t frag)
|
||||||
{
|
{
|
||||||
// spiceTerm *vt = SPICE_CONTAINEROF(sin, spiceTerm, keyboard_sin);
|
// spiceTerm *vt = SPICE_CONTAINEROF(sin, spiceTerm, keyboard_sin);
|
||||||
@ -1453,7 +1452,7 @@ my_kbd_push_key(SpiceKbdInstance *sin, uint8_t frag)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
my_kbd_push_keyval(SpiceKbdInstance *sin, uint32_t keySym, int flags)
|
my_kbd_push_keyval(SpiceKbdInstance *sin, uint32_t keySym, int flags)
|
||||||
{
|
{
|
||||||
spiceTerm *vt = SPICE_CONTAINEROF(sin, spiceTerm, keyboard_sin);
|
spiceTerm *vt = SPICE_CONTAINEROF(sin, spiceTerm, keyboard_sin);
|
||||||
@ -1587,7 +1586,7 @@ ret:
|
|||||||
spiceterm_update_watch_mask(vt, TRUE);
|
spiceterm_update_watch_mask(vt, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t
|
static uint8_t
|
||||||
my_kbd_get_leds(SpiceKbdInstance *sin)
|
my_kbd_get_leds(SpiceKbdInstance *sin)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
@ -1604,7 +1603,7 @@ static SpiceKbdInterface my_keyboard_sif = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* vdagent interface - to get mouse/clipboarde support */
|
/* vdagent interface - to get mouse/clipboarde support */
|
||||||
static int
|
static int
|
||||||
vmc_write(SpiceCharDeviceInstance *sin, const uint8_t *buf, int len)
|
vmc_write(SpiceCharDeviceInstance *sin, const uint8_t *buf, int len)
|
||||||
{
|
{
|
||||||
spiceTerm *vt = SPICE_CONTAINEROF(sin, spiceTerm, vdagent_sin);
|
spiceTerm *vt = SPICE_CONTAINEROF(sin, spiceTerm, vdagent_sin);
|
||||||
@ -1612,7 +1611,7 @@ vmc_write(SpiceCharDeviceInstance *sin, const uint8_t *buf, int len)
|
|||||||
VDIChunkHeader *hdr = (VDIChunkHeader *)buf;
|
VDIChunkHeader *hdr = (VDIChunkHeader *)buf;
|
||||||
VDAgentMessage *msg = (VDAgentMessage *)&hdr[1];
|
VDAgentMessage *msg = (VDAgentMessage *)&hdr[1];
|
||||||
|
|
||||||
//g_assert(hdr->port == VDP_SERVER_PORT);
|
//g_assert(hdr->port == VDP_SERVER_PORT);
|
||||||
g_assert(msg->protocol == VD_AGENT_PROTOCOL);
|
g_assert(msg->protocol == VD_AGENT_PROTOCOL);
|
||||||
|
|
||||||
DPRINTF(1, "%d %d %d %d", len, hdr->port, msg->protocol, msg->type);
|
DPRINTF(1, "%d %d %d %d", len, hdr->port, msg->protocol, msg->type);
|
||||||
@ -1631,7 +1630,7 @@ vmc_write(SpiceCharDeviceInstance *sin, const uint8_t *buf, int len)
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
vmc_read(SpiceCharDeviceInstance *sin, uint8_t *buf, int len)
|
vmc_read(SpiceCharDeviceInstance *sin, uint8_t *buf, int len)
|
||||||
{
|
{
|
||||||
DPRINTF(1, "%d", len);
|
DPRINTF(1, "%d", len);
|
||||||
@ -1639,7 +1638,7 @@ vmc_read(SpiceCharDeviceInstance *sin, uint8_t *buf, int len)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vmc_state(SpiceCharDeviceInstance *sin, int connected)
|
vmc_state(SpiceCharDeviceInstance *sin, int connected)
|
||||||
{
|
{
|
||||||
/* IGNORE */
|
/* IGNORE */
|
||||||
@ -1724,8 +1723,8 @@ create_spiceterm(int argc, char** argv, int maxx, int maxy, guint timeout)
|
|||||||
return vt;
|
return vt;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
master_error_callback(GIOChannel *channel, GIOCondition condition,
|
master_error_callback(GIOChannel *channel, GIOCondition condition,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
//spiceTerm *vt = (spiceTerm *)data;
|
//spiceTerm *vt = (spiceTerm *)data;
|
||||||
@ -1737,7 +1736,7 @@ master_error_callback(GIOChannel *channel, GIOCondition condition,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
master_watch(int master, int event, void *opaque)
|
master_watch(int master, int event, void *opaque)
|
||||||
{
|
{
|
||||||
spiceTerm *vt = (spiceTerm *)opaque;
|
spiceTerm *vt = (spiceTerm *)opaque;
|
||||||
@ -1759,11 +1758,11 @@ master_watch(int master, int event, void *opaque)
|
|||||||
DPRINTF(1, "write input %x %d", vt->ibuf[0], vt->ibuf_count);
|
DPRINTF(1, "write input %x %d", vt->ibuf[0], vt->ibuf_count);
|
||||||
if ((c = write (master, vt->ibuf, vt->ibuf_count)) >= 0) {
|
if ((c = write (master, vt->ibuf, vt->ibuf_count)) >= 0) {
|
||||||
if (c == vt->ibuf_count) {
|
if (c == vt->ibuf_count) {
|
||||||
vt->ibuf_count = 0;
|
vt->ibuf_count = 0;
|
||||||
} else if (c > 0) {
|
} else if (c > 0) {
|
||||||
// not all data written
|
// not all data written
|
||||||
memmove(vt->ibuf, vt->ibuf + c, vt->ibuf_count - c);
|
memmove(vt->ibuf, vt->ibuf + c, vt->ibuf_count - c);
|
||||||
vt->ibuf_count -= c;
|
vt->ibuf_count -= c;
|
||||||
} else {
|
} else {
|
||||||
// nothing written -ignore and try later
|
// nothing written -ignore and try later
|
||||||
}
|
}
|
||||||
@ -1846,7 +1845,7 @@ main (int argc, char** argv)
|
|||||||
g_io_channel_set_flags(channel, G_IO_FLAG_NONBLOCK, NULL);
|
g_io_channel_set_flags(channel, G_IO_FLAG_NONBLOCK, NULL);
|
||||||
g_io_channel_set_encoding(channel, NULL, NULL);
|
g_io_channel_set_encoding(channel, NULL, NULL);
|
||||||
g_io_add_watch(channel, G_IO_ERR|G_IO_HUP, master_error_callback, vt);
|
g_io_add_watch(channel, G_IO_ERR|G_IO_HUP, master_error_callback, vt);
|
||||||
|
|
||||||
vt->screen->mwatch = vt->screen->core->watch_add(
|
vt->screen->mwatch = vt->screen->core->watch_add(
|
||||||
master, SPICE_WATCH_EVENT_READ /* |SPICE_WATCH_EVENT_WRITE */,
|
master, SPICE_WATCH_EVENT_READ /* |SPICE_WATCH_EVENT_WRITE */,
|
||||||
master_watch, vt);
|
master_watch, vt);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user