aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2008-08-23 16:55:52 +0000
committerEli Zaretskii2008-08-23 16:55:52 +0000
commit84704c5c583eaf1008d150da72460bbffd81802e (patch)
tree64bb269fad0fdab68f922b4d4205e5ba82c59e94 /src
parent3e1944a3d890c2c9a85a7beef0caff322ae2ddec (diff)
downloademacs-84704c5c583eaf1008d150da72460bbffd81802e.tar.gz
emacs-84704c5c583eaf1008d150da72460bbffd81802e.zip
[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')
-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/>. */
57#include "syssignal.h" 57#include "syssignal.h"
58#include "systty.h" 58#include "systty.h"
59#include "intervals.h" 59#include "intervals.h"
60#ifdef MSDOS
61#include "msdos.h"
62static int been_here = -1;
63#endif
60 64
61/* For now, don't try to include termcap.h. On some systems, 65/* For now, don't try to include termcap.h. On some systems,
62 configure finds a non-standard termcap.h that the main build 66 configure finds a non-standard termcap.h that the main build
@@ -2067,7 +2071,7 @@ is not on a tty device. */)
2067 return make_number (t->display_info.tty->TN_max_colors); 2071 return make_number (t->display_info.tty->TN_max_colors);
2068} 2072}
2069 2073
2070#ifndef WINDOWSNT 2074#ifndef DOS_NT
2071 2075
2072/* Declare here rather than in the function, as in the rest of Emacs, 2076/* Declare here rather than in the function, as in the rest of Emacs,
2073 to work around an HPUX compiler bug (?). See 2077 to work around an HPUX compiler bug (?). See
@@ -2188,7 +2192,7 @@ set_tty_color_mode (tty, f)
2188 } 2192 }
2189} 2193}
2190 2194
2191#endif /* !WINDOWSNT */ 2195#endif /* !DOS_NT */
2192 2196
2193 2197
2194 2198
@@ -2199,7 +2203,7 @@ get_tty_terminal (Lisp_Object terminal, int throw)
2199{ 2203{
2200 struct terminal *t = get_terminal (terminal, throw); 2204 struct terminal *t = get_terminal (terminal, throw);
2201 2205
2202 if (t && t->type != output_termcap) 2206 if (t && t->type != output_termcap && t->type != output_msdos_raw)
2203 { 2207 {
2204 if (throw) 2208 if (throw)
2205 error ("Device %d is not a termcap terminal device", t->id); 2209 error ("Device %d is not a termcap terminal device", t->id);
@@ -2228,7 +2232,7 @@ get_named_tty (name)
2228 2232
2229 for (t = terminal_list; t; t = t->next_terminal) 2233 for (t = terminal_list; t; t = t->next_terminal)
2230 { 2234 {
2231 if (t->type == output_termcap 2235 if (t->type == output_termcap || t->type == output_msdos_raw
2232 && !strcmp (t->display_info.tty->name, name) 2236 && !strcmp (t->display_info.tty->name, name)
2233 && TERMINAL_ACTIVE_P (t)) 2237 && TERMINAL_ACTIVE_P (t))
2234 return t; 2238 return t;
@@ -2249,7 +2253,7 @@ frame's terminal). */)
2249{ 2253{
2250 struct terminal *t = get_terminal (terminal, 1); 2254 struct terminal *t = get_terminal (terminal, 1);
2251 2255
2252 if (t->type != output_termcap) 2256 if (t->type != output_termcap && t->type != output_msdos_raw)
2253 return Qnil; 2257 return Qnil;
2254 2258
2255 if (t->display_info.tty->type) 2259 if (t->display_info.tty->type)
@@ -2259,7 +2263,7 @@ frame's terminal). */)
2259} 2263}
2260 2264
2261DEFUN ("controlling-tty-p", Fcontrolling_tty_p, Scontrolling_tty_p, 0, 1, 0, 2265DEFUN ("controlling-tty-p", Fcontrolling_tty_p, Scontrolling_tty_p, 0, 1, 0,
2262 doc: /* Return non-nil if TERMINAL is on the controlling tty of the Emacs process. 2266 doc: /* Return non-nil if TERMINAL is the controlling tty of the Emacs process.
2263 2267
2264TERMINAL can be a terminal id, a frame or nil (meaning the selected 2268TERMINAL can be a terminal id, a frame or nil (meaning the selected
2265frame's terminal). This function always returns nil if TERMINAL 2269frame's terminal). This function always returns nil if TERMINAL
@@ -2269,7 +2273,8 @@ is not on a tty device. */)
2269{ 2273{
2270 struct terminal *t = get_terminal (terminal, 1); 2274 struct terminal *t = get_terminal (terminal, 1);
2271 2275
2272 if (t->type != output_termcap || strcmp (t->display_info.tty->name, DEV_TTY)) 2276 if ((t->type != output_termcap && t->type != output_msdos_raw)
2277 || strcmp (t->display_info.tty->name, DEV_TTY) != 0)
2273 return Qnil; 2278 return Qnil;
2274 else 2279 else
2275 return Qt; 2280 return Qt;
@@ -2341,11 +2346,15 @@ A suspended tty may be resumed by calling `resume-tty' on it. */)
2341 2346
2342 reset_sys_modes (t->display_info.tty); 2347 reset_sys_modes (t->display_info.tty);
2343 2348
2349#ifdef subprocesses
2344 delete_keyboard_wait_descriptor (fileno (f)); 2350 delete_keyboard_wait_descriptor (fileno (f));
2351#endif
2345 2352
2353#ifndef MSDOS
2346 fclose (f); 2354 fclose (f);
2347 if (f != t->display_info.tty->output) 2355 if (f != t->display_info.tty->output)
2348 fclose (t->display_info.tty->output); 2356 fclose (t->display_info.tty->output);
2357#endif
2349 2358
2350 t->display_info.tty->input = 0; 2359 t->display_info.tty->input = 0;
2351 t->display_info.tty->output = 0; 2360 t->display_info.tty->output = 0;
@@ -2392,6 +2401,10 @@ the currently selected frame. */)
2392 if (get_named_tty (t->display_info.tty->name)) 2401 if (get_named_tty (t->display_info.tty->name))
2393 error ("Cannot resume display while another display is active on the same device"); 2402 error ("Cannot resume display while another display is active on the same device");
2394 2403
2404#ifdef MSDOS
2405 t->display_info.tty->output = stdout;
2406 t->display_info.tty->input = stdin;
2407#else /* !MSDOS */
2395 fd = emacs_open (t->display_info.tty->name, O_RDWR | O_NOCTTY, 0); 2408 fd = emacs_open (t->display_info.tty->name, O_RDWR | O_NOCTTY, 0);
2396 2409
2397 if (fd == -1) 2410 if (fd == -1)
@@ -2402,8 +2415,11 @@ the currently selected frame. */)
2402 2415
2403 t->display_info.tty->output = fdopen (fd, "w+"); 2416 t->display_info.tty->output = fdopen (fd, "w+");
2404 t->display_info.tty->input = t->display_info.tty->output; 2417 t->display_info.tty->input = t->display_info.tty->output;
2418#endif
2405 2419
2420#ifdef subprocesses
2406 add_keyboard_wait_descriptor (fd); 2421 add_keyboard_wait_descriptor (fd);
2422#endif
2407 2423
2408 if (FRAMEP (t->display_info.tty->top_frame)) 2424 if (FRAMEP (t->display_info.tty->top_frame))
2409 FRAME_SET_VISIBLE (XFRAME (t->display_info.tty->top_frame), 1); 2425 FRAME_SET_VISIBLE (XFRAME (t->display_info.tty->top_frame), 1);
@@ -3211,7 +3227,7 @@ set_tty_hooks (struct terminal *terminal)
3211static void 3227static void
3212dissociate_if_controlling_tty (int fd) 3228dissociate_if_controlling_tty (int fd)
3213{ 3229{
3214#ifndef WINDOWSNT 3230#ifndef DOS_NT
3215 int pgid; 3231 int pgid;
3216 EMACS_GET_TTY_PGRP (fd, &pgid); /* If tcgetpgrp succeeds, fd is the ctty. */ 3232 EMACS_GET_TTY_PGRP (fd, &pgid); /* If tcgetpgrp succeeds, fd is the ctty. */
3217 if (pgid != -1) 3233 if (pgid != -1)
@@ -3239,7 +3255,7 @@ dissociate_if_controlling_tty (int fd)
3239#endif /* ! TIOCNOTTY */ 3255#endif /* ! TIOCNOTTY */
3240#endif /* ! USG */ 3256#endif /* ! USG */
3241 } 3257 }
3242#endif /* !WINDOWSNT */ 3258#endif /* !DOS_NT */
3243} 3259}
3244 3260
3245static void maybe_fatal(); 3261static void maybe_fatal();
@@ -3288,7 +3304,15 @@ init_tty (char *name, char *terminal_type, int must_succeed)
3288 return terminal; 3304 return terminal;
3289 3305
3290 terminal = create_terminal (); 3306 terminal = create_terminal ();
3307#ifdef MSDOS
3308 if (been_here > 0)
3309 maybe_fatal (1, 0, 0, "Attempt to create another terminal %s", "",
3310 name, "");
3311 been_here = 1;
3312 tty = &the_only_display_info;
3313#else
3291 tty = (struct tty_display_info *) xmalloc (sizeof (struct tty_display_info)); 3314 tty = (struct tty_display_info *) xmalloc (sizeof (struct tty_display_info));
3315#endif
3292 bzero (tty, sizeof (struct tty_display_info)); 3316 bzero (tty, sizeof (struct tty_display_info));
3293 tty->next = tty_list; 3317 tty->next = tty_list;
3294 tty_list = tty; 3318 tty_list = tty;
@@ -3300,7 +3324,7 @@ init_tty (char *name, char *terminal_type, int must_succeed)
3300 tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); 3324 tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm));
3301 Wcm_clear (tty); 3325 Wcm_clear (tty);
3302 3326
3303#ifndef WINDOWSNT 3327#ifndef DOS_NT
3304 set_tty_hooks (terminal); 3328 set_tty_hooks (terminal);
3305 3329
3306 { 3330 {
@@ -3350,10 +3374,12 @@ init_tty (char *name, char *terminal_type, int must_succeed)
3350 3374
3351 tty->type = xstrdup (terminal_type); 3375 tty->type = xstrdup (terminal_type);
3352 3376
3377#ifdef subprocesses
3353 add_keyboard_wait_descriptor (fileno (tty->input)); 3378 add_keyboard_wait_descriptor (fileno (tty->input));
3354
3355#endif 3379#endif
3356 3380
3381#endif /* !DOS_NT */
3382
3357 encode_terminal_src_size = 0; 3383 encode_terminal_src_size = 0;
3358 encode_terminal_dst_size = 0; 3384 encode_terminal_dst_size = 0;
3359 3385
@@ -3362,8 +3388,16 @@ init_tty (char *name, char *terminal_type, int must_succeed)
3362 mouse_face_window = Qnil; 3388 mouse_face_window = Qnil;
3363#endif 3389#endif
3364 3390
3391#ifdef DOS_NT
3365#ifdef WINDOWSNT 3392#ifdef WINDOWSNT
3366 initialize_w32_display (terminal); 3393 initialize_w32_display (terminal);
3394#else /* MSDOS */
3395 if (strcmp (terminal_type, "internal") == 0)
3396 terminal->type = output_msdos_raw;
3397 initialize_msdos_display (terminal);
3398#endif /* MSDOS */
3399 tty->output = stdout;
3400 tty->input = stdin;
3367 /* The following two are inaccessible from w32console.c. */ 3401 /* The following two are inaccessible from w32console.c. */
3368 terminal->delete_frame_hook = &delete_tty_output; 3402 terminal->delete_frame_hook = &delete_tty_output;
3369 terminal->delete_terminal_hook = &delete_tty; 3403 terminal->delete_terminal_hook = &delete_tty;
@@ -3372,12 +3406,13 @@ init_tty (char *name, char *terminal_type, int must_succeed)
3372 terminal->name = xstrdup (name); 3406 terminal->name = xstrdup (name);
3373 tty->type = xstrdup (terminal_type); 3407 tty->type = xstrdup (terminal_type);
3374 3408
3375 tty->output = stdout; 3409#ifdef subprocesses
3376 tty->input = stdin;
3377 add_keyboard_wait_descriptor (0); 3410 add_keyboard_wait_descriptor (0);
3411#endif
3378 3412
3379 Wcm_clear (tty); 3413 Wcm_clear (tty);
3380 3414
3415#ifdef WINDOWSNT
3381 { 3416 {
3382 struct frame *f = XFRAME (selected_frame); 3417 struct frame *f = XFRAME (selected_frame);
3383 3418
@@ -3388,6 +3423,14 @@ init_tty (char *name, char *terminal_type, int must_succeed)
3388 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; 3423 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
3389 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; 3424 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none;
3390 } 3425 }
3426#else /* MSDOS */
3427 {
3428 int height, width;
3429 get_tty_size (fileno (tty->input), &width, &height);
3430 FrameCols (tty) = width;
3431 FrameRows (tty) = height;
3432 }
3433#endif /* MSDOS */
3391 tty->delete_in_insert_mode = 1; 3434 tty->delete_in_insert_mode = 1;
3392 3435
3393 UseTabs (tty) = 0; 3436 UseTabs (tty) = 0;
@@ -3397,13 +3440,17 @@ init_tty (char *name, char *terminal_type, int must_succeed)
3397 display. In doing a trace, it didn't seem to be called much, so I 3440 display. In doing a trace, it didn't seem to be called much, so I
3398 don't think we're losing anything by turning it off. */ 3441 don't think we're losing anything by turning it off. */
3399 terminal->line_ins_del_ok = 0; 3442 terminal->line_ins_del_ok = 0;
3443#ifdef WINDOWSNT
3400 terminal->char_ins_del_ok = 1; 3444 terminal->char_ins_del_ok = 1;
3401
3402 baud_rate = 19200; 3445 baud_rate = 19200;
3446#else /* MSDOS */
3447 terminal->char_ins_del_ok = 0;
3448 init_baud_rate (fileno (tty->input));
3449#endif /* MSDOS */
3403 3450
3404 tty->TN_max_colors = 16; /* Required to be non-zero for tty-display-color-p */ 3451 tty->TN_max_colors = 16; /* Required to be non-zero for tty-display-color-p */
3405 3452
3406#else /* not WINDOWSNT */ 3453#else /* not DOS_NT */
3407 3454
3408 Wcm_clear (tty); 3455 Wcm_clear (tty);
3409 3456
@@ -3564,7 +3611,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
3564 tty->TF_underscore = tgetflag ("ul"); 3611 tty->TF_underscore = tgetflag ("ul");
3565 tty->TF_teleray = tgetflag ("xt"); 3612 tty->TF_teleray = tgetflag ("xt");
3566 3613
3567#endif /* !WINDOWSNT */ 3614#endif /* !DOS_NT */
3568 terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); 3615 terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
3569 init_kboard (terminal->kboard); 3616 init_kboard (terminal->kboard);
3570 terminal->kboard->Vwindow_system = Qnil; 3617 terminal->kboard->Vwindow_system = Qnil;
@@ -3576,7 +3623,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
3576 prompt in the mini-buffer. */ 3623 prompt in the mini-buffer. */
3577 if (current_kboard == initial_kboard) 3624 if (current_kboard == initial_kboard)
3578 current_kboard = terminal->kboard; 3625 current_kboard = terminal->kboard;
3579#ifndef WINDOWSNT 3626#ifndef DOS_NT
3580 term_get_fkeys (address, terminal->kboard); 3627 term_get_fkeys (address, terminal->kboard);
3581 3628
3582 /* Get frame size from system, or else from termcap. */ 3629 /* Get frame size from system, or else from termcap. */
@@ -3774,7 +3821,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
3774 /* Don't do this. I think termcap may still need the buffer. */ 3821 /* Don't do this. I think termcap may still need the buffer. */
3775 /* xfree (buffer); */ 3822 /* xfree (buffer); */
3776 3823
3777#endif /* not WINDOWSNT */ 3824#endif /* not DOS_NT */
3778 3825
3779 /* Init system terminal modes (RAW or CBREAK, etc.). */ 3826 /* Init system terminal modes (RAW or CBREAK, etc.). */
3780 init_sys_modes (tty); 3827 init_sys_modes (tty);
@@ -3879,7 +3926,9 @@ delete_tty (struct terminal *terminal)
3879 3926
3880 if (tty->input) 3927 if (tty->input)
3881 { 3928 {
3929#ifdef subprocesses
3882 delete_keyboard_wait_descriptor (fileno (tty->input)); 3930 delete_keyboard_wait_descriptor (fileno (tty->input));
3931#endif
3883 if (tty->input != stdin) 3932 if (tty->input != stdin)
3884 fclose (tty->input); 3933 fclose (tty->input);
3885 } 3934 }
@@ -3957,11 +4006,11 @@ bigger, or it may make it blink, or it may do nothing at all. */);
3957 staticpro (&mouse_face_window); 4006 staticpro (&mouse_face_window);
3958#endif /* HAVE_GPM */ 4007#endif /* HAVE_GPM */
3959 4008
3960#ifndef WINDOWSNT 4009#ifndef DOS_NT
3961 default_orig_pair = NULL; 4010 default_orig_pair = NULL;
3962 default_set_foreground = NULL; 4011 default_set_foreground = NULL;
3963 default_set_background = NULL; 4012 default_set_background = NULL;
3964#endif /* WINDOWSNT */ 4013#endif /* !DOS_NT */
3965} 4014}
3966 4015
3967 4016