Mercurial > hg > xemacs-beta
comparison src/extents.c @ 110:fe104dbd9147 r20-1b7
Import from CVS: tag r20-1b7
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:19:45 +0200 |
parents | 4be1180a9e89 |
children | cca96a509cfe |
comparison
equal
deleted
inserted
replaced
109:e183fc049578 | 110:fe104dbd9147 |
---|---|
1576 /* A change to an extent occurred that will change the display, so | 1576 /* A change to an extent occurred that will change the display, so |
1577 notify redisplay. Maybe also recurse over all the extent's | 1577 notify redisplay. Maybe also recurse over all the extent's |
1578 descendants. */ | 1578 descendants. */ |
1579 | 1579 |
1580 static void | 1580 static void |
1581 extent_changed_for_redisplay (EXTENT extent, int descendants_too) | 1581 extent_changed_for_redisplay (EXTENT extent, int descendants_too, |
1582 int invisibility_change) | |
1582 { | 1583 { |
1583 Lisp_Object object; | 1584 Lisp_Object object; |
1584 Lisp_Object rest; | 1585 Lisp_Object rest; |
1585 | 1586 |
1586 /* we could easily encounter a detached extent while traversing the | 1587 /* we could easily encounter a detached extent while traversing the |
1595 { | 1596 { |
1596 /* first mark all of the extent's children. We will lose big-time | 1597 /* first mark all of the extent's children. We will lose big-time |
1597 if there are any circularities here, so we sure as hell better | 1598 if there are any circularities here, so we sure as hell better |
1598 ensure that there aren't. */ | 1599 ensure that there aren't. */ |
1599 LIST_LOOP (rest, XWEAK_LIST_LIST (children)) | 1600 LIST_LOOP (rest, XWEAK_LIST_LIST (children)) |
1600 extent_changed_for_redisplay (XEXTENT (XCAR (rest)), 1); | 1601 extent_changed_for_redisplay (XEXTENT (XCAR (rest)), 1, |
1602 invisibility_change); | |
1601 } | 1603 } |
1602 } | 1604 } |
1603 | 1605 |
1604 /* now mark the extent itself. */ | 1606 /* now mark the extent itself. */ |
1605 | 1607 |
1624 { | 1626 { |
1625 struct buffer *b; | 1627 struct buffer *b; |
1626 b = XBUFFER (object); | 1628 b = XBUFFER (object); |
1627 BUF_FACECHANGE (b)++; | 1629 BUF_FACECHANGE (b)++; |
1628 MARK_EXTENTS_CHANGED; | 1630 MARK_EXTENTS_CHANGED; |
1631 if (invisibility_change) | |
1632 MARK_CLIP_CHANGED; | |
1629 buffer_extent_signal_changed_region (b, | 1633 buffer_extent_signal_changed_region (b, |
1630 extent_endpoint_bufpos (extent, 0), | 1634 extent_endpoint_bufpos (extent, 0), |
1631 extent_endpoint_bufpos (extent, 1)); | 1635 extent_endpoint_bufpos (extent, 1)); |
1632 } | 1636 } |
1633 } | 1637 } |
1636 This is called when properties such as the endpoints, the layout, | 1640 This is called when properties such as the endpoints, the layout, |
1637 or the priority changes. Redisplay will be affected only if | 1641 or the priority changes. Redisplay will be affected only if |
1638 the extent has any displayable attributes. */ | 1642 the extent has any displayable attributes. */ |
1639 | 1643 |
1640 static void | 1644 static void |
1641 extent_maybe_changed_for_redisplay (EXTENT extent, int descendants_too) | 1645 extent_maybe_changed_for_redisplay (EXTENT extent, int descendants_too, |
1646 int invisibility_change) | |
1642 { | 1647 { |
1643 /* Retrieve the ancestor for efficiency */ | 1648 /* Retrieve the ancestor for efficiency */ |
1644 EXTENT anc = extent_ancestor (extent); | 1649 EXTENT anc = extent_ancestor (extent); |
1645 if (!NILP (extent_face (anc)) || !NILP (extent_begin_glyph (anc)) || | 1650 if (!NILP (extent_face (anc)) || !NILP (extent_begin_glyph (anc)) || |
1646 !NILP (extent_end_glyph (anc)) || !NILP (extent_mouse_face (anc)) || | 1651 !NILP (extent_end_glyph (anc)) || !NILP (extent_mouse_face (anc)) || |
1647 !NILP (extent_invisible (anc))) | 1652 !NILP (extent_invisible (anc)) || invisibility_change) |
1648 extent_changed_for_redisplay (extent, descendants_too); | 1653 extent_changed_for_redisplay (extent, descendants_too, |
1654 invisibility_change); | |
1649 } | 1655 } |
1650 | 1656 |
1651 static EXTENT | 1657 static EXTENT |
1652 make_extent_detached (Lisp_Object object) | 1658 make_extent_detached (Lisp_Object object) |
1653 { | 1659 { |
1791 Extent_List *el = extent_extent_list (extent); | 1797 Extent_List *el = extent_extent_list (extent); |
1792 | 1798 |
1793 extent_list_insert (el, extent); | 1799 extent_list_insert (el, extent); |
1794 soe_insert (extent_object (extent), extent); | 1800 soe_insert (extent_object (extent), extent); |
1795 /* only this extent changed */ | 1801 /* only this extent changed */ |
1796 extent_maybe_changed_for_redisplay (extent, 0); | 1802 extent_maybe_changed_for_redisplay (extent, 0, |
1803 !NILP (extent_invisible (extent))); | |
1797 } | 1804 } |
1798 | 1805 |
1799 static void | 1806 static void |
1800 extent_detach (EXTENT extent) | 1807 extent_detach (EXTENT extent) |
1801 { | 1808 { |
1804 if (extent_detached_p (extent)) | 1811 if (extent_detached_p (extent)) |
1805 return; | 1812 return; |
1806 el = extent_extent_list (extent); | 1813 el = extent_extent_list (extent); |
1807 | 1814 |
1808 /* call this before messing with the extent. */ | 1815 /* call this before messing with the extent. */ |
1809 extent_maybe_changed_for_redisplay (extent, 0); | 1816 extent_maybe_changed_for_redisplay (extent, 0, |
1817 !NILP (extent_invisible (extent))); | |
1810 extent_list_delete (el, extent); | 1818 extent_list_delete (el, extent); |
1811 soe_delete (extent_object (extent), extent); | 1819 soe_delete (extent_object (extent), extent); |
1812 set_extent_start (extent, -1); | 1820 set_extent_start (extent, -1); |
1813 set_extent_end (extent, -1); | 1821 set_extent_end (extent, -1); |
1814 } | 1822 } |
3510 add_extent_to_children_list (XEXTENT (parent), extent); | 3518 add_extent_to_children_list (XEXTENT (parent), extent); |
3511 set_extent_no_chase_aux_field (e, parent, parent); | 3519 set_extent_no_chase_aux_field (e, parent, parent); |
3512 e->flags.has_parent = 1; | 3520 e->flags.has_parent = 1; |
3513 } | 3521 } |
3514 /* changing the parent also changes the properties of all children. */ | 3522 /* changing the parent also changes the properties of all children. */ |
3515 extent_maybe_changed_for_redisplay (e, 1); | 3523 { |
3524 int old_invis = (!NILP (cur_parent) && | |
3525 !NILP (extent_invisible (XEXTENT (cur_parent)))); | |
3526 int new_invis = (!NILP (parent) && | |
3527 !NILP (extent_invisible (XEXTENT (parent)))); | |
3528 | |
3529 extent_maybe_changed_for_redisplay (e, 1, new_invis != old_invis); | |
3530 } | |
3531 | |
3516 return Qnil; | 3532 return Qnil; |
3517 } | 3533 } |
3518 | 3534 |
3519 | 3535 |
3520 /************************************************************************/ | 3536 /************************************************************************/ |
4609 set_extent_invisible (EXTENT extent, Lisp_Object value) | 4625 set_extent_invisible (EXTENT extent, Lisp_Object value) |
4610 { | 4626 { |
4611 if (!EQ (extent_invisible (extent), value)) | 4627 if (!EQ (extent_invisible (extent), value)) |
4612 { | 4628 { |
4613 set_extent_invisible_1 (extent, value); | 4629 set_extent_invisible_1 (extent, value); |
4614 extent_changed_for_redisplay (extent, 1); | 4630 extent_changed_for_redisplay (extent, 1, 1); |
4615 } | 4631 } |
4616 } | 4632 } |
4617 | 4633 |
4618 /* This function does "memoization" -- similar to the interning | 4634 /* This function does "memoization" -- similar to the interning |
4619 that happens with symbols. Given a list of faces, an equivalent | 4635 that happens with symbols. Given a list of faces, an equivalent |
4766 with faces earlier in the list taking priority over those later in the | 4782 with faces earlier in the list taking priority over those later in the |
4767 list. | 4783 list. |
4768 */ | 4784 */ |
4769 (extent, face)) | 4785 (extent, face)) |
4770 { | 4786 { |
4771 EXTENT e; | 4787 EXTENT e = decode_extent(extent, 0); |
4772 Lisp_Object orig_face = face; | 4788 Lisp_Object orig_face = face; |
4773 | 4789 |
4774 CHECK_EXTENT (extent); | |
4775 e = XEXTENT (extent); | |
4776 /* retrieve the ancestor for efficiency and proper redisplay noting. */ | 4790 /* retrieve the ancestor for efficiency and proper redisplay noting. */ |
4777 e = extent_ancestor (e); | 4791 e = extent_ancestor (e); |
4778 | 4792 |
4779 face = memoize_extent_face_internal (face); | 4793 face = memoize_extent_face_internal (face); |
4780 | 4794 |
4781 extent_face (e) = face; | 4795 extent_face (e) = face; |
4782 extent_changed_for_redisplay (e, 1); | 4796 extent_changed_for_redisplay (e, 1, 0); |
4783 | 4797 |
4784 return orig_face; | 4798 return orig_face; |
4785 } | 4799 } |
4786 | 4800 |
4787 | 4801 |
4817 e = extent_ancestor (e); | 4831 e = extent_ancestor (e); |
4818 | 4832 |
4819 face = memoize_extent_face_internal (face); | 4833 face = memoize_extent_face_internal (face); |
4820 | 4834 |
4821 set_extent_mouse_face (e, face); | 4835 set_extent_mouse_face (e, face); |
4822 extent_changed_for_redisplay (e, 1); | 4836 extent_changed_for_redisplay (e, 1, 0); |
4823 | 4837 |
4824 return orig_face; | 4838 return orig_face; |
4825 } | 4839 } |
4826 | 4840 |
4827 void | 4841 void |
4839 { | 4853 { |
4840 set_extent_end_glyph (extent, glyph); | 4854 set_extent_end_glyph (extent, glyph); |
4841 extent_end_glyph_layout (extent) = layout; | 4855 extent_end_glyph_layout (extent) = layout; |
4842 } | 4856 } |
4843 | 4857 |
4844 extent_changed_for_redisplay (extent, 1); | 4858 extent_changed_for_redisplay (extent, 1, 0); |
4845 } | 4859 } |
4846 | 4860 |
4847 static Lisp_Object | 4861 static Lisp_Object |
4848 glyph_layout_to_symbol (unsigned int layout) | 4862 glyph_layout_to_symbol (unsigned int layout) |
4849 { | 4863 { |
4941 (extent, layout)) | 4955 (extent, layout)) |
4942 { | 4956 { |
4943 EXTENT e = decode_extent (extent, 0); | 4957 EXTENT e = decode_extent (extent, 0); |
4944 e = extent_ancestor (e); | 4958 e = extent_ancestor (e); |
4945 extent_begin_glyph_layout (e) = symbol_to_glyph_layout (layout); | 4959 extent_begin_glyph_layout (e) = symbol_to_glyph_layout (layout); |
4946 extent_maybe_changed_for_redisplay (e, 1); | 4960 extent_maybe_changed_for_redisplay (e, 1, 0); |
4947 return layout; | 4961 return layout; |
4948 } | 4962 } |
4949 | 4963 |
4950 DEFUN ("set-extent-end-glyph-layout", Fset_extent_end_glyph_layout, 2, 2, 0, /* | 4964 DEFUN ("set-extent-end-glyph-layout", Fset_extent_end_glyph_layout, 2, 2, 0, /* |
4951 Set the layout policy of the given extent's end glyph. | 4965 Set the layout policy of the given extent's end glyph. |
4954 (extent, layout)) | 4968 (extent, layout)) |
4955 { | 4969 { |
4956 EXTENT e = decode_extent (extent, 0); | 4970 EXTENT e = decode_extent (extent, 0); |
4957 e = extent_ancestor (e); | 4971 e = extent_ancestor (e); |
4958 extent_end_glyph_layout (e) = symbol_to_glyph_layout (layout); | 4972 extent_end_glyph_layout (e) = symbol_to_glyph_layout (layout); |
4959 extent_maybe_changed_for_redisplay (e, 1); | 4973 extent_maybe_changed_for_redisplay (e, 1, 0); |
4960 return layout; | 4974 return layout; |
4961 } | 4975 } |
4962 | 4976 |
4963 DEFUN ("extent-begin-glyph-layout", Fextent_begin_glyph_layout, 1, 1, 0, /* | 4977 DEFUN ("extent-begin-glyph-layout", Fextent_begin_glyph_layout, 1, 1, 0, /* |
4964 Return the layout policy associated with the given extent's begin glyph. | 4978 Return the layout policy associated with the given extent's begin glyph. |
4993 EXTENT e = decode_extent (extent, 0); | 5007 EXTENT e = decode_extent (extent, 0); |
4994 | 5008 |
4995 CHECK_INT (pri); | 5009 CHECK_INT (pri); |
4996 e = extent_ancestor (e); | 5010 e = extent_ancestor (e); |
4997 set_extent_priority (e, XINT (pri)); | 5011 set_extent_priority (e, XINT (pri)); |
4998 extent_maybe_changed_for_redisplay (e, 1); | 5012 extent_maybe_changed_for_redisplay (e, 1, 0); |
4999 return pri; | 5013 return pri; |
5000 } | 5014 } |
5001 | 5015 |
5002 DEFUN ("extent-priority", Fextent_priority, 1, 1, 0, /* | 5016 DEFUN ("extent-priority", Fextent_priority, 1, 1, 0, /* |
5003 Return the display priority of EXTENT; see `set-extent-priority'. | 5017 Return the display priority of EXTENT; see `set-extent-priority'. |
5373 if (EXTENTP (Vlast_highlighted_extent) && | 5387 if (EXTENTP (Vlast_highlighted_extent) && |
5374 EXTENT_LIVE_P (XEXTENT (Vlast_highlighted_extent))) | 5388 EXTENT_LIVE_P (XEXTENT (Vlast_highlighted_extent))) |
5375 { | 5389 { |
5376 /* do not recurse on descendants. Only one extent is highlighted | 5390 /* do not recurse on descendants. Only one extent is highlighted |
5377 at a time. */ | 5391 at a time. */ |
5378 extent_changed_for_redisplay (XEXTENT (Vlast_highlighted_extent), 0); | 5392 extent_changed_for_redisplay (XEXTENT (Vlast_highlighted_extent), 0, 0); |
5379 } | 5393 } |
5380 Vlast_highlighted_extent = Qnil; | 5394 Vlast_highlighted_extent = Qnil; |
5381 if (!NILP (extent_obj) | 5395 if (!NILP (extent_obj) |
5382 && BUFFERP (extent_object (XEXTENT (extent_obj))) | 5396 && BUFFERP (extent_object (XEXTENT (extent_obj))) |
5383 && highlight_p) | 5397 && highlight_p) |
5384 { | 5398 { |
5385 extent_changed_for_redisplay (XEXTENT (extent_obj), 0); | 5399 extent_changed_for_redisplay (XEXTENT (extent_obj), 0, 0); |
5386 Vlast_highlighted_extent = extent_obj; | 5400 Vlast_highlighted_extent = extent_obj; |
5387 } | 5401 } |
5388 } | 5402 } |
5389 | 5403 |
5390 DEFUN ("force-highlight-extent", Fforce_highlight_extent, 1, 2, 0, /* | 5404 DEFUN ("force-highlight-extent", Fforce_highlight_extent, 1, 2, 0, /* |