comparison src/term.c @ 40081:07d7dbf18784

(reassert_line_highlight_hook, change_line_highlight_hook): Variables removed. (reassert_line_highlight, change_line_highlight): Functions removed. (standout_requested): Variable removed. (update_end, highlight_if_desired): Don't use it. (chars_wasted, copybuf): Variables removed. (write_standout_marker): Function removed. (cursor_to, clear_to_end, clear_frame, clear_end_of_line_raw) (clear_end_of_line_raw, write_glyphs, ins_del_lines): Don't use `chars_wasted' or `copybuf'. (calculate_costs): Don't allocate `chars_wasted' or `copybuf'. Set `costs_set' to true. (cursor_to, clear_end_of_line): Test `costs_set' instead of `chars_wasted'. (clear_end_of_line): Function removed. (clear_end_of_line_raw): Renamed to `clear_end_of_line'. (clear_to_end): Call `clear_end_of_line' instead of `clear_end_of_line_raw'.
author Miles Bader <miles@gnu.org>
date Sat, 20 Oct 2001 05:53:04 +0000
parents eac4e9ae201c
children 050b19294988
comparison
equal deleted inserted replaced
40080:30ac10baa2b5 40081:07d7dbf18784
115 void (*clear_to_end_hook) P_ ((void)); 115 void (*clear_to_end_hook) P_ ((void));
116 void (*clear_frame_hook) P_ ((void)); 116 void (*clear_frame_hook) P_ ((void));
117 void (*clear_end_of_line_hook) P_ ((int)); 117 void (*clear_end_of_line_hook) P_ ((int));
118 118
119 void (*ins_del_lines_hook) P_ ((int, int)); 119 void (*ins_del_lines_hook) P_ ((int, int));
120
121 void (*change_line_highlight_hook) P_ ((int, int, int, int));
122 void (*reassert_line_highlight_hook) P_ ((int, int));
123 120
124 void (*delete_glyphs_hook) P_ ((int)); 121 void (*delete_glyphs_hook) P_ ((int));
125 122
126 void (*ring_bell_hook) P_ ((void)); 123 void (*ring_bell_hook) P_ ((void));
127 124
386 383
387 /* The largest frame height in any call to calculate_costs. */ 384 /* The largest frame height in any call to calculate_costs. */
388 385
389 int max_frame_height; 386 int max_frame_height;
390 387
391 /* Number of chars of space used for standout marker at beginning of line, 388 int costs_set = 0; /* Nonzero if costs have been calculated. */
392 or'd with 0100. Zero if no standout marker at all.
393 The length of these vectors is max_frame_height.
394
395 Used IFF TN_standout_width >= 0. */
396
397 static char *chars_wasted;
398 static char *copybuf;
399
400 /* nonzero means supposed to write text in standout mode. */
401
402 int standout_requested;
403 389
404 int insert_mode; /* Nonzero when in insert mode. */ 390 int insert_mode; /* Nonzero when in insert mode. */
405 int standout_mode; /* Nonzero when in standout mode. */ 391 int standout_mode; /* Nonzero when in standout mode. */
406 392
407 /* Size of window specified by higher levels. 393 /* Size of window specified by higher levels.
525 { 511 {
526 if (!XWINDOW (selected_window)->cursor_off_p) 512 if (!XWINDOW (selected_window)->cursor_off_p)
527 tty_show_cursor (); 513 tty_show_cursor ();
528 turn_off_insert (); 514 turn_off_insert ();
529 background_highlight (); 515 background_highlight ();
530 standout_requested = 0;
531 } 516 }
532 else 517 else
533 update_end_hook (f); 518 update_end_hook (f);
534 519
535 updating_frame = NULL; 520 updating_frame = NULL;
674 static void 659 static void
675 highlight_if_desired () 660 highlight_if_desired ()
676 { 661 {
677 if (TN_standout_width >= 0) 662 if (TN_standout_width >= 0)
678 return; 663 return;
679 if (!inverse_video == !standout_requested) 664 if (inverse_video)
665 turn_on_highlight ();
666 else
680 turn_off_highlight (); 667 turn_off_highlight ();
681 else
682 turn_on_highlight ();
683 }
684
685 /* Handle standout mode for terminals in which TN_standout_width >= 0.
686 On these terminals, standout is controlled by markers that
687 live inside the terminal's memory. TN_standout_width is the width
688 that the marker occupies in memory. Standout runs from the marker
689 to the end of the line on some terminals, or to the next
690 turn-off-standout marker (TS_end_standout_mode) string
691 on other terminals. */
692
693 /* Write a standout marker or end-standout marker at the front of the line
694 at vertical position vpos. */
695
696 static void
697 write_standout_marker (flag, vpos)
698 int flag, vpos;
699 {
700 if (flag
701 || (TS_end_standout_mode && !TF_teleray && !se_is_so
702 && !(TF_xs && TN_standout_width == 0)))
703 {
704 cmgoto (vpos, 0);
705 cmplus (TN_standout_width);
706 OUTPUT (flag ? TS_standout_mode : TS_end_standout_mode);
707 chars_wasted[curY] = TN_standout_width | 0100;
708 }
709 }
710
711 /* External interface to control of standout mode.
712 Call this when about to modify line at position VPOS
713 and not change whether it is highlighted. */
714
715 void
716 reassert_line_highlight (highlight, vpos)
717 int highlight;
718 int vpos;
719 {
720 struct frame *f = updating_frame ? updating_frame : XFRAME (selected_frame);
721 if (! FRAME_TERMCAP_P (f))
722 {
723 (*reassert_line_highlight_hook) (highlight, vpos);
724 return;
725 }
726 if (TN_standout_width < 0)
727 /* Handle terminals where standout takes affect at output time */
728 standout_requested = highlight;
729 else if (chars_wasted && chars_wasted[vpos] == 0)
730 /* For terminals with standout markers, write one on this line
731 if there isn't one already. */
732 write_standout_marker (inverse_video ? !highlight : highlight, vpos);
733 }
734
735 /* Call this when about to modify line at position VPOS
736 and change whether it is highlighted. */
737
738 void
739 change_line_highlight (new_highlight, vpos, y, first_unused_hpos)
740 int new_highlight, vpos, y, first_unused_hpos;
741 {
742 standout_requested = new_highlight;
743 if (! FRAME_TERMCAP_P (updating_frame))
744 {
745 (*change_line_highlight_hook) (new_highlight, vpos, y, first_unused_hpos);
746 return;
747 }
748
749 cursor_to (vpos, 0);
750
751 if (TN_standout_width < 0)
752 background_highlight ();
753 /* If line starts with a marker, delete the marker */
754 else if (TS_clr_line && chars_wasted[curY])
755 {
756 turn_off_insert ();
757 /* On Teleray, make sure to erase the SO marker. */
758 if (TF_teleray)
759 {
760 cmgoto (curY - 1, FRAME_WIDTH (XFRAME (selected_frame)) - 4);
761 OUTPUT ("\033S");
762 curY++; /* ESC S moves to next line where the TS_standout_mode was */
763 curX = 0;
764 }
765 else
766 cmgoto (curY, 0); /* reposition to kill standout marker */
767 }
768 clear_end_of_line_raw (first_unused_hpos);
769 reassert_line_highlight (new_highlight, curY);
770 } 668 }
771 669
772 670
773 /* Move cursor to row/column position VPOS/HPOS. HPOS/VPOS are 671 /* Move cursor to row/column position VPOS/HPOS. HPOS/VPOS are
774 frame-relative coordinates. */ 672 frame-relative coordinates. */
785 return; 683 return;
786 } 684 }
787 685
788 /* Detect the case where we are called from reset_sys_modes 686 /* Detect the case where we are called from reset_sys_modes
789 and the costs have never been calculated. Do nothing. */ 687 and the costs have never been calculated. Do nothing. */
790 if (chars_wasted == 0) 688 if (! costs_set)
791 return; 689 return;
792 690
793 hpos += chars_wasted[vpos] & 077;
794 if (curY == vpos && curX == hpos) 691 if (curY == vpos && curX == hpos)
795 return; 692 return;
796 if (!TF_standout_motion) 693 if (!TF_standout_motion)
797 background_highlight (); 694 background_highlight ();
798 if (!TF_insmode_motion) 695 if (!TF_insmode_motion)
836 } 733 }
837 if (TS_clr_to_bottom) 734 if (TS_clr_to_bottom)
838 { 735 {
839 background_highlight (); 736 background_highlight ();
840 OUTPUT (TS_clr_to_bottom); 737 OUTPUT (TS_clr_to_bottom);
841 bzero (chars_wasted + curY,
842 FRAME_HEIGHT (XFRAME (selected_frame)) - curY);
843 } 738 }
844 else 739 else
845 { 740 {
846 for (i = curY; i < FRAME_HEIGHT (XFRAME (selected_frame)); i++) 741 for (i = curY; i < FRAME_HEIGHT (XFRAME (selected_frame)); i++)
847 { 742 {
848 cursor_to (i, 0); 743 cursor_to (i, 0);
849 clear_end_of_line_raw (FRAME_WIDTH (XFRAME (selected_frame))); 744 clear_end_of_line (FRAME_WIDTH (XFRAME (selected_frame)));
850 } 745 }
851 } 746 }
852 } 747 }
853 748
854 /* Clear entire frame */ 749 /* Clear entire frame */
866 } 761 }
867 if (TS_clr_frame) 762 if (TS_clr_frame)
868 { 763 {
869 background_highlight (); 764 background_highlight ();
870 OUTPUT (TS_clr_frame); 765 OUTPUT (TS_clr_frame);
871 bzero (chars_wasted, FRAME_HEIGHT (sf));
872 cmat (0, 0); 766 cmat (0, 0);
873 } 767 }
874 else 768 else
875 { 769 {
876 cursor_to (0, 0); 770 cursor_to (0, 0);
877 clear_to_end (); 771 clear_to_end ();
878 } 772 }
879 } 773 }
880 774
881 /* Clear to end of line, but do not clear any standout marker. 775 /* Clear from cursor to end of line.
882 Assumes that the cursor is positioned at a character of real text, 776 Assume that the line is already clear starting at column first_unused_hpos.
883 which implies it cannot be before a standout marker 777
884 unless the marker has zero width. 778 Note that the cursor may be moved, on terminals lacking a `ce' string. */
885
886 Note that the cursor may be moved. */
887 779
888 void 780 void
889 clear_end_of_line (first_unused_hpos) 781 clear_end_of_line (first_unused_hpos)
890 int first_unused_hpos;
891 {
892 if (FRAME_TERMCAP_P (XFRAME (selected_frame))
893 && chars_wasted != 0
894 && TN_standout_width == 0 && curX == 0 && chars_wasted[curY] != 0)
895 write_glyphs (&space_glyph, 1);
896 clear_end_of_line_raw (first_unused_hpos);
897 }
898
899 /* Clear from cursor to end of line.
900 Assume that the line is already clear starting at column first_unused_hpos.
901 If the cursor is at a standout marker, erase the marker.
902
903 Note that the cursor may be moved, on terminals lacking a `ce' string. */
904
905 void
906 clear_end_of_line_raw (first_unused_hpos)
907 int first_unused_hpos; 782 int first_unused_hpos;
908 { 783 {
909 register int i; 784 register int i;
910 785
911 if (clear_end_of_line_hook 786 if (clear_end_of_line_hook
917 return; 792 return;
918 } 793 }
919 794
920 /* Detect the case where we are called from reset_sys_modes 795 /* Detect the case where we are called from reset_sys_modes
921 and the costs have never been calculated. Do nothing. */ 796 and the costs have never been calculated. Do nothing. */
922 if (chars_wasted == 0) 797 if (! costs_set)
923 return; 798 return;
924 799
925 first_unused_hpos += chars_wasted[curY] & 077;
926 if (curX >= first_unused_hpos) 800 if (curX >= first_unused_hpos)
927 return; 801 return;
928 /* Notice if we are erasing a magic cookie */
929 if (curX == 0)
930 chars_wasted[curY] = 0;
931 background_highlight (); 802 background_highlight ();
932 if (TS_clr_line) 803 if (TS_clr_line)
933 { 804 {
934 OUTPUT1 (TS_clr_line); 805 OUTPUT1 (TS_clr_line);
935 } 806 }
1085 /* Don't dare write in last column of bottom line, if Auto-Wrap, 956 /* Don't dare write in last column of bottom line, if Auto-Wrap,
1086 since that would scroll the whole frame on some terminals. */ 957 since that would scroll the whole frame on some terminals. */
1087 958
1088 if (AutoWrap 959 if (AutoWrap
1089 && curY + 1 == FRAME_HEIGHT (sf) 960 && curY + 1 == FRAME_HEIGHT (sf)
1090 && (curX + len - (chars_wasted[curY] & 077) == FRAME_WIDTH (sf))) 961 && (curX + len) == FRAME_WIDTH (sf))
1091 len --; 962 len --;
1092 if (len <= 0) 963 if (len <= 0)
1093 return; 964 return;
1094 965
1095 cmplus (len); 966 cmplus (len);
1355 { 1226 {
1356 register int lower_limit 1227 register int lower_limit
1357 = (scroll_region_ok 1228 = (scroll_region_ok
1358 ? specified_window 1229 ? specified_window
1359 : FRAME_HEIGHT (sf)); 1230 : FRAME_HEIGHT (sf));
1360
1361 if (n < 0)
1362 {
1363 bcopy (&chars_wasted[vpos - n], &chars_wasted[vpos],
1364 lower_limit - vpos + n);
1365 bzero (&chars_wasted[lower_limit + n], - n);
1366 }
1367 else
1368 {
1369 bcopy (&chars_wasted[vpos], &copybuf[vpos], lower_limit - vpos - n);
1370 bcopy (&copybuf[vpos], &chars_wasted[vpos + n],
1371 lower_limit - vpos - n);
1372 bzero (&chars_wasted[vpos], n);
1373 }
1374 } 1231 }
1375 if (!scroll_region_ok && memory_below_frame && n < 0) 1232 if (!scroll_region_ok && memory_below_frame && n < 0)
1376 { 1233 {
1377 cursor_to (FRAME_HEIGHT (sf) + n, 0); 1234 cursor_to (FRAME_HEIGHT (sf) + n, 0);
1378 clear_to_end (); 1235 clear_to_end ();
1507 1364
1508 /* These variables are only used for terminal stuff. They are allocated 1365 /* These variables are only used for terminal stuff. They are allocated
1509 once for the terminal frame of X-windows emacs, but not used afterwards. 1366 once for the terminal frame of X-windows emacs, but not used afterwards.
1510 1367
1511 char_ins_del_vector (i.e., char_ins_del_cost) isn't used because 1368 char_ins_del_vector (i.e., char_ins_del_cost) isn't used because
1512 X turns off char_ins_del_ok. 1369 X turns off char_ins_del_ok. */
1513
1514 chars_wasted and copybuf are only used here in term.c in cases where
1515 the term hook isn't called. */
1516 1370
1517 max_frame_height = max (max_frame_height, FRAME_HEIGHT (frame)); 1371 max_frame_height = max (max_frame_height, FRAME_HEIGHT (frame));
1518 max_frame_width = max (max_frame_width, FRAME_WIDTH (frame)); 1372 max_frame_width = max (max_frame_width, FRAME_WIDTH (frame));
1519 1373
1520 if (chars_wasted != 0) 1374 costs_set = 1;
1521 chars_wasted = (char *) xrealloc (chars_wasted, max_frame_height);
1522 else
1523 chars_wasted = (char *) xmalloc (max_frame_height);
1524
1525 if (copybuf != 0)
1526 copybuf = (char *) xrealloc (copybuf, max_frame_height);
1527 else
1528 copybuf = (char *) xmalloc (max_frame_height);
1529 1375
1530 if (char_ins_del_vector != 0) 1376 if (char_ins_del_vector != 0)
1531 char_ins_del_vector 1377 char_ins_del_vector
1532 = (int *) xrealloc (char_ins_del_vector, 1378 = (int *) xrealloc (char_ins_del_vector,
1533 (sizeof (int) 1379 (sizeof (int)
1535 else 1381 else
1536 char_ins_del_vector 1382 char_ins_del_vector
1537 = (int *) xmalloc (sizeof (int) 1383 = (int *) xmalloc (sizeof (int)
1538 + 2 * max_frame_width * sizeof (int)); 1384 + 2 * max_frame_width * sizeof (int));
1539 1385
1540 bzero (chars_wasted, max_frame_height);
1541 bzero (copybuf, max_frame_height);
1542 bzero (char_ins_del_vector, (sizeof (int) 1386 bzero (char_ins_del_vector, (sizeof (int)
1543 + 2 * max_frame_width * sizeof (int))); 1387 + 2 * max_frame_width * sizeof (int)));
1544 1388
1545 if (f && (!TS_ins_line && !TS_del_line)) 1389 if (f && (!TS_ins_line && !TS_del_line))
1546 do_line_insertion_deletion_costs (frame, 1390 do_line_insertion_deletion_costs (frame,