Mercurial > emacs
comparison src/term.c @ 37959:b53edc686faf
(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.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Thu, 31 May 2001 08:56:32 +0000 |
parents | b8ff92361366 |
children | 5f60884970a8 |
comparison
equal
deleted
inserted
replaced
37958:d1fdbba91c71 | 37959:b53edc686faf |
---|---|
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 |
7 GNU Emacs is free software; you can redistribute it and/or modify | 7 GNU Emacs is free software; you can redistribute it and/or modify |
8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
17 You should have received a copy of the GNU General Public License | 17 You should have received a copy of the GNU General Public License |
18 along with GNU Emacs; see the file COPYING. If not, write to | 18 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> |
27 #include <ctype.h> | 26 #include <ctype.h> |
28 #include <string.h> | 27 #include <string.h> |
156 | 155 |
157 Set *time to the time the mouse was at the returned position. | 156 Set *time to the time the mouse was at the returned position. |
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, |
164 Lisp_Object *x, | 164 Lisp_Object *x, |
165 Lisp_Object *y, | 165 Lisp_Object *y, |
168 /* When reading from a minibuffer in a different frame, Emacs wants | 168 /* When reading from a minibuffer in a different frame, Emacs wants |
169 to shift the highlight from the selected frame to the mini-buffer's | 169 to shift the highlight from the selected frame to the mini-buffer's |
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 |
176 frames on top of each other, this hook allows you to bring a frame | 177 frames on top of each other, this hook allows you to bring a frame |
177 to the front, or bury it behind all the other windows. If this | 178 to the front, or bury it behind all the other windows. If this |
180 anything. | 181 anything. |
181 | 182 |
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 |
188 at (TOP, LEFT), and be LENGTH rows high. Set its handle to | 190 at (TOP, LEFT), and be LENGTH rows high. Set its handle to |
189 indicate that we are displaying PORTION characters out of a total | 191 indicate that we are displaying PORTION characters out of a total |
213 this and the judge_scroll_bars_hook will get rid of them. | 215 this and the judge_scroll_bars_hook will get rid of them. |
214 | 216 |
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 |
225 last call to `*condemn_scroll_bars_hook'. | 229 last call to `*condemn_scroll_bars_hook'. |
226 | 230 |
230 calling this and condemn_scroll_bars_hook will get rid of them. | 234 calling this and condemn_scroll_bars_hook will get rid of them. |
231 | 235 |
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. */ |
238 | 243 |
239 int (* estimate_mode_line_height_hook) P_ ((struct frame *f, enum face_id)); | 244 int (* estimate_mode_line_height_hook) P_ ((struct frame *f, enum face_id)); |
416 | 421 |
417 /* Provided for lisp packages. */ | 422 /* Provided for lisp packages. */ |
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 (); |
424 | 433 |
425 | 434 |
435 #endif /* WINDOWSNT */ | 444 #endif /* WINDOWSNT */ |
436 | 445 |
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 |
444 /* Temporarily set the global variable to nil | 453 /* Temporarily set the global variable to nil |
445 so that if we get an error, it stays nil | 454 so that if we get an error, it stays nil |
446 and we don't call it over and over. | 455 and we don't call it over and over. |
447 | 456 |
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; | 467 } |
458 } | 468 else if (!FRAME_TERMCAP_P (XFRAME (selected_frame))) |
459 | 469 (*ring_bell_hook) (); |
460 if (! FRAME_TERMCAP_P (XFRAME (selected_frame))) | 470 else |
461 { | 471 OUTPUT (TS_visible_bell && visible_bell ? TS_visible_bell : TS_bell); |
462 (*ring_bell_hook) (); | |
463 return; | |
464 } | |
465 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); |
475 } | 481 OUTPUT_IF (TS_keypad_mode); |
476 OUTPUT_IF (TS_termcap_modes); | 482 losecursor (); |
477 OUTPUT_IF (TS_cursor_visible); | 483 } |
478 OUTPUT_IF (TS_keypad_mode); | 484 else |
479 losecursor (); | 485 (*set_terminal_modes_hook) (); |
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); |
519 } | |
520 | |
521 void | |
522 update_end (f) | |
523 struct frame *f; | |
524 { | |
525 if (FRAME_TERMCAP_P (f)) | |
526 { | |
527 if (!XWINDOW (selected_window)->cursor_off_p) | |
528 tty_show_cursor (); | |
529 turn_off_insert (); | |
530 background_highlight (); | |
531 standout_requested = 0; | |
532 } | |
513 else | 533 else |
514 tty_hide_cursor (); | 534 update_end_hook (f); |
515 } | |
516 | |
517 void | |
518 update_end (f) | |
519 FRAME_PTR f; | |
520 { | |
521 if (! FRAME_TERMCAP_P (f)) | |
522 { | |
523 (*update_end_hook) (f); | |
524 updating_frame = 0; | |
525 return; | |
526 } | |
527 | |
528 if (!XWINDOW (selected_window)->cursor_off_p) | |
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) |
545 } | 547 set_scroll_region (0, specified_window); |
546 specified_window = size ? size : FRAME_HEIGHT (XFRAME (selected_frame)); | 548 } |
547 if (!scroll_region_ok) | 549 else |
548 return; | 550 set_terminal_window_hook (size); |
549 set_scroll_region (0, specified_window); | |
550 } | 551 } |
551 | 552 |
552 void | 553 void |
553 set_scroll_region (start, stop) | 554 set_scroll_region (start, stop) |
554 int start, stop; | 555 int start, stop; |
555 { | 556 { |
556 char *buf; | 557 char *buf; |
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) |
583 OUTPUT (TS_insert_mode); | 580 OUTPUT (TS_insert_mode); |
584 insert_mode = 1; | 581 insert_mode = 1; |
608 OUTPUT_IF (TS_end_standout_mode); | 605 OUTPUT_IF (TS_end_standout_mode); |
609 standout_mode = 0; | 606 standout_mode = 0; |
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) |
617 { | 614 { |
618 if (!standout_mode) | 615 if (!standout_mode) |
634 /* Make cursor invisible. */ | 631 /* Make cursor invisible. */ |
635 | 632 |
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 |
643 /* Ensure that cursor is visible. */ | 644 /* Ensure that cursor is visible. */ |
644 | 645 |
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 |
653 /* Set standout mode to the state it should be in for | 658 /* Set standout mode to the state it should be in for |
654 empty space inside windows. What this is, | 659 empty space inside windows. What this is, |
687 on other terminals. */ | 692 on other terminals. */ |
688 | 693 |
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); |
701 OUTPUT (flag ? TS_standout_mode : TS_end_standout_mode); | 707 OUTPUT (flag ? TS_standout_mode : TS_end_standout_mode); |
702 chars_wasted[curY] = TN_standout_width | 0100; | 708 chars_wasted[curY] = TN_standout_width | 0100; |
1073 (*write_glyphs_hook) (string, len); | 1079 (*write_glyphs_hook) (string, len); |
1074 return; | 1080 return; |
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. */ |
1081 | 1088 |
1082 if (AutoWrap | 1089 if (AutoWrap |