/*
* $Log$
+ * Revision 1.18 2008/02/28 11:27:48 james
+ * *** empty log message ***
+ *
* Revision 1.17 2008/02/27 09:42:53 james
* *** empty log message ***
*
}
+ vt102_reset(&c);
+
+
if (server_socket)
{
if (client_socket)
/*
* $Log$
+ * Revision 1.4 2008/02/28 11:27:48 james
+ * *** empty log message ***
+ *
* Revision 1.3 2008/02/22 17:07:00 james
* *** empty log message ***
*
{
if (!strcmp (buf, "quit"))
c->disconnect++;
-
- if (!strcmp (buf, "flow"))
+ else if (!strcmp (buf, "flow"))
ctx->k->set_flow (ctx->k, ctx, 1);
- if (!strcmp (buf, "noflow"))
+ else if (!strcmp (buf, "noflow"))
ctx->k->set_flow (ctx->k, ctx, 0);
- if (!strcmp (buf, "ansi"))
+ else if (!strcmp (buf, "ansi"))
ctx->k->set_ansi (ctx->k, ctx, 0);
- if (!strcmp (buf, "noansi"))
+ else if (!strcmp (buf, "noansi"))
ctx->k->set_ansi (ctx->k, ctx, 1);
- if (!strncmp (buf, "baud", 4))
+ else if (!strncmp (buf, "baud", 4))
ctx->k->set_baud (ctx->k, ctx, atoi (buf + 4));
- if (!strncmp (buf, "break", 4))
+ else if (!strcmp (buf, "break"))
ctx->k->send_break (ctx->k, ctx);
- if (!strncmp (buf, "hangup", 4))
+ else if (!strcmp (buf, "hangup"))
ctx->k->hangup (ctx->k, ctx);
+ else if (!strcmp (buf, "reset"))
+ ctx->k->reset (ctx->k, ctx);
+ else if (!strncmp (buf, "width", 5))
+ ctx->k->set_size (ctx->k, ctx,atoi(buf+5),0);
+ else if (!strncmp (buf, "height", 6))
+ ctx->k->set_size (ctx->k, ctx,0,atoi(buf+6));
+ else
+ c->error++;
}
if (!ctx->v)
return;
- if (!c->active)
+ if (c->error)
+ vt102_status_line (ctx->v, "Command not recognized - press any key");
+ else if (!c->active)
vt102_status_line (ctx->v, c->csl);
else
vt102_status_line (ctx->v, c->buf);
-
}
int
cmd_key (Cmd * c, Context * ctx, int key)
{
+ if (c->error) {
+ c->error=0;
+ cmd_show_status (c, ctx);
+ return 0;
+ }
+
if (key == 13)
{
cmd_parse (c, ctx, c->buf + 1);
/*
* $Log$
+ * Revision 1.3 2008/02/28 11:27:48 james
+ * *** empty log message ***
+ *
* Revision 1.2 2008/02/23 11:48:37 james
* *** empty log message ***
*
typedef struct
{
int active;
+ int error;
int disconnect;
char csl[128];
char buf[128];
/*
* $Log$
+ * Revision 1.5 2008/02/28 11:27:48 james
+ * *** empty log message ***
+ *
* Revision 1.4 2008/02/22 17:07:00 james
* *** empty log message ***
*
m.type = IPC_MSG_TYPE_HANGUP;
return ipc_msg_send (s, (IPC_Msg *) & m);
}
+
+int
+ipc_msg_send_setsize (Socket * s,CRT_Pos size)
+{
+ IPC_Msg_setsize m;
+
+ m.size = sizeof (m);
+ m.type = IPC_MSG_TYPE_SETSIZE;
+ m.winsize=size;
+
+ return ipc_msg_send (s, (IPC_Msg *) & m);
+}
+
+int
+ipc_msg_send_reset (Socket * s)
+{
+ IPC_Msg_reset m;
+
+ m.size = sizeof (m);
+ m.type = IPC_MSG_TYPE_RESET;
+ return ipc_msg_send (s, (IPC_Msg *) & m);
+}
/*
* $Log$
+ * Revision 1.6 2008/02/28 11:27:48 james
+ * *** empty log message ***
+ *
* Revision 1.5 2008/02/23 11:48:37 james
* *** empty log message ***
*
#define IPC_MSG_TYPE_SETFLOW 9
#define IPC_MSG_TYPE_SETANSI 10
#define IPC_MSG_TYPE_HANGUP 11
+#define IPC_MSG_TYPE_SETSIZE 12
+#define IPC_MSG_TYPE_RESET 13
typedef struct
{
} IPC_Msg_hangup;
+typedef struct
+{
+ int32_t size;
+ int32_t type;
+ CRT_Pos winsize;
+} IPC_Msg_setsize;
+
+
+typedef struct
+{
+ int32_t size;
+ int32_t type;
+} IPC_Msg_reset;
+
+
typedef union
{
IPC_Msg_setflow setflow;
IPC_Msg_setansi setansi;
IPC_Msg_hangup hangup;
+ IPC_Msg_setsize setsize;
+ IPC_Msg_reset reset;
} IPC_Msg;
/*
* $Log$
+ * Revision 1.6 2008/02/28 11:27:48 james
+ * *** empty log message ***
+ *
* Revision 1.5 2008/02/23 11:48:37 james
* *** empty log message ***
*
int (*send_break)(struct KeyDis_struct *,struct Context_struct *); \
int (*set_flow)(struct KeyDis_struct *,struct Context_struct *,int flow); \
int (*set_ansi)(struct KeyDis_struct *,struct Context_struct *,int ansi); \
- int (*hangup)(struct KeyDis_struct *,struct Context_struct *)
+ int (*hangup)(struct KeyDis_struct *,struct Context_struct *); \
+ int (*reset)(struct KeyDis_struct *,struct Context_struct *); \
+ int (*set_size)(struct KeyDis_struct *,struct Context_struct *,int width, int height)
/* vt102.c */
extern int vt102_cmd_length[128];
extern int vt102_cmd_termination[128];
+extern void vt102_do_resize(Context *c);
extern void vt102_log_line(Context *c, int line);
extern void vt102_history(Context *c, CRT_Pos t, CRT_Pos b);
extern void vt102_clip_cursor(VT102 *v, CRT_Pos tl, CRT_Pos br);
extern int vt102_cursor_relative(VT102 *v, int x, int y);
extern void vt102_delete_from_line(VT102 *v, CRT_Pos p);
extern void vt102_insert_into_line(VT102 *v, CRT_Pos p);
-extern void vt102_change_mode(VT102 *v, int private, char *ns, int set);
-extern void vt102_parse_mode_string(VT102 *v, char *buf, int len);
+extern void vt102_change_mode(Context *c, int private, char *ns, int set);
+extern void vt102_parse_mode_string(Context *c, char *buf, int len);
extern void vt102_change_attr(VT102 *v, char *na);
extern void vt102_parse_attr_string(VT102 *v, char *buf, int len);
extern void vt102_save_state(VT102 *v);
extern void vt102_parse_esc(Context *c);
extern void vt102_status_line(VT102 *v, char *str);
extern void vt102_parser_reset(VT102_parser *p);
-extern void vt102_reset_state(VT102 *v);
+extern void vt102_reset_state(Context *c);
extern void vt102_parse_char(Context *c, int ch);
extern void vt102_send(Context *c, uint8_t key);
-extern void vt102_reset(VT102 *v);
+extern void vt102_reset(Context *c);
extern VT102 *vt102_new(CRT_Pos *size);
extern void vt102_set_ansi(VT102 *v, int ansi);
+extern void vt102_resize(Context *c, CRT_Pos size);
extern void vt102_free(VT102 *v);
/* tty.c */
extern void tty_pre_select(TTY *t, fd_set *rfds, fd_set *wfds);
extern int ipc_msg_send_setflow(Socket *s, int flow);
extern int ipc_msg_send_setansi(Socket *s, int ansi);
extern int ipc_msg_send_hangup(Socket *s);
+extern int ipc_msg_send_setsize(Socket *s, CRT_Pos size);
+extern int ipc_msg_send_reset(Socket *s);
/* slide.c */
extern void slide_free(Slide *s);
extern void slide_consume(Slide *s, int n);
/*
* $Log$
+ * Revision 1.49 2008/02/28 11:27:48 james
+ * *** empty log message ***
+ *
+ * Revision 1.48 2008/02/27 09:42:53 james
+ * *** empty log message ***
+ *
* Revision 1.47 2008/02/27 09:42:22 james
* *** empty log message ***
*
return 1;
}
+void vt102_do_resize(Context *c)
+{
+
+VT102 *v=c->v;
+
+ v->crt.size = v->current_size;
+ v->crt.size.y++;
+ v->screen_end = v->current_size;
+ v->screen_end.x--;
+ v->screen_end.y--;
+ v->top_margin = v->screen_start;
+ v->bottom_margin = v->screen_end;
+ vt102_cursor_home (v);
+ crt_cls (&v->crt);
+
+ if (c->t)
+ tty_winch(c->t,v->current_size);
+}
+
+
void
vt102_log_line (Context * c, int line)
{
void
-vt102_change_mode (VT102 * v, int private, char *ns, int set)
+vt102_change_mode (Context *c, int private, char *ns, int set)
{
+ VT102 *v=c->v;
int m;
private_modes[VT102_PRIVATE_MODE_132COLS] ? VT102_COLS_132 :
VT102_COLS_80;
- v->crt.size = v->current_size;
- v->crt.size.y++;
- v->screen_end=v->current_size;
- v->screen_end.x--;
- v->screen_end.y--;
- v->top_margin = v->screen_start;
- v->bottom_margin = v->screen_end;
- vt102_cursor_home (v);
- crt_cls (&v->crt);
-
-
+ vt102_do_resize(c);
break;
}
}
void
-vt102_parse_mode_string (VT102 * v, char *buf, int len)
+vt102_parse_mode_string (Context *c, char *buf, int len)
{
+ VT102 *v=c->v;
int private = 0;
char last = buf[len - 1];
char num[4];
{
if (*buf == ';')
{
- vt102_change_mode (v, private, &num[o], last == 'h');
+ vt102_change_mode (c, private, &num[o], last == 'h');
memset (num, 0, sizeof (num));
o = sizeof (num) - 1;
buf++;
buf++;
}
- vt102_change_mode (v, private, &num[o], last == 'h');
+ vt102_change_mode (c, private, &num[o], last == 'h');
}
break;
case 'h':
case 'l':
- vt102_parse_mode_string (v, &buf[1], len - 1);
+ vt102_parse_mode_string (c, &buf[1], len - 1);
break;
vt102_send_id (c, terminal_id);
break;
case 'c':
- vt102_reset (v);
-
-
+ vt102_reset (c);
break;
case '=':
v->application_keypad_mode = 1;
void
-vt102_reset_state (VT102 * v)
+vt102_reset_state (Context *c)
{
+ VT102 *v=c->v;
vt102_parser_reset (&v->parser);
v->attr = CRT_ATTR_NORMAL;
v->application_keypad_mode = 0;
- v->current_size=v->original_size;
- v->crt.size = v->current_size;
- v->crt.size.y++;
- v->screen_end = v->current_size;
- v->screen_end.x--;
- v->screen_end.y--;
+ v->current_size = v->original_size;
- v->top_margin = v->screen_start;
- v->bottom_margin = v->screen_end;
+ vt102_do_resize(c);
memset (v->modes, 0, VT102_NMODES);
memset (v->private_modes, 0, VT102_NMODES);
#endif
if (ch == SYM_CHAR_RESET)
{
- vt102_reset_state (v);
+ vt102_reset_state (c);
}
else if (p->in_cmd && !ctrl_chr (ch, p->cmd_termination))
{
}
void
-vt102_reset (VT102 * v)
+vt102_reset (Context * c)
{
+ VT102 *v=c->v;
VT102_parser *p = &v->parser;
v->screen_start.x = 0;
v->screen_start.y = 0;
- v->current_size=v->original_size;
- v->crt.size=v->current_size;
- v->crt.size.y++;
- v->screen_end=v->current_size;
+ v->current_size = v->original_size;
+ v->crt.size = v->current_size;
+ v->crt.size.y++;
+ v->screen_end = v->current_size;
v->screen_end.x--;
v->screen_end.y--;
v->current_line = v->pos;
vt102_parser_reset (p);
- vt102_reset_state (v);
+ vt102_reset_state (c);
vt102_save_state (v);
}
VT102 *
-vt102_new (CRT_Pos *size)
+vt102_new (CRT_Pos * size)
{
VT102 *v;
v->xn_glitch = 1;
-
- if (size) {
+
+ if (size)
+ {
v->original_size = *size;
- if (v->original_size.x<1) v->original_size.x=1;
- if (v->original_size.y<1) v->original_size.y=1;
+ if (v->original_size.x < 1)
+ v->original_size.x = 1;
+ if (v->original_size.y < 1)
+ v->original_size.y = 1;
- if (v->original_size.x>VT102_MAX_COLS) v->original_size.x=VT102_MAX_COLS;
- if (v->original_size.y>VT102_ROWS) v->original_size.y=VT102_ROWS;
+ if (v->original_size.x > VT102_MAX_COLS)
+ v->original_size.x = VT102_MAX_COLS;
+ if (v->original_size.y > VT102_ROWS)
+ v->original_size.y = VT102_ROWS;
- } else {
- v->original_size.x=VT102_COLS_80;
- v->original_size.y=VT102_ROWS;
}
-
- vt102_reset (v);
+ else
+ {
+ v->original_size.x = VT102_COLS_80;
+ v->original_size.y = VT102_ROWS;
+ }
return v;
}
v->xn_glitch = ansi ? 0 : 1;
}
+void vt102_resize(Context *c,CRT_Pos size)
+{
+
+
+ if (size.x < 1)
+ size.x = 1;
+ if (size.y < 1)
+ size.y = 1;
+
+ if (size.x > VT102_MAX_COLS)
+ size.x = VT102_MAX_COLS;
+ if (size.y > VT102_ROWS)
+ size.y = VT102_ROWS;
+
+ c->v->current_size=size;
+ vt102_do_resize(c);
+}
+
void
vt102_free (VT102 * v)
{
.B hangup
de-assert DTR for one second.
.TP 7
+.B width \fInn\fB
+set the current width of the screen to \fInn\fP, and reset the terminal emulator.
+.TP 7
+.B height \fInn\fB
+set the current height of the screen to \fInn\fP, and reset the terminal emulator.
+.TP 7
+.B reset
+reset the terminal emulator
+.TP 7
.B quit
exit this instance of sympathy (disconnect from the server if present)
.SH CHARACTER ENCODINGS
.SH BUGS
.PD
.IP \(bu 3
-the command line editor and parser should support better line editing and report failed commands
+The command editor and parser should support better line editing.
.IP \(bu 3
-when the \-\fBc\fP \-\fBs\fP major mode is used without the \-\fBk\fP option the pid
+It should be possible to change the escape character.
+.IP \(bu 3
+When the \-\fBc\fP \-\fBs\fP major mode is used without the \-\fBk\fP option the pid
used in the socket is that of the client process and therefore not unique.
.IP \(bu 3
-the HTML generated with the \-\fBH\fP option is ugly.
+The HTML generated with the \-\fBH\fP option is ugly.
.IP \(bu 3
-no useful error message is generated if opening the terminal device fails in the
+No useful error message is generated if opening the terminal device fails in the
\-\fBc\fP \-\fBs\fP major mode.
.IP \(bu 3
-no facility is made for rotation of the log files.
-.SH AUTHOR
-James McKenzie, james@fishsoup.dhs.org
+No facility is made for rotation of the log files.
.SH AUTHOR
James McKenzie, james@fishsoup.dhs.org