From db1db309387c253d42ea86465b21acc086120a92 Mon Sep 17 00:00:00 2001 From: Gerd Moellmann Date: Fri, 12 Apr 2002 09:36:56 +0000 Subject: [PATCH] (marginal_area_string): New. --- src/dispnew.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/dispnew.c b/src/dispnew.c index 0ef62cfb4bc..8217dec33aa 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -5754,6 +5754,57 @@ mode_line_string (w, x, y, mode_line_p, charpos) } +/* Value is the string under window-relative coordinates X/Y in either + marginal area, or nil if none. *CHARPOS is set to the position in + the string returned. */ + +Lisp_Object +marginal_area_string (w, x, y, area, charpos) + struct window *w; + int x, y; + int *charpos; + int area; +{ + struct glyph_row *row = w->current_matrix->rows; + struct glyph *glyph, *end; + int x0, i, wy = y; + Lisp_Object string = Qnil; + + if (area == 6) + area = LEFT_MARGIN_AREA; + else if (area == 7) + area = RIGHT_MARGIN_AREA; + else + abort (); + + for (i = 0; row->enabled_p && i < w->current_matrix->nrows; ++i, ++row) + if (wy >= row->y && wy < MATRIX_ROW_BOTTOM_Y (row)) + break; + + if (row->enabled_p) + { + /* Find the glyph under X. If we find one with a string object, + it's the one we were looking for. */ + glyph = row->glyphs[area]; + end = glyph + row->used[area]; + if (area == RIGHT_MARGIN_AREA) + x0 = (window_box_width (w, TEXT_AREA) + + window_box_width (w, LEFT_MARGIN_AREA)); + else + x0 = 0; + for (; glyph < end; x0 += glyph->pixel_width, ++glyph) + if (x >= x0 && x < x0 + glyph->pixel_width) + { + string = glyph->object; + *charpos = glyph->charpos; + break; + } + } + + return string; +} + + /*********************************************************************** Changing Frame Sizes ***********************************************************************/ -- 2.39.5