changeset 97658:53d01aafa957

[MSDOS]: Include msdos.h. (init_tty) [MSDOS]: Reuse most of WINDOWSNT branch. Change cpp conditional to DOS_NT. Allow only one call to this function in a session. Don't allocate a new struct tty_display_info; instead, reuse the_only_display_info. Call get_tty_size to get screen dimensions. Call init_baud_rate to set bad_rate. (dissociate_if_controlling_tty) [MSDOS]: Ifdef away function body. (Fsuspend_tty) [MSDOS]: Don't close input and output. (Fresume_tty) [MSDOS]: Don't reopen the TTY; instead, use stdin/stdout. (get_tty_terminal, get_named_tty, Ftty_type) (Fcontrolling_tty_p): Handle output_msdos_raw in addition to output_termcap. (Fresume_tty, Fsuspend_tty, init_tty, delete_tty): Call add_keyboard_wait_descriptor and delete_keyboard_wait_descriptor only when subprocesses are supported
author Eli Zaretskii <eliz@gnu.org>
date Sat, 23 Aug 2008 16:55:52 +0000
parents 24f1cb4150ef
children 6358f03eb003
files src/term.c
diffstat 1 files changed, 71 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/src/term.c	Sat Aug 23 16:54:45 2008 +0000
+++ b/src/term.c	Sat Aug 23 16:55:52 2008 +0000
@@ -57,6 +57,10 @@
 #include "syssignal.h"
 #include "systty.h"
 #include "intervals.h"
+#ifdef MSDOS
+#include "msdos.h"
+static int been_here = -1;
+#endif
 
 /* For now, don't try to include termcap.h.  On some systems,
    configure finds a non-standard termcap.h that the main build
@@ -2067,7 +2071,7 @@
     return make_number (t->display_info.tty->TN_max_colors);
 }
 
-#ifndef WINDOWSNT
+#ifndef DOS_NT
 
 /* Declare here rather than in the function, as in the rest of Emacs,
    to work around an HPUX compiler bug (?). See
@@ -2188,7 +2192,7 @@
     }
 }
 
-#endif /* !WINDOWSNT */
+#endif /* !DOS_NT */
 
 
 
