aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjames <>2008-02-27 09:42:22 +0000
committerjames <>2008-02-27 09:42:22 +0000
commitd6c2a27d3304842fab285a4217518046b57b771b (patch)
treec2461f0ca793f2cc6704f5343b02c0d77b19b9a5 /src
parent331559e304d549308e45c84ed0ffe67b2ad42b65 (diff)
downloadsympathy-d6c2a27d3304842fab285a4217518046b57b771b.tar.gz
sympathy-d6c2a27d3304842fab285a4217518046b57b771b.tar.bz2
sympathy-d6c2a27d3304842fab285a4217518046b57b771b.zip
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r--src/ansi.c42
-rw-r--r--src/crt.c6
-rw-r--r--src/crt.h5
-rw-r--r--src/html.c7
-rw-r--r--src/prototypes.h5
-rw-r--r--src/ptty.c9
-rw-r--r--src/version.c7
-rw-r--r--src/vt102.c68
8 files changed, 94 insertions, 55 deletions
diff --git a/src/ansi.c b/src/ansi.c
index e029c25..42f6a4c 100644
--- a/src/ansi.c
+++ b/src/ansi.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * 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 ***
*
@@ -502,7 +505,7 @@ ansi_draw_line (ANSI * a, CRT_CA * cap, int y)
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;
@@ -522,10 +525,10 @@ ansi_draw_line (ANSI * a, CRT_CA * cap, int y)
}
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))
{
@@ -538,8 +541,8 @@ ansi_resize_check (ANSI * a, int new_width)
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);
@@ -564,7 +567,6 @@ ansi_resize_check (ANSI * a, int new_width)
}
}
-#define HISTORY_GUESS_SCROLL 24 /*guess all 24 lines usually scroll */
/*if they haven't then ansi_draw will patch it up*/
static void
@@ -572,19 +574,23 @@ ansi_history (ANSI * a, History * h)
{
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);
@@ -602,14 +608,14 @@ ansi_history (ANSI * a, History * h)
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;
@@ -623,11 +629,11 @@ ansi_history (ANSI * a, History * h)
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 */
@@ -653,10 +659,10 @@ ansi_draw (ANSI * a, CRT * c)
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;
@@ -666,7 +672,7 @@ ansi_draw (ANSI * a, CRT * c)
}
- 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;
@@ -675,7 +681,7 @@ ansi_draw (ANSI * a, CRT * c)
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);
@@ -710,7 +716,7 @@ ansi_reset (ANSI * a, CRT * c)
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);
diff --git a/src/crt.c b/src/crt.c
index 9d6606a..7e7c647 100644
--- a/src/crt.c
+++ b/src/crt.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $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 ***
*
@@ -167,7 +170,8 @@ crt_reset (CRT * c)
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
diff --git a/src/crt.h b/src/crt.h
index 5883c04..bc58a5d 100644
--- a/src/crt.h
+++ b/src/crt.h
@@ -12,6 +12,9 @@
/*
* $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 ***
*
@@ -119,7 +122,7 @@ typedef struct CRT_struct
CRT_CA screen[CRT_CELS];
CRT_Pos pos;
int hide_cursor;
- int width;
+ CRT_Pos size;
} CRT;
diff --git a/src/html.c b/src/html.c
index 5a0bf4a..15ca782 100644
--- a/src/html.c
+++ b/src/html.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $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 ***
*
@@ -156,13 +159,13 @@ html_draw (FILE * f, CRT * c)
#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]);
}
diff --git a/src/prototypes.h b/src/prototypes.h
index dd7dfeb..d1de9a9 100644
--- a/src/prototypes.h
+++ b/src/prototypes.h
@@ -13,6 +13,7 @@ extern ANSI *ansi_new_html(FILE *f);
/* 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];
@@ -51,7 +52,7 @@ extern void vt102_reset_state(VT102 *v);
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 */
@@ -81,7 +82,7 @@ extern int ring_space(Ring *r);
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);
diff --git a/src/ptty.c b/src/ptty.c
index b2e5d0f..fba3202 100644
--- a/src/ptty.c
+++ b/src/ptty.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * 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 ***
*
@@ -143,7 +146,7 @@ ptty_write (TTY * _t, void *buf, int len)
}
TTY *
-ptty_open (char *path, char *argv[], int width)
+ptty_open (char *path, char *argv[], CRT_Pos *size)
{
PTTY *t;
pid_t child;
@@ -155,8 +158,8 @@ ptty_open (char *path, char *argv[], int width)
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);
diff --git a/src/version.c b/src/version.c
index 651093d..e62a5f9 100644
--- a/src/version.c
+++ b/src/version.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $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 ***
*
@@ -21,8 +24,8 @@ static char rcsid[] = "$Id$";
#include "version.h"
-static char *
-GetVersion (void)
+char *
+libsympathy_version (void)
{
return VERSION;
}
diff --git a/src/vt102.c b/src/vt102.c
index 52f7fb9..1940dcf 100644
--- a/src/vt102.c
+++ b/src/vt102.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * 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 ***
*
@@ -391,7 +394,7 @@ in_margins (VT102 * v, CRT_Pos p)
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;
@@ -734,13 +737,16 @@ vt102_change_mode (VT102 * v, int private, char *ns, int set)
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);
@@ -1163,7 +1169,7 @@ vt102_parse_csi (Context * c, char *buf, int len)
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 */
@@ -1405,7 +1411,7 @@ vt102_parse_esc (Context * c)
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;
@@ -1545,10 +1551,10 @@ vt102_parse_esc (Context * c)
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;
@@ -1589,9 +1595,12 @@ vt102_reset_state (VT102 * v)
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;
@@ -2005,10 +2014,12 @@ vt102_reset (VT102 * v)
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, "");
@@ -2025,7 +2036,7 @@ vt102_reset (VT102 * v)
}
VT102 *
-vt102_new (int width)
+vt102_new (CRT_Pos *size)
{
VT102 *v;
@@ -2033,18 +2044,23 @@ vt102_new (int width)
v->xn_glitch = 1;
- vt102_reset (v);
+
+ if (size) {
+ v->original_size = *size;
- 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);
+ 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->original_size.x=VT102_COLS_80;
+ v->original_size.y=VT102_ROWS;
}
+ vt102_reset (v);
+
return v;
}