* Re: How to calculate X when dealing with truncate-lines non-nil.
@ 2017-09-28 17:31 Keith David Bershatsky
2017-09-29 16:25 ` Eli Zaretskii
0 siblings, 1 reply; 5+ messages in thread
From: Keith David Bershatsky @ 2017-09-28 17:31 UTC (permalink / raw
To: emacs-devel
I believe this issue is resolvable mathematically as follows:
int x;
if (it.line_wrap == TRUNCATE)
x = it.current_x - it.first_visible_x;
else
x = it.current_x;
Unless anyone sees a problem with this method, the issue is resolved.
Thanks,
Keith
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to calculate X when dealing with truncate-lines non-nil.
2017-09-28 17:31 How to calculate X when dealing with truncate-lines non-nil Keith David Bershatsky
@ 2017-09-29 16:25 ` Eli Zaretskii
0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2017-09-29 16:25 UTC (permalink / raw
To: Keith David Bershatsky; +Cc: emacs-devel
> Date: Thu, 28 Sep 2017 10:31:58 -0700
> From: Keith David Bershatsky <esq@lawlist.com>
>
> I believe this issue is resolvable mathematically as follows:
>
> int x;
> if (it.line_wrap == TRUNCATE)
> x = it.current_x - it.first_visible_x;
> else
> x = it.current_x;
>
> Unless anyone sees a problem with this method, the issue is resolved.
This could be a solution in some cases. The real answer depends on
what exactly does your code do, something that you didn't disclose.
In any case, I think that the 'it.line_wrap == TRUNCATE' condition is
not needed: if you want the window-relative X coordinate, you should
always subtract the first_visible_x value: if it's zero, no harm will
be done.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to calculate X when dealing with truncate-lines non-nil.
@ 2017-09-30 16:32 Keith David Bershatsky
0 siblings, 0 replies; 5+ messages in thread
From: Keith David Bershatsky @ 2017-09-30 16:32 UTC (permalink / raw
To: Eli Zaretskii; +Cc: emacs-devel
Thank you, Eli, for helping me to simplify the code for the window-relative X coordinate. I have implemented the suggested revision.
I now have a working draft of crosshairs for all three situations (i.e., TRUNCATE, WINDOW_WRAP, and WORD_WRAP) by using a combination of window-relative X *and* the absolute IT X. Drawing/erasing multiple fake cursors is done with the former, whereas decision making is based on the latter.
Keith
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
DATE: [09-29-2017 09:25:44] <29 Sep 2017 19:25:44 +0300>
FROM: Eli Zaretskii <eliz@gnu.org>
>
> > Date: Thu, 28 Sep 2017 10:31:58 -0700
> > From: Keith David Bershatsky <esq@lawlist.com>
> >
> > I believe this issue is resolvable mathematically as follows:
> >
> > int x;
> > if (it.line_wrap == TRUNCATE)
> > x = it.current_x - it.first_visible_x;
> > else
> > x = it.current_x;
> >
> > Unless anyone sees a problem with this method, the issue is resolved.
>
> This could be a solution in some cases. The real answer depends on
> what exactly does your code do, something that you didn't disclose.
>
> In any case, I think that the 'it.line_wrap == TRUNCATE' condition is
> not needed: if you want the window-relative X coordinate, you should
> always subtract the first_visible_x value: if it's zero, no harm will
> be done.
^ permalink raw reply [flat|nested] 5+ messages in thread
* How to calculate X when dealing with truncate-lines non-nil.
@ 2017-09-28 3:16 Keith David Bershatsky
2017-09-29 16:13 ` Eli Zaretskii
0 siblings, 1 reply; 5+ messages in thread
From: Keith David Bershatsky @ 2017-09-28 3:16 UTC (permalink / raw
To: Emacs Devel
In developing my own feature requests to draw crosshairs (#17684) using multiple fake cursors (#22873), I have reached a roadblock in understanding why
move_it_to (&it, PT, it.last_visible_x, it.last_visible_y - 1, -1, MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y);
is giving me an it.current_x of non-existent coordinates to the imaginary right of the visible window when truncate-lines is non-nil.
For example, my screen is 1920 x 1080. When PT is somewhere to the right of the initial visible window, I'm getting X coordinates to a tune of 8,000 and so forth.
How can I obtain the correct X, Y, HPOS, VPOS when dealing with a non-nil truncate-lines situation?
[Everything works as expected when truncate-lines is nil.]
Thanks,
Keith
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to calculate X when dealing with truncate-lines non-nil.
2017-09-28 3:16 Keith David Bershatsky
@ 2017-09-29 16:13 ` Eli Zaretskii
0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2017-09-29 16:13 UTC (permalink / raw
To: Keith David Bershatsky; +Cc: emacs-devel
> Date: Wed, 27 Sep 2017 20:16:11 -0700
> From: Keith David Bershatsky <esq@lawlist.com>
>
> In developing my own feature requests to draw crosshairs (#17684) using multiple fake cursors (#22873), I have reached a roadblock in understanding why
>
> move_it_to (&it, PT, it.last_visible_x, it.last_visible_y - 1, -1, MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y);
>
> is giving me an it.current_x of non-existent coordinates to the imaginary right of the visible window when truncate-lines is non-nil.
>
> For example, my screen is 1920 x 1080. When PT is somewhere to the right of the initial visible window, I'm getting X coordinates to a tune of 8,000 and so forth.
>
> How can I obtain the correct X, Y, HPOS, VPOS when dealing with a non-nil truncate-lines situation?
You didn't show enough of your code to answer the question. Please
show everything from the call to init_iterator or start_display to the
above call to move_it_to.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-09-30 16:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-28 17:31 How to calculate X when dealing with truncate-lines non-nil Keith David Bershatsky
2017-09-29 16:25 ` Eli Zaretskii
-- strict thread matches above, loose matches on Subject: below --
2017-09-30 16:32 Keith David Bershatsky
2017-09-28 3:16 Keith David Bershatsky
2017-09-29 16:13 ` Eli Zaretskii
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.