diff options
| author | Karoly Lorentey | 2004-01-09 18:57:53 +0000 |
|---|---|---|
| committer | Karoly Lorentey | 2004-01-09 18:57:53 +0000 |
| commit | 3224dac1b8a3929f02ebea7766ed04704810586b (patch) | |
| tree | 59ca226110bd1c50909f389fd2b037494b4dd1b2 /src | |
| parent | 08c8c725b26298d9d4fb035b4c456f10ac6adc1b (diff) | |
| download | emacs-3224dac1b8a3929f02ebea7766ed04704810586b.tar.gz emacs-3224dac1b8a3929f02ebea7766ed04704810586b.zip | |
Hookified termcap devices, added bootstrap display device, plus many bugfixes.
lisp/frame.el (display-color-cells): Pass display parameter to tty-display-color-cells.
lisp/term/xterm.el (xterm-register-default-colors): Pass the selected-frame to display-color-cells.
src/dispextern.h (set_terminal_modes, reset_terminal_modes): Removed declarations.
(get_named_tty_display): New prototype.
(tty_clear_end_of_line, term_init): Updated to new prototype.
(initial_term_init): Renamed to init_initial_display.
src/dispnew.c (Fredraw_frame): ifdef-out DOS-specific code. Add display parameter to set_terminal_modes call.
(update_frame): Don't flush the tty of there is no tty.
(init_display): Set up a termcap display on the controlling tty and
change the initial frame to use that. Delete the initial display.
src/frame.c (Fframep): Return t for the initial frame.
(make_initial_frame): New function for creating the initial frame during bootstrap. Use init_initial_display, not initial_term_init.
(make_terminal_frame): Removed special cases for creating the initial frame.
src/frame.h (enum output_method): New entry: output_initial for the bootstrap display.
(FRAME_INITIAL_P): New macro.
(make_initial_frame): New prototype.
src/keyboard.c (interrupt_signal): Exit Emacs on SIGINT from the (frameless) controlling tty, if possible. Explain this in a comment.
(init_keyboard): Added comment about exiting on SIGINT.
(Fset_input_mode): A termcap frame is never the initial frame anymore.
src/sysdep.c (init_sys_modes): Update tty_set_terminal_modes call to the new prototype.
(reset_sys_modes): Comment out tty_clear_end_of_line call; it doesn't work anymore. Update tty_reset_terminal_modes call.
src/termchar.h (struct tty_display_info): Added pointer to the display structure, for reset_sys_modes.
src/termhooks.h (struct display): Added display parameter to set_terminal_modes_hook and reset_terminal_modes_hook.
src/term.c (initial_display): New variable.
(tty_ring_bell, tty_update_end, tty_set_terminal_window, tty_cursor_to)
(tty_raw_cursor_to, tty_clear_to_end, tty_clear_frame, tty_clear_end_of_line)
(tty_write_glyphs, tty_insert_glyphs, tty_delete_glyphs, tty_ins_del_lines): New functions.
(ring_bell, update_end, set_terminal_window, cursor_to, raw_cursor_to)
(clear_to_end, clear_frame, clear_end_of_line, write_glyphs, insert_glyphs)
(delete_glyphs, ins_del_lines): Removed special casing of termcap displays.
(get_tty_display): New function.
(Ftty_display_color_p, Ftty_display_color_cells): Use it.
(get_named_tty_display): Removed static.
(tty_set_terminal_modes, tty_reset_terminal_modes): Changed to use a display parameter
instead of tty_display_info for hook compatibility.
(set_terminal_modes, reset_terminal_modes): Removed.
(initial_term_init): Renamed to init_initial_display. Set up an
output_initial device, not a termcap display.
(delete_initial_display): New function.
(maybe_fatal): New function, for private use of term_init.
(term_init): New parameter for choosing between fatal and simple errors.
Removed incomprehensible special casing for the second initialization of the
controlling tty. Use maybe_fatal for error handling.
Initialize termcap display hooks in the new device.
Initialize the display pointer in the tty_display_info structure.
(delete_tty): Replace order of reset_sys_modes and delete_display.
src/window.c (init_window_once): Call make_initial_frame instead of make_terminal_frame.
src/xfaces.c (realize_default_face, realize_face): Don't abort on the bootstrap display device.
src/xterm.c (XTset_terminal_modes, XTreset_terminal_modes): Added display parameter.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-48
Diffstat (limited to 'src')
| -rw-r--r-- | src/dispextern.h | 9 | ||||
| -rw-r--r-- | src/dispnew.c | 31 | ||||
| -rw-r--r-- | src/frame.c | 57 | ||||
| -rw-r--r-- | src/frame.h | 5 | ||||
| -rw-r--r-- | src/keyboard.c | 27 | ||||
| -rw-r--r-- | src/sysdep.c | 6 | ||||
| -rw-r--r-- | src/term.c | 722 | ||||
| -rw-r--r-- | src/termchar.h | 3 | ||||
| -rw-r--r-- | src/termhooks.h | 4 | ||||
| -rw-r--r-- | src/window.c | 2 | ||||
| -rw-r--r-- | src/xfaces.c | 6 | ||||
| -rw-r--r-- | src/xterm.c | 8 |
12 files changed, 550 insertions, 330 deletions
diff --git a/src/dispextern.h b/src/dispextern.h index a6c14da3f65..a30a86f2c7b 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -2728,8 +2728,6 @@ extern Lisp_Object Qredisplay_dont_pause; | |||
| 2728 | /* Defined in term.c */ | 2728 | /* Defined in term.c */ |
| 2729 | 2729 | ||
| 2730 | extern void ring_bell P_ ((void)); | 2730 | extern void ring_bell P_ ((void)); |
| 2731 | extern void set_terminal_modes P_ ((void)); | ||
| 2732 | extern void reset_terminal_modes P_ ((void)); | ||
| 2733 | extern void update_begin P_ ((struct frame *)); | 2731 | extern void update_begin P_ ((struct frame *)); |
| 2734 | extern void update_end P_ ((struct frame *)); | 2732 | extern void update_end P_ ((struct frame *)); |
| 2735 | extern void set_terminal_window P_ ((int)); | 2733 | extern void set_terminal_window P_ ((int)); |
| @@ -2740,7 +2738,7 @@ extern void background_highlight P_ ((struct tty_display_info *)); | |||
| 2740 | extern void clear_frame P_ ((void)); | 2738 | extern void clear_frame P_ ((void)); |
| 2741 | extern void clear_end_of_line P_ ((int)); | 2739 | extern void clear_end_of_line P_ ((int)); |
| 2742 | extern void clear_end_of_line_raw P_ ((int)); | 2740 | extern void clear_end_of_line_raw P_ ((int)); |
| 2743 | extern void tty_clear_end_of_line P_ ((struct tty_display_info *, int)); | 2741 | extern void tty_clear_end_of_line P_ ((int)); |
| 2744 | extern void delete_glyphs P_ ((int)); | 2742 | extern void delete_glyphs P_ ((int)); |
| 2745 | extern void ins_del_lines P_ ((int, int)); | 2743 | extern void ins_del_lines P_ ((int, int)); |
| 2746 | extern int string_cost P_ ((char *)); | 2744 | extern int string_cost P_ ((char *)); |
| @@ -2748,8 +2746,9 @@ extern int per_line_cost P_ ((char *)); | |||
| 2748 | extern void calculate_costs P_ ((struct frame *)); | 2746 | extern void calculate_costs P_ ((struct frame *)); |
| 2749 | extern void set_tty_color_mode P_ ((struct frame *, Lisp_Object)); | 2747 | extern void set_tty_color_mode P_ ((struct frame *, Lisp_Object)); |
| 2750 | extern void tty_setup_colors P_ ((struct tty_display_info *, int)); | 2748 | extern void tty_setup_colors P_ ((struct tty_display_info *, int)); |
| 2751 | extern struct display *term_init P_ ((char *, char *)); | 2749 | extern struct display *get_named_tty_display P_ ((char *)); |
| 2752 | extern struct display *initial_term_init P_ ((void)); | 2750 | extern struct display *init_initial_display P_ ((void)); |
| 2751 | extern struct display *term_init P_ ((char *, char *, int)); | ||
| 2753 | extern void fatal P_ ((/* char *, ... */)); | 2752 | extern void fatal P_ ((/* char *, ... */)); |
| 2754 | void cursor_to P_ ((int, int)); | 2753 | void cursor_to P_ ((int, int)); |
| 2755 | extern int tty_capable_p P_ ((struct tty_display_info *, unsigned, unsigned long, unsigned long)); | 2754 | extern int tty_capable_p P_ ((struct tty_display_info *, unsigned, unsigned long, unsigned long)); |
diff --git a/src/dispnew.c b/src/dispnew.c index 3fbd8305365..72669aadc61 100644 --- a/src/dispnew.c +++ b/src/dispnew.c | |||
| @@ -3306,8 +3306,10 @@ DEFUN ("redraw-frame", Fredraw_frame, Sredraw_frame, 1, 1, 0, | |||
| 3306 | return Qnil; | 3306 | return Qnil; |
| 3307 | 3307 | ||
| 3308 | update_begin (f); | 3308 | update_begin (f); |
| 3309 | #ifdef MSDOS | ||
| 3309 | if (FRAME_MSDOS_P (f)) | 3310 | if (FRAME_MSDOS_P (f)) |
| 3310 | set_terminal_modes (); | 3311 | set_terminal_modes (FRAME_DISPLAY (f)); |
| 3312 | #endif | ||
| 3311 | clear_frame (); | 3313 | clear_frame (); |
| 3312 | clear_current_matrices (f); | 3314 | clear_current_matrices (f); |
| 3313 | update_end (f); | 3315 | update_end (f); |
| @@ -3833,9 +3835,12 @@ update_frame (f, force_p, inhibit_hairy_id_p) | |||
| 3833 | paused_p = update_frame_1 (f, force_p, inhibit_hairy_id_p); | 3835 | paused_p = update_frame_1 (f, force_p, inhibit_hairy_id_p); |
| 3834 | update_end (f); | 3836 | update_end (f); |
| 3835 | 3837 | ||
| 3836 | if (TTY_TERMSCRIPT (FRAME_TTY (f))) | 3838 | if (FRAME_TERMCAP_P (f)) |
| 3837 | fflush (TTY_TERMSCRIPT (FRAME_TTY (f))); | 3839 | { |
| 3838 | fflush (TTY_OUTPUT (FRAME_TTY (f))); | 3840 | if (TTY_TERMSCRIPT (FRAME_TTY (f))) |
| 3841 | fflush (TTY_TERMSCRIPT (FRAME_TTY (f))); | ||
| 3842 | fflush (TTY_OUTPUT (FRAME_TTY (f))); | ||
| 3843 | } | ||
| 3839 | 3844 | ||
| 3840 | /* Check window matrices for lost pointers. */ | 3845 | /* Check window matrices for lost pointers. */ |
| 3841 | #if GLYPH_DEBUG | 3846 | #if GLYPH_DEBUG |
| @@ -6634,10 +6639,24 @@ For types not defined in VMS, use define emacs_term \"TYPE\".\n\ | |||
| 6634 | 6639 | ||
| 6635 | { | 6640 | { |
| 6636 | struct display *d; | 6641 | struct display *d; |
| 6637 | 6642 | struct frame *f = XFRAME (selected_frame); | |
| 6638 | d = term_init (0, terminal_type); | 6643 | |
| 6644 | /* Open a display on the controlling tty. */ | ||
| 6645 | d = term_init (0, terminal_type, 1); /* Errors are fatal. */ | ||
| 6646 | |||
| 6647 | /* Convert the initial frame to use the new display. */ | ||
| 6648 | if (! f->output_method == output_initial) | ||
| 6649 | abort (); | ||
| 6650 | f->output_method = d->type; | ||
| 6651 | f->display = d; | ||
| 6652 | |||
| 6639 | d->display_info.tty->top_frame = selected_frame; | 6653 | d->display_info.tty->top_frame = selected_frame; |
| 6640 | change_frame_size (XFRAME (selected_frame), FrameRows (d->display_info.tty), FrameCols (d->display_info.tty), 0, 0, 1); | 6654 | change_frame_size (XFRAME (selected_frame), FrameRows (d->display_info.tty), FrameCols (d->display_info.tty), 0, 0, 1); |
| 6655 | |||
| 6656 | /* Delete the initial display. */ | ||
| 6657 | if (--initial_display->reference_count == 0 | ||
| 6658 | && initial_display->delete_display_hook) | ||
| 6659 | (*initial_display->delete_display_hook) (initial_display); | ||
| 6641 | } | 6660 | } |
| 6642 | 6661 | ||
| 6643 | { | 6662 | { |
diff --git a/src/frame.c b/src/frame.c index 86c26b9d86b..57b9af19704 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -202,6 +202,7 @@ See also `frame-live-p'. */) | |||
| 202 | return Qnil; | 202 | return Qnil; |
| 203 | switch (XFRAME (object)->output_method) | 203 | switch (XFRAME (object)->output_method) |
| 204 | { | 204 | { |
| 205 | case output_initial: /* The initial frame is like a termcap frame. */ | ||
| 205 | case output_termcap: | 206 | case output_termcap: |
| 206 | return Qt; | 207 | return Qt; |
| 207 | case output_x_window: | 208 | case output_x_window: |
| @@ -502,15 +503,12 @@ make_minibuffer_frame () | |||
| 502 | static int terminal_frame_count; | 503 | static int terminal_frame_count; |
| 503 | 504 | ||
| 504 | struct frame * | 505 | struct frame * |
| 505 | make_terminal_frame (tty_name, tty_type) | 506 | make_initial_frame (void) |
| 506 | char *tty_name; | ||
| 507 | char *tty_type; | ||
| 508 | { | 507 | { |
| 509 | register struct frame *f; | 508 | struct frame *f; |
| 510 | struct display *display; | 509 | struct display *display; |
| 511 | Lisp_Object frame; | 510 | Lisp_Object frame; |
| 512 | char name[20]; | 511 | |
| 513 | |||
| 514 | #ifdef MULTI_KBOARD | 512 | #ifdef MULTI_KBOARD |
| 515 | /* Create the initial keyboard. */ | 513 | /* Create the initial keyboard. */ |
| 516 | if (!initial_kboard) | 514 | if (!initial_kboard) |
| @@ -526,12 +524,51 @@ make_terminal_frame (tty_name, tty_type) | |||
| 526 | if (! (NILP (Vframe_list) || CONSP (Vframe_list))) | 524 | if (! (NILP (Vframe_list) || CONSP (Vframe_list))) |
| 527 | Vframe_list = Qnil; | 525 | Vframe_list = Qnil; |
| 528 | 526 | ||
| 527 | display = init_initial_display (); | ||
| 528 | |||
| 529 | f = make_frame (1); | ||
| 530 | XSETFRAME (frame, f); | ||
| 531 | |||
| 532 | Vframe_list = Fcons (frame, Vframe_list); | ||
| 533 | |||
| 534 | terminal_frame_count = 1; | ||
| 535 | f->name = build_string ("F1"); | ||
| 536 | |||
| 537 | f->visible = 1; | ||
| 538 | f->async_visible = 1; | ||
| 539 | |||
| 540 | f->output_method = display->type; | ||
| 541 | f->display = display; | ||
| 542 | f->display->reference_count++; | ||
| 543 | f->output_data.nothing = 0; | ||
| 544 | |||
| 545 | FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR; | ||
| 546 | FRAME_BACKGROUND_PIXEL (f) = FACE_TTY_DEFAULT_BG_COLOR; | ||
| 547 | |||
| 548 | FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; | ||
| 549 | FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; | ||
| 550 | |||
| 551 | #ifdef MULTI_KBOARD | ||
| 552 | f->kboard = initial_kboard; | ||
| 553 | #endif | ||
| 554 | |||
| 555 | return f; | ||
| 556 | } | ||
| 557 | |||
| 558 | |||
| 559 | struct frame * | ||
| 560 | make_terminal_frame (tty_name, tty_type) | ||
| 561 | char *tty_name; | ||
| 562 | char *tty_type; | ||
| 563 | { | ||
| 564 | register struct frame *f; | ||
| 565 | struct display *display; | ||
| 566 | Lisp_Object frame; | ||
| 567 | char name[20]; | ||
| 568 | |||
| 529 | /* Open the display before creating the new frame, because | 569 | /* Open the display before creating the new frame, because |
| 530 | create_tty_display might throw an error. */ | 570 | create_tty_display might throw an error. */ |
| 531 | if (initialized) | 571 | display = term_init (tty_name, tty_type, 0); /* Errors are not fatal. */ |
| 532 | display = term_init (tty_name, tty_type); | ||
| 533 | else | ||
| 534 | display = initial_term_init (); | ||
| 535 | 572 | ||
| 536 | f = make_frame (1); | 573 | f = make_frame (1); |
| 537 | 574 | ||
diff --git a/src/frame.h b/src/frame.h index 9b6d6afa1e6..0b58420b18d 100644 --- a/src/frame.h +++ b/src/frame.h | |||
| @@ -41,6 +41,7 @@ extern int message_buf_print; | |||
| 41 | 41 | ||
| 42 | enum output_method | 42 | enum output_method |
| 43 | { | 43 | { |
| 44 | output_initial, | ||
| 44 | output_termcap, | 45 | output_termcap, |
| 45 | output_x_window, | 46 | output_x_window, |
| 46 | output_msdos_raw, | 47 | output_msdos_raw, |
| @@ -462,6 +463,7 @@ typedef struct frame *FRAME_PTR; | |||
| 462 | #define WINDOW_FRAME(w) (w)->frame | 463 | #define WINDOW_FRAME(w) (w)->frame |
| 463 | 464 | ||
| 464 | /* Test a frame for particular kinds of display methods. */ | 465 | /* Test a frame for particular kinds of display methods. */ |
| 466 | #define FRAME_INITIAL_P(f) ((f)->output_method == output_initial) | ||
| 465 | #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap) | 467 | #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap) |
| 466 | #define FRAME_X_P(f) ((f)->output_method == output_x_window) | 468 | #define FRAME_X_P(f) ((f)->output_method == output_x_window) |
| 467 | #define FRAME_W32_P(f) ((f)->output_method == output_w32) | 469 | #define FRAME_W32_P(f) ((f)->output_method == output_w32) |
| @@ -771,7 +773,8 @@ extern Lisp_Object Qframep, Qframe_live_p; | |||
| 771 | 773 | ||
| 772 | extern struct frame *last_nonminibuf_frame; | 774 | extern struct frame *last_nonminibuf_frame; |
| 773 | 775 | ||
| 774 | extern struct frame *make_terminal_frame P_ ((char *tty, char *tty_type)); | 776 | extern struct frame *make_initial_frame P_ ((void)); |
| 777 | extern struct frame *make_terminal_frame P_ ((char *, char *)); | ||
| 775 | extern struct frame *make_frame P_ ((int)); | 778 | extern struct frame *make_frame P_ ((int)); |
| 776 | #ifdef HAVE_WINDOW_SYSTEM | 779 | #ifdef HAVE_WINDOW_SYSTEM |
| 777 | extern struct frame *make_minibuffer_frame P_ ((void)); | 780 | extern struct frame *make_minibuffer_frame P_ ((void)); |
diff --git a/src/keyboard.c b/src/keyboard.c index fdd0447a649..dd939f32af6 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -10281,8 +10281,26 @@ interrupt_signal (signalnum) /* If we don't have an argument, */ | |||
| 10281 | signal (SIGQUIT, interrupt_signal); | 10281 | signal (SIGQUIT, interrupt_signal); |
| 10282 | #endif /* USG */ | 10282 | #endif /* USG */ |
| 10283 | 10283 | ||
| 10284 | if (! tty_list) | ||
| 10285 | { | ||
| 10286 | /* If there are no tty frames, exit Emacs. | ||
| 10287 | |||
| 10288 | Emacs should exit on SIGINT if and only if there are no | ||
| 10289 | frames on its controlling tty and the signal came from there. | ||
| 10290 | We can check for the first condition, but (alas) not for the | ||
| 10291 | second. The best we can do is that we only exit if we are | ||
| 10292 | sure that the SIGINT was from the controlling tty, i.e., if | ||
| 10293 | there are no termcap frames. | ||
| 10294 | */ | ||
| 10295 | Fkill_emacs (Qnil); | ||
| 10296 | |||
| 10297 | errno = old_errno; | ||
| 10298 | return; | ||
| 10299 | } | ||
| 10300 | |||
| 10284 | cancel_echoing (); | 10301 | cancel_echoing (); |
| 10285 | 10302 | ||
| 10303 | /* XXX This code needs to be revised for multi-tty support. */ | ||
| 10286 | if (!NILP (Vquit_flag) | 10304 | if (!NILP (Vquit_flag) |
| 10287 | && (FRAME_TERMCAP_P (sf) || FRAME_MSDOS_P (sf))) | 10305 | && (FRAME_TERMCAP_P (sf) || FRAME_MSDOS_P (sf))) |
| 10288 | { | 10306 | { |
| @@ -10463,7 +10481,7 @@ See also `current-input-mode'. */) | |||
| 10463 | 10481 | ||
| 10464 | #ifndef DOS_NT | 10482 | #ifndef DOS_NT |
| 10465 | /* this causes startup screen to be restored and messes with the mouse */ | 10483 | /* this causes startup screen to be restored and messes with the mouse */ |
| 10466 | if (FRAME_TERMCAP_P (SELECTED_FRAME ()) && CURTTY ()->type) | 10484 | if (FRAME_TERMCAP_P (SELECTED_FRAME ())) |
| 10467 | reset_sys_modes (CURTTY ()); | 10485 | reset_sys_modes (CURTTY ()); |
| 10468 | #endif | 10486 | #endif |
| 10469 | 10487 | ||
| @@ -10502,7 +10520,7 @@ See also `current-input-mode'. */) | |||
| 10502 | tty->meta_key = 2; | 10520 | tty->meta_key = 2; |
| 10503 | } | 10521 | } |
| 10504 | 10522 | ||
| 10505 | if (!NILP (quit)) | 10523 | if (FRAME_TERMCAP_P (XFRAME (selected_frame)) && !NILP (quit)) |
| 10506 | /* Don't let this value be out of range. */ | 10524 | /* Don't let this value be out of range. */ |
| 10507 | quit_char = XINT (quit) & (CURTTY ()->meta_key ? 0377 : 0177); | 10525 | quit_char = XINT (quit) & (CURTTY ()->meta_key ? 0377 : 0177); |
| 10508 | 10526 | ||
| @@ -10660,6 +10678,11 @@ init_keyboard () | |||
| 10660 | 10678 | ||
| 10661 | if (!noninteractive) | 10679 | if (!noninteractive) |
| 10662 | { | 10680 | { |
| 10681 | /* Before multi-tty support, these handlers used to be installed | ||
| 10682 | only if the current session was a tty session. Now an Emacs | ||
| 10683 | session may have multiple display types, so we always handle | ||
| 10684 | SIGINT. There is special code in interrupt_signal to exit | ||
| 10685 | Emacs on SIGINT when there are no termcap frames. */ | ||
| 10663 | signal (SIGINT, interrupt_signal); | 10686 | signal (SIGINT, interrupt_signal); |
| 10664 | #if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS) | 10687 | #if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS) |
| 10665 | /* For systems with SysV TERMIO, C-g is set up for both SIGINT and | 10688 | /* For systems with SysV TERMIO, C-g is set up for both SIGINT and |
diff --git a/src/sysdep.c b/src/sysdep.c index d5c72c52dde..fbbc20c2e72 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -1689,7 +1689,7 @@ nil means don't delete them until `list-processes' is run. */); | |||
| 1689 | ) | 1689 | ) |
| 1690 | #endif | 1690 | #endif |
| 1691 | #endif | 1691 | #endif |
| 1692 | tty_set_terminal_modes (tty_out); | 1692 | tty_set_terminal_modes (tty_out->display); |
| 1693 | 1693 | ||
| 1694 | if (!tty_out->term_initted) | 1694 | if (!tty_out->term_initted) |
| 1695 | { | 1695 | { |
| @@ -1869,7 +1869,9 @@ reset_sys_modes (tty_out) | |||
| 1869 | #endif | 1869 | #endif |
| 1870 | 1870 | ||
| 1871 | cmgoto (tty_out, FrameRows (tty_out) - 1, 0); | 1871 | cmgoto (tty_out, FrameRows (tty_out) - 1, 0); |
| 1872 | #if 0 /* XXX This doesn't work anymore, the signature has changed. */ | ||
| 1872 | tty_clear_end_of_line (tty_out, FrameCols (tty_out)); | 1873 | tty_clear_end_of_line (tty_out, FrameCols (tty_out)); |
| 1874 | #endif | ||
| 1873 | cmgoto (tty_out, FrameRows (tty_out) - 1, 0); | 1875 | cmgoto (tty_out, FrameRows (tty_out) - 1, 0); |
| 1874 | fflush (tty_out->output); | 1876 | fflush (tty_out->output); |
| 1875 | 1877 | ||
| @@ -1884,7 +1886,7 @@ reset_sys_modes (tty_out) | |||
| 1884 | } | 1886 | } |
| 1885 | #endif | 1887 | #endif |
| 1886 | 1888 | ||
| 1887 | tty_reset_terminal_modes (tty_out); | 1889 | tty_reset_terminal_modes (tty_out->display); |
| 1888 | fflush (TTY_OUTPUT (tty_out)); | 1890 | fflush (TTY_OUTPUT (tty_out)); |
| 1889 | #ifdef BSD_SYSTEM | 1891 | #ifdef BSD_SYSTEM |
| 1890 | #ifndef BSD4_1 | 1892 | #ifndef BSD4_1 |
diff --git a/src/term.c b/src/term.c index 178ded7fc85..753067430f2 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -71,6 +71,7 @@ static void turn_off_face P_ ((struct frame *, int face_id)); | |||
| 71 | static void tty_show_cursor P_ ((struct tty_display_info *)); | 71 | static void tty_show_cursor P_ ((struct tty_display_info *)); |
| 72 | static void tty_hide_cursor P_ ((struct tty_display_info *)); | 72 | static void tty_hide_cursor P_ ((struct tty_display_info *)); |
| 73 | 73 | ||
| 74 | void delete_initial_display P_ ((struct display *)); | ||
| 74 | void delete_tty P_ ((struct display *)); | 75 | void delete_tty P_ ((struct display *)); |
| 75 | void create_tty_output P_ ((struct frame *)); | 76 | void create_tty_output P_ ((struct frame *)); |
| 76 | void delete_tty_output P_ ((struct frame *)); | 77 | void delete_tty_output P_ ((struct frame *)); |
| @@ -105,6 +106,9 @@ Lisp_Object Vdelete_tty_after_functions; | |||
| 105 | /* Chain of all displays currently in use. */ | 106 | /* Chain of all displays currently in use. */ |
| 106 | struct display *display_list; | 107 | struct display *display_list; |
| 107 | 108 | ||
| 109 | /* The initial display device, created by initial_term_init. */ | ||
| 110 | struct display *initial_display; | ||
| 111 | |||
| 108 | /* Chain of all tty device parameters. */ | 112 | /* Chain of all tty device parameters. */ |
| 109 | struct tty_display_info *tty_list; | 113 | struct tty_display_info *tty_list; |
| 110 | 114 | ||
| @@ -172,7 +176,9 @@ extern char *tgetstr (); | |||
| 172 | void | 176 | void |
| 173 | ring_bell () | 177 | ring_bell () |
| 174 | { | 178 | { |
| 175 | struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | 179 | struct frame *f = (updating_frame |
| 180 | ? updating_frame | ||
| 181 | : XFRAME (selected_frame)); | ||
| 176 | 182 | ||
| 177 | if (!NILP (Vring_bell_function)) | 183 | if (!NILP (Vring_bell_function)) |
| 178 | { | 184 | { |
| @@ -195,32 +201,36 @@ ring_bell () | |||
| 195 | } | 201 | } |
| 196 | else if (FRAME_DISPLAY (f)->ring_bell_hook) | 202 | else if (FRAME_DISPLAY (f)->ring_bell_hook) |
| 197 | (*FRAME_DISPLAY (f)->ring_bell_hook) (); | 203 | (*FRAME_DISPLAY (f)->ring_bell_hook) (); |
| 198 | else { | ||
| 199 | struct tty_display_info *tty = FRAME_TTY (f); | ||
| 200 | OUTPUT (tty, tty->TS_visible_bell && visible_bell ? tty->TS_visible_bell : tty->TS_bell); | ||
| 201 | } | ||
| 202 | } | 204 | } |
| 203 | 205 | ||
| 204 | void tty_set_terminal_modes (struct tty_display_info *tty) | 206 | void |
| 207 | tty_ring_bell () | ||
| 208 | { | ||
| 209 | struct frame *f = (updating_frame | ||
| 210 | ? updating_frame | ||
| 211 | : XFRAME (selected_frame)); | ||
| 212 | |||
| 213 | struct tty_display_info *tty = FRAME_TTY (f); | ||
| 214 | |||
| 215 | OUTPUT (tty, (tty->TS_visible_bell && visible_bell | ||
| 216 | ? tty->TS_visible_bell | ||
| 217 | : tty->TS_bell)); | ||
| 218 | } | ||
| 219 | |||
| 220 | void tty_set_terminal_modes (struct display *display) | ||
| 205 | { | 221 | { |
| 222 | struct tty_display_info *tty = display->display_info.tty; | ||
| 223 | |||
| 206 | OUTPUT_IF (tty, tty->TS_termcap_modes); | 224 | OUTPUT_IF (tty, tty->TS_termcap_modes); |
| 207 | OUTPUT_IF (tty, tty->TS_cursor_visible); | 225 | OUTPUT_IF (tty, tty->TS_cursor_visible); |
| 208 | OUTPUT_IF (tty, tty->TS_keypad_mode); | 226 | OUTPUT_IF (tty, tty->TS_keypad_mode); |
| 209 | losecursor (tty); | 227 | losecursor (tty); |
| 210 | } | 228 | } |
| 211 | 229 | ||
| 212 | void | 230 | void tty_reset_terminal_modes (struct display *display) |
| 213 | set_terminal_modes () | ||
| 214 | { | ||
| 215 | struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | ||
| 216 | if (FRAME_DISPLAY (f)->set_terminal_modes_hook) | ||
| 217 | (*FRAME_DISPLAY (f)->set_terminal_modes_hook) (); | ||
| 218 | else | ||
| 219 | tty_set_terminal_modes (FRAME_TTY (f)); | ||
| 220 | } | ||
| 221 | |||
| 222 | void tty_reset_terminal_modes (struct tty_display_info *tty) | ||
| 223 | { | 231 | { |
| 232 | struct tty_display_info *tty = display->display_info.tty; | ||
| 233 | |||
| 224 | turn_off_highlight (tty); | 234 | turn_off_highlight (tty); |
| 225 | turn_off_insert (tty); | 235 | turn_off_insert (tty); |
| 226 | OUTPUT_IF (tty, tty->TS_end_keypad_mode); | 236 | OUTPUT_IF (tty, tty->TS_end_keypad_mode); |
| @@ -233,16 +243,6 @@ void tty_reset_terminal_modes (struct tty_display_info *tty) | |||
| 233 | } | 243 | } |
| 234 | 244 | ||
| 235 | void | 245 | void |
| 236 | reset_terminal_modes () | ||
| 237 | { | ||
| 238 | struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | ||
| 239 | if (FRAME_DISPLAY (f)->reset_terminal_modes_hook) | ||
| 240 | (*FRAME_DISPLAY (f)->reset_terminal_modes_hook) (); | ||
| 241 | else | ||
| 242 | tty_reset_terminal_modes (FRAME_TTY (f)); | ||
| 243 | } | ||
| 244 | |||
| 245 | void | ||
| 246 | update_begin (f) | 246 | update_begin (f) |
| 247 | struct frame *f; | 247 | struct frame *f; |
| 248 | { | 248 | { |
| @@ -257,32 +257,44 @@ update_end (f) | |||
| 257 | { | 257 | { |
| 258 | if (FRAME_DISPLAY (f)->update_end_hook) | 258 | if (FRAME_DISPLAY (f)->update_end_hook) |
| 259 | (*FRAME_DISPLAY (f)->update_end_hook) (f); | 259 | (*FRAME_DISPLAY (f)->update_end_hook) (f); |
| 260 | else if (FRAME_TERMCAP_P (f)) | ||
| 261 | { | ||
| 262 | struct tty_display_info *tty = FRAME_TTY (f); | ||
| 263 | if (!XWINDOW (selected_window)->cursor_off_p) | ||
| 264 | tty_show_cursor (tty); | ||
| 265 | turn_off_insert (tty); | ||
| 266 | background_highlight (tty); | ||
| 267 | } | ||
| 268 | |||
| 269 | updating_frame = NULL; | 260 | updating_frame = NULL; |
| 270 | } | 261 | } |
| 271 | 262 | ||
| 272 | void | 263 | void |
| 264 | tty_update_end (struct frame *f) | ||
| 265 | { | ||
| 266 | struct tty_display_info *tty = FRAME_TTY (f); | ||
| 267 | |||
| 268 | if (!XWINDOW (selected_window)->cursor_off_p) | ||
| 269 | tty_show_cursor (tty); | ||
| 270 | turn_off_insert (tty); | ||
| 271 | background_highlight (tty); | ||
| 272 | } | ||
| 273 | |||
| 274 | void | ||
| 273 | set_terminal_window (size) | 275 | set_terminal_window (size) |
| 274 | int size; | 276 | int size; |
| 275 | { | 277 | { |
| 276 | struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | 278 | struct frame *f = (updating_frame |
| 279 | ? updating_frame | ||
| 280 | : XFRAME (selected_frame)); | ||
| 281 | |||
| 277 | if (FRAME_DISPLAY (f)->set_terminal_window_hook) | 282 | if (FRAME_DISPLAY (f)->set_terminal_window_hook) |
| 278 | (*FRAME_DISPLAY (f)->set_terminal_window_hook) (size); | 283 | (*FRAME_DISPLAY (f)->set_terminal_window_hook) (size); |
| 279 | else if (FRAME_TERMCAP_P (f)) | 284 | } |
| 280 | { | 285 | |
| 281 | struct tty_display_info *tty = FRAME_TTY (f); | 286 | void |
| 282 | tty->specified_window = size ? size : FRAME_LINES (f); | 287 | tty_set_terminal_window (int size) |
| 283 | if (FRAME_SCROLL_REGION_OK (f)) | 288 | { |
| 284 | set_scroll_region (0, tty->specified_window); | 289 | struct frame *f = (updating_frame |
| 285 | } | 290 | ? updating_frame |
| 291 | : XFRAME (selected_frame)); | ||
| 292 | |||
| 293 | struct tty_display_info *tty = FRAME_TTY (f); | ||
| 294 | |||
| 295 | tty->specified_window = size ? size : FRAME_LINES (f); | ||
| 296 | if (FRAME_SCROLL_REGION_OK (f)) | ||
| 297 | set_scroll_region (0, tty->specified_window); | ||
| 286 | } | 298 | } |
| 287 | 299 | ||
| 288 | void | 300 | void |
| @@ -290,7 +302,10 @@ set_scroll_region (start, stop) | |||
| 290 | int start, stop; | 302 | int start, stop; |
| 291 | { | 303 | { |
| 292 | char *buf; | 304 | char *buf; |
| 293 | struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | 305 | struct frame *f = (updating_frame |
| 306 | ? updating_frame | ||
| 307 | : XFRAME (selected_frame)); | ||
| 308 | |||
| 294 | struct tty_display_info *tty = FRAME_TTY (f); | 309 | struct tty_display_info *tty = FRAME_TTY (f); |
| 295 | 310 | ||
| 296 | if (tty->TS_set_scroll_region) | 311 | if (tty->TS_set_scroll_region) |
| @@ -412,16 +427,22 @@ void | |||
| 412 | cursor_to (vpos, hpos) | 427 | cursor_to (vpos, hpos) |
| 413 | int vpos, hpos; | 428 | int vpos, hpos; |
| 414 | { | 429 | { |
| 415 | struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | 430 | struct frame *f = (updating_frame |
| 416 | struct tty_display_info *tty; | 431 | ? updating_frame |
| 432 | : XFRAME (selected_frame)); | ||
| 417 | 433 | ||
| 418 | if (FRAME_DISPLAY (f)->cursor_to_hook) | 434 | if (FRAME_DISPLAY (f)->cursor_to_hook) |
| 419 | { | 435 | (*FRAME_DISPLAY (f)->cursor_to_hook) (vpos, hpos); |
| 420 | (*FRAME_DISPLAY (f)->cursor_to_hook) (vpos, hpos); | 436 | } |
| 421 | return; | ||
| 422 | } | ||
| 423 | 437 | ||
| 424 | tty = FRAME_TTY (f); | 438 | void |
| 439 | tty_cursor_to (int vpos, int hpos) | ||
| 440 | { | ||
| 441 | struct frame *f = (updating_frame | ||
| 442 | ? updating_frame | ||
| 443 | : XFRAME (selected_frame)); | ||
| 444 | |||
| 445 | struct tty_display_info *tty = FRAME_TTY (f); | ||
| 425 | 446 | ||
| 426 | /* Detect the case where we are called from reset_sys_modes | 447 | /* Detect the case where we are called from reset_sys_modes |
| 427 | and the costs have never been calculated. Do nothing. */ | 448 | and the costs have never been calculated. Do nothing. */ |
| @@ -444,14 +465,23 @@ void | |||
| 444 | raw_cursor_to (row, col) | 465 | raw_cursor_to (row, col) |
| 445 | int row, col; | 466 | int row, col; |
| 446 | { | 467 | { |
| 447 | struct frame *f = updating_frame ? updating_frame : XFRAME (selected_frame); | 468 | struct frame *f = (updating_frame |
| 448 | struct tty_display_info *tty; | 469 | ? updating_frame |
| 470 | : XFRAME (selected_frame)); | ||
| 471 | |||
| 449 | if (FRAME_DISPLAY (f)->raw_cursor_to_hook) | 472 | if (FRAME_DISPLAY (f)->raw_cursor_to_hook) |
| 450 | { | 473 | (*FRAME_DISPLAY (f)->raw_cursor_to_hook) (row, col); |
| 451 | (*FRAME_DISPLAY (f)->raw_cursor_to_hook) (row, col); | 474 | } |
| 452 | return; | 475 | |
| 453 | } | 476 | void |
| 454 | tty = FRAME_TTY (f); | 477 | tty_raw_cursor_to (int row, int col) |
| 478 | { | ||
| 479 | struct frame *f = (updating_frame | ||
| 480 | ? updating_frame | ||
| 481 | : XFRAME (selected_frame)); | ||
| 482 | |||
| 483 | struct tty_display_info *tty = FRAME_TTY (f); | ||
| 484 | |||
| 455 | if (curY (tty) == row | 485 | if (curY (tty) == row |
| 456 | && curX (tty) == col) | 486 | && curX (tty) == col) |
| 457 | return; | 487 | return; |
| @@ -468,17 +498,23 @@ raw_cursor_to (row, col) | |||
| 468 | void | 498 | void |
| 469 | clear_to_end () | 499 | clear_to_end () |
| 470 | { | 500 | { |
| 471 | register int i; | 501 | struct frame *f = (updating_frame |
| 472 | 502 | ? updating_frame | |
| 473 | struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | 503 | : XFRAME (selected_frame)); |
| 474 | struct tty_display_info *tty; | ||
| 475 | 504 | ||
| 476 | if (FRAME_DISPLAY (f)->clear_to_end_hook) | 505 | if (FRAME_DISPLAY (f)->clear_to_end_hook) |
| 477 | { | 506 | (*FRAME_DISPLAY (f)->clear_to_end_hook) (); |
| 478 | (*FRAME_DISPLAY (f)->clear_to_end_hook) (); | 507 | } |
| 479 | return; | 508 | |
| 480 | } | 509 | void |
| 481 | tty = FRAME_TTY (f); | 510 | tty_clear_to_end (void) |
| 511 | { | ||
| 512 | register int i; | ||
| 513 | struct frame *f = (updating_frame | ||
| 514 | ? updating_frame | ||
| 515 | : XFRAME (selected_frame)); | ||
| 516 | struct tty_display_info *tty = FRAME_TTY (f); | ||
| 517 | |||
| 482 | if (tty->TS_clr_to_bottom) | 518 | if (tty->TS_clr_to_bottom) |
| 483 | { | 519 | { |
| 484 | background_highlight (tty); | 520 | background_highlight (tty); |
| @@ -500,14 +536,20 @@ void | |||
| 500 | clear_frame () | 536 | clear_frame () |
| 501 | { | 537 | { |
| 502 | struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | 538 | struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); |
| 503 | struct tty_display_info *tty; | ||
| 504 | 539 | ||
| 505 | if (FRAME_DISPLAY (f)->clear_frame_hook) | 540 | if (FRAME_DISPLAY (f)->clear_frame_hook) |
| 506 | { | 541 | (*FRAME_DISPLAY (f)->clear_frame_hook) (); |
| 507 | (*FRAME_DISPLAY (f)->clear_frame_hook) (); | 542 | } |
| 508 | return; | 543 | |
| 509 | } | 544 | void |
| 510 | tty = FRAME_TTY (f); | 545 | tty_clear_frame () |
| 546 | { | ||
| 547 | struct frame *f = (updating_frame | ||
| 548 | ? updating_frame | ||
| 549 | : XFRAME (selected_frame)); | ||
| 550 | |||
| 551 | struct tty_display_info *tty = FRAME_TTY (f); | ||
| 552 | |||
| 511 | if (tty->TS_clr_frame) | 553 | if (tty->TS_clr_frame) |
| 512 | { | 554 | { |
| 513 | background_highlight (tty); | 555 | background_highlight (tty); |
| @@ -530,22 +572,23 @@ void | |||
| 530 | clear_end_of_line (first_unused_hpos) | 572 | clear_end_of_line (first_unused_hpos) |
| 531 | int first_unused_hpos; | 573 | int first_unused_hpos; |
| 532 | { | 574 | { |
| 533 | struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | 575 | struct frame *f = (updating_frame |
| 534 | struct tty_display_info *tty; | 576 | ? updating_frame |
| 577 | : XFRAME (selected_frame)); | ||
| 535 | 578 | ||
| 536 | if (FRAME_DISPLAY (f)->clear_end_of_line_hook) | 579 | if (FRAME_DISPLAY (f)->clear_end_of_line_hook) |
| 537 | { | 580 | (*FRAME_DISPLAY (f)->clear_end_of_line_hook) (first_unused_hpos); |
| 538 | (*FRAME_DISPLAY (f)->clear_end_of_line_hook) (first_unused_hpos); | ||
| 539 | return; | ||
| 540 | } | ||
| 541 | |||
| 542 | tty_clear_end_of_line (FRAME_TTY (f), first_unused_hpos); | ||
| 543 | } | 581 | } |
| 544 | 582 | ||
| 545 | void | 583 | void |
| 546 | tty_clear_end_of_line (struct tty_display_info *tty, int first_unused_hpos) | 584 | tty_clear_end_of_line (int first_unused_hpos) |
| 547 | { | 585 | { |
| 548 | register int i; | 586 | register int i; |
| 587 | struct frame *f = (updating_frame | ||
| 588 | ? updating_frame | ||
| 589 | : XFRAME (selected_frame)); | ||
| 590 | struct tty_display_info *tty = FRAME_TTY (f); | ||
| 591 | |||
| 549 | /* Detect the case where we are called from reset_sys_modes | 592 | /* Detect the case where we are called from reset_sys_modes |
| 550 | and the costs have never been calculated. Do nothing. */ | 593 | and the costs have never been calculated. Do nothing. */ |
| 551 | if (! tty->costs_set) | 594 | if (! tty->costs_set) |
| @@ -692,19 +735,26 @@ write_glyphs (string, len) | |||
| 692 | register struct glyph *string; | 735 | register struct glyph *string; |
| 693 | register int len; | 736 | register int len; |
| 694 | { | 737 | { |
| 738 | struct frame *f = (updating_frame | ||
| 739 | ? updating_frame | ||
| 740 | : XFRAME (selected_frame)); | ||
| 741 | |||
| 742 | if (FRAME_DISPLAY (f)->write_glyphs_hook) | ||
| 743 | (*FRAME_DISPLAY (f)->write_glyphs_hook) (string, len); | ||
| 744 | } | ||
| 745 | |||
| 746 | void | ||
| 747 | tty_write_glyphs (struct glyph *string, int len) | ||
| 748 | { | ||
| 695 | int produced, consumed; | 749 | int produced, consumed; |
| 696 | struct frame *f = updating_frame ? updating_frame : XFRAME (selected_frame); | ||
| 697 | struct tty_display_info *tty; | ||
| 698 | unsigned char conversion_buffer[1024]; | 750 | unsigned char conversion_buffer[1024]; |
| 699 | int conversion_buffer_size = sizeof conversion_buffer; | 751 | int conversion_buffer_size = sizeof conversion_buffer; |
| 700 | 752 | ||
| 701 | if (FRAME_DISPLAY (f)->write_glyphs_hook) | 753 | struct frame *f = (updating_frame |
| 702 | { | 754 | ? updating_frame |
| 703 | (*FRAME_DISPLAY (f)->write_glyphs_hook) (string, len); | 755 | : XFRAME (selected_frame)); |
| 704 | return; | ||
| 705 | } | ||
| 706 | 756 | ||
| 707 | tty = FRAME_TTY (f); | 757 | struct tty_display_info *tty = FRAME_TTY (f); |
| 708 | 758 | ||
| 709 | turn_off_insert (tty); | 759 | turn_off_insert (tty); |
| 710 | tty_hide_cursor (tty); | 760 | tty_hide_cursor (tty); |
| @@ -795,23 +845,27 @@ insert_glyphs (start, len) | |||
| 795 | register struct glyph *start; | 845 | register struct glyph *start; |
| 796 | register int len; | 846 | register int len; |
| 797 | { | 847 | { |
| 798 | char *buf; | 848 | struct frame *f = (updating_frame |
| 799 | struct glyph *glyph = NULL; | 849 | ? updating_frame |
| 800 | struct frame *f; | 850 | : XFRAME (selected_frame)); |
| 801 | struct tty_display_info *tty; | ||
| 802 | 851 | ||
| 803 | if (len <= 0) | 852 | if (len <= 0) |
| 804 | return; | 853 | return; |
| 805 | 854 | ||
| 806 | f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | ||
| 807 | |||
| 808 | if (FRAME_DISPLAY (f)->insert_glyphs_hook) | 855 | if (FRAME_DISPLAY (f)->insert_glyphs_hook) |
| 809 | { | 856 | (*FRAME_DISPLAY (f)->insert_glyphs_hook) (start, len); |
| 810 | (*FRAME_DISPLAY (f)->insert_glyphs_hook) (start, len); | 857 | } |
| 811 | return; | ||
| 812 | } | ||
| 813 | 858 | ||
| 814 | tty = FRAME_TTY (f); | 859 | void |
| 860 | tty_insert_glyphs (struct glyph *start, int len) | ||
| 861 | { | ||
| 862 | char *buf; | ||
| 863 | struct glyph *glyph = NULL; | ||
| 864 | struct frame *f = (updating_frame | ||
| 865 | ? updating_frame | ||
| 866 | : XFRAME (selected_frame)); | ||
| 867 | |||
| 868 | struct tty_display_info *tty = FRAME_TTY (f); | ||
| 815 | 869 | ||
| 816 | if (tty->TS_ins_multi_chars) | 870 | if (tty->TS_ins_multi_chars) |
| 817 | { | 871 | { |
| @@ -889,17 +943,24 @@ void | |||
| 889 | delete_glyphs (n) | 943 | delete_glyphs (n) |
| 890 | register int n; | 944 | register int n; |
| 891 | { | 945 | { |
| 892 | char *buf; | 946 | struct frame *f = (updating_frame |
| 893 | register int i; | 947 | ? updating_frame |
| 894 | struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | 948 | : XFRAME (selected_frame)); |
| 895 | struct tty_display_info *tty = FRAME_TTY (f); | ||
| 896 | 949 | ||
| 897 | if (FRAME_DISPLAY (f)->delete_glyphs_hook) | 950 | if (FRAME_DISPLAY (f)->delete_glyphs_hook) |
| 898 | { | 951 | (*FRAME_DISPLAY (f)->delete_glyphs_hook) (n); |
| 899 | (*FRAME_DISPLAY (f)->delete_glyphs_hook) (n); | 952 | } |
| 900 | return; | ||
| 901 | } | ||
| 902 | 953 | ||
| 954 | void | ||
| 955 | tty_delete_glyphs (int n) | ||
| 956 | { | ||
| 957 | char *buf; | ||
| 958 | register int i; | ||
| 959 | struct frame *f = (updating_frame | ||
| 960 | ? updating_frame | ||
| 961 | : XFRAME (selected_frame)); | ||
| 962 | |||
| 963 | struct tty_display_info *tty = FRAME_TTY (f); | ||
| 903 | 964 | ||
| 904 | if (tty->delete_in_insert_mode) | 965 | if (tty->delete_in_insert_mode) |
| 905 | { | 966 | { |
| @@ -930,73 +991,79 @@ void | |||
| 930 | ins_del_lines (vpos, n) | 991 | ins_del_lines (vpos, n) |
| 931 | int vpos, n; | 992 | int vpos, n; |
| 932 | { | 993 | { |
| 933 | struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | 994 | struct frame *f = (updating_frame |
| 995 | ? updating_frame | ||
| 996 | : XFRAME (selected_frame)); | ||
| 997 | |||
| 934 | if (FRAME_DISPLAY (f)->ins_del_lines_hook) | 998 | if (FRAME_DISPLAY (f)->ins_del_lines_hook) |
| 999 | (*FRAME_DISPLAY (f)->ins_del_lines_hook) (vpos, n); | ||
| 1000 | } | ||
| 1001 | |||
| 1002 | void | ||
| 1003 | tty_ins_del_lines (int vpos, int n) | ||
| 1004 | { | ||
| 1005 | struct frame *f = (updating_frame | ||
| 1006 | ? updating_frame | ||
| 1007 | : XFRAME (selected_frame)); | ||
| 1008 | |||
| 1009 | struct tty_display_info *tty = FRAME_TTY (f); | ||
| 1010 | char *multi = n > 0 ? tty->TS_ins_multi_lines : tty->TS_del_multi_lines; | ||
| 1011 | char *single = n > 0 ? tty->TS_ins_line : tty->TS_del_line; | ||
| 1012 | char *scroll = n > 0 ? tty->TS_rev_scroll : tty->TS_fwd_scroll; | ||
| 1013 | |||
| 1014 | register int i = n > 0 ? n : -n; | ||
| 1015 | register char *buf; | ||
| 1016 | |||
| 1017 | /* If the lines below the insertion are being pushed | ||
| 1018 | into the end of the window, this is the same as clearing; | ||
| 1019 | and we know the lines are already clear, since the matching | ||
| 1020 | deletion has already been done. So can ignore this. */ | ||
| 1021 | /* If the lines below the deletion are blank lines coming | ||
| 1022 | out of the end of the window, don't bother, | ||
| 1023 | as there will be a matching inslines later that will flush them. */ | ||
| 1024 | if (FRAME_SCROLL_REGION_OK (f) | ||
| 1025 | && vpos + i >= tty->specified_window) | ||
| 1026 | return; | ||
| 1027 | if (!FRAME_MEMORY_BELOW_FRAME (f) | ||
| 1028 | && vpos + i >= FRAME_LINES (f)) | ||
| 1029 | return; | ||
| 1030 | |||
| 1031 | if (multi) | ||
| 935 | { | 1032 | { |
| 936 | (*FRAME_DISPLAY (f)->ins_del_lines_hook) (vpos, n); | 1033 | raw_cursor_to (vpos, 0); |
| 937 | return; | 1034 | background_highlight (tty); |
| 1035 | buf = tparam (multi, 0, 0, i); | ||
| 1036 | OUTPUT (tty, buf); | ||
| 1037 | xfree (buf); | ||
| 1038 | } | ||
| 1039 | else if (single) | ||
| 1040 | { | ||
| 1041 | raw_cursor_to (vpos, 0); | ||
| 1042 | background_highlight (tty); | ||
| 1043 | while (--i >= 0) | ||
| 1044 | OUTPUT (tty, single); | ||
| 1045 | if (tty->TF_teleray) | ||
| 1046 | curX (tty) = 0; | ||
| 938 | } | 1047 | } |
| 939 | else | 1048 | else |
| 940 | { | 1049 | { |
| 941 | struct tty_display_info *tty = FRAME_TTY (f); | 1050 | set_scroll_region (vpos, tty->specified_window); |
| 942 | char *multi = n > 0 ? tty->TS_ins_multi_lines : tty->TS_del_multi_lines; | 1051 | if (n < 0) |
| 943 | char *single = n > 0 ? tty->TS_ins_line : tty->TS_del_line; | 1052 | raw_cursor_to (tty->specified_window - 1, 0); |
| 944 | char *scroll = n > 0 ? tty->TS_rev_scroll : tty->TS_fwd_scroll; | ||
| 945 | |||
| 946 | register int i = n > 0 ? n : -n; | ||
| 947 | register char *buf; | ||
| 948 | |||
| 949 | /* If the lines below the insertion are being pushed | ||
| 950 | into the end of the window, this is the same as clearing; | ||
| 951 | and we know the lines are already clear, since the matching | ||
| 952 | deletion has already been done. So can ignore this. */ | ||
| 953 | /* If the lines below the deletion are blank lines coming | ||
| 954 | out of the end of the window, don't bother, | ||
| 955 | as there will be a matching inslines later that will flush them. */ | ||
| 956 | if (FRAME_SCROLL_REGION_OK (f) | ||
| 957 | && vpos + i >= tty->specified_window) | ||
| 958 | return; | ||
| 959 | if (!FRAME_MEMORY_BELOW_FRAME (f) | ||
| 960 | && vpos + i >= FRAME_LINES (f)) | ||
| 961 | return; | ||
| 962 | |||
| 963 | if (multi) | ||
| 964 | { | ||
| 965 | raw_cursor_to (vpos, 0); | ||
| 966 | background_highlight (tty); | ||
| 967 | buf = tparam (multi, 0, 0, i); | ||
| 968 | OUTPUT (tty, buf); | ||
| 969 | xfree (buf); | ||
| 970 | } | ||
| 971 | else if (single) | ||
| 972 | { | ||
| 973 | raw_cursor_to (vpos, 0); | ||
| 974 | background_highlight (tty); | ||
| 975 | while (--i >= 0) | ||
| 976 | OUTPUT (tty, single); | ||
| 977 | if (tty->TF_teleray) | ||
| 978 | curX (tty) = 0; | ||
| 979 | } | ||
| 980 | else | 1053 | else |
| 981 | { | 1054 | raw_cursor_to (vpos, 0); |
| 982 | set_scroll_region (vpos, tty->specified_window); | 1055 | background_highlight (tty); |
| 983 | if (n < 0) | 1056 | while (--i >= 0) |
| 984 | raw_cursor_to (tty->specified_window - 1, 0); | 1057 | OUTPUTL (tty, scroll, tty->specified_window - vpos); |
| 985 | else | 1058 | set_scroll_region (0, tty->specified_window); |
| 986 | raw_cursor_to (vpos, 0); | 1059 | } |
| 987 | background_highlight (tty); | 1060 | |
| 988 | while (--i >= 0) | 1061 | if (!FRAME_SCROLL_REGION_OK (f) |
| 989 | OUTPUTL (tty, scroll, tty->specified_window - vpos); | 1062 | && FRAME_MEMORY_BELOW_FRAME (f) |
| 990 | set_scroll_region (0, tty->specified_window); | 1063 | && n < 0) |
| 991 | } | 1064 | { |
| 992 | 1065 | cursor_to (FRAME_LINES (f) + n, 0); | |
| 993 | if (!FRAME_SCROLL_REGION_OK (f) | 1066 | clear_to_end (); |
| 994 | && FRAME_MEMORY_BELOW_FRAME (f) | ||
| 995 | && n < 0) | ||
| 996 | { | ||
| 997 | cursor_to (FRAME_LINES (f) + n, 0); | ||
| 998 | clear_to_end (); | ||
| 999 | } | ||
| 1000 | } | 1067 | } |
| 1001 | } | 1068 | } |
| 1002 | 1069 | ||
| @@ -1809,6 +1876,48 @@ tty_capable_p (tty, caps, fg, bg) | |||
| 1809 | return 1; | 1876 | return 1; |
| 1810 | } | 1877 | } |
| 1811 | 1878 | ||
| 1879 | /* Return the tty display object specified by DISPLAY. | ||
| 1880 | DISPLAY may be a frame or a string. */ | ||
| 1881 | |||
| 1882 | static struct display * | ||
| 1883 | get_tty_display (Lisp_Object display) | ||
| 1884 | { | ||
| 1885 | struct display *d; | ||
| 1886 | |||
| 1887 | if (! FRAMEP (display) && ! STRINGP (display)) | ||
| 1888 | return 0; | ||
| 1889 | |||
| 1890 | /* The initial frame does not support colors. */ | ||
| 1891 | if (FRAMEP (display) && FRAME_INITIAL_P (XFRAME (display))) | ||
| 1892 | return 0; | ||
| 1893 | |||
| 1894 | if (FRAMEP (display)) | ||
| 1895 | { | ||
| 1896 | if (! FRAME_TERMCAP_P (XFRAME (display))) | ||
| 1897 | #if 0 /* XXX We need a predicate as the first argument; find one. */ | ||
| 1898 | wrong_type_argument ("Not a termcap frame", display); | ||
| 1899 | #else /* Until we fix the wrong_type_argument call above, simply throw | ||
| 1900 | a dumb error. */ | ||
| 1901 | error ("DISPLAY is not a termcap frame"); | ||
| 1902 | #endif | ||
| 1903 | |||
| 1904 | d = FRAME_DISPLAY (XFRAME (display)); | ||
| 1905 | } | ||
| 1906 | else if (STRINGP (display)) | ||
| 1907 | { | ||
| 1908 | char *name = (char *) alloca (SBYTES (display) + 1); | ||
| 1909 | strncpy (name, SDATA (display), SBYTES (display)); | ||
| 1910 | name[SBYTES (display)] = 0; | ||
| 1911 | |||
| 1912 | d = get_named_tty_display (name); | ||
| 1913 | |||
| 1914 | if (!d) | ||
| 1915 | error ("There is no tty display on %s", name); | ||
| 1916 | } | ||
| 1917 | |||
| 1918 | return d; | ||
| 1919 | } | ||
| 1920 | |||
| 1812 | 1921 | ||
| 1813 | /* Return non-zero if the terminal is capable to display colors. */ | 1922 | /* Return non-zero if the terminal is capable to display colors. */ |
| 1814 | 1923 | ||
| @@ -1818,13 +1927,11 @@ DEFUN ("tty-display-color-p", Ftty_display_color_p, Stty_display_color_p, | |||
| 1818 | (display) | 1927 | (display) |
| 1819 | Lisp_Object display; | 1928 | Lisp_Object display; |
| 1820 | { | 1929 | { |
| 1821 | struct tty_display_info *tty; | 1930 | struct display *d = get_tty_display (display); |
| 1822 | 1931 | if (!d) | |
| 1823 | if (! FRAMEP (display)) | ||
| 1824 | return Qnil; | 1932 | return Qnil; |
| 1825 | 1933 | else | |
| 1826 | tty = FRAME_TTY (XFRAME (display)); | 1934 | return d->display_info.tty->TN_max_colors > 0 ? Qt : Qnil; |
| 1827 | return tty->TN_max_colors > 0 ? Qt : Qnil; | ||
| 1828 | } | 1935 | } |
| 1829 | 1936 | ||
| 1830 | /* Return the number of supported colors. */ | 1937 | /* Return the number of supported colors. */ |
| @@ -1834,13 +1941,11 @@ DEFUN ("tty-display-color-cells", Ftty_display_color_cells, | |||
| 1834 | (display) | 1941 | (display) |
| 1835 | Lisp_Object display; | 1942 | Lisp_Object display; |
| 1836 | { | 1943 | { |
| 1837 | struct tty_display_info *tty; | 1944 | struct display *d = get_tty_display (display); |
| 1838 | 1945 | if (!d) | |
| 1839 | if (! FRAMEP (display)) | ||
| 1840 | return Qnil; | 1946 | return Qnil; |
| 1841 | 1947 | else | |
| 1842 | tty = FRAME_TTY (XFRAME (display)); | 1948 | return make_number (d->display_info.tty->TN_max_colors); |
| 1843 | return make_number (tty->TN_max_colors); | ||
| 1844 | } | 1949 | } |
| 1845 | 1950 | ||
| 1846 | #ifndef WINDOWSNT | 1951 | #ifndef WINDOWSNT |
| @@ -1982,7 +2087,7 @@ set_tty_color_mode (f, val) | |||
| 1982 | 2087 | ||
| 1983 | 2088 | ||
| 1984 | 2089 | ||
| 1985 | static struct display * | 2090 | struct display * |
| 1986 | get_named_tty_display (name) | 2091 | get_named_tty_display (name) |
| 1987 | char *name; | 2092 | char *name; |
| 1988 | { | 2093 | { |
| @@ -2058,33 +2163,50 @@ DEFUN ("frame-tty-type", Fframe_tty_type, Sframe_tty_type, 0, 1, 0, | |||
| 2058 | Initialization | 2163 | Initialization |
| 2059 | ***********************************************************************/ | 2164 | ***********************************************************************/ |
| 2060 | 2165 | ||
| 2166 | /* Create the bootstrap display device for the initial frame. | ||
| 2167 | |||
| 2168 | Returns a display of type output_initial. */ | ||
| 2061 | struct display * | 2169 | struct display * |
| 2062 | initial_term_init (void) | 2170 | init_initial_display (void) |
| 2063 | { | 2171 | { |
| 2172 | struct tty_display_info *tty; | ||
| 2173 | |||
| 2064 | if (initialized || display_list || tty_list) | 2174 | if (initialized || display_list || tty_list) |
| 2065 | abort (); | 2175 | abort (); |
| 2066 | 2176 | ||
| 2067 | display_list = create_display (); | 2177 | initial_display = create_display (); |
| 2068 | 2178 | initial_display->type = output_initial; | |
| 2069 | tty_list = xmalloc (sizeof (struct tty_display_info)); | ||
| 2070 | bzero (tty_list, sizeof (struct tty_display_info)); | ||
| 2071 | tty_list->name = 0; | ||
| 2072 | tty_list->input = stdin; | ||
| 2073 | tty_list->output = stdout; | ||
| 2074 | tty_list->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); | ||
| 2075 | #ifdef MULTI_KBOARD | ||
| 2076 | tty_list->kboard = initial_kboard; | ||
| 2077 | #endif | ||
| 2078 | 2179 | ||
| 2079 | display_list->type = output_termcap; | 2180 | initial_display->delete_display_hook = &delete_initial_display; |
| 2080 | display_list->display_info.tty = tty_list; | 2181 | /* All other hooks are NULL. */ |
| 2081 | 2182 | ||
| 2082 | return display_list; | 2183 | return initial_display; |
| 2184 | } | ||
| 2185 | |||
| 2186 | /* Deletes the bootstrap display device. | ||
| 2187 | Called through delete_display_hook. */ | ||
| 2188 | void | ||
| 2189 | delete_initial_display (struct display *display) | ||
| 2190 | { | ||
| 2191 | if (display != initial_display) | ||
| 2192 | abort (); | ||
| 2193 | |||
| 2194 | delete_display (display); | ||
| 2195 | initial_display = NULL; | ||
| 2083 | } | 2196 | } |
| 2084 | 2197 | ||
| 2198 | /* Create a termcap display on the tty device with the given name and | ||
| 2199 | type. | ||
| 2200 | |||
| 2201 | If NAME is NULL, then use the controlling tty, i.e., stdin/stdout. | ||
| 2202 | Otherwise NAME should be a path to the tty device file, | ||
| 2203 | e.g. "/dev/pts/7". | ||
| 2085 | 2204 | ||
| 2205 | TERMINAL_TYPE is the termcap type of the device, e.g. "vt100". | ||
| 2206 | |||
| 2207 | If MUST_SUCCEED is true, then all errors are fatal. */ | ||
| 2086 | struct display * | 2208 | struct display * |
| 2087 | term_init (char *name, char *terminal_type) | 2209 | term_init (char *name, char *terminal_type, int must_succeed) |
| 2088 | { | 2210 | { |
| 2089 | char *area; | 2211 | char *area; |
| 2090 | char **address = &area; | 2212 | char **address = &area; |
| @@ -2095,39 +2217,65 @@ term_init (char *name, char *terminal_type) | |||
| 2095 | struct tty_display_info *tty; | 2217 | struct tty_display_info *tty; |
| 2096 | struct display *display; | 2218 | struct display *display; |
| 2097 | 2219 | ||
| 2220 | static void maybe_fatal(); | ||
| 2221 | |||
| 2222 | if (!terminal_type) | ||
| 2223 | maybe_fatal (must_succeed, 0, 0, | ||
| 2224 | "Unknown terminal type", | ||
| 2225 | "Unknown terminal type"); | ||
| 2226 | |||
| 2098 | display = get_named_tty_display (name); | 2227 | display = get_named_tty_display (name); |
| 2099 | if (display) | 2228 | if (display) |
| 2100 | { | 2229 | return display; /* We have already opened a display there. */ |
| 2101 | tty = display->display_info.tty; | ||
| 2102 | 2230 | ||
| 2103 | /* Return the previously initialized terminal, except if it is | 2231 | display = create_display (); |
| 2104 | the dummy terminal created for the initial frame. */ | 2232 | tty = (struct tty_display_info *) xmalloc (sizeof (struct tty_display_info)); |
| 2105 | if (tty->type) | 2233 | bzero (tty, sizeof (struct tty_display_info)); |
| 2106 | return display; | 2234 | tty->next = tty_list; |
| 2107 | 2235 | tty_list = tty; | |
| 2108 | /* Free up temporary structures. */ | ||
| 2109 | if (tty->Wcm) | ||
| 2110 | xfree (tty->Wcm); | ||
| 2111 | if (tty->kboard != initial_kboard) | ||
| 2112 | abort (); | ||
| 2113 | tty->kboard = 0; | ||
| 2114 | } | ||
| 2115 | else | ||
| 2116 | { | ||
| 2117 | display = create_display (); | ||
| 2118 | tty = (struct tty_display_info *) xmalloc (sizeof (struct tty_display_info)); | ||
| 2119 | bzero (tty, sizeof (struct tty_display_info)); | ||
| 2120 | tty->next = tty_list; | ||
| 2121 | tty_list = tty; | ||
| 2122 | 2236 | ||
| 2123 | display->type = output_termcap; | 2237 | display->type = output_termcap; |
| 2124 | display->display_info.tty = tty; | 2238 | display->display_info.tty = tty; |
| 2125 | } | 2239 | tty->display = display; |
| 2126 | 2240 | ||
| 2127 | tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); | 2241 | tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); |
| 2128 | Wcm_clear (tty); | 2242 | Wcm_clear (tty); |
| 2129 | 2243 | ||
| 2130 | display->rif = 0; /* ttys don't support window-based redisplay. */ | 2244 | display->rif = 0; /* ttys don't support window-based redisplay. */ |
| 2245 | |||
| 2246 | display->cursor_to_hook = &tty_cursor_to; | ||
| 2247 | display->raw_cursor_to_hook = &tty_raw_cursor_to; | ||
| 2248 | |||
| 2249 | display->clear_to_end_hook = &tty_clear_to_end; | ||
| 2250 | display->clear_frame_hook = &tty_clear_frame; | ||
| 2251 | display->clear_end_of_line_hook = &tty_clear_end_of_line; | ||
| 2252 | |||
| 2253 | display->ins_del_lines_hook = &tty_ins_del_lines; | ||
| 2254 | |||
| 2255 | display->insert_glyphs_hook = &tty_insert_glyphs; | ||
| 2256 | display->write_glyphs_hook = &tty_write_glyphs; | ||
| 2257 | display->delete_glyphs_hook = &tty_delete_glyphs; | ||
| 2258 | |||
| 2259 | display->ring_bell_hook = &tty_ring_bell; | ||
| 2260 | |||
| 2261 | display->reset_terminal_modes_hook = &tty_reset_terminal_modes; | ||
| 2262 | display->set_terminal_modes_hook = &tty_set_terminal_modes; | ||
| 2263 | display->update_begin_hook = 0; /* Not needed. */ | ||
| 2264 | display->update_end_hook = &tty_update_end; | ||
| 2265 | display->set_terminal_window_hook = &tty_set_terminal_window; | ||
| 2266 | |||
| 2267 | display->mouse_position_hook = 0; /* Not needed. */ | ||
| 2268 | display->frame_rehighlight_hook = 0; /* Not needed. */ | ||
| 2269 | display->frame_raise_lower_hook = 0; /* Not needed. */ | ||
| 2270 | |||
| 2271 | display->set_vertical_scroll_bar_hook = 0; /* Not needed. */ | ||
| 2272 | display->condemn_scroll_bars_hook = 0; /* Not needed. */ | ||
| 2273 | display->redeem_scroll_bar_hook = 0; /* Not needed. */ | ||
| 2274 | display->judge_scroll_bars_hook = 0; /* Not needed. */ | ||
| 2275 | |||
| 2276 | display->read_socket_hook = 0; /* Not needed. */ | ||
| 2277 | display->frame_up_to_date_hook = 0; /* Not needed. */ | ||
| 2278 | |||
| 2131 | display->delete_frame_hook = &delete_tty_output; | 2279 | display->delete_frame_hook = &delete_tty_output; |
| 2132 | display->delete_display_hook = &delete_tty; | 2280 | display->delete_display_hook = &delete_tty; |
| 2133 | 2281 | ||
| @@ -2196,55 +2344,35 @@ term_init (char *name, char *terminal_type) | |||
| 2196 | if (status < 0) | 2344 | if (status < 0) |
| 2197 | { | 2345 | { |
| 2198 | #ifdef TERMINFO | 2346 | #ifdef TERMINFO |
| 2199 | if (name) | 2347 | maybe_fatal (must_succeed, buffer, display, |
| 2200 | { | 2348 | "Cannot open terminfo database file", |
| 2201 | xfree (buffer); | 2349 | "Cannot open terminfo database file"); |
| 2202 | delete_tty (display); | ||
| 2203 | error ("Cannot open terminfo database file"); | ||
| 2204 | } | ||
| 2205 | else | ||
| 2206 | fatal ("Cannot open terminfo database file"); | ||
| 2207 | #else | 2350 | #else |
| 2208 | if (name) | 2351 | maybe_fatal (must_succeed, buffer, display, |
| 2209 | { | 2352 | "Cannot open termcap database file", |
| 2210 | xfree (buffer); | 2353 | "Cannot open termcap database file"); |
| 2211 | delete_tty (display); | ||
| 2212 | error ("Cannot open termcap database file"); | ||
| 2213 | } | ||
| 2214 | else | ||
| 2215 | fatal ("Cannot open termcap database file"); | ||
| 2216 | #endif | 2354 | #endif |
| 2217 | } | 2355 | } |
| 2218 | if (status == 0) | 2356 | if (status == 0) |
| 2219 | { | 2357 | { |
| 2220 | #ifdef TERMINFO | 2358 | #ifdef TERMINFO |
| 2221 | if (name) | 2359 | maybe_fatal (must_succeed, buffer, display, |
| 2222 | { | 2360 | "Terminal type %s is not defined", |
| 2223 | xfree (buffer); | 2361 | "Terminal type %s is not defined.\n\ |
| 2224 | delete_tty (display); | ||
| 2225 | error ("Terminal type %s is not defined", terminal_type); | ||
| 2226 | } | ||
| 2227 | else | ||
| 2228 | fatal ("Terminal type %s is not defined.\n\ | ||
| 2229 | If that is not the actual type of terminal you have,\n\ | 2362 | If that is not the actual type of terminal you have,\n\ |
| 2230 | use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ | 2363 | use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ |
| 2231 | `setenv TERM ...') to specify the correct type. It may be necessary\n\ | 2364 | `setenv TERM ...') to specify the correct type. It may be necessary\n\ |
| 2232 | to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.", | 2365 | to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.", |
| 2233 | terminal_type); | 2366 | terminal_type); |
| 2234 | #else | 2367 | #else |
| 2235 | if (name) | 2368 | maybe_fatal (must_succeed, buffer, display, |
| 2236 | { | 2369 | "Terminal type %s is not defined", |
| 2237 | xfree (buffer); | 2370 | "Terminal type %s is not defined.\n\ |
| 2238 | delete_tty (display); | ||
| 2239 | error ("Terminal type %s is not defined", terminal_type); | ||
| 2240 | } | ||
| 2241 | else | ||
| 2242 | fatal ("Terminal type %s is not defined.\n\ | ||
| 2243 | If that is not the actual type of terminal you have,\n\ | 2371 | If that is not the actual type of terminal you have,\n\ |
| 2244 | use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ | 2372 | use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ |
| 2245 | `setenv TERM ...') to specify the correct type. It may be necessary\n\ | 2373 | `setenv TERM ...') to specify the correct type. It may be necessary\n\ |
| 2246 | to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", | 2374 | to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", |
| 2247 | terminal_type); | 2375 | terminal_type); |
| 2248 | #endif | 2376 | #endif |
| 2249 | } | 2377 | } |
| 2250 | 2378 | ||
| @@ -2384,19 +2512,10 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", | |||
| 2384 | FrameRows (tty) = tgetnum ("li"); | 2512 | FrameRows (tty) = tgetnum ("li"); |
| 2385 | 2513 | ||
| 2386 | if (FrameRows (tty) < 3 || FrameCols (tty) < 3) | 2514 | if (FrameRows (tty) < 3 || FrameCols (tty) < 3) |
| 2387 | { | 2515 | maybe_fatal (must_succeed, NULL, display, |
| 2388 | if (initialized) | 2516 | "Screen size %dx%d is too small" |
| 2389 | { | 2517 | "Screen size %dx%d is too small", |
| 2390 | delete_tty (display); | ||
| 2391 | error ("Screen size %dx%d is too small", | ||
| 2392 | FrameCols (tty), FrameRows (tty)); | ||
| 2393 | } | ||
| 2394 | else | ||
| 2395 | { | ||
| 2396 | fatal ("Screen size %dx%d is too small", | ||
| 2397 | FrameCols (tty), FrameRows (tty)); | 2518 | FrameCols (tty), FrameRows (tty)); |
| 2398 | } | ||
| 2399 | } | ||
| 2400 | 2519 | ||
| 2401 | #if 0 /* This is not used anywhere. */ | 2520 | #if 0 /* This is not used anywhere. */ |
| 2402 | tty->display->min_padding_speed = tgetnum ("pb"); | 2521 | tty->display->min_padding_speed = tgetnum ("pb"); |
| @@ -2525,51 +2644,39 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", | |||
| 2525 | tty->specified_window = FrameRows (tty); | 2644 | tty->specified_window = FrameRows (tty); |
| 2526 | 2645 | ||
| 2527 | if (Wcm_init (tty) == -1) /* can't do cursor motion */ | 2646 | if (Wcm_init (tty) == -1) /* can't do cursor motion */ |
| 2528 | if (name) | 2647 | { |
| 2529 | { | 2648 | maybe_fatal (must_succeed, NULL, display, |
| 2530 | delete_tty (display); | 2649 | "Terminal type \"%s\" is not powerful enough to run Emacs", |
| 2531 | error ("Terminal type \"%s\" is not powerful enough to run Emacs", | ||
| 2532 | terminal_type); | ||
| 2533 | } | ||
| 2534 | else { | ||
| 2535 | #ifdef VMS | 2650 | #ifdef VMS |
| 2536 | fatal ("Terminal type \"%s\" is not powerful enough to run Emacs.\n\ | 2651 | "Terminal type \"%s\" is not powerful enough to run Emacs.\n\ |
| 2537 | It lacks the ability to position the cursor.\n\ | 2652 | It lacks the ability to position the cursor.\n\ |
| 2538 | If that is not the actual type of terminal you have, use either the\n\ | 2653 | If that is not the actual type of terminal you have, use either the\n\ |
| 2539 | DCL command `SET TERMINAL/DEVICE= ...' for DEC-compatible terminals,\n\ | 2654 | DCL command `SET TERMINAL/DEVICE= ...' for DEC-compatible terminals,\n\ |
| 2540 | or `define EMACS_TERM \"terminal type\"' for non-DEC terminals.", | 2655 | or `define EMACS_TERM \"terminal type\"' for non-DEC terminals.", |
| 2541 | terminal_type); | ||
| 2542 | #else /* not VMS */ | 2656 | #else /* not VMS */ |
| 2543 | # ifdef TERMINFO | 2657 | # ifdef TERMINFO |
| 2544 | fatal ("Terminal type \"%s\" is not powerful enough to run Emacs.\n\ | 2658 | "Terminal type \"%s\" is not powerful enough to run Emacs.\n\ |
| 2545 | It lacks the ability to position the cursor.\n\ | 2659 | It lacks the ability to position the cursor.\n\ |
| 2546 | If that is not the actual type of terminal you have,\n\ | 2660 | If that is not the actual type of terminal you have,\n\ |
| 2547 | use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ | 2661 | use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ |
| 2548 | `setenv TERM ...') to specify the correct type. It may be necessary\n\ | 2662 | `setenv TERM ...') to specify the correct type. It may be necessary\n\ |
| 2549 | to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.", | 2663 | to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.", |
| 2550 | terminal_type); | ||
| 2551 | # else /* TERMCAP */ | 2664 | # else /* TERMCAP */ |
| 2552 | fatal ("Terminal type \"%s\" is not powerful enough to run Emacs.\n\ | 2665 | "Terminal type \"%s\" is not powerful enough to run Emacs.\n\ |
| 2553 | It lacks the ability to position the cursor.\n\ | 2666 | It lacks the ability to position the cursor.\n\ |
| 2554 | If that is not the actual type of terminal you have,\n\ | 2667 | If that is not the actual type of terminal you have,\n\ |
| 2555 | use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ | 2668 | use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ |
| 2556 | `setenv TERM ...') to specify the correct type. It may be necessary\n\ | 2669 | `setenv TERM ...') to specify the correct type. It may be necessary\n\ |
| 2557 | to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", | 2670 | to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", |
| 2558 | terminal_type); | ||
| 2559 | # endif /* TERMINFO */ | 2671 | # endif /* TERMINFO */ |
| 2560 | #endif /*VMS */ | 2672 | #endif /*VMS */ |
| 2673 | terminal_type); | ||
| 2561 | } | 2674 | } |
| 2562 | 2675 | ||
| 2563 | if (FrameRows (tty) <= 0 || FrameCols (tty) <= 0) | 2676 | if (FrameRows (tty) <= 0 || FrameCols (tty) <= 0) |
| 2564 | { | 2677 | maybe_fatal (must_succeed, NULL, display, |
| 2565 | if (name) | 2678 | "Could not determine the frame size", |
| 2566 | { | 2679 | "Could not determine the frame size"); |
| 2567 | delete_tty (display); | ||
| 2568 | error ("The frame size has not been specified"); | ||
| 2569 | } | ||
| 2570 | else | ||
| 2571 | fatal ("The frame size has not been specified"); | ||
| 2572 | } | ||
| 2573 | 2680 | ||
| 2574 | tty->delete_in_insert_mode | 2681 | tty->delete_in_insert_mode |
| 2575 | = tty->TS_delete_mode && tty->TS_insert_mode | 2682 | = tty->TS_delete_mode && tty->TS_insert_mode |
| @@ -2635,6 +2742,31 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", | |||
| 2635 | #endif /* not WINDOWSNT */ | 2742 | #endif /* not WINDOWSNT */ |
| 2636 | } | 2743 | } |
| 2637 | 2744 | ||
| 2745 | /* Auxiliary error-handling function for term_init. | ||
| 2746 | Free BUFFER and delete DISPLAY, then call error or fatal | ||
| 2747 | with str1 or str2, respectively, according to MUST_SUCCEED. | ||
| 2748 | */ | ||
| 2749 | static void | ||
| 2750 | maybe_fatal (must_succeed, buffer, display, str1, str2, arg1, arg2) | ||
| 2751 | int must_succeed; | ||
| 2752 | char *buffer; | ||
| 2753 | struct display *display; | ||
| 2754 | char *str1, *str2, *arg1, *arg2; | ||
| 2755 | { | ||
| 2756 | if (buffer) | ||
| 2757 | xfree (buffer); | ||
| 2758 | |||
| 2759 | if (display) | ||
| 2760 | delete_tty (display); | ||
| 2761 | |||
| 2762 | if (must_succeed) | ||
| 2763 | fatal (str2, arg1, arg2); | ||
| 2764 | else | ||
| 2765 | error (str1, arg1, arg2); | ||
| 2766 | |||
| 2767 | abort (); | ||
| 2768 | } | ||
| 2769 | |||
| 2638 | /* VARARGS 1 */ | 2770 | /* VARARGS 1 */ |
| 2639 | void | 2771 | void |
| 2640 | fatal (str, arg1, arg2) | 2772 | fatal (str, arg1, arg2) |
| @@ -2725,10 +2857,12 @@ delete_tty (struct display *display) | |||
| 2725 | } | 2857 | } |
| 2726 | } | 2858 | } |
| 2727 | 2859 | ||
| 2728 | delete_display (display); | 2860 | /* reset_sys_modes needs a valid display, so this call needs to be |
| 2729 | 2861 | before delete_display. */ | |
| 2730 | reset_sys_modes (tty); | 2862 | reset_sys_modes (tty); |
| 2731 | 2863 | ||
| 2864 | delete_display (display); | ||
| 2865 | |||
| 2732 | tty_name = tty->name; | 2866 | tty_name = tty->name; |
| 2733 | if (tty->type) | 2867 | if (tty->type) |
| 2734 | xfree (tty->type); | 2868 | xfree (tty->type); |
diff --git a/src/termchar.h b/src/termchar.h index fe9cd4b27df..ff5bd7bb1ad 100644 --- a/src/termchar.h +++ b/src/termchar.h | |||
| @@ -52,6 +52,9 @@ struct tty_display_info | |||
| 52 | 52 | ||
| 53 | 53 | ||
| 54 | int reference_count; /* Number of frames that are on this display. */ | 54 | int reference_count; /* Number of frames that are on this display. */ |
| 55 | |||
| 56 | struct display *display; /* Points back to the generic display | ||
| 57 | structure. This is sometimes handy. */ | ||
| 55 | 58 | ||
| 56 | /* Info on cursor positioning. */ | 59 | /* Info on cursor positioning. */ |
| 57 | struct cm *Wcm; | 60 | struct cm *Wcm; |
diff --git a/src/termhooks.h b/src/termhooks.h index 36a31ff4f6a..59f19c676b0 100644 --- a/src/termhooks.h +++ b/src/termhooks.h | |||
| @@ -344,8 +344,8 @@ struct display | |||
| 344 | 344 | ||
| 345 | void (*ring_bell_hook) P_ ((void)); | 345 | void (*ring_bell_hook) P_ ((void)); |
| 346 | 346 | ||
| 347 | void (*reset_terminal_modes_hook) P_ ((void)); | 347 | void (*reset_terminal_modes_hook) P_ ((struct display *)); |
| 348 | void (*set_terminal_modes_hook) P_ ((void)); | 348 | void (*set_terminal_modes_hook) P_ ((struct display *)); |
| 349 | void (*update_begin_hook) P_ ((struct frame *)); | 349 | void (*update_begin_hook) P_ ((struct frame *)); |
| 350 | void (*update_end_hook) P_ ((struct frame *)); | 350 | void (*update_end_hook) P_ ((struct frame *)); |
| 351 | void (*set_terminal_window_hook) P_ ((int)); | 351 | void (*set_terminal_window_hook) P_ ((int)); |
diff --git a/src/window.c b/src/window.c index f3f3c6b8bf0..14defa74257 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -6394,7 +6394,7 @@ and scrolling positions. */) | |||
| 6394 | void | 6394 | void |
| 6395 | init_window_once () | 6395 | init_window_once () |
| 6396 | { | 6396 | { |
| 6397 | struct frame *f = make_terminal_frame (0, 0); | 6397 | struct frame *f = make_initial_frame (); |
| 6398 | XSETFRAME (selected_frame, f); | 6398 | XSETFRAME (selected_frame, f); |
| 6399 | Vterminal_frame = selected_frame; | 6399 | Vterminal_frame = selected_frame; |
| 6400 | minibuf_window = f->minibuffer_window; | 6400 | minibuf_window = f->minibuffer_window; |
diff --git a/src/xfaces.c b/src/xfaces.c index 77a2663a2cb..94474ec94cd 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -6728,7 +6728,7 @@ realize_default_face (f) | |||
| 6728 | LFACE_FOREGROUND (lface) = XCDR (color); | 6728 | LFACE_FOREGROUND (lface) = XCDR (color); |
| 6729 | else if (FRAME_WINDOW_P (f)) | 6729 | else if (FRAME_WINDOW_P (f)) |
| 6730 | return 0; | 6730 | return 0; |
| 6731 | else if (FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)) | 6731 | else if (FRAME_INITIAL_P (f) || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)) |
| 6732 | LFACE_FOREGROUND (lface) = build_string (unspecified_fg); | 6732 | LFACE_FOREGROUND (lface) = build_string (unspecified_fg); |
| 6733 | else | 6733 | else |
| 6734 | abort (); | 6734 | abort (); |
| @@ -6743,7 +6743,7 @@ realize_default_face (f) | |||
| 6743 | LFACE_BACKGROUND (lface) = XCDR (color); | 6743 | LFACE_BACKGROUND (lface) = XCDR (color); |
| 6744 | else if (FRAME_WINDOW_P (f)) | 6744 | else if (FRAME_WINDOW_P (f)) |
| 6745 | return 0; | 6745 | return 0; |
| 6746 | else if (FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)) | 6746 | else if (FRAME_INITIAL_P (f) || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)) |
| 6747 | LFACE_BACKGROUND (lface) = build_string (unspecified_bg); | 6747 | LFACE_BACKGROUND (lface) = build_string (unspecified_bg); |
| 6748 | else | 6748 | else |
| 6749 | abort (); | 6749 | abort (); |
| @@ -6830,7 +6830,7 @@ realize_face (cache, attrs, c, base_face, former_face_id) | |||
| 6830 | 6830 | ||
| 6831 | if (FRAME_WINDOW_P (cache->f)) | 6831 | if (FRAME_WINDOW_P (cache->f)) |
| 6832 | face = realize_x_face (cache, attrs, c, base_face); | 6832 | face = realize_x_face (cache, attrs, c, base_face); |
| 6833 | else if (FRAME_TERMCAP_P (cache->f) || FRAME_MSDOS_P (cache->f)) | 6833 | else if (FRAME_INITIAL_P (cache->f) || FRAME_TERMCAP_P (cache->f) || FRAME_MSDOS_P (cache->f)) |
| 6834 | face = realize_tty_face (cache, attrs, c); | 6834 | face = realize_tty_face (cache, attrs, c); |
| 6835 | else | 6835 | else |
| 6836 | abort (); | 6836 | abort (); |
diff --git a/src/xterm.c b/src/xterm.c index fcb431a472c..0de8ce18f0a 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -331,8 +331,8 @@ static void x_font_min_bounds P_ ((XFontStruct *, int *, int *)); | |||
| 331 | static int x_compute_min_glyph_bounds P_ ((struct frame *)); | 331 | static int x_compute_min_glyph_bounds P_ ((struct frame *)); |
| 332 | static void x_update_end P_ ((struct frame *)); | 332 | static void x_update_end P_ ((struct frame *)); |
| 333 | static void XTframe_up_to_date P_ ((struct frame *)); | 333 | static void XTframe_up_to_date P_ ((struct frame *)); |
| 334 | static void XTset_terminal_modes P_ ((void)); | 334 | static void XTset_terminal_modes P_ ((struct display *)); |
| 335 | static void XTreset_terminal_modes P_ ((void)); | 335 | static void XTreset_terminal_modes P_ ((struct display *)); |
| 336 | static void x_clear_frame P_ ((void)); | 336 | static void x_clear_frame P_ ((void)); |
| 337 | static void frame_highlight P_ ((struct frame *)); | 337 | static void frame_highlight P_ ((struct frame *)); |
| 338 | static void frame_unhighlight P_ ((struct frame *)); | 338 | static void frame_unhighlight P_ ((struct frame *)); |
| @@ -747,7 +747,7 @@ x_draw_fringe_bitmap (w, row, p) | |||
| 747 | rarely happens). */ | 747 | rarely happens). */ |
| 748 | 748 | ||
| 749 | static void | 749 | static void |
| 750 | XTset_terminal_modes () | 750 | XTset_terminal_modes (struct display *display) |
| 751 | { | 751 | { |
| 752 | } | 752 | } |
| 753 | 753 | ||
| @@ -755,7 +755,7 @@ XTset_terminal_modes () | |||
| 755 | the X-windows go away, and suspending requires no action. */ | 755 | the X-windows go away, and suspending requires no action. */ |
| 756 | 756 | ||
| 757 | static void | 757 | static void |
| 758 | XTreset_terminal_modes () | 758 | XTreset_terminal_modes (struct display *display) |
| 759 | { | 759 | { |
| 760 | } | 760 | } |
| 761 | 761 | ||