static int terminal_frame_count;
struct frame *
-make_terminal_frame (tty, tty_type)
- char *tty;
+make_terminal_frame (tty_name, tty_type)
+ char *tty_name;
char *tty_type;
{
register struct frame *f;
Lisp_Object frame;
char name[20];
-
+
#ifdef MULTI_KBOARD
if (!initial_kboard)
{
#ifdef MAC_OS8
make_mac_terminal_frame (f);
#else
- f->output_method = output_termcap;
- if (initialized)
- f->output_data.tty = term_init (tty, tty_type);
- else
- f->output_data.tty = term_dummy_init ();
- f->output_data.tty->top_frame = frame;
+ {
+ struct tty_display_info *tty;
+ f->output_method = output_termcap;
+
+ f->output_data.tty = (struct tty_output *) xmalloc (sizeof (struct tty_output));
+ bzero (f->output_data.tty, sizeof (struct tty_output));
+
+ FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR;
+ FRAME_BACKGROUND_PIXEL (f) = FACE_TTY_DEFAULT_BG_COLOR;
+
+ if (initialized)
+ {
+ /* Note that term_init may signal an error, but then it is its
+ responsibility to make sure this frame is deleted. */
+ f->output_data.tty->display_info = term_init (frame, tty_name, tty_type);
+ }
+ else
+ {
+ /* init_display() will reinitialize the terminal with correct values after dump. */
+ f->output_data.tty->display_info = term_dummy_init ();
+ }
+ FRAME_TTY (f)->reference_count++;
+ }
+
#ifdef CANNOT_DUMP
FRAME_FOREGROUND_PIXEL(f) = FACE_TTY_DEFAULT_FG_COLOR;
FRAME_BACKGROUND_PIXEL(f) = FACE_TTY_DEFAULT_BG_COLOR;
/* XXX Ugh, there must be a better way to do this. */
tty = Fassq (Qtty, parms);
+ if (EQ (tty, Qnil))
+ tty = Fassq (Qtty, XFRAME (selected_frame)->param_alist);
if (EQ (tty, Qnil))
tty = Fassq (Qtty, Vdefault_frame_alist);
if (! EQ (tty, Qnil))
tty_type = Fassq (Qtty_type, parms);
if (EQ (tty_type, Qnil))
tty_type = Fassq (Qtty_type, Vdefault_frame_alist);
+ if (EQ (tty_type, Qnil))
+ tty_type = Fassq (Qtty, XFRAME (selected_frame)->param_alist);
if (! EQ (tty_type, Qnil))
tty_type = XCDR (tty_type);
if (EQ (tty_type, Qnil) || !STRINGP (tty_type))
{
int width, height;
- get_tty_size (FRAME_TTY (f), &width, &height);
+ get_tty_size (fileno (TTY_INPUT (FRAME_TTY (f))), &width, &height);
change_frame_size (f, height, width, 0, 0, 0);
}
{
FOR_EACH_FRAME (tail, frame1)
{
- if (! EQ (frame, frame1))
+ if (! EQ (frame, frame1) && FRAME_LIVE_P (XFRAME (frame1)))
break;
}
}
x_destroy_window (f);
#endif
- f->output_data.nothing = 0;
+ if (FRAME_TERMCAP_P (f))
+ {
+ int delete = 1;
+ struct tty_display_info *tty = FRAME_TTY (f);
+
+ if (! --tty->reference_count)
+ {
+ /* delete_tty would call us recursively if we don't kill the
+ frame now. */
+ xfree (f->output_data.tty);
+ f->output_data.nothing = 0;
+ delete_tty (tty);
+ }
+ }
+ else
+ {
+ f->output_data.nothing = 0;
+ }
/* If we've deleted the last_nonminibuf_frame, then try to find
another one. */