From 09551c3a191201ebe45e1345e5c515b59ad3d728 Mon Sep 17 00:00:00 2001 From: Vladimir Kazanov Date: Tue, 19 Dec 2023 19:11:26 +0000 Subject: [PATCH] first draft version of user fringe tooltips --- src/dispextern.h | 12 ++++++++++++ src/xdisp.c | 39 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/src/dispextern.h b/src/dispextern.h index ece128949f5..53dee99ab05 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -940,6 +940,12 @@ #define CHECK_MATRIX(MATRIX) ((void) 0) it specifies actual fringe bitmap number. */ int overlay_arrow_bitmap; + /* Left fringe caption (Qnil or a stringp)*/ + Lisp_Object left_user_fringe_caption; + + /* Right fringe caption (Qnil or a stringp)*/ + Lisp_Object right_user_fringe_caption; + /* Left fringe bitmap number (enum fringe_bitmap_type). */ unsigned left_user_fringe_bitmap : FRINGE_ID_BITS; @@ -2762,6 +2768,12 @@ #define OVERLAY_STRING_CHUNK_SIZE 16 is in effect, and only in hscrolled windows. */ int stretch_adjust; + /* Left fringe caption (Qnil or a stringp) */ + Lisp_Object left_user_fringe_caption; + + /* Right fringe caption (Qnil or a stringp)*/ + Lisp_Object right_user_fringe_caption; + /* Left fringe bitmap number (enum fringe_bitmap_type). */ unsigned left_user_fringe_bitmap : FRINGE_ID_BITS; diff --git a/src/xdisp.c b/src/xdisp.c index fdb4acd71bf..0e8a18da358 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -3252,6 +3252,10 @@ init_iterator (struct it *it, struct window *w, /* Clear IT, and set it->object and other IT's Lisp objects to Qnil. Other parts of redisplay rely on that. */ memclear (it, sizeof *it); + + it->left_user_fringe_caption = Qnil; + it->right_user_fringe_caption = Qnil; + it->current.overlay_string_index = -1; it->current.dpvec_index = -1; it->base_face_id = remapped_base_face_id; @@ -6082,6 +6086,13 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, face_id = face_id2; } + Lisp_Object caption = Qnil; + if (CONSP (XCDR (XCDR (XCDR (spec))))) + { + caption = XCAR (XCDR (XCDR (XCDR (spec)))); + } + + /* Save current settings of IT so that we can restore them when we are finished with the glyph property value. */ push_it (it, position); @@ -6105,11 +6116,13 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, { it->left_user_fringe_bitmap = fringe_bitmap; it->left_user_fringe_face_id = face_id; + it->left_user_fringe_caption = caption; } else { it->right_user_fringe_bitmap = fringe_bitmap; it->right_user_fringe_face_id = face_id; + it->right_user_fringe_caption = caption; } } #endif /* HAVE_WINDOW_SYSTEM */ @@ -25593,13 +25606,19 @@ #define RECORD_MAX_MIN_POS(IT) \ /* Save fringe bitmaps in this row. */ row->left_user_fringe_bitmap = it->left_user_fringe_bitmap; row->left_user_fringe_face_id = it->left_user_fringe_face_id; + row->left_user_fringe_caption = it->left_user_fringe_caption; + row->right_user_fringe_bitmap = it->right_user_fringe_bitmap; row->right_user_fringe_face_id = it->right_user_fringe_face_id; + row->right_user_fringe_caption = it->right_user_fringe_caption; it->left_user_fringe_bitmap = 0; it->left_user_fringe_face_id = 0; + it->left_user_fringe_caption = Qnil; + it->right_user_fringe_bitmap = 0; it->right_user_fringe_face_id = 0; + it->right_user_fringe_caption = Qnil; /* When they turn off tooltip-mode on a GUI frame, we call 'message' with message-truncate-lines bound to non-nil, which produces @@ -35273,8 +35292,24 @@ note_mouse_highlight (struct frame *f, int x, int y) } else cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor; - else if (part == ON_LEFT_FRINGE || part == ON_RIGHT_FRINGE - || part == ON_VERTICAL_SCROLL_BAR + else if (part == ON_LEFT_FRINGE || part == ON_RIGHT_FRINGE) + { + cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor; + + if (NILP (help_echo_string)) { + int hpos, vpos, area; + x_y_to_hpos_vpos (w, x, y, &hpos, &vpos, 0, 0, &area); + struct glyph_row *r = MATRIX_ROW (w->current_matrix, vpos); + if (part == ON_LEFT_FRINGE + && !NILP(r->left_user_fringe_caption)) + help_echo_string = r->left_user_fringe_caption; + else if (part == ON_RIGHT_FRINGE + && !NILP(r->right_user_fringe_caption)) + help_echo_string = r->right_user_fringe_caption; + } + + } + else if (part == ON_VERTICAL_SCROLL_BAR || part == ON_HORIZONTAL_SCROLL_BAR) cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor; else -- 2.34.1