comparison src/xdisp.c @ 58240:cbd61b964e09

(store_mode_line_string, produce_stretch_glyph): Use Fsafe_plist_get. (note_mode_line_or_margin_highlight, note_mouse_highlight): Fix image map element parsing. Use Fsafe_plist_get.
author Kim F. Storm <storm@cua.dk>
date Mon, 15 Nov 2004 15:21:34 +0000
parents e4b0cf06e5c1
children 2f12a89f27dd
comparison
equal deleted inserted replaced
58239:6c9552cf734a 58240:cbd61b964e09
15816 lisp_string = make_string (string, len); 15816 lisp_string = make_string (string, len);
15817 if (NILP (props)) 15817 if (NILP (props))
15818 props = mode_line_string_face_prop; 15818 props = mode_line_string_face_prop;
15819 else if (!NILP (mode_line_string_face)) 15819 else if (!NILP (mode_line_string_face))
15820 { 15820 {
15821 Lisp_Object face = Fplist_get (props, Qface); 15821 Lisp_Object face = Fsafe_plist_get (props, Qface);
15822 props = Fcopy_sequence (props); 15822 props = Fcopy_sequence (props);
15823 if (NILP (face)) 15823 if (NILP (face))
15824 face = mode_line_string_face; 15824 face = mode_line_string_face;
15825 else 15825 else
15826 face = Fcons (face, Fcons (mode_line_string_face, Qnil)); 15826 face = Fcons (face, Fcons (mode_line_string_face, Qnil));
15841 if (!NILP (mode_line_string_face)) 15841 if (!NILP (mode_line_string_face))
15842 { 15842 {
15843 Lisp_Object face; 15843 Lisp_Object face;
15844 if (NILP (props)) 15844 if (NILP (props))
15845 props = Ftext_properties_at (make_number (0), lisp_string); 15845 props = Ftext_properties_at (make_number (0), lisp_string);
15846 face = Fplist_get (props, Qface); 15846 face = Fsafe_plist_get (props, Qface);
15847 if (NILP (face)) 15847 if (NILP (face))
15848 face = mode_line_string_face; 15848 face = mode_line_string_face;
15849 else 15849 else
15850 face = Fcons (face, Fcons (mode_line_string_face, Qnil)); 15850 face = Fcons (face, Fcons (mode_line_string_face, Qnil));
15851 props = Fcons (Qface, Fcons (face, Qnil)); 15851 props = Fcons (Qface, Fcons (face, Qnil));
18622 /* List should start with `space'. */ 18622 /* List should start with `space'. */
18623 xassert (CONSP (it->object) && EQ (XCAR (it->object), Qspace)); 18623 xassert (CONSP (it->object) && EQ (XCAR (it->object), Qspace));
18624 plist = XCDR (it->object); 18624 plist = XCDR (it->object);
18625 18625
18626 /* Compute the width of the stretch. */ 18626 /* Compute the width of the stretch. */
18627 if ((prop = Fplist_get (plist, QCwidth), !NILP (prop)) 18627 if ((prop = Fsafe_plist_get (plist, QCwidth), !NILP (prop))
18628 && calc_pixel_width_or_height (&tem, it, prop, font, 1, 0)) 18628 && calc_pixel_width_or_height (&tem, it, prop, font, 1, 0))
18629 { 18629 {
18630 /* Absolute width `:width WIDTH' specified and valid. */ 18630 /* Absolute width `:width WIDTH' specified and valid. */
18631 zero_width_ok_p = 1; 18631 zero_width_ok_p = 1;
18632 width = (int)tem; 18632 width = (int)tem;
18633 } 18633 }
18634 else if (prop = Fplist_get (plist, QCrelative_width), 18634 else if (prop = Fsafe_plist_get (plist, QCrelative_width),
18635 NUMVAL (prop) > 0) 18635 NUMVAL (prop) > 0)
18636 { 18636 {
18637 /* Relative width `:relative-width FACTOR' specified and valid. 18637 /* Relative width `:relative-width FACTOR' specified and valid.
18638 Compute the width of the characters having the `glyph' 18638 Compute the width of the characters having the `glyph'
18639 property. */ 18639 property. */
18653 it2.glyph_row = NULL; 18653 it2.glyph_row = NULL;
18654 it2.what = IT_CHARACTER; 18654 it2.what = IT_CHARACTER;
18655 x_produce_glyphs (&it2); 18655 x_produce_glyphs (&it2);
18656 width = NUMVAL (prop) * it2.pixel_width; 18656 width = NUMVAL (prop) * it2.pixel_width;
18657 } 18657 }
18658 else if ((prop = Fplist_get (plist, QCalign_to), !NILP (prop)) 18658 else if ((prop = Fsafe_plist_get (plist, QCalign_to), !NILP (prop))
18659 && calc_pixel_width_or_height (&tem, it, prop, font, 1, &align_to)) 18659 && calc_pixel_width_or_height (&tem, it, prop, font, 1, &align_to))
18660 { 18660 {
18661 if (it->glyph_row == NULL || !it->glyph_row->mode_line_p) 18661 if (it->glyph_row == NULL || !it->glyph_row->mode_line_p)
18662 align_to = (align_to < 0 18662 align_to = (align_to < 0
18663 ? 0 18663 ? 0
18673 18673
18674 if (width <= 0 && (width < 0 || !zero_width_ok_p)) 18674 if (width <= 0 && (width < 0 || !zero_width_ok_p))
18675 width = 1; 18675 width = 1;
18676 18676
18677 /* Compute height. */ 18677 /* Compute height. */
18678 if ((prop = Fplist_get (plist, QCheight), !NILP (prop)) 18678 if ((prop = Fsafe_plist_get (plist, QCheight), !NILP (prop))
18679 && calc_pixel_width_or_height (&tem, it, prop, font, 0, 0)) 18679 && calc_pixel_width_or_height (&tem, it, prop, font, 0, 0))
18680 { 18680 {
18681 height = (int)tem; 18681 height = (int)tem;
18682 zero_height_ok_p = 1; 18682 zero_height_ok_p = 1;
18683 } 18683 }
18684 else if (prop = Fplist_get (plist, QCrelative_height), 18684 else if (prop = Fsafe_plist_get (plist, QCrelative_height),
18685 NUMVAL (prop) > 0) 18685 NUMVAL (prop) > 0)
18686 height = FONT_HEIGHT (font) * NUMVAL (prop); 18686 height = FONT_HEIGHT (font) * NUMVAL (prop);
18687 else 18687 else
18688 height = FONT_HEIGHT (font); 18688 height = FONT_HEIGHT (font);
18689 18689
18691 height = 1; 18691 height = 1;
18692 18692
18693 /* Compute percentage of height used for ascent. If 18693 /* Compute percentage of height used for ascent. If
18694 `:ascent ASCENT' is present and valid, use that. Otherwise, 18694 `:ascent ASCENT' is present and valid, use that. Otherwise,
18695 derive the ascent from the font in use. */ 18695 derive the ascent from the font in use. */
18696 if (prop = Fplist_get (plist, QCascent), 18696 if (prop = Fsafe_plist_get (plist, QCascent),
18697 NUMVAL (prop) > 0 && NUMVAL (prop) <= 100) 18697 NUMVAL (prop) > 0 && NUMVAL (prop) <= 100)
18698 ascent = height * NUMVAL (prop) / 100.0; 18698 ascent = height * NUMVAL (prop) / 100.0;
18699 else if (!NILP (prop) 18699 else if (!NILP (prop)
18700 && calc_pixel_width_or_height (&tem, it, prop, font, 0, 0)) 18700 && calc_pixel_width_or_height (&tem, it, prop, font, 0, 0))
18701 ascent = min (max (0, (int)tem), height); 18701 ascent = min (max (0, (int)tem), height);
20895 help = Qnil; 20895 help = Qnil;
20896 20896
20897 if (IMAGEP (object)) 20897 if (IMAGEP (object))
20898 { 20898 {
20899 Lisp_Object image_map, hotspot; 20899 Lisp_Object image_map, hotspot;
20900 if ((image_map = Fplist_get (XCDR (object), QCmap), 20900 if ((image_map = Fsafe_plist_get (XCDR (object), QCmap),
20901 !NILP (image_map)) 20901 !NILP (image_map))
20902 && (hotspot = find_hot_spot (image_map, dx, dy), 20902 && (hotspot = find_hot_spot (image_map, dx, dy),
20903 CONSP (hotspot)) 20903 CONSP (hotspot))
20904 && (hotspot = XCDR (hotspot), CONSP (hotspot))) 20904 && (hotspot = XCDR (hotspot), CONSP (hotspot)))
20905 { 20905 {
20907 20907
20908 area_id = XCAR (hotspot); 20908 area_id = XCAR (hotspot);
20909 /* Could check AREA_ID to see if we enter/leave this hot-spot. 20909 /* Could check AREA_ID to see if we enter/leave this hot-spot.
20910 If so, we could look for mouse-enter, mouse-leave 20910 If so, we could look for mouse-enter, mouse-leave
20911 properties in PLIST (and do something...). */ 20911 properties in PLIST (and do something...). */
20912 if ((plist = XCDR (hotspot), CONSP (plist))) 20912 hotspot = XCDR (hotspot);
20913 if (CONSP (hotspot)
20914 && (plist = XCAR (hotspot), CONSP (plist)))
20913 { 20915 {
20914 pointer = Fplist_get (plist, Qpointer); 20916 pointer = Fsafe_plist_get (plist, Qpointer);
20915 if (NILP (pointer)) 20917 if (NILP (pointer))
20916 pointer = Qhand; 20918 pointer = Qhand;
20917 help = Fplist_get (plist, Qhelp_echo); 20919 help = Fsafe_plist_get (plist, Qhelp_echo);
20918 if (!NILP (help)) 20920 if (!NILP (help))
20919 { 20921 {
20920 help_echo_string = help; 20922 help_echo_string = help;
20921 /* Is this correct? ++kfs */ 20923 /* Is this correct? ++kfs */
20922 XSETWINDOW (help_echo_window, w); 20924 XSETWINDOW (help_echo_window, w);
20923 help_echo_object = w->buffer; 20925 help_echo_object = w->buffer;
20924 help_echo_pos = charpos; 20926 help_echo_pos = charpos;
20925 } 20927 }
20926 } 20928 }
20927 if (NILP (pointer)) 20929 if (NILP (pointer))
20928 pointer = Fplist_get (XCDR (object), QCpointer); 20930 pointer = Fsafe_plist_get (XCDR (object), QCpointer);
20929 } 20931 }
20930 } 20932 }
20931 20933
20932 if (STRINGP (string)) 20934 if (STRINGP (string))
20933 { 20935 {
21074 { 21076 {
21075 struct image *img = IMAGE_FROM_ID (f, glyph->u.img_id); 21077 struct image *img = IMAGE_FROM_ID (f, glyph->u.img_id);
21076 if (img != NULL && IMAGEP (img->spec)) 21078 if (img != NULL && IMAGEP (img->spec))
21077 { 21079 {
21078 Lisp_Object image_map, hotspot; 21080 Lisp_Object image_map, hotspot;
21079 if ((image_map = Fplist_get (XCDR (img->spec), QCmap), 21081 if ((image_map = Fsafe_plist_get (XCDR (img->spec), QCmap),
21080 !NILP (image_map)) 21082 !NILP (image_map))
21081 && (hotspot = find_hot_spot (image_map, 21083 && (hotspot = find_hot_spot (image_map,
21082 glyph->slice.x + dx, 21084 glyph->slice.x + dx,
21083 glyph->slice.y + dy), 21085 glyph->slice.y + dy),
21084 CONSP (hotspot)) 21086 CONSP (hotspot))
21088 21090
21089 area_id = XCAR (hotspot); 21091 area_id = XCAR (hotspot);
21090 /* Could check AREA_ID to see if we enter/leave this hot-spot. 21092 /* Could check AREA_ID to see if we enter/leave this hot-spot.
21091 If so, we could look for mouse-enter, mouse-leave 21093 If so, we could look for mouse-enter, mouse-leave
21092 properties in PLIST (and do something...). */ 21094 properties in PLIST (and do something...). */
21093 if ((plist = XCDR (hotspot), CONSP (plist))) 21095 hotspot = XCDR (hotspot);
21096 if (CONSP (hotspot)
21097 && (plist = XCAR (hotspot), CONSP (plist)))
21094 { 21098 {
21095 pointer = Fplist_get (plist, Qpointer); 21099 pointer = Fsafe_plist_get (plist, Qpointer);
21096 if (NILP (pointer)) 21100 if (NILP (pointer))
21097 pointer = Qhand; 21101 pointer = Qhand;
21098 help_echo_string = Fplist_get (plist, Qhelp_echo); 21102 help_echo_string = Fsafe_plist_get (plist, Qhelp_echo);
21099 if (!NILP (help_echo_string)) 21103 if (!NILP (help_echo_string))
21100 { 21104 {
21101 help_echo_window = window; 21105 help_echo_window = window;
21102 help_echo_object = glyph->object; 21106 help_echo_object = glyph->object;
21103 help_echo_pos = glyph->charpos; 21107 help_echo_pos = glyph->charpos;
21104 } 21108 }
21105 } 21109 }
21106 } 21110 }
21107 if (NILP (pointer)) 21111 if (NILP (pointer))
21108 pointer = Fplist_get (XCDR (img->spec), QCpointer); 21112 pointer = Fsafe_plist_get (XCDR (img->spec), QCpointer);
21109 } 21113 }
21110 } 21114 }
21111 21115
21112 /* Clear mouse face if X/Y not over text. */ 21116 /* Clear mouse face if X/Y not over text. */
21113 if (glyph == NULL 21117 if (glyph == NULL