X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcmd.c;h=7e86977a7e1c7a2e2d4e96305aa8b0c44124babf;hb=3e72a1f6fc28777c26e4fb109867bd2a3c7b89b0;hp=6017ccb488b051f0068597dee371bb59d3869a6d;hpb=ecb64606aef408784023c0f6a1d9373d4e28f86e;p=sympathy.git diff --git a/src/cmd.c b/src/cmd.c index 6017ccb..7e86977 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -10,6 +10,21 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.6 2008/02/28 16:57:51 james + * *** empty log message *** + * + * 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 *** + * + * Revision 1.3 2008/02/22 17:07:00 james + * *** empty log message *** + * + * Revision 1.2 2008/02/15 23:52:12 james + * *** empty log message *** + * * Revision 1.1 2008/02/15 15:14:19 james * *** empty log message *** * @@ -18,20 +33,36 @@ static char rcsid[] = "$Id$"; #include "project.h" -void +int cmd_parse (Cmd * c, Context * ctx, char *buf) { 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 (!strncmp (buf, "baud", 4)) + else if (!strcmp (buf, "ansi")) + ctx->k->set_ansi (ctx->k, ctx, 0); + else if (!strcmp (buf, "noansi")) + ctx->k->set_ansi (ctx->k, ctx, 1); + 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); + 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 + return -1; + + return 0; + } @@ -41,26 +72,41 @@ cmd_show_status (Cmd * c, Context * ctx) 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 (key == 13) + if (c->error) { - cmd_parse (c, ctx, c->buf + 1); + c->error = 0; c->active = 0; cmd_show_status (c, ctx); return 0; } + if (key == 13) + { + if (cmd_parse (c, ctx, c->buf + 1)) + { + c->error++; + } + else + { + c->active = 0; + } + cmd_show_status (c, ctx); + return 0; + } + if (((key == 8) || (key == 127)) && (c->ptr > 1)) { c->ptr--;