[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to record the line number pixel width for each window.
From: |
Keith David Bershatsky |
Subject: |
How to record the line number pixel width for each window. |
Date: |
Thu, 05 Dec 2019 10:19:07 -0800 |
I am working on feature requests 22873 (multiple fake cursors) and 17684
(crosshairs and visible fill column, both of which able to vertically intersect
characters at any screen X coordinate). The latest patch is:
VERSION: 022.005 [11/17/2019]
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22873#176
Features 17684/22873 have been purposefully designed to obviate the need to
call start_display; i.e., there is no need to move IT in order to obtain any
values used in the implementation of 17684/22873.
I do not want to use the built-in function line_number_display_width, which
fires up start_display and moves IT to figure out the line number pixel width
(among other values). Instead, I would like to devise a reliable method
whereby the display engine records the value (line number pixel width) for each
window (wherever features 17684/22873 are active), such that those values are
reliably accessible when Emacs calls update_window (located in dispnew.c).
I have been using the snippet below to record the value of the line number
pixel width for each window. This value, however, is unreliable when dealing
with a window containing folded/hidden text, such as an org-mode buffer. When
dealing with folded/hidden text (e.g., org-mode), the recorded value
sporadically changes while moving the cursor (e.g. pressing the arrow keys)
even though the contents of the window do not change.
How can I perfect the recorded value of the line number pixel width, and also
avoid expressly firing up a new instance of start_display and moving IT for the
sole purpose of determining the value for each window during update_window (in
dispnew.c)?
Thanks,
Keith
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
diff --git a/src/xdisp.c b/src/xdisp.c
index 2467b33..dd901da 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -22720,6 +22720,28 @@ maybe_produce_line_number (struct it *it)
}
}
+
+/* ***************************************************************************
*/
+/* MULTIPLE-CURSORS */
+
+ struct buffer *b = XBUFFER (it->w->contents);
+ struct buffer *old_buffer = NULL;
+ /* Needed so that buffer-local values can be determined; e.g., when switching
+ to the minibuffer. */
+ if (b != current_buffer)
+ {
+ old_buffer = current_buffer;
+ set_buffer_internal (b);
+ }
+ it->w->mc.lnum_pixel_width = (!NILP (Vdisplay_line_numbers))
+ ? tem_it.current_x
+ : 0;
+ if (old_buffer)
+ set_buffer_internal (old_buffer);
+
+/* ***************************************************************************
*/
+
+
/* Record the width in pixels we need for the line number display. */
it->lnum_pixel_width = tem_it.current_x;
/* Copy the produced glyphs into IT's glyph_row. */
- How to record the line number pixel width for each window.,
Keith David Bershatsky <=