chiark / gitweb /
*** empty log message ***
authorjames <james>
Wed, 27 Feb 2008 01:31:14 +0000 (01:31 +0000)
committerjames <james>
Wed, 27 Feb 2008 01:31:14 +0000 (01:31 +0000)
apps/mainloop.c
apps/sympathy.c
apps/usage.c
src/ptty.c
src/vt102.c

index 3f1c28dbfec8e1c3897776105b419c52bdd06504..07290e1a4125207adad489a9caf08df37ba2aed0 100644 (file)
@@ -11,6 +11,9 @@ static char rcsid[] =
 
 /*
  * $Log$
 
 /*
  * $Log$
+ * Revision 1.14  2008/02/27 01:31:14  james
+ * *** empty log message ***
+ *
  * Revision 1.13  2008/02/26 23:56:12  james
  * *** empty log message ***
  *
  * Revision 1.13  2008/02/26 23:56:12  james
  * *** empty log message ***
  *
@@ -391,7 +394,7 @@ msg_from_server (ANSI * a, IPC_Msg * m, Context * c)
 
 void
 mainloop (TTY * tty, Socket * server_socket, Socket * client_socket,
 
 void
 mainloop (TTY * tty, Socket * server_socket, Socket * client_socket,
-          ANSI * ansi, Log * log, int nhistory)
+          ANSI * ansi, Log * log, int nhistory,int width)
 {
   fd_set rfds, wfds;
   Context c = { 0 };
 {
   fd_set rfds, wfds;
   Context c = { 0 };
@@ -402,7 +405,7 @@ mainloop (TTY * tty, Socket * server_socket, Socket * client_socket,
   c.tp = tty_parser_new ();
   c.u = utf8_new ();
 
   c.tp = tty_parser_new ();
   c.u = utf8_new ();
 
-  c.v = vt102_new ();
+  c.v = vt102_new (width);
   c.h = history_new (nhistory);
   c.l = log;
   /* are we being fed by a tty or a socket */
   c.h = history_new (nhistory);
   c.l = log;
   /* are we being fed by a tty or a socket */
