summaryrefslogtreecommitdiff
path: root/src/term.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2008-08-23 16:55:52 +0000
committerEli Zaretskii <eliz@gnu.org>2008-08-23 16:55:52 +0000
commit84704c5c583eaf1008d150da72460bbffd81802e (patch)
tree64bb269fad0fdab68f922b4d4205e5ba82c59e94 /src/term.c
parent3e1944a3d890c2c9a85a7beef0caff322ae2ddec (diff)
downloademacs-84704c5c583eaf1008d150da72460bbffd81802e.tar.gz
[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
Diffstat (limited to 'src/term.c')
-rw-r--r--src/term.c89
1 files changed, 69 insertions, 20 deletions
diff --git a/src/term.c b/src/term.c
index c956766eb36..287133a2d4a 100644
--- a/src/term.c
+++ b/src/term.c
@@ -57,6 +57,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#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 @@ is not on a tty device. */)
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 @@ set_tty_color_mode (tty, f)
}
}
-#endif /* !WINDOWSNT */
+#endif /* !DOS_NT */
@@ -2199,7 +2203,7 @@ get_tty_terminal (Lisp_Object terminal, int throw)
{
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 @@ get_named_tty (name)
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 @@ frame's terminal). */)
{
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 @@ frame's terminal). */)
}
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 @@ is not on a tty device. */)
{
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 @@ A suspended tty may be resumed by calling `resume-tty' on it. */)
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 @@ the currently selected frame. */)
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 @@ the currently selected frame. */)
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 @@ set_tty_hooks (struct terminal *terminal)
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 @@ dissociate_if_controlling_tty (int fd)
#endif /* ! TIOCNOTTY */
#endif /* ! USG */
}
-#endif /* !WINDOWSNT */
+#endif /* !DOS_NT */
}
static void maybe_fatal();
@@ -3288,7 +3304,15 @@ init_tty (char *name, char *terminal_type, int must_succeed)
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 @@ init_tty (char *name, char *terminal_type, int must_succeed)
tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm));
Wcm_clear (tty);
-#ifndef WINDOWSNT
+#ifndef DOS_NT
set_tty_hooks (terminal);
{
@@ -3350,10 +3374,12 @@ init_tty (char *name, char *terminal_type, int must_succeed)
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 @@ init_tty (char *name, char *terminal_type, int must_succeed)
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 @@ init_tty (char *name, char *terminal_type, int must_succeed)
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 @@ init_tty (char *name, char *terminal_type, int must_succeed)
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 @@ init_tty (char *name, char *terminal_type, int must_succeed)
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 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
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 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
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 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
/* 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 @@ delete_tty (struct terminal *terminal)
if (tty->input)
{
+#ifdef subprocesses
delete_keyboard_wait_descriptor (fileno (tty->input));
+#endif
if (tty->input != stdin)
fclose (tty->input);
}
@@ -3957,11 +4006,11 @@ bigger, or it may make it blink, or it may do nothing at all. */);
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 */
}