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/term.c | |
| 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/term.c')
| -rw-r--r-- | src/term.c | 722 |
1 files changed, 428 insertions, 294 deletions
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); |