index b92dbe473978040f6f541615ff6a567c5ba758ed..4a9f18aa743dde3730367fec0e2a33f2116c72fb 100644 (file)
@@ -11,6 +11,12 @@ static char rcsid[] =
 
 /*
  * $Log$
 
 /*
  * $Log$
+ * Revision 1.15  2008/02/27 01:31:14  james
+ * *** empty log message ***
+ *
+ * Revision 1.14  2008/02/24 00:43:55  james
+ * *** empty log message ***
+ *
  * Revision 1.13  2008/02/24 00:42:53  james
  * *** empty log message ***
  *
  * Revision 1.13  2008/02/24 00:42:53  james
  * *** empty log message ***
  *
@@ -236,6 +242,7 @@ main (int argc, char *argv[])
   int c;
   extern char *optarg;
   extern int optind, opterr, optopt;
   int c;
   extern char *optarg;
   extern int optind, opterr, optopt;
+  int width=VT102_COLS_80;
 
   int oflags[128];
   char *oargs[128];
 
   int oflags[128];
   char *oargs[128];
@@ -252,16 +259,7 @@ main (int argc, char *argv[])
 
   memset (oflags, 0, sizeof (oflags));
   memset (oargs, 0, sizeof (oargs));
 
   memset (oflags, 0, sizeof (oflags));
   memset (oargs, 0, sizeof (oargs));
-#if 0
-  "sympathy -t      [-K] [-d serialdev|-p] [-b baud] [-f] [-L log]\n"
-    "sympathy -s      [-K] [-d serialdev|-p] [-b baud] [-f] [-L log] [-F] [-k skt]\n"
-    "                      [-n hlines]\n"
-    "sympathy [-s -c] [-K] [-d serialdev|-p] [-b baud] [-f] [-L log] [-k skt]\n"
-    "                      [-n hlines]\n"
-    "sympathy -c      [-H] -k skt\n"
-    "sympathy -r id   [-H]\n" "sympathy {-l|-ls}\n"
-#endif
-    while ((c = getopt (argc, argv, "utscr:lKHd:pb:fL:Fk:n:")) != EOF)
+    while ((c = getopt (argc, argv, "w:utscr:lKHd:pb:fL:Fk:n:")) != EOF)
     {
       switch (c)
         {
     {
       switch (c)
         {
@@ -394,6 +392,7 @@ main (int argc, char *argv[])
           oflags['f'] = 0;
           oflags['L'] = 0;
           oflags['n'] = 0;
           oflags['f'] = 0;
           oflags['L'] = 0;
           oflags['n'] = 0;
+         oflags['w'] = 0;        
           if (server_socket)
             {
               socket_free_parent (server_socket);
           if (server_socket)
             {
               socket_free_parent (server_socket);
@@ -402,6 +401,7 @@ main (int argc, char *argv[])
         }
     }
 
         }
     }
 
+
   if (oflags['c'] && !oflags['k'])
     fatal_moan ("-c requires a socket to be specified with -s or -k");
 
   if (oflags['c'] && !oflags['k'])
     fatal_moan ("-c requires a socket to be specified with -s or -k");
 
@@ -415,6 +415,12 @@ main (int argc, char *argv[])
         oflags['p']++;
     }
 
         oflags['p']++;
     }
 
+  if (oflags['w']) {
+       width=safe_atoi(oargs['w']);
+       if ((width>VT102_MAX_COLS) || (width<1)) 
+               fatal_moan("-w requires a width between 1 and %d\n",VT102_MAX_COLS);
+  }
+
   if (oflags['s'] && !oflags['F'])
     {
       daemon (1, 0);            /*incase socket is relative path, unlink then will fail */
   if (oflags['s'] && !oflags['F'])
     {
       daemon (1, 0);            /*incase socket is relative path, unlink then will fail */
@@ -433,7 +439,7 @@ main (int argc, char *argv[])
 
       if (oflags['p'])
         {
 
       if (oflags['p'])
         {
-          tty = ptty_open (NULL, NULL);
+          tty = ptty_open (NULL, NULL, width);
           if (!tty)
             fatal_moan ("unable to open a ptty");
         }
           if (!tty)
             fatal_moan ("unable to open a ptty");
         }
@@ -483,12 +489,14 @@ main (int argc, char *argv[])
       else
         {
           terminal_register_handlers ();
       else
         {
           terminal_register_handlers ();
-          ansi = ansi_new_from_terminal (terminal_open (0, 1),oflags['u'] ? 0:1);
+          ansi =
+            ansi_new_from_terminal (terminal_open (0, 1),
+                                    oflags['u'] ? 0 : 1);
           ansi->reset (ansi, NULL);
         }
     }
 
           ansi->reset (ansi, NULL);
         }
     }
 
