X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcmd.c;h=aa1418635e8e2fc41776e194be3c00ee25a6e40a;hb=refs%2Fheads%2Fmaster;hp=7e86977a7e1c7a2e2d4e96305aa8b0c44124babf;hpb=3e72a1f6fc28777c26e4fb109867bd2a3c7b89b0;p=sympathy.git diff --git a/src/cmd.c b/src/cmd.c index 7e86977..aa14186 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1,15 +1,36 @@ -/* +/* * cmd.c: * - * Copyright (c) 2008 James McKenzie , + * Copyright (c) 2008 James McKenzie , * All rights reserved. * */ -static char rcsid[] = "$Id$"; +static char rcsid[] = "$Id: cmd.c,v 1.13 2008/03/07 13:16:02 james Exp $"; -/* - * $Log$ +/* + * $Log: cmd.c,v $ + * Revision 1.13 2008/03/07 13:16:02 james + * *** empty log message *** + * + * Revision 1.12 2008/03/07 12:37:04 james + * *** empty log message *** + * + * Revision 1.11 2008/03/03 06:04:42 james + * *** empty log message *** + * + * Revision 1.10 2008/03/02 10:50:32 staffcvs + * *** empty log message *** + * + * Revision 1.9 2008/03/02 10:37:56 james + * *** empty log message *** + * + * Revision 1.8 2008/02/29 22:50:29 james + * *** empty log message *** + * + * Revision 1.7 2008/02/28 22:00:42 james + * *** empty log message *** + * * Revision 1.6 2008/02/28 16:57:51 james * *** empty log message *** * @@ -34,7 +55,7 @@ static char rcsid[] = "$Id$"; int -cmd_parse (Cmd * c, Context * ctx, char *buf) +cmd_parse (Cmd * c, Context * ctx, ANSI * a, char *buf) { if (!strcmp (buf, "quit")) c->disconnect++; @@ -54,7 +75,11 @@ cmd_parse (Cmd * c, Context * ctx, char *buf) ctx->k->hangup (ctx->k, ctx); else if (!strcmp (buf, "reset")) ctx->k->reset (ctx->k, ctx); - else if (!strncmp (buf, "width", 5)) + else if (!strcmp (buf, "expand")) { + int w = a->terminal->size.x; + int h = a->terminal->size.y - 1; + ctx->k->set_size (ctx->k, ctx, w, h); + } 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)); @@ -82,45 +107,38 @@ cmd_show_status (Cmd * c, Context * ctx) } int -cmd_key (Cmd * c, Context * ctx, int key) +cmd_key (Cmd * c, Context * ctx, ANSI * a, int key) { - if (c->error) - { - c->error = 0; + if (c->error) { + c->error = 0; + c->active = 0; + cmd_show_status (c, ctx); + return 0; + } + + if (key == 13) { + if (cmd_parse (c, ctx, a, c->buf + 1)) { + c->error++; + } else { 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; } + cmd_show_status (c, ctx); + return 0; + } - if (((key == 8) || (key == 127)) && (c->ptr > 1)) - { - c->ptr--; - c->buf[c->ptr] = 0; - } + if (((key == 8) || (key == 127)) && (c->ptr > 1)) { + c->ptr--; + c->buf[c->ptr] = 0; + } - if ((key >= 32) && (key < 127)) - { + if ((key >= 32) && (key < 127)) { - c->buf[c->ptr] = key; - c->ptr++; - c->buf[c->ptr] = 0; + c->buf[c->ptr] = key; + c->ptr++; + c->buf[c->ptr] = 0; - } + } cmd_show_status (c, ctx); @@ -128,6 +146,14 @@ cmd_key (Cmd * c, Context * ctx, int key) } +int +cmd_deactivate (Cmd * c, Context * ctx) +{ + c->active = 0; + cmd_show_status (c, ctx); + return 0; +} + int cmd_activate (Cmd * c, Context * ctx) { @@ -155,9 +181,10 @@ cmd_new (void) { Cmd *ret; - ret = (Cmd *) malloc (sizeof (Cmd)); + ret = (Cmd *) xmalloc (sizeof (Cmd)); ret->disconnect = 0; ret->active = 0; + ret->error = 0; ret->csl[0] = 0; }