From cc6c5bbd8a277969b30b85dfab8a0fb11066bc9e Mon Sep 17 00:00:00 2001 From: james <> Date: Thu, 28 Feb 2008 15:37:06 +0000 Subject: *** empty log message *** --- src/cmd.c | 17 +++++++++++++---- src/prototypes.h | 3 ++- src/tty.c | 15 +++++++++++++++ 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/cmd.c b/src/cmd.c index 21a7909..a2cf7cd 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -10,6 +10,9 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.5 2008/02/28 15:37:06 james + * *** empty log message *** + * * Revision 1.4 2008/02/28 11:27:48 james * *** empty log message *** * @@ -27,7 +30,7 @@ static char rcsid[] = "$Id$"; #include "project.h" -void +int cmd_parse (Cmd * c, Context * ctx, char *buf) { if (!strcmp (buf, "quit")) @@ -52,8 +55,10 @@ cmd_parse (Cmd * c, Context * ctx, char *buf) 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++; + else return -1; + +return 0; + } @@ -78,14 +83,18 @@ cmd_key (Cmd * c, Context * ctx, int key) if (c->error) { c->error=0; + c->active=0; cmd_show_status (c, ctx); return 0; } if (key == 13) { - cmd_parse (c, ctx, c->buf + 1); + if (cmd_parse (c, ctx, c->buf + 1)) { + c->error++; + } else{ c->active = 0; + } cmd_show_status (c, ctx); return 0; } diff --git a/src/prototypes.h b/src/prototypes.h index 7d90a8e..07fd0df 100644 --- a/src/prototypes.h +++ b/src/prototypes.h @@ -65,6 +65,7 @@ extern void tty_set_baud(TTY *t, int rate); extern void tty_send_break(TTY *t); extern void tty_set_flow(TTY *t, int flow); extern void tty_hangup(TTY *t); +extern void tty_winch(TTY *t, CRT_Pos size); extern void tty_parse_reset(Context *c); extern void tty_analyse(Context *c); extern TTY_Parser *tty_parser_new(void); @@ -141,7 +142,7 @@ extern int socket_write(Socket *s, void *buf, int len); /* serial.c */ extern TTY *serial_open(char *path, int lock_mode); /* cmd.c */ -extern void cmd_parse(Cmd *c, Context *ctx, char *buf); +extern int cmd_parse(Cmd *c, Context *ctx, char *buf); extern void cmd_show_status(Cmd *c, Context *ctx); extern int cmd_key(Cmd *c, Context *ctx, int key); extern int cmd_activate(Cmd *c, Context *ctx); diff --git a/src/tty.c b/src/tty.c index e165dd5..6090af2 100644 --- a/src/tty.c +++ b/src/tty.c @@ -10,6 +10,9 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.17 2008/02/28 15:37:06 james + * *** empty log message *** + * * Revision 1.16 2008/02/28 12:12:25 james * *** empty log message *** * @@ -341,6 +344,18 @@ tty_hangup (TTY * t) } +void tty_winch(TTY * t,CRT_Pos size) +{ + struct winsize sz = { 0 }; + + sz.ws_col=size.x; + sz.ws_row=size.y; + + ioctl (t->wfd, TIOCGWINSZ, &sz); +} + + + #if 0 typedef struct { -- cgit v1.2.3