chiark / gitweb /
*** empty log message ***
authorjames <james>
Thu, 28 Feb 2008 11:27:48 +0000 (11:27 +0000)
committerjames <james>
Thu, 28 Feb 2008 11:27:48 +0000 (11:27 +0000)
apps/mainloop.c
src/cmd.c
src/cmd.h
src/ipc.c
src/ipc.h
src/keydis.h
src/prototypes.h
src/vt102.c
sympathy.1

index e9c299cd4d8d620fd3d2ed20af2d2be1cf92e88a..4a3fdcafa44836b8417ff16f0bb49b21cfcfc504 100644 (file)
@@ -11,6 +11,9 @@ static char rcsid[] =
 
 /*
  * $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 ***
  *
@@ -444,6 +447,9 @@ mainloop (TTY * tty, Socket * server_socket, Socket * client_socket,
     }
 
 
+   vt102_reset(&c);
+
+
   if (server_socket)
     {
       if (client_socket)
index 7105c5b1a28bf920c9c4046194e55bea767bff8e..21a7909ff23bbaa7fd77a442c3e912ee7483157e 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $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 ***
  *
@@ -29,21 +32,28 @@ 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 (!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++;
 
 }
 
@@ -53,18 +63,25 @@ 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 (c->error) {
+       c->error=0;
+        cmd_show_status (c, ctx);
+       return 0;
+  }
+
   if (key == 13)
     {
       cmd_parse (c, ctx, c->buf + 1);
index 43a1bbfd3988f220c6674ddbe092f1b50a2681b1..15ce41ecd50ddd1736e6b0385a62bfa9f56da4b0 100644 (file)
--- a/src/cmd.h
+++ b/src/cmd.h
@@ -12,6 +12,9 @@
 
 /*
  * $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 ***
  *
@@ -28,6 +31,7 @@
 typedef struct
 {
   int active;
+  int error;
   int disconnect;
   char csl[128];
   char buf[128];
index 8809f362bf42d1e57da1a3c7cc68524d0901514d..480281009348db52a7007068f9b2719b6d5e4d86 100644 (file)
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $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 ***
  *
@@ -215,3 +218,25 @@ ipc_msg_send_hangup (Socket * s)
   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);
+}
index 91589edd4ce0834359b1932df330807f834775fb..aed692e34197d8e26396a63d65b281a179baa695 100644 (file)
--- a/src/ipc.h
+++ b/src/ipc.h
@@ -12,6 +12,9 @@
 
 /*
  * $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 ***
  *
@@ -46,6 +49,8 @@
 #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
 {
@@ -146,6 +151,21 @@ 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
 {
@@ -162,6 +182,8 @@ typedef union
   IPC_Msg_setflow setflow;
   IPC_Msg_setansi setansi;
   IPC_Msg_hangup hangup;
+  IPC_Msg_setsize setsize;
+  IPC_Msg_reset reset;
 } IPC_Msg;
 
 
index 21a73f8952bfb27066774f480d855556061c025d..ad0de798894ce907c3a0339d06b926c5515f9247 100644 (file)
@@ -12,6 +12,9 @@
 
 /*
  * $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 ***
  *
@@ -45,7 +48,9 @@ struct Context_struct;
        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)
 
 
 
index d1de9a9e839fa4cb954a23531de8f4a86354f910..7d90a8ebfaa7c21bc65ad10907326a4c06093503 100644 (file)
@@ -17,6 +17,7 @@ extern char *libsympathy_version(void);
 /* 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);
@@ -35,8 +36,8 @@ extern int vt102_cursor_absolute(VT102 *v, int x, int y);
 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);
@@ -48,12 +49,13 @@ extern void vt102_parse_csi(Context *c, char *buf, int len);
 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);
@@ -116,6 +118,8 @@ extern int ipc_msg_send_sendbreak(Socket *s);
 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);
index 1940dcf513de86d1dde690e0753636f6d715631f..f1e00e8ae8d6211c450e08da548d461fc5035035 100644 (file)
@@ -10,6 +10,12 @@ static char rcsid[] = "$Id$";
 
 /*
  * $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 ***
  *
@@ -391,6 +397,26 @@ in_margins (VT102 * v, CRT_Pos p)
   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)
 {
@@ -699,8 +725,9 @@ vt102_insert_into_line (VT102 * v, CRT_Pos p)
 
 
 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;
 
 
@@ -742,17 +769,7 @@ vt102_change_mode (VT102 * v, int private, char *ns, int set)
             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;
         }
 
@@ -766,8 +783,9 @@ vt102_change_mode (VT102 * v, int private, char *ns, int set)
 }
 
 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];
@@ -792,7 +810,7 @@ vt102_parse_mode_string (VT102 * v, char *buf, int len)
     {
       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++;
@@ -809,7 +827,7 @@ vt102_parse_mode_string (VT102 * v, char *buf, int len)
       buf++;
     }
 
-  vt102_change_mode (v, private, &num[o], last == 'h');
+  vt102_change_mode (c, private, &num[o], last == 'h');
 
 }
 
@@ -1278,7 +1296,7 @@ vt102_parse_csi (Context * c, char *buf, int len)
           break;
         case 'h':
         case 'l':
-          vt102_parse_mode_string (v, &buf[1], len - 1);
+          vt102_parse_mode_string (c, &buf[1], len - 1);
           break;
 
 
@@ -1474,9 +1492,7 @@ vt102_parse_esc (Context * c)
       vt102_send_id (c, terminal_id);
       break;
     case 'c':
-      vt102_reset (v);
-
-
+      vt102_reset (c);
       break;
     case '=':
       v->application_keypad_mode = 1;
@@ -1586,8 +1602,9 @@ vt102_parser_reset (VT102_parser * p)
 
 
 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;
@@ -1595,15 +1612,9 @@ vt102_reset_state (VT102 * v)
 
   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);
@@ -1676,7 +1687,7 @@ vt102_parse_char (Context * c, int ch)
 #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))
     {
@@ -2003,8 +2014,9 @@ vt102_send (Context * c, uint8_t key)
 }
 
 void
-vt102_reset (VT102 * v)
+vt102_reset (Context * c)
 {
+  VT102 *v=c->v;
   VT102_parser *p = &v->parser;
 
 
@@ -2014,10 +2026,10 @@ vt102_reset (VT102 * v)
 
   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--;
 
@@ -2028,7 +2040,7 @@ vt102_reset (VT102 * v)
   v->current_line = v->pos;
 
   vt102_parser_reset (p);
-  vt102_reset_state (v);
+  vt102_reset_state (c);
 
   vt102_save_state (v);
 
@@ -2036,7 +2048,7 @@ vt102_reset (VT102 * v)
 }
 
 VT102 *
-vt102_new (CRT_Pos *size)
+vt102_new (CRT_Pos * size)
 {
   VT102 *v;
 
@@ -2044,22 +2056,27 @@ vt102_new (CRT_Pos *size)
 
   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;
 }
@@ -2070,6 +2087,24 @@ vt102_set_ansi (VT102 * v, int ansi)
   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)
 {
index 2ec7ea3d3601b521e62715586fc61bf36b31968c..0fbbac211fa821b9d93f0d7683c421a3a0a9bb9d 100644 (file)
@@ -336,6 +336,15 @@ disable RTS/CTS flow control
 .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
@@ -491,18 +500,18 @@ ANSI X3.64, ISO-6429, ECMA-48, ISO-2202, ISO-8859, ISO-10646, Digital Equipment
 .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