4 * Copyright (c) 2008 James McKenzie <sympathy@madingley.org>,
9 static char rcsid[] = "$Id: cmd.c,v 1.13 2008/03/07 13:16:02 james Exp $";
13 * Revision 1.13 2008/03/07 13:16:02 james
14 * *** empty log message ***
16 * Revision 1.12 2008/03/07 12:37:04 james
17 * *** empty log message ***
19 * Revision 1.11 2008/03/03 06:04:42 james
20 * *** empty log message ***
22 * Revision 1.10 2008/03/02 10:50:32 staffcvs
23 * *** empty log message ***
25 * Revision 1.9 2008/03/02 10:37:56 james
26 * *** empty log message ***
28 * Revision 1.8 2008/02/29 22:50:29 james
29 * *** empty log message ***
31 * Revision 1.7 2008/02/28 22:00:42 james
32 * *** empty log message ***
34 * Revision 1.6 2008/02/28 16:57:51 james
35 * *** empty log message ***
37 * Revision 1.5 2008/02/28 15:37:06 james
38 * *** empty log message ***
40 * Revision 1.4 2008/02/28 11:27:48 james
41 * *** empty log message ***
43 * Revision 1.3 2008/02/22 17:07:00 james
44 * *** empty log message ***
46 * Revision 1.2 2008/02/15 23:52:12 james
47 * *** empty log message ***
49 * Revision 1.1 2008/02/15 15:14:19 james
50 * *** empty log message ***
58 cmd_parse (Cmd * c, Context * ctx, ANSI * a, char *buf)
60 if (!strcmp (buf, "quit"))
62 else if (!strcmp (buf, "flow"))
63 ctx->k->set_flow (ctx->k, ctx, 1);
64 else if (!strcmp (buf, "noflow"))
65 ctx->k->set_flow (ctx->k, ctx, 0);
66 else if (!strcmp (buf, "ansi"))
67 ctx->k->set_ansi (ctx->k, ctx, 0);
68 else if (!strcmp (buf, "noansi"))
69 ctx->k->set_ansi (ctx->k, ctx, 1);
70 else if (!strncmp (buf, "baud", 4))
71 ctx->k->set_baud (ctx->k, ctx, atoi (buf + 4));
72 else if (!strcmp (buf, "break"))
73 ctx->k->send_break (ctx->k, ctx);
74 else if (!strcmp (buf, "hangup"))
75 ctx->k->hangup (ctx->k, ctx);
76 else if (!strcmp (buf, "reset"))
77 ctx->k->reset (ctx->k, ctx);
78 else if (!strcmp (buf, "expand")) {
79 int w = a->terminal->size.x;
80 int h = a->terminal->size.y - 1;
81 ctx->k->set_size (ctx->k, ctx, w, h);
82 } else if (!strncmp (buf, "width", 5))
83 ctx->k->set_size (ctx->k, ctx, atoi (buf + 5), 0);
84 else if (!strncmp (buf, "height", 6))
85 ctx->k->set_size (ctx->k, ctx, 0, atoi (buf + 6));
95 cmd_show_status (Cmd * c, Context * ctx)
101 vt102_status_line (ctx->v, "Command not recognized - press any key");
103 vt102_status_line (ctx->v, c->csl);
105 vt102_status_line (ctx->v, c->buf);
110 cmd_key (Cmd * c, Context * ctx, ANSI * a, int key)
116 cmd_show_status (c, ctx);
121 if (cmd_parse (c, ctx, a, c->buf + 1)) {
126 cmd_show_status (c, ctx);
130 if (((key == 8) || (key == 127)) && (c->ptr > 1)) {
135 if ((key >= 32) && (key < 127)) {
137 c->buf[c->ptr] = key;
143 cmd_show_status (c, ctx);
150 cmd_deactivate (Cmd * c, Context * ctx)
153 cmd_show_status (c, ctx);
158 cmd_activate (Cmd * c, Context * ctx)
165 cmd_show_status (c, ctx);
171 cmd_new_status (Cmd * c, Context * ctx, char *msg)
173 strcpy (c->csl, msg);
174 cmd_show_status (c, ctx);
184 ret = (Cmd *) xmalloc (sizeof (Cmd));