emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calculating screen relative X when horizontal scrolling.


From: Keith David Bershatsky
Subject: Re: Calculating screen relative X when horizontal scrolling.
Date: Sat, 20 Oct 2018 02:55:35 -0700

When line numbers are _not_ displayed, it->current_x - it->first_visible_x 
yields the correct relative_x when calling (scroll-left INTEGER).  Partially 
displayed characters are supported at the far left of the screen in that 
scenario.

In the (scroll-left 11) situation (with the first visible text character being 
a middle dot with a pixel width of 11), the first wide character 'の' is already 
hidden off to the left of the screen.  However, that hidden wide character 'の' 
is apparently affecting the ability to obtain the correct it->first-visible_x / 
it->current_x.  In other words, the situation does not appear to be caused by 
virtue of the first _visible_ text character to the immediate right of the line 
numbers.

Is there a test you can think of for these situations such that I can instruct 
Emacs _when_ to use a _modified_ it->first-visible_x / it->current_x for 
purposes of calculating the relative_x?

Here are the printouts from my debugging stderr messages....  The line 
beginning with "POSITION ..." is generated when moving IT on the current line 
and stopping at each new X.  The line beginning with "Glyph# ..." is generated 
by a modified version of dump_glyph_row, which lets us see the real 
it->current_x when the glyph was actually drawn on the screen.


(scroll-left 9)

POSITION     X    Y HPOS VPOS HSCL MIN_H 1ST_X LNUMW  TYPE N   F   W     C D
      19    99  204    0    9    9     0    99    44  CHAR 1  24  18 12398 の

Glyph# Rel.X Type       Pos O   W     Code Face LR     X    Y HPOS VPOS C
     0     0    C        -1 0  11 0x000020   17 00     0   24    0    0  
     1    11    C        -1 0  11 0x000031   17 00    11   24    0    0 1
     2    22    C        -1 0  11 0x000030   17 00    22   24    0    0 0
     3    33    C        -1 0  11 0x000020   17 00    33   24    0    0  
     4    44    C        19 B  18 0x00306e   24 00   143  204    4    9 の


(scroll-left 10)

POSITION     X    Y HPOS VPOS HSCL MIN_H 1ST_X LNUMW  TYPE N   F   W     C D
      19    99  204    0    9   10     0   110    44  CHAR 1  24  18 12398 の

Glyph# Rel.X Type       Pos O   W     Code Face LR     X    Y HPOS VPOS C
     0     0    C        -1 0  11 0x000020   17 00     0   24    0    0  
     1    11    C        -1 0  11 0x000031   17 00    11   24    0    0 1
     2    22    C        -1 0  11 0x000030   17 00    22   24    0    0 0
     3    33    C        -1 0  11 0x000020   17 00    33   24    0    0  
     4    44    C        19 B  18 0x00306e   24 00   143  204    3    9 の


(scroll-left 11)

POSITION     X    Y HPOS VPOS HSCL MIN_H 1ST_X LNUMW  TYPE N   F   W     C D
      20   117  204    0    9   11     0   121    44  CHAR 1  19  11   183 ·

Glyph# Rel.X Type       Pos O   W     Code Face LR     X    Y HPOS VPOS C
     0     0    C        -1 0  11 0x000020   17 00     0   24    0    0  
     1    11    C        -1 0  11 0x000031   17 00    11   24    0    0 1
     2    22    C        -1 0  11 0x000030   17 00    22   24    0    0 0
     3    33    C        -1 0  11 0x000020   17 00    33   24    0    0  
     4    44    C        20 B  11 0x0000b7   19 00   161  204    4    9 ·

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

> Date: [10-20-2018 00:13:26] <20 Oct 2018 10:13:26 +0300>
> From: Eli Zaretskii <address@hidden>
> To: Keith David Bershatsky <address@hidden>
> CC: address@hidden
> Subject: Re: Calculating screen relative X when horizontal scrolling.
> 
> > Date:  Fri, 19 Oct 2018 12:58:56 -0700
> > From:  Keith David Bershatsky <address@hidden>
> > Cc:  address@hidden
> >
> > For reference point of this particular analysis:
> >
> > it->lnum_pixel_width == 44
> 
> Are your problems limited to the situation where line numbers are
> displayed?
> 
> > To help me see what is happening, I put in a few new entries just above 
> > 'glyph->charpos = ' in all six (6) locations within xdisp.c and assigned a 
> > new "gizmo" (for lack of knowing the proper name) like this 'glyph->x = 
> > it->current_x;' with the appropriate corresponding entry for glyph->x in 
> > dispextern.h.  In the custom dump glyph row (discussed above), I can see 
> > that glyph->x for the first 'の' character is actually 143, not 99.
> 
> Since 143 = 99 + 44, and first_visible_x for scroll-left of 9 is 99 in
> your case, I think everything is OK.  You just need to account for
> lnum_pixel_width, which is 44 in this case.
> 
> When you change scroll-left to 10, a wide character such as 'の' will
> not move off the display if line numbers are displayed, because we
> don't know how to draw partial characters in that mode.  This might be
> considered a bug in the current display code.  But I don't think this
> should affect your code.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]