@@ -2199,7 +2203,7 @@
 {
   struct terminal *t = get_terminal (terminal, throw);
 
-  if (t && t->type != output_termcap)
+  if (t && t->type != output_termcap && t->type != output_msdos_raw)
     {
       if (throw)
         error ("Device %d is not a termcap terminal device", t->id);
@@ -2228,7 +2232,7 @@
 
   for (t = terminal_list; t; t = t->next_terminal)
     {
-      if (t->type == output_termcap
+      if (t->type == output_termcap || t->type == output_msdos_raw
           && !strcmp (t->display_info.tty->name, name)
           && TERMINAL_ACTIVE_P (t))
         return t;
@@ -2249,7 +2253,7 @@
 {
   struct terminal *t = get_terminal (terminal, 1);
 
-  if (t->type != output_termcap)
+  if (t->type != output_termcap && t->type != output_msdos_raw)
     return Qnil;
 
   if (t->display_info.tty->type)
@@ -2259,7 +2263,7 @@
 }
 
 DEFUN ("controlling-tty-p", Fcontrolling_tty_p, Scontrolling_tty_p, 0, 1, 0,
-       doc: /* Return non-nil if TERMINAL is on the controlling tty of the Emacs process.
+       doc: /* Return non-nil if TERMINAL is the controlling tty of the Emacs process.
 
 TERMINAL can be a terminal id, a frame or nil (meaning the selected
 frame's terminal).  This function always returns nil if TERMINAL
@@ -2269,7 +2273,8 @@
 {
   struct terminal *t = get_terminal (terminal, 1);
 
-  if (t->type != output_termcap || strcmp (t->display_info.tty->name, DEV_TTY))
+  if ((t->type != output_termcap && t->type != output_msdos_raw)
+      || strcmp (t->display_info.tty->name, DEV_TTY) != 0)
     return Qnil;
   else
     return Qt;
@@ -2341,11 +2346,15 @@
 
       reset_sys_modes (t->display_info.tty);
 
+#ifdef subprocesses
       delete_keyboard_wait_descriptor (fileno (f));
-
+#endif
+
+#ifndef MSDOS
       fclose (f);
       if (f != t->display_info.tty->output)
         fclose (t->display_info.tty->output);
+#endif
 
       t->display_info.tty->input = 0;
       t->display_info.tty->output = 0;
@@ -2392,6 +2401,10 @@
       if (get_named_tty (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);
 
       if (fd == -1)
@@ -2402,8 +2415,11 @@
 
       t->display_info.tty->output = fdopen (fd, "w+");
       t->display_info.tty->input = t->display_info.tty->output;
-
+#endif
+
+#ifdef subprocesses
       add_keyboard_wait_descriptor (fd);
+#endif
 
       if (FRAMEP (t->display_info.tty->top_frame))
         FRAME_SET_VISIBLE (XFRAME (t->display_info.tty->top_frame), 1);
@@ -3211,7 +3227,7 @@
 static void
 dissociate_if_controlling_tty (int fd)
 {
-#ifndef WINDOWSNT
+#ifndef DOS_NT
   int pgid;
   EMACS_GET_TTY_PGRP (fd, &pgid); /* If tcgetpgrp succeeds, fd is the ctty. */
   if (pgid != -1)
@@ -3239,7 +3255,7 @@
 #endif  /* ! TIOCNOTTY */
 #endif  /* ! USG */
     }
-#endif	/* !WINDOWSNT */
+#endif	/* !DOS_NT */
 }
 
 static void maybe_fatal();
@@ -3288,7 +3304,15 @@
     return terminal;
 
   terminal = create_terminal ();
+#ifdef MSDOS
+  if (been_here > 0)
+    maybe_fatal (1, 0, 0, "Attempt to create another terminal %s", "",
+		 name, "");
+  been_here = 1;
+  tty = &the_only_display_info;
+#else
   tty = (struct tty_display_info *) xmalloc (sizeof (struct tty_display_info));
+#endif
   bzero (tty, sizeof (struct tty_display_info));
   tty->next = tty_list;
   tty_list = tty;
@@ -3300,7 +3324,7 @@
   tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm));
   Wcm_clear (tty);
 
-#ifndef WINDOWSNT
+#ifndef DOS_NT
   set_tty_hooks (terminal);
 
   {
@@ -3350,10 +3374,12 @@
 
   tty->type = xstrdup (terminal_type);
 
+#ifdef subprocesses
   add_keyboard_wait_descriptor (fileno (tty->input));
-
 #endif
 
+#endif	/* !DOS_NT */
+
   encode_terminal_src_size = 0;
   encode_terminal_dst_size = 0;
 
@@ -3362,8 +3388,16 @@
   mouse_face_window = Qnil;
 #endif
 
+#ifdef DOS_NT
 #ifdef WINDOWSNT
   initialize_w32_display (terminal);
+#else  /* MSDOS */
+  if (strcmp (terminal_type, "internal") == 0)
+    terminal->type = output_msdos_raw;
+  initialize_msdos_display (terminal);
+#endif	/* MSDOS */
+  tty->output = stdout;
+  tty->input = stdin;
   /* The following two are inaccessible from w32console.c.  */
   terminal->delete_frame_hook = &delete_tty_output;
   terminal->delete_terminal_hook = &delete_tty;
@@ -3372,12 +3406,13 @@
   terminal->name = xstrdup (name);
   tty->type = xstrdup (terminal_type);
 
-  tty->output = stdout;
-  tty->input = stdin;
+#ifdef subprocesses
   add_keyboard_wait_descriptor (0);
+#endif
 
   Wcm_clear (tty);
 
+#ifdef WINDOWSNT
   {
     struct frame *f = XFRAME (selected_frame);
 
@@ -3388,6 +3423,14 @@
     FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
     FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none;
   }
+#else  /* MSDOS */
+  {
+    int height, width;
+    get_tty_size (fileno (tty->input), &width, &height);
+    FrameCols (tty) = width;
+    FrameRows (tty) = height;
+  }
+#endif	/* MSDOS */
   tty->delete_in_insert_mode = 1;
 
   UseTabs (tty) = 0;
@@ -3397,13 +3440,17 @@
      display.  In doing a trace, it didn't seem to be called much, so I
      don't think we're losing anything by turning it off.  */
   terminal->line_ins_del_ok = 0;
+#ifdef WINDOWSNT
   terminal->char_ins_del_ok = 1;
-
   baud_rate = 19200;
+#else  /* MSDOS */
+  terminal->char_ins_del_ok = 0;
+  init_baud_rate (fileno (tty->input));
+#endif	/* MSDOS */
 
   tty->TN_max_colors = 16;  /* Required to be non-zero for tty-display-color-p */
 
-#else  /* not WINDOWSNT */
+#else  /* not DOS_NT */
 
   Wcm_clear (tty);
 
@@ -3564,7 +3611,7 @@
   tty->TF_underscore = tgetflag ("ul");
   tty->TF_teleray = tgetflag ("xt");
 
-#endif /* !WINDOWSNT  */
+#endif /* !DOS_NT  */
   terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
   init_kboard (terminal->kboard);
   terminal->kboard->Vwindow_system = Qnil;
@@ -3576,7 +3623,7 @@
      prompt in the mini-buffer.  */
   if (current_kboard == initial_kboard)
     current_kboard = terminal->kboard;
-#ifndef WINDOWSNT
+#ifndef DOS_NT
   term_get_fkeys (address, terminal->kboard);
 
   /* Get frame size from system, or else from termcap.  */
@@ -3774,7 +3821,7 @@
   /* Don't do this.  I think termcap may still need the buffer. */
   /* xfree (buffer); */
 
-#endif /* not WINDOWSNT */
+#endif /* not DOS_NT */
 
   /* Init system terminal modes (RAW or CBREAK, etc.).  */
   init_sys_modes (tty);
@@ -3879,7 +3926,9 @@
 
   if (tty->input)
     {
+#ifdef subprocesses
       delete_keyboard_wait_descriptor (fileno (tty->input));
+#endif
       if (tty->input != stdin)
         fclose (tty->input);
     }
@@ -3957,11 +4006,11 @@
   staticpro (&mouse_face_window);
 #endif /* HAVE_GPM */
 
-#ifndef WINDOWSNT
+#ifndef DOS_NT
   default_orig_pair = NULL;
   default_set_foreground = NULL;
   default_set_background = NULL;
-#endif /* WINDOWSNT */
+#endif /* !DOS_NT */
 }