diff options
| author | Gerd Moellmann | 2001-05-31 08:56:32 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2001-05-31 08:56:32 +0000 |
| commit | d284f58f0c4c08c24fa9e84e1904454bcc60ef26 (patch) | |
| tree | c291fe1617dc02dce130f678c97c952aa4a8f92c /src | |
| parent | 1300e2720b8fe0bc06b8965404c5fba3adae65eb (diff) | |
| download | emacs-d284f58f0c4c08c24fa9e84e1904454bcc60ef26.tar.gz emacs-d284f58f0c4c08c24fa9e84e1904454bcc60ef26.zip | |
(tty_cursor_hidden): New variable.
(update_begin): Don't call tty_hide_cursor. Clean up.
(update_end, set_terminal_window, set_scroll_region): Clean up.
(ring_bell, reset_terminal_modes): Clean up.
(tty_hide_cursor, tty_show_cursor): Hide/show cursor depending
on tty_cursor_hidden.
(write_glyphs): Call tty_hide_cursor.
Diffstat (limited to 'src')
| -rw-r--r-- | src/term.c | 171 |
1 files changed, 89 insertions, 82 deletions
diff --git a/src/term.c b/src/term.c index 4bd5f1617c7..6cdfa8d4355 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* terminal control module for terminals described by TERMCAP | 1 | /* Terminal control module for terminals described by TERMCAP |
| 2 | Copyright (C) 1985, 86, 87, 93, 94, 95, 98, 2000, 2001 | 2 | Copyright (C) 1985, 86, 87, 93, 94, 95, 98, 2000, 2001 |
| 3 | Free Software Foundation, Inc. | 3 | Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
| 6 | 6 | ||
| @@ -19,8 +19,7 @@ along with GNU Emacs; see the file COPYING. If not, write to | |||
| 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 20 | Boston, MA 02111-1307, USA. */ | 20 | Boston, MA 02111-1307, USA. */ |
| 21 | 21 | ||
| 22 | /* New redisplay, TTY faces by Gerd Moellmann <gerd@acm.org>. */ | 22 | /* New redisplay, TTY faces by Gerd Moellmann <gerd@gnu.org>. */ |
| 23 | |||
| 24 | 23 | ||
| 25 | #include <config.h> | 24 | #include <config.h> |
| 26 | #include <stdio.h> | 25 | #include <stdio.h> |
| @@ -158,6 +157,7 @@ void (*frame_up_to_date_hook) P_ ((struct frame *)); | |||
| 158 | 157 | ||
| 159 | This should clear mouse_moved until the next motion | 158 | This should clear mouse_moved until the next motion |
| 160 | event arrives. */ | 159 | event arrives. */ |
| 160 | |||
| 161 | void (*mouse_position_hook) P_ ((FRAME_PTR *f, int insist, | 161 | void (*mouse_position_hook) P_ ((FRAME_PTR *f, int insist, |
| 162 | Lisp_Object *bar_window, | 162 | Lisp_Object *bar_window, |
| 163 | enum scroll_bar_part *part, | 163 | enum scroll_bar_part *part, |
| @@ -170,6 +170,7 @@ void (*mouse_position_hook) P_ ((FRAME_PTR *f, int insist, | |||
| 170 | frame; under X, this means it lies about where the focus is. | 170 | frame; under X, this means it lies about where the focus is. |
| 171 | This hook tells the window system code to re-decide where to put | 171 | This hook tells the window system code to re-decide where to put |
| 172 | the highlight. */ | 172 | the highlight. */ |
| 173 | |||
| 173 | void (*frame_rehighlight_hook) P_ ((FRAME_PTR f)); | 174 | void (*frame_rehighlight_hook) P_ ((FRAME_PTR f)); |
| 174 | 175 | ||
| 175 | /* If we're displaying frames using a window system that can stack | 176 | /* If we're displaying frames using a window system that can stack |
| @@ -182,6 +183,7 @@ void (*frame_rehighlight_hook) P_ ((FRAME_PTR f)); | |||
| 182 | If RAISE is non-zero, F is brought to the front, before all other | 183 | If RAISE is non-zero, F is brought to the front, before all other |
| 183 | windows. If RAISE is zero, F is sent to the back, behind all other | 184 | windows. If RAISE is zero, F is sent to the back, behind all other |
| 184 | windows. */ | 185 | windows. */ |
| 186 | |||
| 185 | void (*frame_raise_lower_hook) P_ ((FRAME_PTR f, int raise)); | 187 | void (*frame_raise_lower_hook) P_ ((FRAME_PTR f, int raise)); |
| 186 | 188 | ||
| 187 | /* Set the vertical scroll bar for WINDOW to have its upper left corner | 189 | /* Set the vertical scroll bar for WINDOW to have its upper left corner |
| @@ -215,10 +217,12 @@ void (*set_vertical_scroll_bar_hook) | |||
| 215 | If non-zero, this hook should be safe to apply to any frame, | 217 | If non-zero, this hook should be safe to apply to any frame, |
| 216 | whether or not it can support scroll bars, and whether or not it is | 218 | whether or not it can support scroll bars, and whether or not it is |
| 217 | currently displaying them. */ | 219 | currently displaying them. */ |
| 220 | |||
| 218 | void (*condemn_scroll_bars_hook) P_ ((FRAME_PTR frame)); | 221 | void (*condemn_scroll_bars_hook) P_ ((FRAME_PTR frame)); |
| 219 | 222 | ||
| 220 | /* Unmark WINDOW's scroll bar for deletion in this judgement cycle. | 223 | /* Unmark WINDOW's scroll bar for deletion in this judgement cycle. |
| 221 | Note that it's okay to redeem a scroll bar that is not condemned. */ | 224 | Note that it's okay to redeem a scroll bar that is not condemned. */ |
| 225 | |||
| 222 | void (*redeem_scroll_bar_hook) P_ ((struct window *window)); | 226 | void (*redeem_scroll_bar_hook) P_ ((struct window *window)); |
| 223 | 227 | ||
| 224 | /* Remove all scroll bars on FRAME that haven't been saved since the | 228 | /* Remove all scroll bars on FRAME that haven't been saved since the |
| @@ -232,6 +236,7 @@ void (*redeem_scroll_bar_hook) P_ ((struct window *window)); | |||
| 232 | If non-zero, this hook should be safe to apply to any frame, | 236 | If non-zero, this hook should be safe to apply to any frame, |
| 233 | whether or not it can support scroll bars, and whether or not it is | 237 | whether or not it can support scroll bars, and whether or not it is |
| 234 | currently displaying them. */ | 238 | currently displaying them. */ |
| 239 | |||
| 235 | void (*judge_scroll_bars_hook) P_ ((FRAME_PTR FRAME)); | 240 | void (*judge_scroll_bars_hook) P_ ((FRAME_PTR FRAME)); |
| 236 | 241 | ||
| 237 | /* Hook to call in estimate_mode_line_height, if any. */ | 242 | /* Hook to call in estimate_mode_line_height, if any. */ |
| @@ -418,6 +423,10 @@ FRAME_PTR updating_frame; | |||
| 418 | 423 | ||
| 419 | static int system_uses_terminfo; | 424 | static int system_uses_terminfo; |
| 420 | 425 | ||
| 426 | /* Flag used in tty_show/hide_cursor. */ | ||
| 427 | |||
| 428 | static int tty_cursor_hidden; | ||
| 429 | |||
| 421 | char *tparam (); | 430 | char *tparam (); |
| 422 | 431 | ||
| 423 | extern char *tgetstr (); | 432 | extern char *tgetstr (); |
| @@ -437,7 +446,7 @@ extern char *tgetstr (); | |||
| 437 | void | 446 | void |
| 438 | ring_bell () | 447 | ring_bell () |
| 439 | { | 448 | { |
| 440 | if (! NILP (Vring_bell_function)) | 449 | if (!NILP (Vring_bell_function)) |
| 441 | { | 450 | { |
| 442 | Lisp_Object function; | 451 | Lisp_Object function; |
| 443 | 452 | ||
| @@ -448,105 +457,97 @@ ring_bell () | |||
| 448 | We don't specbind it, because that would carefully | 457 | We don't specbind it, because that would carefully |
| 449 | restore the bad value if there's an error | 458 | restore the bad value if there's an error |
| 450 | and make the loop of errors happen anyway. */ | 459 | and make the loop of errors happen anyway. */ |
| 460 | |||
| 451 | function = Vring_bell_function; | 461 | function = Vring_bell_function; |
| 452 | Vring_bell_function = Qnil; | 462 | Vring_bell_function = Qnil; |
| 453 | 463 | ||
| 454 | call0 (function); | 464 | call0 (function); |
| 455 | 465 | ||
| 456 | Vring_bell_function = function; | 466 | Vring_bell_function = function; |
| 457 | return; | ||
| 458 | } | ||
| 459 | |||
| 460 | if (! FRAME_TERMCAP_P (XFRAME (selected_frame))) | ||
| 461 | { | ||
| 462 | (*ring_bell_hook) (); | ||
| 463 | return; | ||
| 464 | } | 467 | } |
| 465 | OUTPUT (TS_visible_bell && visible_bell ? TS_visible_bell : TS_bell); | 468 | else if (!FRAME_TERMCAP_P (XFRAME (selected_frame))) |
| 469 | (*ring_bell_hook) (); | ||
| 470 | else | ||
| 471 | OUTPUT (TS_visible_bell && visible_bell ? TS_visible_bell : TS_bell); | ||
| 466 | } | 472 | } |
| 467 | 473 | ||
| 468 | void | 474 | void |
| 469 | set_terminal_modes () | 475 | set_terminal_modes () |
| 470 | { | 476 | { |
| 471 | if (! FRAME_TERMCAP_P (XFRAME (selected_frame))) | 477 | if (FRAME_TERMCAP_P (XFRAME (selected_frame))) |
| 472 | { | 478 | { |
| 473 | (*set_terminal_modes_hook) (); | 479 | OUTPUT_IF (TS_termcap_modes); |
| 474 | return; | 480 | OUTPUT_IF (TS_cursor_visible); |
| 481 | OUTPUT_IF (TS_keypad_mode); | ||
| 482 | losecursor (); | ||
| 475 | } | 483 | } |
| 476 | OUTPUT_IF (TS_termcap_modes); | 484 | else |
| 477 | OUTPUT_IF (TS_cursor_visible); | 485 | (*set_terminal_modes_hook) (); |
| 478 | OUTPUT_IF (TS_keypad_mode); | ||
| 479 | losecursor (); | ||
| 480 | } | 486 | } |
| 481 | 487 | ||
| 482 | void | 488 | void |
| 483 | reset_terminal_modes () | 489 | reset_terminal_modes () |
| 484 | { | 490 | { |
| 485 | if (! FRAME_TERMCAP_P (XFRAME (selected_frame))) | 491 | if (FRAME_TERMCAP_P (XFRAME (selected_frame))) |
| 486 | { | 492 | { |
| 487 | if (reset_terminal_modes_hook) | 493 | if (TN_standout_width < 0) |
| 488 | (*reset_terminal_modes_hook) (); | 494 | turn_off_highlight (); |
| 489 | return; | 495 | turn_off_insert (); |
| 490 | } | 496 | OUTPUT_IF (TS_end_keypad_mode); |
| 491 | if (TN_standout_width < 0) | 497 | OUTPUT_IF (TS_cursor_normal); |
| 492 | turn_off_highlight (); | 498 | OUTPUT_IF (TS_end_termcap_modes); |
| 493 | turn_off_insert (); | 499 | OUTPUT_IF (TS_orig_pair); |
| 494 | OUTPUT_IF (TS_end_keypad_mode); | 500 | /* Output raw CR so kernel can track the cursor hpos. */ |
| 495 | OUTPUT_IF (TS_cursor_normal); | 501 | /* But on magic-cookie terminals this can erase an end-standout |
| 496 | OUTPUT_IF (TS_end_termcap_modes); | 502 | marker and cause the rest of the frame to be in standout, so |
| 497 | OUTPUT_IF (TS_orig_pair); | 503 | move down first. */ |
| 498 | /* Output raw CR so kernel can track the cursor hpos. */ | 504 | if (TN_standout_width >= 0) |
| 499 | /* But on magic-cookie terminals this can erase an end-standout marker and | 505 | cmputc ('\n'); |
| 500 | cause the rest of the frame to be in standout, so move down first. */ | 506 | cmputc ('\r'); |
| 501 | if (TN_standout_width >= 0) | 507 | } |
| 502 | cmputc ('\n'); | 508 | else if (reset_terminal_modes_hook) |
| 503 | cmputc ('\r'); | 509 | (*reset_terminal_modes_hook) (); |
| 504 | } | 510 | } |
| 505 | 511 | ||
| 506 | void | 512 | void |
| 507 | update_begin (f) | 513 | update_begin (f) |
| 508 | FRAME_PTR f; | 514 | struct frame *f; |
| 509 | { | 515 | { |
| 510 | updating_frame = f; | 516 | updating_frame = f; |
| 511 | if (! FRAME_TERMCAP_P (updating_frame)) | 517 | if (!FRAME_TERMCAP_P (f)) |
| 512 | (*update_begin_hook) (f); | 518 | update_begin_hook (f); |
| 513 | else | ||
| 514 | tty_hide_cursor (); | ||
| 515 | } | 519 | } |
| 516 | 520 | ||
| 517 | void | 521 | void |
| 518 | update_end (f) | 522 | update_end (f) |
| 519 | FRAME_PTR f; | 523 | struct frame *f; |
| 520 | { | 524 | { |
| 521 | if (! FRAME_TERMCAP_P (f)) | 525 | if (FRAME_TERMCAP_P (f)) |
| 522 | { | 526 | { |
| 523 | (*update_end_hook) (f); | 527 | if (!XWINDOW (selected_window)->cursor_off_p) |
| 524 | updating_frame = 0; | 528 | tty_show_cursor (); |
| 525 | return; | 529 | turn_off_insert (); |
| 530 | background_highlight (); | ||
| 531 | standout_requested = 0; | ||
| 526 | } | 532 | } |
| 527 | 533 | else | |
| 528 | if (!XWINDOW (selected_window)->cursor_off_p) | 534 | update_end_hook (f); |
| 529 | tty_show_cursor (); | ||
| 530 | 535 | ||
| 531 | turn_off_insert (); | 536 | updating_frame = NULL; |
| 532 | background_highlight (); | ||
| 533 | standout_requested = 0; | ||
| 534 | updating_frame = 0; | ||
| 535 | } | 537 | } |
| 536 | 538 | ||
| 537 | void | 539 | void |
| 538 | set_terminal_window (size) | 540 | set_terminal_window (size) |
| 539 | int size; | 541 | int size; |
| 540 | { | 542 | { |
| 541 | if (! FRAME_TERMCAP_P (updating_frame)) | 543 | if (FRAME_TERMCAP_P (updating_frame)) |
| 542 | { | 544 | { |
| 543 | (*set_terminal_window_hook) (size); | 545 | specified_window = size ? size : FRAME_HEIGHT (updating_frame); |
| 544 | return; | 546 | if (scroll_region_ok) |
| 547 | set_scroll_region (0, specified_window); | ||
| 545 | } | 548 | } |
| 546 | specified_window = size ? size : FRAME_HEIGHT (XFRAME (selected_frame)); | 549 | else |
| 547 | if (!scroll_region_ok) | 550 | set_terminal_window_hook (size); |
| 548 | return; | ||
| 549 | set_scroll_region (0, specified_window); | ||
| 550 | } | 551 | } |
| 551 | 552 | ||
| 552 | void | 553 | void |
| @@ -557,26 +558,22 @@ set_scroll_region (start, stop) | |||
| 557 | struct frame *sf = XFRAME (selected_frame); | 558 | struct frame *sf = XFRAME (selected_frame); |
| 558 | 559 | ||
| 559 | if (TS_set_scroll_region) | 560 | if (TS_set_scroll_region) |
| 560 | { | 561 | buf = tparam (TS_set_scroll_region, 0, 0, start, stop - 1); |
| 561 | buf = tparam (TS_set_scroll_region, 0, 0, start, stop - 1); | ||
| 562 | } | ||
| 563 | else if (TS_set_scroll_region_1) | 562 | else if (TS_set_scroll_region_1) |
| 564 | { | 563 | buf = tparam (TS_set_scroll_region_1, 0, 0, |
| 565 | buf = tparam (TS_set_scroll_region_1, 0, 0, | 564 | FRAME_HEIGHT (sf), start, |
| 566 | FRAME_HEIGHT (sf), start, | 565 | FRAME_HEIGHT (sf) - stop, |
| 567 | FRAME_HEIGHT (sf) - stop, | 566 | FRAME_HEIGHT (sf)); |
| 568 | FRAME_HEIGHT (sf)); | ||
| 569 | } | ||
| 570 | else | 567 | else |
| 571 | { | 568 | buf = tparam (TS_set_window, 0, 0, start, 0, stop, FRAME_WIDTH (sf)); |
| 572 | buf = tparam (TS_set_window, 0, 0, start, 0, stop, FRAME_WIDTH (sf)); | 569 | |
| 573 | } | ||
| 574 | OUTPUT (buf); | 570 | OUTPUT (buf); |
| 575 | xfree (buf); | 571 | xfree (buf); |
| 576 | losecursor (); | 572 | losecursor (); |
| 577 | } | 573 | } |
| 574 | |||
| 578 | 575 | ||
| 579 | void | 576 | static void |
| 580 | turn_on_insert () | 577 | turn_on_insert () |
| 581 | { | 578 | { |
| 582 | if (!insert_mode) | 579 | if (!insert_mode) |
| @@ -610,7 +607,7 @@ turn_off_highlight () | |||
| 610 | } | 607 | } |
| 611 | } | 608 | } |
| 612 | 609 | ||
| 613 | void | 610 | static void |
| 614 | turn_on_highlight () | 611 | turn_on_highlight () |
| 615 | { | 612 | { |
| 616 | if (TN_standout_width < 0) | 613 | if (TN_standout_width < 0) |
| @@ -636,7 +633,11 @@ toggle_highlight () | |||
| 636 | static void | 633 | static void |
| 637 | tty_hide_cursor () | 634 | tty_hide_cursor () |
| 638 | { | 635 | { |
| 639 | OUTPUT_IF (TS_cursor_invisible); | 636 | if (tty_cursor_hidden == 0) |
| 637 | { | ||
| 638 | tty_cursor_hidden = 1; | ||
| 639 | OUTPUT_IF (TS_cursor_invisible); | ||
| 640 | } | ||
| 640 | } | 641 | } |
| 641 | 642 | ||
| 642 | 643 | ||
| @@ -645,8 +646,12 @@ tty_hide_cursor () | |||
| 645 | static void | 646 | static void |
| 646 | tty_show_cursor () | 647 | tty_show_cursor () |
| 647 | { | 648 | { |
| 648 | OUTPUT_IF (TS_cursor_normal); | 649 | if (tty_cursor_hidden) |
| 649 | OUTPUT_IF (TS_cursor_visible); | 650 | { |
| 651 | tty_cursor_hidden = 0; | ||
| 652 | OUTPUT_IF (TS_cursor_normal); | ||
| 653 | OUTPUT_IF (TS_cursor_visible); | ||
| 654 | } | ||
| 650 | } | 655 | } |
| 651 | 656 | ||
| 652 | 657 | ||
| @@ -689,12 +694,13 @@ highlight_if_desired () | |||
| 689 | /* Write a standout marker or end-standout marker at the front of the line | 694 | /* Write a standout marker or end-standout marker at the front of the line |
| 690 | at vertical position vpos. */ | 695 | at vertical position vpos. */ |
| 691 | 696 | ||
| 692 | void | 697 | static void |
| 693 | write_standout_marker (flag, vpos) | 698 | write_standout_marker (flag, vpos) |
| 694 | int flag, vpos; | 699 | int flag, vpos; |
| 695 | { | 700 | { |
| 696 | if (flag || (TS_end_standout_mode && !TF_teleray && !se_is_so | 701 | if (flag |
| 697 | && !(TF_xs && TN_standout_width == 0))) | 702 | || (TS_end_standout_mode && !TF_teleray && !se_is_so |
| 703 | && !(TF_xs && TN_standout_width == 0))) | ||
| 698 | { | 704 | { |
| 699 | cmgoto (vpos, 0); | 705 | cmgoto (vpos, 0); |
| 700 | cmplus (TN_standout_width); | 706 | cmplus (TN_standout_width); |
| @@ -1075,6 +1081,7 @@ write_glyphs (string, len) | |||
| 1075 | } | 1081 | } |
| 1076 | 1082 | ||
| 1077 | turn_off_insert (); | 1083 | turn_off_insert (); |
| 1084 | tty_hide_cursor (); | ||
| 1078 | 1085 | ||
| 1079 | /* Don't dare write in last column of bottom line, if Auto-Wrap, | 1086 | /* Don't dare write in last column of bottom line, if Auto-Wrap, |
| 1080 | since that would scroll the whole frame on some terminals. */ | 1087 | since that would scroll the whole frame on some terminals. */ |