/*
* $Log$
+ * Revision 1.19 2008/02/27 09:47:05 james
+ * *** empty log message ***
+ *
+ * Revision 1.18 2008/02/27 09:42:53 james
+ * *** empty log message ***
+ *
+ * Revision 1.17 2008/02/27 09:42:21 james
+ * *** empty log message ***
+ *
* Revision 1.16 2008/02/27 01:31:38 james
* *** empty log message ***
*
int c;
extern char *optarg;
extern int optind, opterr, optopt;
- int width = VT102_COLS_80;
+ CRT_Pos size = { VT102_COLS_80, VT102_ROWS };
int oflags[128];
char *oargs[128];
memset (oflags, 0, sizeof (oflags));
memset (oargs, 0, sizeof (oargs));
- while ((c = getopt (argc, argv, "w:utscr:lKHd:pb:fL:Fk:n:")) != EOF)
+ while ((c = getopt (argc, argv, "vw:utscr:lKHd:pb:fL:Fk:n:")) != EOF)
{
switch (c)
{
oflags['s'] = 0;
- if (!oflags['s'] && !oflags['c'] && !oflags['t'] && !oflags['r']
- && !oflags['l'])
- {
- /*If no mode is specified behave like screen */
- oflags['s']++;
- oflags['c']++;
- }
-
-
{
int sum = 0;
sum += oflags['t'];
sum += (oflags['s'] || oflags['c']) ? 1 : 0;
sum += oflags['r'];
sum += oflags['l'];
+ sum += oflags['v'];
+ if (!sum) {
+ /*If no mode is specified behave like screen */
+ oflags['s']++;
+ oflags['c']++;
+ }
+
if (sum != 1)
- fatal_moan ("specifiy exactly one of ( -c and or -s ), -t, -r and -l");
+ fatal_moan
+ ("specifiy exactly one of ( -c and or -s ), -t, -r, -l and -v");
}
+ if (oflags['v'])
+ {
+ fprintf (stderr, "Version: %s\n", libsympathy_version ());
+ fprintf (stderr, "Version: %s\n", rcsid);
+ return 0;
+ }
if (oflags['l'])
return list_sockets ();
if (oflags['w'])
{
- width = safe_atoi (oargs['w']);
- if ((width > VT102_MAX_COLS) || (width < 1))
+ char buf[128], *ptr;
+ strcpy (buf, oargs['w']);
+ ptr = index (buf, 'x');
+ if (ptr)
+ {
+ *ptr = 0;
+ ptr++;
+ size.y = safe_atoi (ptr);
+ }
+ size.x = safe_atoi (buf);
+
+ if ((size.x > VT102_MAX_COLS) || (size.x < 1))
fatal_moan ("-w requires a width between 1 and %d\n", VT102_MAX_COLS);
+
+ if ((size.y > VT102_ROWS) || (size.y < 1))
+ fatal_moan ("-w requires a height between 1 and %d\n",
+ VT102_MAX_COLS);
+
}
if (oflags['s'] && !oflags['F'])
if (oflags['p'])
{
- tty = ptty_open (NULL, NULL, width);
+ tty = ptty_open (NULL, NULL, &size);
if (!tty)
fatal_moan ("unable to open a ptty");
}
}
}
- mainloop (tty, server_socket, client_socket, ansi, log, history, width);
+ mainloop (tty, server_socket, client_socket, ansi, log, history, &size);
if (ansi)
{
/*
* $Log$
+ * Revision 1.13 2008/02/27 09:42:53 james
+ * *** empty log message ***
+ *
+ * Revision 1.12 2008/02/27 09:42:21 james
+ * *** empty log message ***
+ *
* Revision 1.11 2008/02/27 01:31:38 james
* *** empty log message ***
*
"sympathy -c [-H] [-u] -k skt\n"
"sympathy -r id [-H] [-u]\n"
"sympathy {-l|-ls}\n"
+ "sympathy -v\n"
"sympathy -h\n"
"\n"
"Main mode:\n"
" -r id client mode: connect to server mode process on socket\n"
" ~/.sympathy/id\n"
" -l or -ls list active sockets in ~/.sympathy\n"
+ " -v show version\n"
+ " -h show help\n"
"\n"
"Options:\n"
" -K lock the serial device. By default sympathy checks that no\n"
# $Id$
#
# $Log$
+# Revision 1.3 2008/02/27 09:50:15 james
+# *** empty log message ***
+#
+# Revision 1.2 2008/02/27 09:49:25 james
+# *** empty log message ***
+#
# Revision 1.1 2008/02/03 16:20:24 james
# *** empty log message ***
#
#
#
#
+set -x
+
cvs commit -m ""
FILES=`cat version-files`
echo "$CHK ${MAJOR}.${MINOR}.${MICRO}" >> version-md5sums
cvs commit -m ""
-cvs tag libsympathy-$MAJOR_$MINOR_$MICRO .
+cvs tag libsympathy-${MAJOR}_${MINOR}_${MICRO} .
/*
* $Log$
+ * Revision 1.34 2008/02/27 09:42:53 james
+ * *** empty log message ***
+ *
+ * Revision 1.33 2008/02/27 09:42:21 james
+ * *** empty log message ***
+ *
* Revision 1.32 2008/02/26 23:56:12 james
* *** empty log message ***
*
CRT_Pos p = { 0, y };
CRT_CA *acap = &a->crt.screen[CRT_ADDR_POS (&p)];
- for (p.x = 0; p.x < a->crt.width; ++p.x)
+ for (p.x = 0; p.x < a->crt.size.x; ++p.x)
{
if (p.x >= a->size.x)
continue;
}
static void
-ansi_resize_check (ANSI * a, int new_width)
+ansi_resize_check (ANSI * a, CRT_Pos * size)
{
- if ((new_width && (new_width != a->crt.width))
+ if ((size && crt_pos_cmp (a->crt.size, *size))
|| crt_pos_cmp (a->terminal->size, a->size))
{
crt_reset (&a->crt);
- if (new_width)
- a->crt.width = new_width;
+ if (size)
+ a->crt.size = *size;
// FIXME: -- echos back crap?
// a->terminal->xmit (a->terminal, "\033[c", 3);
}
}
-#define HISTORY_GUESS_SCROLL 24 /*guess all 24 lines usually scroll */
/*if they haven't then ansi_draw will patch it up*/
static void
{
char buf[32];
int i;
+ int guess_scroll;
/*Do we need to catch up on history?*/
if (a->history_ptr == h->wptr)
return;
- ansi_resize_check (a, 0);
+ ansi_resize_check (a, NULL);
- if ((a->size.x < a->crt.width) || (a->size.y < CRT_ROWS))
+ if ((a->size.x < a->crt.size.x) || (a->size.y < a->crt.size.y))
return;
+ guess_scroll = a->crt.size.y - 1; /*Bototm line should be a status line */
+
+
ansi_force_attr_normal (a);
ansi_set_color (a, CRT_COLOR_NORMAL);
- i = sprintf (buf, "\033[%d;%dr", 1, HISTORY_GUESS_SCROLL);
+ i = sprintf (buf, "\033[%d;%dr", 1, guess_scroll);
a->terminal->xmit (a->terminal, buf, i);
ansi_draw_line (a, e->line, 0);
- /*Roll HISTORY_GUESS_SCROLL lines up putting the top line into the xterm's history */
+ /*Roll guess_scroll lines up putting the top line into the xterm's history */
/*Make extra lines a predictable colour */
ansi_set_color (a, CRT_COLOR_NORMAL);
ansi_showhide_cursor (a, 1);
- i = sprintf (buf, "\033[%d;%dH", HISTORY_GUESS_SCROLL, 1);
+ i = sprintf (buf, "\033[%d;%dH", guess_scroll, 1);
a->terminal->xmit (a->terminal, buf, i);
a->terminal->xmit (a->terminal, "\033D", 2);
a->pos.x = ANSI_INVAL;
0};
/*scroll lines up */
- for (s.y++; s.y < HISTORY_GUESS_SCROLL; s.y++, e.y++)
+ for (s.y++; s.y < guess_scroll; s.y++, e.y++)
{
memcpy (&a->crt.screen[CRT_ADDR_POS (&e)],
&a->crt.screen[CRT_ADDR_POS (&s)],
- sizeof (CRT_CA) * a->crt.width);
+ sizeof (CRT_CA) * a->crt.size.x);
}
/* erase new line */
int o;
int hidden_cursor = 0;
- ansi_resize_check (a, c->width);
+ ansi_resize_check (a, &c->size);
- for (p.y = 0; p.y < CRT_ROWS; ++p.y)
+ for (p.y = 0; p.y < a->crt.size.y; ++p.y)
{
if (p.y >= a->size.y)
continue;
}
- if ((c->width > a->size.x) || (CRT_ROWS > a->size.y))
+ if ((c->size.x > a->size.x) || (c->size.y > a->size.y))
{
char msg[1024]; // = "Window is too small";
int i;
i =
sprintf (msg, "Window too small (%dx%d need %dx%d)", a->size.x,
- a->size.y, c->width, CRT_ROWS);
+ a->size.y, c->size.x, c->size.y);
ansi_showhide_cursor (a, 1);
ansi_set_attr (a, CRT_ATTR_REVERSE);
static void
ansi_terminal_reset (ANSI * a)
{
- CRT_Pos p = { 0, CRT_ROWS };
+ CRT_Pos p = { 0, a->crt.size.y };
ansi_force_attr_normal (a);
ansi_move (a, p);
/*
* $Log$
+ * Revision 1.15 2008/02/27 09:42:21 james
+ * *** empty log message ***
+ *
* Revision 1.14 2008/02/27 00:27:21 james
* *** empty log message ***
*
c->pos.x = 0;
c->pos.y = 0;
c->hide_cursor = 1;
- c->width = CRT_COLS;
+ c->size.x = CRT_COLS;
+ c->size.y = CRT_ROWS;
#if 0
c->sh.dir = 0;
#endif
/*
* $Log$
+ * Revision 1.13 2008/02/27 09:42:22 james
+ * *** empty log message ***
+ *
* Revision 1.12 2008/02/26 23:23:17 james
* *** empty log message ***
*
CRT_CA screen[CRT_CELS];
CRT_Pos pos;
int hide_cursor;
- int width;
+ CRT_Pos size;
} CRT;
/*
* $Log$
+ * Revision 1.9 2008/02/27 09:42:22 james
+ * *** empty log message ***
+ *
* Revision 1.8 2008/02/27 01:52:38 james
* *** empty log message ***
*
#else
fprintf (f, "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n");
#endif
- for (p.y = 0; p.y < CRT_ROWS; ++p.y)
+ for (p.y = 0; p.y < c->size.y; ++p.y)
{
o = CRT_ADDR (p.y, 0);
#ifndef CSS
fprintf (f, "<tr>");
#endif
- for (p.x = 0; p.x < CRT_COLS; ++p.x, ++o)
+ for (p.x = 0; p.x < c->size.x; ++p.x, ++o)
{
html_render (f, c->screen[o]);
}
/* libsympathy.c */
/* render.c */
/* version.c */
+extern char *libsympathy_version(void);
/* vt102.c */
extern int vt102_cmd_length[128];
extern int vt102_cmd_termination[128];
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 VT102 *vt102_new(int width);
+extern VT102 *vt102_new(CRT_Pos *size);
extern void vt102_set_ansi(VT102 *v, int ansi);
extern void vt102_free(VT102 *v);
/* tty.c */
extern int ring_bytes(Ring *r);
extern Ring *ring_new(int n);
/* ptty.c */
-extern TTY *ptty_open(char *path, char *argv[], int width);
+extern TTY *ptty_open(char *path, char *argv[], CRT_Pos *size);
/* terminal.c */
extern int terminal_winches;
extern void terminal_atexit(void);
/*
* $Log$
+ * Revision 1.15 2008/02/27 09:42:53 james
+ * *** empty log message ***
+ *
+ * Revision 1.14 2008/02/27 09:42:22 james
+ * *** empty log message ***
+ *
* Revision 1.13 2008/02/27 01:31:38 james
* *** empty log message ***
*
}
TTY *
-ptty_open (char *path, char *argv[], int width)
+ptty_open (char *path, char *argv[], CRT_Pos * size)
{
PTTY *t;
pid_t child;
client_termios (&ctermios);
- winsize.ws_row = VT102_ROWS;
- winsize.ws_col = width ? width : VT102_COLS_80;
+ winsize.ws_row = size ? size->y : VT102_ROWS;
+ winsize.ws_col = size ? size->x : VT102_COLS_80;
child = forkpty (&fd, name, &ctermios, &winsize);
/*
* $Log$
+ * Revision 1.3 2008/02/27 09:42:22 james
+ * *** empty log message ***
+ *
* Revision 1.2 2008/02/04 02:05:06 james
* *** empty log message ***
*
#include "version.h"
-static char *
-GetVersion (void)
+char *
+libsympathy_version (void)
{
return VERSION;
}
/*
* $Log$
+ * 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 ***
+ *
* Revision 1.46 2008/02/27 01:31:38 james
* *** empty log message ***
*
void
vt102_log_line (Context * c, int line)
{
- CRT_Pos e = { c->v->current_width - 1, line };
+ CRT_Pos e = { c->v->current_size.x - 1, line };
CRT_Pos p = { 0, line };
char logbuf[4 * (VT102_MAX_COLS + 1)], *logptr = logbuf;
case VT102_PRIVATE_MODE_132COLS:
/* We don't implement 132 col mode - yet */
- v->current_width =
+ v->current_size.x =
v->
private_modes[VT102_PRIVATE_MODE_132COLS] ? VT102_COLS_132 :
VT102_COLS_80;
- v->crt.width = v->current_width;
- v->screen_end.x = v->current_width - 1;
+ 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);
case 'K':
{
CRT_Pos ls = { 0, v->pos.y };
- CRT_Pos le = { v->current_width - 1, v->pos.y };
+ CRT_Pos le = { v->current_size.x - 1, v->pos.y };
if (len == 2)
narg = 0; /*Different default */
break;
case 'K':
{
- CRT_Pos le = { v->current_width - 1, v->pos.y };
+ CRT_Pos le = { v->current_size.x - 1, v->pos.y };
crt_erase (&v->crt, v->pos, le, 1, v->color);
}
break;
void
vt102_status_line (VT102 * v, char *str)
{
- int i = v->current_width - 1;
- CRT_CA *ca = &v->crt.screen[CRT_ADDR (VT102_STATUS_ROW, 0)];
+ int i;
+ CRT_CA *ca = &v->crt.screen[CRT_ADDR (v->current_size.y, 0)];
- for (i = 0; i < v->current_width; ++i)
+ for (i = 0; i < v->current_size.x; ++i)
{
ca->attr = CRT_ATTR_REVERSE;
ca->color = CRT_COLOR_NORMAL;
v->application_keypad_mode = 0;
- v->current_width = VT102_COLS_80;
- v->crt.width = v->current_width;
- v->screen_end.x = v->current_width - 1;
+ 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->top_margin = v->screen_start;
v->bottom_margin = v->screen_end;
v->screen_start.x = 0;
v->screen_start.y = 0;
- v->current_width = VT102_COLS_80;
- v->crt.width = v->current_width;
- v->screen_end.x = v->current_width - 1;
- v->screen_end.y = VT102_ROWS - 1;
+ 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--;
vt102_cursor_home (v);
vt102_status_line (v, "");
}
VT102 *
-vt102_new (int width)
+vt102_new (CRT_Pos * size)
{
VT102 *v;
v->xn_glitch = 1;
- vt102_reset (v);
- if (width)
+ 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 > 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->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);
+ v->original_size.x = VT102_COLS_80;
+ v->original_size.y = VT102_ROWS;
}
+ vt102_reset (v);
+
return v;
}
/*
* $Log$
+ * Revision 1.20 2008/02/27 09:42:22 james
+ * *** empty log message ***
+ *
* Revision 1.19 2008/02/26 23:23:17 james
* *** empty log message ***
*
int last_reg_char;
int xn_glitch;
- int current_width;
+ CRT_Pos current_size;
+ CRT_Pos original_size;
int g[2];
int cs;
*
*/
-static char rcsid[] =
- "$Id$";
+static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.8 2008/02/27 09:42:22 james
+ * *** empty log message ***
+ *
* Revision 1.7 2008/02/20 20:16:07 james
* *** empty log message ***
*
int
main (int argc, char *argv[])
{
-#if 0
- fd_set rfds, wfds;
- ANSI a = { 0 };
- Context c;
-
-
- c.t = ptty_open (NULL, NULL);
- c.v = vt102_new ();
- c.h = history_new (200);
- c.l = file_log_new ("log");
- c.k = keydis_vt102_new ();
-
- terminal_register_handlers ();
- a.terminal = terminal_open (0, 1);
-
- ansi_reset (&a, NULL);
-
- for (;;)
- {
- struct timeval tv = { 10, 0 };
-
- FD_ZERO (&rfds);
- FD_ZERO (&wfds);
-
- tty_pre_select (c.t, &rfds, &wfds);
- tty_pre_select (a.terminal, &rfds, &wfds);
-
-
- select (FD_SETSIZE, &rfds, &wfds, NULL, &tv);
-
- if (FD_ISSET (c.t->rfd, &rfds))
- {
- if (vt102_dispatch(&c)) break;
- }
-
- ansi_dispatch (&a, &c);
- ansi_update (&a, &c);
-
-
- }
-
- ansi_terminal_reset (&a);
- terminal_atexit ();
- printf ("QUAT\n");
-#endif
-return 0;
+ return 0;
}
6488eda7d5c4d46ce3f587f5dc745dfa 1.0.1
ca1ac5a7fc122af620b0cf7296c324c3 1.0.2
+ac9d93b50970b366e4531b4ea5a1c983 1.0.3
+ac9d93b50970b366e4531b4ea5a1c986 1.1.0
+0ea0fc96142920321bfa5354dc6b9daa 1.1.1