-  mainloop (tty, server_socket, client_socket, ansi, log, history);
+  mainloop (tty, server_socket, client_socket, ansi, log, history,width);
 
   if (ansi)
     {
 
   if (ansi)
     {
index 114f81d4bd4cbeea7029da2c12d0de8ed591380a..62061fd3dcdf059f2b1eeac6b7d6bf987c7b3902 100644 (file)
@@ -10,6 +10,12 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
 
 /*
  * $Log$
+ * Revision 1.10  2008/02/27 01:31:14  james
+ * *** empty log message ***
+ *
+ * Revision 1.9  2008/02/24 00:43:55  james
+ * *** empty log message ***
+ *
  * Revision 1.8  2008/02/24 00:42:53  james
  * *** empty log message ***
  *
  * Revision 1.8  2008/02/24 00:42:53  james
  * *** empty log message ***
  *
@@ -45,10 +51,10 @@ usage (void)
 
   fprintf (stderr, "Usage:\n"
            "sympathy -t      [-K] [-d serialdev|-p] [-b baud] [-f] [-L log] [-u]\n"
 
   fprintf (stderr, "Usage:\n"
            "sympathy -t      [-K] [-d serialdev|-p] [-b baud] [-f] [-L log] [-u]\n"
-           "sympathy -s      [-K] [-d serialdev|-p] [-b baud] [-f] [-L log] [-u] [-F]\n"
-          "                      [-k skt] [-n hlines]\n"
+           "sympathy -s      [-K] [-d serialdev|-p] [-b baud] [-f] [-L log] [-u] [-k skt]\n"
+           "                      [-n hlines] [-w width] [-F]\n"
            "sympathy [-s -c] [-K] [-d serialdev|-p] [-b baud] [-f] [-L log] [-u] [-k skt]\n"
            "sympathy [-s -c] [-K] [-d serialdev|-p] [-b baud] [-f] [-L log] [-u] [-k skt]\n"
-           "                      [-n hlines]\n"
+           "                      [-n hlines] [-w width]\n"
            "sympathy -c      [-H] [-u] -k skt\n"
            "sympathy -r id   [-H] [-u]\n"
            "sympathy {-l|-ls}\n"
            "sympathy -c      [-H] [-u] -k skt\n"
            "sympathy -r id   [-H] [-u]\n"
            "sympathy {-l|-ls}\n"
@@ -86,12 +92,13 @@ usage (void)
            "   -F  do not detach, run the server in the foreground\n"
            "   -H  instead of connecting the user's terminal to the session\n"
            "         emit HTML of the current state of the screen on stdout\n"
            "   -F  do not detach, run the server in the foreground\n"
            "   -H  instead of connecting the user's terminal to the session\n"
            "         emit HTML of the current state of the screen on stdout\n"
-           "   -L  log activity on the device to the file log\n"
+           "   -L log  log activity on the device to the file log\n"
            "   -n  hlines  the number of lines of history to store in the\n"
            "                 server, that are replayed on connexion\n"
            "   -n  hlines  the number of lines of history to store in the\n"
            "                 server, that are replayed on connexion\n"
-           "   -u  don't emit utf-8 instead map all non ascii characters as ?\n"
-);
-       
+           "   -u  don't emit utf-8 try to use ISO-2202 to the local terminal\n"
+          "   -w width  start session with a screen of width width<=132\n"
+          );
+
 
   exit (1);
 }
 
   exit (1);
 }
index 98f1282775555933276025f9487587850cab2367..b8e77b189cc2e87b86b7c20fc624b07d0fd3f81d 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
 
 /*
  * $Log$
+ * Revision 1.12  2008/02/27 01:31:14  james
+ * *** empty log message ***
+ *
  * Revision 1.11  2008/02/26 23:23:17  james
  * *** empty log message ***
  *
  * Revision 1.11  2008/02/26 23:23:17  james
  * *** empty log message ***
  *
@@ -137,7 +140,7 @@ ptty_write (TTY * _t, void *buf, int len)
 }
 
 TTY *
 }
 
 TTY *
-ptty_open (char *path, char *argv[])
+ptty_open (char *path, char *argv[],int width)
 {
   PTTY *t;
   pid_t child;
 {
   PTTY *t;
   pid_t child;
@@ -150,7 +153,7 @@ ptty_open (char *path, char *argv[])
 
   client_termios (&ctermios);
   winsize.ws_row = VT102_ROWS;
 
   client_termios (&ctermios);
   winsize.ws_row = VT102_ROWS;
-  winsize.ws_col = VT102_COLS_80;
+  winsize.ws_col = width ? width:VT102_COLS_80;
 
   child = forkpty (&fd, name, &ctermios, &winsize);
 
 
   child = forkpty (&fd, name, &ctermios, &winsize);
 
index 7c211c51cc3d70902e559e08d21033ca53910da0..a879999359a729720987ca7921296d094df93929 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
 
 /*
  * $Log$
+ * Revision 1.45  2008/02/27 01:31:14  james
+ * *** empty log message ***
+ *
  * Revision 1.44  2008/02/27 00:54:16  james
  * *** empty log message ***
  *
  * Revision 1.44  2008/02/27 00:54:16  james
  * *** empty log message ***
  *
@@ -387,7 +390,7 @@ vt102_log_line (Context * c, int line)
 {
   CRT_Pos e = { c->v->current_width - 1, line };
   CRT_Pos p = { 0, line };
 {
   CRT_Pos e = { c->v->current_width - 1, line };
   CRT_Pos p = { 0, line };
-  char logbuf[4*(VT102_MAX_COLS + 1)],*logptr=logbuf;
+  char logbuf[4 * (VT102_MAX_COLS + 1)], *logptr = logbuf;
 
   if (!c->l)
     return;
 
   if (!c->l)
     return;
@@ -404,9 +407,9 @@ vt102_log_line (Context * c, int line)
       int ch = c->v->crt.screen[CRT_ADDR_POS (&p)].chr;
       if (ch < 32)
         ch = ' ';
       int ch = c->v->crt.screen[CRT_ADDR_POS (&p)].chr;
       if (ch < 32)
         ch = ' ';
-       logptr+=utf8_encode(logptr,ch);
+      logptr += utf8_encode (logptr, ch);
     }
     }
-  *logptr=0;
+  *logptr = 0;
 
   c->l->log (c->l, logbuf);
 }
 
   c->l->log (c->l, logbuf);
 }
@@ -996,12 +999,15 @@ vt102_regular_char (Context * c, VT102 * v, uint32_t ch)
 
   if (ch < VT102_CHARSET_SIZE)
     {
 
   if (ch < VT102_CHARSET_SIZE)
     {
-       int cs;
-       if ((cs=vt102_charset_c0[ch])) {
-               ch=cs;
-       } else if ((cs=charset_from_csid[v->g[v->cs]][ch])) {
-               ch=cs;
-       }
+      int cs;
+      if ((cs = vt102_charset_c0[ch]))
+        {
+          ch = cs;
+        }
+      else if ((cs = charset_from_csid[v->g[v->cs]][ch]))
+        {
+          ch = cs;
+        }
     }
   v->crt.screen[CRT_ADDR_POS (&v->pos)].chr = ch;
   v->crt.screen[CRT_ADDR_POS (&v->pos)].attr = v->attr;
     }
   v->crt.screen[CRT_ADDR_POS (&v->pos)].chr = ch;
   v->crt.screen[CRT_ADDR_POS (&v->pos)].attr = v->attr;
@@ -1738,10 +1744,10 @@ vt102_parse_char (Context * c, int ch)
           break;
 #if 0
          /*ACK*/ case 6:
           break;
 #if 0
          /*ACK*/ case 6:
-       break;
+          break;
 #endif
          /*BEL*/ case 7:
 #endif
          /*BEL*/ case 7:
-               //FIXME beep
+          //FIXME beep
           break;
          /*BS*/ case 8:
           vt102_cursor_retreat (c->v);
           break;
          /*BS*/ case 8:
           vt102_cursor_retreat (c->v);
@@ -2016,7 +2022,7 @@ vt102_reset (VT102 * v)
 }
 
 VT102 *
 }
 
 VT102 *
-vt102_new (void)
+vt102_new (int width)
 {
   VT102 *v;
 
 {
   VT102 *v;
 
@@ -2026,6 +2032,14 @@ vt102_new (void)
 
   vt102_reset (v);
 
 
   vt102_reset (v);
 
+  if (width) {
+          v->current_width =width;
+          v->crt.width = v->current_width;
+          v->screen_end.x = v->current_width - 1;
+          v->top_margin = v->screen_start;
+          v->bottom_margin = v->screen_end;
+          vt102_cursor_home (v);
+  }
 
   return v;
 }
 
   return v;
 }