+static void
+ansi_resize_check (ANSI * a, CRT_Pos *size)
+{
+
+ if ((size && crt_pos_cmp(a->crt.size,*size))
+ || crt_pos_cmp (a->terminal->size, a->size))
+ {
+
+ terminal_getsize (a->terminal);
+
+ a->size = a->terminal->size;
+
+ a->pos.x = ANSI_INVAL;
+ a->hide_cursor = ANSI_INVAL;
+
+ crt_reset (&a->crt);
+
+ if (size)
+ a->crt.size =*size;
+
+// FIXME: -- echos back crap?
+// a->terminal->xmit (a->terminal, "\033[c", 3);
+
+// maybe - issue 132 column command if we're 132?
+
+ ansi_cls (a);
+ a->terminal->xmit (a->terminal, "\033=", 2);
+ a->terminal->xmit (a->terminal, "\033[?6l", 5);
+ a->terminal->xmit (a->terminal, "\033[r", 3);
+ if (a->utf8)
+ {
+ a->terminal->xmit (a->terminal, "\033%G", 3);
+ }
+ else
+ {
+ a->terminal->xmit (a->terminal, "\033(B", 3);
+ a->terminal->xmit (a->terminal, "\033)0", 3);
+ a->terminal->xmit (a->terminal, "\017", 1);
+ }
+
+ }
+}
+
+/*if they haven't then ansi_draw will patch it up*/
+
+static void
+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, NULL);
+
+ 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, guess_scroll);
+ a->terminal->xmit (a->terminal, buf, i);
+
+
+ while (a->history_ptr != h->wptr)
+ {
+
+ History_ent *e = &h->lines[a->history_ptr];
+
+ HISTORY_INC (h, a->history_ptr);
+
+ if (!e->valid)
+ continue;
+
+ /*If so write the line ot the top of the screen */
+ ansi_draw_line (a, e->line, 0);