Function: resume-tty

resume-tty is a function defined in term.c.

Signature

(resume-tty &optional TTY)

Documentation

Resume the previously suspended terminal device TTY.

The terminal is opened and reinitialized. Frames that are on the suspended terminal are revived.

It is an error to resume a terminal while another terminal is active on the same device.

This function runs resume-tty-functions after resuming the terminal. The functions are run with one arg, the id of the resumed terminal device.

resume-tty does nothing if it is called on a device that is not suspended.

TTY may be a terminal object, a frame, or nil (meaning the selected frame's terminal).

View in manual

Probably introduced at or before Emacs version 23.1.

Source Code

// Defined in /usr/src/emacs/src/term.c
{
#ifndef HAVE_ANDROID
  struct terminal *t;
  int fd;

  t = decode_tty_terminal (tty);

  if (!t)
    error ("Attempt to resume a non-text terminal device");

  if (!t->display_info.tty->input)
    {
      if (get_named_terminal (t->display_info.tty->name))
        error ("Cannot resume display while another display is active on the same device");

#ifdef MSDOS
      t->display_info.tty->output = stdout;
      t->display_info.tty->input  = stdin;
#else  /* !MSDOS */
      fd = emacs_open (t->display_info.tty->name, O_RDWR | O_NOCTTY, 0);
      t->display_info.tty->input = t->display_info.tty->output
	= fd < 0 ? 0 : emacs_fdopen (fd, "w+");

      if (! t->display_info.tty->input)
	{
	  int open_errno = errno;
	  emacs_close (fd);
	  report_file_errno ("Cannot reopen tty device",
			     build_string (t->display_info.tty->name),
			     open_errno);
	}

      if (!O_IGNORE_CTTY && strcmp (t->display_info.tty->name, dev_tty) != 0)
        dissociate_if_controlling_tty (fd);
#endif /* MSDOS */

      add_keyboard_wait_descriptor (fd);

      if (FRAMEP (t->display_info.tty->top_frame))
	{
	  struct frame *f = XFRAME (t->display_info.tty->top_frame);
	  int width, height;
	  int old_height = FRAME_COLS (f);
	  int old_width = FRAME_TOTAL_LINES (f);

	  /* Check if terminal/window size has changed while the frame
	     was suspended.  */
	  get_tty_size (fileno (t->display_info.tty->input), &width, &height);
	  if (width != old_width || height != old_height)
	    change_frame_size (f, width, height, false, false, false);
	  SET_FRAME_VISIBLE (XFRAME (t->display_info.tty->top_frame), 1);
	}

      set_tty_hooks (t);
      init_sys_modes (t->display_info.tty);

      /* Run `resume-tty-functions'.  */
      Lisp_Object term;
      XSETTERMINAL (term, t);
      CALLN (Frun_hook_with_args, Qresume_tty_functions, term);
    }

  set_tty_hooks (t);
#else /* HAVE_ANDROID */
  /* Android doesn't support TTY terminal devices, so unconditionally
     signal.  */
  error ("Attempt to suspend a non-text terminal device");
#endif /* !HAVE_ANDROID */

  return Qnil;
}