aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGerd Moellmann2001-03-09 18:41:50 +0000
committerGerd Moellmann2001-03-09 18:41:50 +0000
commit74bd6d658d72193652c03de3366388b9cce1911c (patch)
tree3c0d4f9fc7608e30483443c1f070e7eddce0eae5 /src
parent56ab5d27d04a4e2262af6960b4154bac8813a3c4 (diff)
downloademacs-74bd6d658d72193652c03de3366388b9cce1911c.tar.gz
emacs-74bd6d658d72193652c03de3366388b9cce1911c.zip
(string_buffer_position, display_prop_string_p)
(single_display_prop_string_p): New functions.
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c128
1 files changed, 128 insertions, 0 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 23fc0a4b089..314ba0ac06f 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -654,6 +654,8 @@ enum move_it_result
654 654
655/* Function prototypes. */ 655/* Function prototypes. */
656 656
657static int single_display_prop_string_p P_ ((Lisp_Object, Lisp_Object));
658static int display_prop_string_p P_ ((Lisp_Object, Lisp_Object));
657static int cursor_row_p P_ ((struct window *, struct glyph_row *)); 659static int cursor_row_p P_ ((struct window *, struct glyph_row *));
658static int redisplay_mode_lines P_ ((Lisp_Object, int)); 660static int redisplay_mode_lines P_ ((Lisp_Object, int));
659static char *decode_mode_spec_coding P_ ((Lisp_Object, char *, int)); 661static char *decode_mode_spec_coding P_ ((Lisp_Object, char *, int));
@@ -2995,6 +2997,132 @@ display_prop_intangible_p (prop)
2995 return 0; 2997 return 0;
2996} 2998}
2997 2999
3000
3001/* Return 1 if PROP is a display sub-property value containing STRING. */
3002
3003static int
3004single_display_prop_string_p (prop, string)
3005 Lisp_Object prop, string;
3006{
3007 extern Lisp_Object Qwhen, Qmargin;
3008
3009 if (EQ (string, prop))
3010 return 1;
3011
3012 /* Skip over `when FORM'. */
3013 if (CONSP (prop) && EQ (XCAR (prop), Qwhen))
3014 {
3015 prop = XCDR (prop);
3016 if (!CONSP (prop))
3017 return 0;
3018 prop = XCDR (prop);
3019 }
3020
3021 if (CONSP (prop))
3022 /* Skip over `margin LOCATION'. */
3023 if (EQ (XCAR (prop), Qmargin))
3024 {
3025 prop = XCDR (prop);
3026 if (!CONSP (prop))
3027 return 0;
3028
3029 prop = XCDR (prop);
3030 if (!CONSP (prop))
3031 return 0;
3032 }
3033
3034 return CONSP (prop) && EQ (XCAR (prop), string);
3035}
3036
3037
3038/* Return 1 if STRING appears in the `display' property PROP. */
3039
3040static int
3041display_prop_string_p (prop, string)
3042 Lisp_Object prop, string;
3043{
3044 extern Lisp_Object Qwhen, Qmargin;
3045
3046 if (CONSP (prop)
3047 && CONSP (XCAR (prop))
3048 && !EQ (Qmargin, XCAR (XCAR (prop))))
3049 {
3050 /* A list of sub-properties. */
3051 while (CONSP (prop))
3052 {
3053 if (single_display_prop_string_p (XCAR (prop), string))
3054 return 1;
3055 prop = XCDR (prop);
3056 }
3057 }
3058 else if (VECTORP (prop))
3059 {
3060 /* A vector of sub-properties. */
3061 int i;
3062 for (i = 0; i < ASIZE (prop); ++i)
3063 if (single_display_prop_string_p (AREF (prop, i), string))
3064 return 1;
3065 }
3066 else
3067 return single_display_prop_string_p (prop, string);
3068
3069 return 0;
3070}
3071
3072
3073/* Determine from which buffer position in W's buffer STRING comes
3074 from. AROUND_CHARPOS is an approximate position where it could
3075 be from. Value is the buffer position or 0 if it couldn't be
3076 determined.
3077
3078 W's buffer must be current.
3079
3080 This function is necessary because we don't record buffer positions
3081 in glyphs generated from strings (to keep struct glyph small).
3082 This function may only use code that doesn't eval because it is
3083 called asynchronously from note_mouse_highlight. */
3084
3085int
3086string_buffer_position (w, string, around_charpos)
3087 struct window *w;
3088 Lisp_Object string;
3089 int around_charpos;
3090{
3091 Lisp_Object around = make_number (around_charpos);
3092 Lisp_Object limit, prop, pos;
3093 const int MAX_DISTANCE = 1000;
3094 int found = 0;
3095
3096 pos = around_charpos;
3097 limit = make_number (min (XINT (pos) + MAX_DISTANCE, ZV));
3098 while (!found && !EQ (pos, limit))
3099 {
3100 prop = Fget_char_property (pos, Qdisplay, Qnil);
3101 if (!NILP (prop) && display_prop_string_p (prop, string))
3102 found = 1;
3103 else
3104 pos = Fnext_single_property_change (pos, Qdisplay, Qnil, limit);
3105 }
3106
3107 if (!found)
3108 {
3109 pos = around_charpos;
3110 limit = make_number (max (XINT (pos) - MAX_DISTANCE, BEGV));
3111 while (!found && !EQ (pos, limit))
3112 {
3113 prop = Fget_char_property (pos, Qdisplay, Qnil);
3114 if (!NILP (prop) && display_prop_string_p (prop, string))
3115 found = 1;
3116 else
3117 pos = Fprevious_single_property_change (pos, Qdisplay, Qnil,
3118 limit);
3119 }
3120 }
3121
3122 return found ? XINT (pos) : 0;
3123}
3124
3125
2998 3126
2999/*********************************************************************** 3127/***********************************************************************
3000 `composition' property 3128 `composition' property