unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#30226: Fixing it->pixel_width / it->current_x when tabs and line numbers.
@ 2018-01-23  7:32 Keith David Bershatsky
  2018-01-23  7:52 ` Keith David Bershatsky
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Keith David Bershatsky @ 2018-01-23  7:32 UTC (permalink / raw)
  To: 30226

[-- Attachment #1: Type: text/plain, Size: 2119 bytes --]

The following snippet contains the ingredients that can be used to ultimately fix the problem described on the emacs-devel mailing list beginning at:

https://lists.gnu.org/archive/html/emacs-devel/2018-01/msg00466.html

In a nutshell, it->pixel_width and it->current_x are both incorrect in that situation.  Because the X is wrong, all subsequent references to it->current_x on the same line are also wrong.  In this snippet, we create a new gizmo in dispextern.h called my_pixel_width so as not to break anything while working on this issue.  Someone more knowledgeable than myself (e.g., Eli) will need to figure out what other adjustments in x_produce_glyphs are necessary so that it->pixel_width == it->my_pixel_width in this particular situation.  It is a little confusing, but here is what happens in this snippet:

it->pixel_width "should be" equal to it->my_pixel_width.  If we do that, however, then it->current_x will be wrong.

it->current_x "should be" equal to it->current_x less one (1) font->space_width.  Setting it->pixel_width to be one (1) font->space_width less than what it was fixes the value of it->current_x and does not break anything else in the process (as far as I can see).


dispextern.h:2590

  int my_pixel_width;


xdisp.c:28298

  if (it->char_to_display == '\t'
      && !NILP (Vdisplay_line_numbers)
      && it->w->hscroll > 0
      && it->current_x < it->lnum_pixel_width)
    {
      int my_tab_width = it->tab_width * font->space_width;
      int my_x = it->current_x + it->continuation_lines_width;
      int my_next_tab_x = ((1 + my_x + my_tab_width - 1) / my_tab_width)
                          * my_tab_width;
      if (my_next_tab_x - my_x < font->space_width)
        my_next_tab_x += my_tab_width;
      if (!NILP (Vdisplay_line_numbers))
        my_next_tab_x += it->lnum_pixel_width
                         - ((it->w->hscroll * font->space_width)
                            % my_tab_width);
      it->my_pixel_width = my_next_tab_x - it->lnum_pixel_width - font->space_width;
      it->pixel_width -= font->space_width;
    }
    else
      it->my_pixel_width = 0;


[-- Attachment #2: patch.diff --]
[-- Type: application/diff, Size: 9234 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2018-02-19 18:52 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-23  7:32 bug#30226: Fixing it->pixel_width / it->current_x when tabs and line numbers Keith David Bershatsky
2018-01-23  7:52 ` Keith David Bershatsky
2018-01-27 14:56   ` Eli Zaretskii
2018-01-27 21:20 ` Keith David Bershatsky
2018-01-28 18:15   ` Eli Zaretskii
2018-01-28 19:52 ` Keith David Bershatsky
2018-01-29 16:14   ` Eli Zaretskii
2018-01-31  8:03 ` Keith David Bershatsky
2018-02-04 19:21 ` Keith David Bershatsky
2018-02-19  2:17 ` Keith David Bershatsky
2018-02-19 16:28   ` Eli Zaretskii
2018-02-19 18:52 ` Keith David Bershatsky

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).