diff src/dispnew.c @ 83065:a871be7b26a5

Implemented suspending of emacsclient frames. lib-src/emacsclient.c (quote_file_name): Renamed to quote_argument. (unquote_argument, handle_sigcont, handle_sigtstp): New functions. (out, in): New global variables for communicating with the Emacs process. (init_signals): Set up handlers for SIGCONT, SIGTSTP and SIGTTOU. (main): Changed out and in to global variables. Prepend `-eval' or '-file' to each argument. Use fsync to force sending the strings to Emacs. Removed obsolete -bad-version code. Support the -suspend command. Cleaned up newline handling. lisp/frame.el (suspend-frame): New function. Substitute key definition of suspend-emacs with suspend-frame. lisp/server.el (server-log): Cosmetic change in log format. (server-handle-delete-tty, server-handle-delete-frame): Added logging. (server-handle-suspend-tty, server-quote-arg): New functions. (server-start): Install server-handle-suspend-tty. (server-process-filter): Reorganized source code for clarity. Implemented -resume, -suspend and -ignore commands. lisp/term/x-win.el (x-initialize-window-system): Don't change the binding of C-z. src/cm.c: Replaced TTY_INPUT, TTY_OUTPUT, TTY_TERMSCRIPT calls with their macro expansion. src/dispnew.c: Ditto. src/frame.c: Ditto. src/keyboard.c: Ditto. src/sysdep.c: Ditto. src/keyboard.c (tty_read_avail_input): Don't read if the terminal is suspended. src/sysdep.c (discard_tty_input, init_sys_modes, reset_sys_modes): Ditto. src/term.c (tty_set_terminal_modes, tty_reset_terminal_modes): Ditto. src/term.c (Vsuspend_tty_functions, Vresume_tty_functions): New hooks. (syms_of_term): Defvar them. (term_init): Don't allow opening a new frame on a suspended tty device. (Fsuspend_tty, Fresume_tty): New functions. (syms_of_term): Defsubr them. src/termchar.c (struct tty_display_info): Update documentation of input and output. (TTY_INPUT, TTY_OUTPUT, TTY_TERMSCRIPT): Removed. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-105
author Karoly Lorentey <lorentey@elte.hu>
date Sat, 28 Feb 2004 01:23:39 +0000
parents 03a73693678e
children b44978264e1d
line wrap: on
line diff
--- a/src/dispnew.c	Fri Feb 27 14:10:47 2004 +0000
+++ b/src/dispnew.c	Sat Feb 28 01:23:39 2004 +0000
@@ -3316,7 +3316,7 @@
   clear_current_matrices (f);
   update_end (f);
   if (FRAME_TERMCAP_P (f))
-    fflush (TTY_OUTPUT (FRAME_TTY (f)));
+    fflush (FRAME_TTY (f)->output);
   windows_or_buffers_changed++;
   /* Mark all windows as inaccurate, so that every window will have
      its redisplay done.  */
@@ -3659,7 +3659,7 @@
   update_end (f);
   updated_row = NULL;
   if (FRAME_TERMCAP_P (f))
-    fflush (TTY_OUTPUT (FRAME_TTY (f)));
+    fflush (FRAME_TTY (f)->output);
 
   TRACE ((stderr, "direct output for insert\n"));
   mark_window_display_accurate (it.window, 1);
@@ -3751,7 +3751,7 @@
     }
 
   if (FRAME_TERMCAP_P (f))
-    fflush (TTY_OUTPUT (FRAME_TTY (f)));
+    fflush (FRAME_TTY (f)->output);
   redisplay_performed_directly_p = 1;
   return 1;
 }
@@ -3849,9 +3849,9 @@
 
       if (FRAME_TERMCAP_P (f))
         {
-          if (TTY_TERMSCRIPT (FRAME_TTY (f)))
-            fflush (TTY_TERMSCRIPT (FRAME_TTY (f)));
-          fflush (TTY_OUTPUT (FRAME_TTY (f)));
+          if (FRAME_TTY (f)->termscript)
+            fflush (FRAME_TTY (f)->termscript);
+          fflush (FRAME_TTY (f)->output);
         }
 
       /* Check window matrices for lost pointers.  */
@@ -5133,18 +5133,18 @@
 		 Also flush out if likely to have more than 1k buffered
 		 otherwise.   I'm told that some telnet connections get
 		 really screwed by more than 1k output at once.  */
-	      int outq = PENDING_OUTPUT_COUNT (TTY_OUTPUT (FRAME_TTY (f)));
+	      int outq = PENDING_OUTPUT_COUNT (FRAME_TTY (f)->output);
 	      if (outq > 900
 		  || (outq > 20 && ((i - 1) % preempt_count == 0)))
 		{
-		  fflush (TTY_OUTPUT (FRAME_TTY (f)));
+		  fflush (FRAME_TTY (f)->output);
 		  if (preempt_count == 1)
 		    {
 #ifdef EMACS_OUTQSIZE
 		      if (EMACS_OUTQSIZE (0, &outq) < 0)
 			/* Probably not a tty.  Ignore the error and reset
 			   the outq count.  */
-			outq = PENDING_OUTPUT_COUNT (TTY_OUTPUT (FRAME_TTY (f)));
+			outq = PENDING_OUTPUT_COUNT (FRAME_TTY (f->output));
 #endif
 		      outq *= 10;
 		      if (baud_rate <= outq && baud_rate > 0)
@@ -5999,7 +5999,7 @@
     if (! tty->term_initted)
       continue;
 
-    get_tty_size (fileno (TTY_INPUT (tty)), &width, &height);
+    get_tty_size (fileno (tty->input), &width, &height);
     
     {
       Lisp_Object tail, frame;
@@ -6211,15 +6211,22 @@
      (file)
      Lisp_Object file;
 {
-  if (TTY_TERMSCRIPT (CURTTY ()) != 0)
-    fclose (TTY_TERMSCRIPT (CURTTY ()));
-  TTY_TERMSCRIPT (CURTTY ()) = 0;
+  struct tty_display_info *tty;
+
+  if (! FRAME_TERMCAP_P (SELECTED_FRAME ()))
+    error ("Current frame is not on a tty device");
+
+  tty = CURTTY ();
+
+  if (tty->termscript != 0)
+    fclose (tty->termscript);
+  tty->termscript = 0;
 
   if (! NILP (file))
     {
       file = Fexpand_file_name (file, Qnil);
-      TTY_TERMSCRIPT (CURTTY ()) = fopen (SDATA (file), "w");
-      if (TTY_TERMSCRIPT (CURTTY ()) == 0)
+      tty->termscript = fopen (SDATA (file), "w");
+      if (tty->termscript == 0)
 	report_file_error ("Opening termscript", Fcons (file, Qnil));
     }
   return Qnil;
@@ -6233,20 +6240,23 @@
      (string)
      Lisp_Object string;
 {
+  struct tty_display_info *tty;
+
   /* ??? Perhaps we should do something special for multibyte strings here.  */
   CHECK_STRING (string);
+
   if (! FRAME_TERMCAP_P (SELECTED_FRAME ()))
     error ("Current frame is not on a tty device");
+
+  tty = CURTTY ();
   
-  if (TTY_TERMSCRIPT (CURTTY ()))
+  if (tty->termscript)
     {
-      fwrite (SDATA (string), 1, SBYTES (string),
-	      TTY_TERMSCRIPT (CURTTY ()));
-      fflush (TTY_TERMSCRIPT (CURTTY ()));
+      fwrite (SDATA (string), 1, SBYTES (string), tty->termscript);
+      fflush (tty->termscript);
     }
-  fwrite (SDATA (string), 1, SBYTES (string),
-          TTY_OUTPUT (CURTTY ()));
-  fflush (TTY_OUTPUT (CURTTY ()));
+  fwrite (SDATA (string), 1, SBYTES (string), tty->output);
+  fflush (tty->output);
   return Qnil;
 }
 
@@ -6265,7 +6275,7 @@
       else
 	ring_bell ();
       if (FRAME_TERMCAP_P (XFRAME (selected_frame)))
-        fflush (TTY_OUTPUT (CURTTY ()));
+        fflush (CURTTY ()->output);
     }
   else
     bitch_at_user ();
@@ -6283,7 +6293,7 @@
   else
     ring_bell ();
   if (FRAME_TERMCAP_P (XFRAME (selected_frame)))
-    fflush (TTY_OUTPUT (CURTTY ()));
+    fflush (CURTTY ()->output);
 }