Mercurial > emacs
comparison src/dispnew.c @ 6617:6309d97ee4bc
(scroll_frame_lines): Handle charstarts like glyphs.
(direct_output_for_insert): Likewise.
(preserve_other_columns): Likewise.
(update_line): Update charstarts like glyphs.
(make_frame_glyphs): Initialize charstarts, total_charstarts.
(free_frame_glyphs): Free those fields.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 31 Mar 1994 23:22:23 +0000 |
parents | d681b16231a8 |
children | 990d7d5095dc |
comparison
equal
deleted
inserted
replaced
6616:951c8941b931 | 6617:6309d97ee4bc |
---|---|
1 /* Updating of data structures for redisplay. | 1 /* Updating of data structures for redisplay. |
2 Copyright (C) 1985, 1986, 1987, 1988, 1993 Free Software Foundation, Inc. | 2 Copyright (C) 1985, 86, 87, 88, 93, 94 Free Software Foundation, Inc. |
3 | 3 |
4 This file is part of GNU Emacs. | 4 This file is part of GNU Emacs. |
5 | 5 |
6 GNU Emacs is free software; you can redistribute it and/or modify | 6 GNU Emacs is free software; you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
233 int empty; | 233 int empty; |
234 { | 234 { |
235 register int i; | 235 register int i; |
236 register width = FRAME_WIDTH (frame); | 236 register width = FRAME_WIDTH (frame); |
237 register height = FRAME_HEIGHT (frame); | 237 register height = FRAME_HEIGHT (frame); |
238 register struct frame_glyphs *new = | 238 register struct frame_glyphs *new |
239 (struct frame_glyphs *) xmalloc (sizeof (struct frame_glyphs)); | 239 = (struct frame_glyphs *) xmalloc (sizeof (struct frame_glyphs)); |
240 | 240 |
241 SET_GLYPHS_FRAME (new, frame); | 241 SET_GLYPHS_FRAME (new, frame); |
242 new->height = height; | 242 new->height = height; |
243 new->width = width; | 243 new->width = width; |
244 new->used = (int *) xmalloc (height * sizeof (int)); | 244 new->used = (int *) xmalloc (height * sizeof (int)); |
245 new->glyphs = (GLYPH **) xmalloc (height * sizeof (GLYPH *)); | 245 new->glyphs = (GLYPH **) xmalloc (height * sizeof (GLYPH *)); |
246 new->charstarts = (int **) xmalloc (height * sizeof (int *)); | |
246 new->highlight = (char *) xmalloc (height * sizeof (char)); | 247 new->highlight = (char *) xmalloc (height * sizeof (char)); |
247 new->enable = (char *) xmalloc (height * sizeof (char)); | 248 new->enable = (char *) xmalloc (height * sizeof (char)); |
248 bzero (new->enable, height * sizeof (char)); | 249 bzero (new->enable, height * sizeof (char)); |
249 new->bufp = (int *) xmalloc (height * sizeof (int)); | 250 new->bufp = (int *) xmalloc (height * sizeof (int)); |
250 | 251 |
274 | 275 |
275 new->total_contents = (GLYPH *) xmalloc (total_glyphs); | 276 new->total_contents = (GLYPH *) xmalloc (total_glyphs); |
276 bzero (new->total_contents, total_glyphs); | 277 bzero (new->total_contents, total_glyphs); |
277 for (i = 0; i < height; i++) | 278 for (i = 0; i < height; i++) |
278 new->glyphs[i] = new->total_contents + i * (width + 2) + 1; | 279 new->glyphs[i] = new->total_contents + i * (width + 2) + 1; |
280 | |
281 if (!FRAME_TERMCAP_P (frame)) | |
282 { | |
283 unsigned int total_charstarts = height * (width + 2) * sizeof (int); | |
284 | |
285 new->total_charstarts = (int *) xmalloc (total_charstarts); | |
286 bzero (new->total_charstarts, total_charstarts); | |
287 for (i = 0; i < height; i++) | |
288 new->charstarts[i] = new->total_charstarts + i * (width + 2) + 1; | |
289 } | |
290 else | |
291 { | |
292 /* Without a window system, we don't really need charstarts. | |
293 So use a small amount of space to make enough data structure | |
294 to prevent crashes in display_text_line. */ | |
295 new->total_charstarts = (int *) xmalloc ((width + 2) * sizeof (int)); | |
296 for (i = 0; i < height; i++) | |
297 new->charstarts[i] = new->total_charstarts; | |
298 } | |
279 } | 299 } |
280 | 300 |
281 return new; | 301 return new; |
282 } | 302 } |
283 | 303 |
286 FRAME_PTR frame; | 306 FRAME_PTR frame; |
287 struct frame_glyphs *glyphs; | 307 struct frame_glyphs *glyphs; |
288 { | 308 { |
289 if (glyphs->total_contents) | 309 if (glyphs->total_contents) |
290 xfree (glyphs->total_contents); | 310 xfree (glyphs->total_contents); |
311 if (glyphs->total_charstarts) | |
312 xfree (glyphs->total_charstarts); | |
291 | 313 |
292 xfree (glyphs->used); | 314 xfree (glyphs->used); |
293 xfree (glyphs->glyphs); | 315 xfree (glyphs->glyphs); |
294 xfree (glyphs->highlight); | 316 xfree (glyphs->highlight); |
295 xfree (glyphs->enable); | 317 xfree (glyphs->enable); |
296 xfree (glyphs->bufp); | 318 xfree (glyphs->bufp); |
319 if (glyphs->charstarts) | |
320 xfree (glyphs->charstarts); | |
297 | 321 |
298 #ifdef HAVE_X_WINDOWS | 322 #ifdef HAVE_X_WINDOWS |
299 if (FRAME_X_P (frame)) | 323 if (FRAME_X_P (frame)) |
300 { | 324 { |
301 xfree (glyphs->top_left_x); | 325 xfree (glyphs->top_left_x); |
569 /* Scroll lines from vpos FROM up to but not including vpos END | 593 /* Scroll lines from vpos FROM up to but not including vpos END |
570 down by AMOUNT lines (AMOUNT may be negative). | 594 down by AMOUNT lines (AMOUNT may be negative). |
571 Returns nonzero if done, zero if terminal cannot scroll them. */ | 595 Returns nonzero if done, zero if terminal cannot scroll them. */ |
572 | 596 |
573 int | 597 int |
574 scroll_frame_lines (frame, from, end, amount) | 598 scroll_frame_lines (frame, from, end, amount, pos_adjust) |
575 register FRAME_PTR frame; | 599 register FRAME_PTR frame; |
576 int from, end, amount; | 600 int from, end, amount, pos_adjust; |
577 { | 601 { |
578 register int i; | 602 register int i; |
579 register struct frame_glyphs *current_frame | 603 register struct frame_glyphs *current_frame |
580 = FRAME_CURRENT_GLYPHS (frame); | 604 = FRAME_CURRENT_GLYPHS (frame); |
581 | 605 |
595 set_terminal_window (0); | 619 set_terminal_window (0); |
596 | 620 |
597 rotate_vector (current_frame->glyphs + from, | 621 rotate_vector (current_frame->glyphs + from, |
598 sizeof (GLYPH *) * (end + amount - from), | 622 sizeof (GLYPH *) * (end + amount - from), |
599 amount * sizeof (GLYPH *)); | 623 amount * sizeof (GLYPH *)); |
624 | |
625 rotate_vector (current_frame->charstarts + from, | |
626 sizeof (GLYPH *) * (end + amount - from), | |
627 amount * sizeof (GLYPH *)); | |
628 | |
629 /* Offset each char position in the charstarts lines we moved | |
630 by pos_adjust. */ | |
631 for (i = from + amount; i < end; i++) | |
632 { | |
633 int *line = current_frame->charstarts[from]; | |
634 int col; | |
635 for (col = 0; col < current_frame->used[from]; col++) | |
636 line[col] += pos_adjust; | |
637 } | |
638 for (i = from; i <= from + amount; i++) | |
639 { | |
640 int *line = current_frame->charstarts[from]; | |
641 int col; | |
642 line[0] = -1; | |
643 for (col = 0; col < current_frame->used[from]; col++) | |
644 line[col] = 0; | |
645 } | |
600 | 646 |
601 safe_bcopy (current_frame->used + from, | 647 safe_bcopy (current_frame->used + from, |
602 current_frame->used + from + amount, | 648 current_frame->used + from + amount, |
603 (end - from) * sizeof current_frame->used[0]); | 649 (end - from) * sizeof current_frame->used[0]); |
604 | 650 |
617 bzero (current_frame->highlight + from, | 663 bzero (current_frame->highlight + from, |
618 amount * sizeof current_frame->highlight[0]); | 664 amount * sizeof current_frame->highlight[0]); |
619 for (i = from; i < from + amount; i++) | 665 for (i = from; i < from + amount; i++) |
620 { | 666 { |
621 current_frame->glyphs[i][0] = '\0'; | 667 current_frame->glyphs[i][0] = '\0'; |
668 current_frame->charstarts[i][0] = -1; | |
622 current_frame->enable[i] = 1; | 669 current_frame->enable[i] = 1; |
623 } | 670 } |
624 | 671 |
625 safe_bcopy (current_frame->bufp + from, | 672 safe_bcopy (current_frame->bufp + from, |
626 current_frame->bufp + from + amount, | 673 current_frame->bufp + from + amount, |
663 set_terminal_window (0); | 710 set_terminal_window (0); |
664 | 711 |
665 rotate_vector (current_frame->glyphs + from + amount, | 712 rotate_vector (current_frame->glyphs + from + amount, |
666 sizeof (GLYPH *) * (end - from - amount), | 713 sizeof (GLYPH *) * (end - from - amount), |
667 amount * sizeof (GLYPH *)); | 714 amount * sizeof (GLYPH *)); |
715 | |
716 rotate_vector (current_frame->charstarts + from + amount, | |
717 sizeof (GLYPH *) * (end - from - amount), | |
718 amount * sizeof (GLYPH *)); | |
719 | |
720 /* Offset each char position in the charstarts lines we moved | |
721 by pos_adjust. */ | |
722 for (i = from + amount; i < end + amount; i++) | |
723 { | |
724 int *line = current_frame->charstarts[from]; | |
725 int col; | |
726 for (col = 0; col < current_frame->used[from]; col++) | |
727 line[col] += pos_adjust; | |
728 } | |
729 for (i = end + amount; i <= end; i++) | |
730 { | |
731 int *line = current_frame->charstarts[from]; | |
732 int col; | |
733 line[0] = -1; | |
734 for (col = 0; col < current_frame->used[from]; col++) | |
735 line[col] = 0; | |
736 } | |
668 | 737 |
669 safe_bcopy (current_frame->used + from, | 738 safe_bcopy (current_frame->used + from, |
670 current_frame->used + from + amount, | 739 current_frame->used + from + amount, |
671 (end - from) * sizeof current_frame->used[0]); | 740 (end - from) * sizeof current_frame->used[0]); |
672 | 741 |
685 bzero (current_frame->highlight + end + amount, | 754 bzero (current_frame->highlight + end + amount, |
686 - amount * sizeof current_frame->highlight[0]); | 755 - amount * sizeof current_frame->highlight[0]); |
687 for (i = end + amount; i < end; i++) | 756 for (i = end + amount; i < end; i++) |
688 { | 757 { |
689 current_frame->glyphs[i][0] = '\0'; | 758 current_frame->glyphs[i][0] = '\0'; |
759 current_frame->charstarts[i][0] = 0; | |
690 current_frame->enable[i] = 1; | 760 current_frame->enable[i] = 1; |
691 } | 761 } |
692 | 762 |
693 safe_bcopy (current_frame->bufp + from, | 763 safe_bcopy (current_frame->bufp + from, |
694 current_frame->bufp + from + amount, | 764 current_frame->bufp + from + amount, |
751 int len; | 821 int len; |
752 | 822 |
753 bcopy (current_frame->glyphs[vpos], | 823 bcopy (current_frame->glyphs[vpos], |
754 desired_frame->glyphs[vpos], | 824 desired_frame->glyphs[vpos], |
755 start * sizeof (current_frame->glyphs[vpos])); | 825 start * sizeof (current_frame->glyphs[vpos])); |
826 bcopy (current_frame->charstarts[vpos], | |
827 desired_frame->charstarts[vpos], | |
828 start * sizeof (current_frame->charstarts[vpos])); | |
756 len = min (start, current_frame->used[vpos]); | 829 len = min (start, current_frame->used[vpos]); |
757 if (desired_frame->used[vpos] < len) | 830 if (desired_frame->used[vpos] < len) |
758 desired_frame->used[vpos] = len; | 831 desired_frame->used[vpos] = len; |
759 } | 832 } |
760 if (current_frame->used[vpos] > end | 833 if (current_frame->used[vpos] > end |
761 && desired_frame->used[vpos] < current_frame->used[vpos]) | 834 && desired_frame->used[vpos] < current_frame->used[vpos]) |
762 { | 835 { |
763 while (desired_frame->used[vpos] < end) | 836 while (desired_frame->used[vpos] < end) |
764 desired_frame->glyphs[vpos][desired_frame->used[vpos]++] | 837 { |
765 = SPACEGLYPH; | 838 int used = desired_frame->used[vpos]++; |
839 desired_frame->glyphs[vpos][used] = SPACEGLYPH; | |
840 desired_frame->glyphs[vpos][used] = 0; | |
841 } | |
766 bcopy (current_frame->glyphs[vpos] + end, | 842 bcopy (current_frame->glyphs[vpos] + end, |
767 desired_frame->glyphs[vpos] + end, | 843 desired_frame->glyphs[vpos] + end, |
768 ((current_frame->used[vpos] - end) | 844 ((current_frame->used[vpos] - end) |
769 * sizeof (current_frame->glyphs[vpos]))); | 845 * sizeof (current_frame->glyphs[vpos]))); |
846 bcopy (current_frame->charstarts[vpos] + end, | |
847 desired_frame->charstarts[vpos] + end, | |
848 ((current_frame->used[vpos] - end) | |
849 * sizeof (current_frame->charstarts[vpos]))); | |
770 desired_frame->used[vpos] = current_frame->used[vpos]; | 850 desired_frame->used[vpos] = current_frame->used[vpos]; |
771 } | 851 } |
772 } | 852 } |
773 } | 853 } |
774 } | 854 } |
818 | 898 |
819 cancel_my_columns (w) | 899 cancel_my_columns (w) |
820 struct window *w; | 900 struct window *w; |
821 { | 901 { |
822 register int vpos; | 902 register int vpos; |
823 register struct frame_glyphs *desired_glyphs = | 903 register struct frame_glyphs *desired_glyphs |
824 FRAME_DESIRED_GLYPHS (XFRAME (w->frame)); | 904 = FRAME_DESIRED_GLYPHS (XFRAME (w->frame)); |
825 register int start = XFASTINT (w->left); | 905 register int start = XFASTINT (w->left); |
826 register int bot = XFASTINT (w->top) + XFASTINT (w->height); | 906 register int bot = XFASTINT (w->top) + XFASTINT (w->height); |
827 | 907 |
828 for (vpos = XFASTINT (w->top); vpos < bot; vpos++) | 908 for (vpos = XFASTINT (w->top); vpos < bot; vpos++) |
829 if (desired_glyphs->enable[vpos] | 909 if (desired_glyphs->enable[vpos] |
896 #ifdef HAVE_X_WINDOWS | 976 #ifdef HAVE_X_WINDOWS |
897 int dummy; | 977 int dummy; |
898 int face = compute_char_face (frame, w, point - 1, -1, -1, &dummy, point); | 978 int face = compute_char_face (frame, w, point - 1, -1, -1, &dummy, point); |
899 #endif | 979 #endif |
900 current_frame->glyphs[vpos][hpos] = MAKE_GLYPH (frame, g, face); | 980 current_frame->glyphs[vpos][hpos] = MAKE_GLYPH (frame, g, face); |
981 current_frame->charstarts[vpos][hpos] = point; | |
901 } | 982 } |
902 unchanged_modified = MODIFF; | 983 unchanged_modified = MODIFF; |
903 beg_unchanged = GPT - BEG; | 984 beg_unchanged = GPT - BEG; |
904 XFASTINT (w->last_point) = point; | 985 XFASTINT (w->last_point) = point; |
905 XFASTINT (w->last_point_x) = hpos; | 986 XFASTINT (w->last_point_x) = hpos; |
1319 update_line (frame, vpos) | 1400 update_line (frame, vpos) |
1320 register FRAME_PTR frame; | 1401 register FRAME_PTR frame; |
1321 int vpos; | 1402 int vpos; |
1322 { | 1403 { |
1323 register GLYPH *obody, *nbody, *op1, *op2, *np1, *temp; | 1404 register GLYPH *obody, *nbody, *op1, *op2, *np1, *temp; |
1405 int *temp1; | |
1324 int tem; | 1406 int tem; |
1325 int osp, nsp, begmatch, endmatch, olen, nlen; | 1407 int osp, nsp, begmatch, endmatch, olen, nlen; |
1326 int save; | 1408 int save; |
1327 register struct frame_glyphs *current_frame | 1409 register struct frame_glyphs *current_frame |
1328 = FRAME_CURRENT_GLYPHS (frame); | 1410 = FRAME_CURRENT_GLYPHS (frame); |
1461 /* Exchange contents between current_frame and new_frame. */ | 1543 /* Exchange contents between current_frame and new_frame. */ |
1462 temp = desired_frame->glyphs[vpos]; | 1544 temp = desired_frame->glyphs[vpos]; |
1463 desired_frame->glyphs[vpos] = current_frame->glyphs[vpos]; | 1545 desired_frame->glyphs[vpos] = current_frame->glyphs[vpos]; |
1464 current_frame->glyphs[vpos] = temp; | 1546 current_frame->glyphs[vpos] = temp; |
1465 | 1547 |
1548 /* Exchange charstarts between current_frame and new_frame. */ | |
1549 temp1 = desired_frame->charstarts[vpos]; | |
1550 desired_frame->charstarts[vpos] = current_frame->charstarts[vpos]; | |
1551 current_frame->charstarts[vpos] = temp1; | |
1552 | |
1466 return; | 1553 return; |
1467 } | 1554 } |
1468 | 1555 |
1469 if (!olen) | 1556 if (!olen) |
1470 { | 1557 { |
1478 | 1565 |
1479 /* Exchange contents between current_frame and new_frame. */ | 1566 /* Exchange contents between current_frame and new_frame. */ |
1480 temp = desired_frame->glyphs[vpos]; | 1567 temp = desired_frame->glyphs[vpos]; |
1481 desired_frame->glyphs[vpos] = current_frame->glyphs[vpos]; | 1568 desired_frame->glyphs[vpos] = current_frame->glyphs[vpos]; |
1482 current_frame->glyphs[vpos] = temp; | 1569 current_frame->glyphs[vpos] = temp; |
1570 | |
1571 /* Exchange charstarts between current_frame and new_frame. */ | |
1572 temp1 = desired_frame->charstarts[vpos]; | |
1573 desired_frame->charstarts[vpos] = current_frame->charstarts[vpos]; | |
1574 current_frame->charstarts[vpos] = temp1; | |
1483 | 1575 |
1484 return; | 1576 return; |
1485 } | 1577 } |
1486 | 1578 |
1487 obody[olen] = 1; | 1579 obody[olen] = 1; |
1639 | 1731 |
1640 /* Exchange contents between current_frame and new_frame. */ | 1732 /* Exchange contents between current_frame and new_frame. */ |
1641 temp = desired_frame->glyphs[vpos]; | 1733 temp = desired_frame->glyphs[vpos]; |
1642 desired_frame->glyphs[vpos] = current_frame->glyphs[vpos]; | 1734 desired_frame->glyphs[vpos] = current_frame->glyphs[vpos]; |
1643 current_frame->glyphs[vpos] = temp; | 1735 current_frame->glyphs[vpos] = temp; |
1736 | |
1737 /* Exchange charstarts between current_frame and new_frame. */ | |
1738 temp1 = desired_frame->charstarts[vpos]; | |
1739 desired_frame->charstarts[vpos] = current_frame->charstarts[vpos]; | |
1740 current_frame->charstarts[vpos] = temp1; | |
1644 } | 1741 } |
1645 | 1742 |
1646 DEFUN ("open-termscript", Fopen_termscript, Sopen_termscript, | 1743 DEFUN ("open-termscript", Fopen_termscript, Sopen_termscript, |
1647 1, 1, "FOpen termscript file: ", | 1744 1, 1, "FOpen termscript file: ", |
1648 "Start writing all terminal output to FILE as well as the terminal.\n\ | 1745 "Start writing all terminal output to FILE as well as the terminal.\n\ |