}
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) {
return;
}
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 (y2 < vt->height) {
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
-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; }
c->attrib.fgcol = vt->cur_attrib.fgcol;
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);
}
}
}
static void
-spiceterm_show_cursor (spiceTerm *vt, int show)
+spiceterm_show_cursor(spiceTerm *vt, int show)
{
int x = vt->cx;
if (x >= vt->width) {
if (show) {
TextAttributes attrib = vt->default_attrib;
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 {
- draw_char_at (vt, x, y, c->ch, c->attrib);
+ draw_char_at(vt, x, y, c->ch, c->attrib);
}
}
}
}
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) {
lines = bottom - top -1;
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;
- 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++) {
}
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) {
lines = bottom - top - 1;
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;
- 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++) {
}
static void
-spiceterm_virtual_scroll (spiceTerm *vt, int lines)
+spiceterm_virtual_scroll(spiceTerm *vt, int lines)
{
if (vt->altbuf || lines == 0) return;
}
}
- spiceterm_refresh (vt);
+ spiceterm_refresh(vt);
}
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;
if (vt->ibuf_count < (IBUFSIZE - 1 - len)) {
}
static void
-spiceterm_put_lf (spiceTerm *vt)
+spiceterm_put_lf(spiceTerm *vt)
{
if (vt->cy + 1 == vt->region_bottom) {
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;
}
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) {
}
static void
-spiceterm_csi_m (spiceTerm *vt)
+spiceterm_csi_m(spiceTerm *vt)
{
int i;
}
static void
-spiceterm_save_cursor (spiceTerm *vt)
+spiceterm_save_cursor(spiceTerm *vt)
{
vt->cx_saved = vt->cx;
vt->cy_saved = vt->cy;
}
static void
-spiceterm_restore_cursor (spiceTerm *vt)
+spiceterm_restore_cursor(spiceTerm *vt)
{
vt->cx = vt->cx_saved;
vt->cy = vt->cy_saved;
}
static void
-spiceterm_set_alternate_buffer (spiceTerm *vt, int on_off)
+spiceterm_set_alternate_buffer(spiceTerm *vt, int on_off)
{
int x, y;
/* alternate buffer & cursor */
- spiceterm_save_cursor (vt);
+ spiceterm_save_cursor(vt);
/* save screen to altcels */
for (y = 0; y < vt->height; y++) {
int y1 = (vt->y_base + y) % vt->total_height;
/* clear screen */
for (y = 0; y <= vt->height; y++) {
for (x = 0; x < vt->width; x++) {
- spiceterm_clear_xy (vt, x, y);
+ spiceterm_clear_xy(vt, x, y);
}
}
}
}
- spiceterm_restore_cursor (vt);
+ spiceterm_restore_cursor(vt);
}
- spiceterm_refresh (vt);
+ spiceterm_refresh(vt);
}
static void
-spiceterm_set_mode (spiceTerm *vt, int on_off)
+spiceterm_set_mode(spiceTerm *vt, int on_off)
{
int i;
}
static void
-spiceterm_gotoxy (spiceTerm *vt, int x, int y)
+spiceterm_gotoxy(spiceTerm *vt, int x, int y)
{
/* verify all boundaries */
vt->cy = y;
}
-static void
+static void
debug_print_escape_buffer(spiceTerm *vt, const char *func, const char *prefix,
const char *qes, gunichar2 ch)
{
ESpalette, ESidquery, ESosc1, ESosc2};
static void
-spiceterm_putchar (spiceTerm *vt, gunichar2 ch)
+spiceterm_putchar(spiceTerm *vt, gunichar2 ch)
{
int x, y, i, c;
vt->tty_state = ESpercent;
break;
case '7':
- spiceterm_save_cursor (vt);
+ spiceterm_save_cursor(vt);
break;
case '8':
- spiceterm_restore_cursor (vt);
+ spiceterm_restore_cursor(vt);
break;
case '(':
vt->tty_state = ESsetG0; // SET G0
case 'M':
/* cursor up (ri) */
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) {
vt->cy--;
}
if (!vt->esc_count) {
vt->esc_count++; // default parameter 0
}
- spiceterm_csi_m (vt);
+ spiceterm_csi_m(vt);
break;
case 'n':
/* report cursor position */
case 'G':
case '`':
/* 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;
case 'd':
/* 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;
case 'f':
case 'H':
/* 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;
case 'J':
switch (vt->esc_buf[0]) {
if (y == vt->cy && x > vt->cx) {
break;
}
- spiceterm_clear_xy (vt, x, y);
+ spiceterm_clear_xy(vt, x, y);
}
}
break;
/* clear entire screen */
for (y = 0; y <= vt->height; y++) {
for (x = 0; x < vt->width; x++) {
- spiceterm_clear_xy (vt, x, y);
+ spiceterm_clear_xy(vt, x, y);
}
}
break;
case 0:
/* clear to eol */
for(x = vt->cx; x < vt->width; x++) {
- spiceterm_clear_xy (vt, x, vt->cy);
+ spiceterm_clear_xy(vt, x, vt->cy);
}
break;
case 1:
/* clear from beginning of line */
for (x = 0; x <= vt->cx; x++) {
- spiceterm_clear_xy (vt, x, vt->cy);
+ spiceterm_clear_xy(vt, x, vt->cy);
}
break;
case 2:
/* clear entire line */
for(x = 0; x < vt->width; x++) {
- spiceterm_clear_xy (vt, x, vt->cy);
+ spiceterm_clear_xy(vt, x, vt->cy);
}
break;
}
else if (!c)
c = 1;
- spiceterm_scroll_down (vt, vt->cy, vt->region_bottom, c);
+ spiceterm_scroll_down(vt, vt->cy, vt->region_bottom, c);
break;
case 'M':
/* delete line */
else if (!c)
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;
case 'T':
/* scroll down */
c = vt->esc_buf[0];
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;
case 'S':
/* scroll up */
c = vt->esc_buf[0];
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;
case 'P':
/* delete c character */
TextCell *dst = &vt->cells[y1 * vt->width + x];
TextCell *src = dst + c;
*dst = *src;
- spiceterm_update_xy (vt, x + c, vt->cy);
+ spiceterm_update_xy(vt, x + c, vt->cy);
src->ch = ' ';
src->attrib = vt->default_attrib;
- spiceterm_update_xy (vt, x, vt->cy);
+ spiceterm_update_xy(vt, x, vt->cy);
}
break;
case 's':
/* save cursor position */
- spiceterm_save_cursor (vt);
+ spiceterm_save_cursor(vt);
break;
case 'u':
/* restore cursor position */
- spiceterm_restore_cursor (vt);
+ spiceterm_restore_cursor(vt);
break;
case 'X':
/* erase c characters */
if (c > (vt->width - vt->cx)) c = vt->width - vt->cx;
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;
case '@':
spiceterm_update_xy (vt, x + c, vt->cy);
src->ch = ' ';
src->attrib = vt->cur_attrib;
- spiceterm_update_xy (vt, x, vt->cy);
+ spiceterm_update_xy(vt, x, vt->cy);
}
break;
if (ch == 'c') {
DPRINTF(1, "ESC[>c Query term ID");
- spiceterm_respond_esc (vt, TERMIDCODE);
+ spiceterm_respond_esc(vt, TERMIDCODE);
}
break;
case ESpercent:
case 9: /* tabspace */
if (vt->cx + (8 - (vt->cx % 8)) > vt->width) {
vt->cx = 0;
- spiceterm_put_lf (vt);
+ spiceterm_put_lf(vt);
} else {
vt->cx = vt->cx + (8 - (vt->cx % 8));
}
case 10: /* LF,*/
case 11: /* VT */
case 12: /* FF */
- spiceterm_put_lf (vt);
+ spiceterm_put_lf(vt);
break;
case 13: /* carriage return */
vt->cx = 0;
if (vt->cx >= vt->width) {
/* line wrap */
vt->cx = 0;
- spiceterm_put_lf (vt);
+ spiceterm_put_lf(vt);
}
int y1 = (vt->y_base + vt->cy) % vt->total_height;
TextCell *c = &vt->cells[y1*vt->width + vt->cx];
c->attrib = vt->cur_attrib;
c->ch = ch;
- spiceterm_update_xy (vt, vt->cx, vt->cy);
+ spiceterm_update_xy(vt, vt->cx, vt->cy);
vt->cx++;
break;
}
}
static int
-spiceterm_puts (spiceTerm *vt, const char *buf, int len)
+spiceterm_puts(spiceTerm *vt, const char *buf, int len)
{
gunichar2 tc;
- spiceterm_show_cursor (vt, 0);
+ spiceterm_show_cursor(vt, 0);
while (len) {
unsigned char c = *buf;
}
}
- spiceterm_putchar (vt, tc);
+ spiceterm_putchar(vt, tc);
}
- spiceterm_show_cursor (vt, 1);
+ spiceterm_show_cursor(vt, 1);
return len;
}
/* fixme:
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;
{
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));
spiceterm_respond_esc(vt, buf);
mouse_report (vt, 1, cx, cy);
}
if (buttons & 8) {
- mouse_report (vt, 2, cx, cy);
+ mouse_report(vt, 2, cx, cy);
}
- if (!buttons) {
- mouse_report (vt, 3, cx, cy);
+ if(!buttons) {
+ mouse_report(vt, 3, cx, cy);
}
}
} else {
if (pos != sel_end_pos) {
-
if (pos > sel_end_pos) {
cx = sel_end_pos; cy=pos;
} else {
}
}
-static void
+static void
my_kbd_push_key(SpiceKbdInstance *sin, uint8_t frag)
{
// spiceTerm *vt = SPICE_CONTAINEROF(sin, spiceTerm, keyboard_sin);
return;
}
-static void
+static void
my_kbd_push_keyval(SpiceKbdInstance *sin, uint32_t keySym, int flags)
{
spiceTerm *vt = SPICE_CONTAINEROF(sin, spiceTerm, keyboard_sin);
spiceterm_update_watch_mask(vt, TRUE);
}
-static uint8_t
+static uint8_t
my_kbd_get_leds(SpiceKbdInstance *sin)
{
return 0;
};
/* vdagent interface - to get mouse/clipboarde support */
-static int
+static int
vmc_write(SpiceCharDeviceInstance *sin, const uint8_t *buf, int len)
{
spiceTerm *vt = SPICE_CONTAINEROF(sin, spiceTerm, vdagent_sin);
VDIChunkHeader *hdr = (VDIChunkHeader *)buf;
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);
DPRINTF(1, "%d %d %d %d", len, hdr->port, msg->protocol, msg->type);
return len;
}
-static int
+static int
vmc_read(SpiceCharDeviceInstance *sin, uint8_t *buf, int len)
{
DPRINTF(1, "%d", len);
return 0;
}
-static void
+static void
vmc_state(SpiceCharDeviceInstance *sin, int connected)
{
/* IGNORE */
return vt;
}
-static gboolean
-master_error_callback(GIOChannel *channel, GIOCondition condition,
+static gboolean
+master_error_callback(GIOChannel *channel, GIOCondition condition,
gpointer data)
{
//spiceTerm *vt = (spiceTerm *)data;
return FALSE;
}
-static void
+static void
master_watch(int master, int event, void *opaque)
{
spiceTerm *vt = (spiceTerm *)opaque;
DPRINTF(1, "write input %x %d", vt->ibuf[0], vt->ibuf_count);
if ((c = write (master, vt->ibuf, vt->ibuf_count)) >= 0) {
if (c == vt->ibuf_count) {
- vt->ibuf_count = 0;
+ vt->ibuf_count = 0;
} else if (c > 0) {
// not all data written
memmove(vt->ibuf, vt->ibuf + c, vt->ibuf_count - c);
- vt->ibuf_count -= c;
+ vt->ibuf_count -= c;
} else {
// nothing written -ignore and try later
}
g_io_channel_set_flags(channel, G_IO_FLAG_NONBLOCK, NULL);
g_io_channel_set_encoding(channel, NULL, NULL);
g_io_add_watch(channel, G_IO_ERR|G_IO_HUP, master_error_callback, vt);
-
+
vt->screen->mwatch = vt->screen->core->watch_add(
master, SPICE_WATCH_EVENT_READ /* |SPICE_WATCH_EVENT_WRITE */,
master_watch, vt);