* Correct way to implement `pixel-point-and-height-at-unseen-line'? [not found] <87pmq1wag9.fsf.ref@yahoo.com> @ 2021-12-13 1:38 ` Po Lu 2021-12-13 2:20 ` Emanuel Berg via Users list for the GNU Emacs text editor 2021-12-13 14:32 ` Eli Zaretskii 0 siblings, 2 replies; 14+ messages in thread From: Po Lu @ 2021-12-13 1:38 UTC (permalink / raw) To: help-gnu-emacs I don't know how to make `pixel-point-and-height-at-unseen-line' work correctly: if I use `line-pixel-height', it will only report the height the first individual line inside a display string if there is one above window start, but if I use `window-text-pixel-size', I have to determine the region to measure, which is quite troublesome. For example, window start is often not the beginning of a visual line in Info buffers, so in order to measure the height of the previous line (or object), I have to find the beginning of the visual line at window start, and pass that as the `to' argument to window-text-pixel-size instead. This works okay until there is a `line-prefix' property at window start: in this case, window start is the beginning of a visual line, but it does not display at the beginning of the line, which means `window-text-pixel-size' will add the height of the current line to that of the previous line. I will add a workaround to pixel-scroll.el, but there must be a cleaner way to implement this. Thanks in advance. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Correct way to implement `pixel-point-and-height-at-unseen-line'? 2021-12-13 1:38 ` Correct way to implement `pixel-point-and-height-at-unseen-line'? Po Lu @ 2021-12-13 2:20 ` Emanuel Berg via Users list for the GNU Emacs text editor 2021-12-13 2:49 ` Po Lu 2021-12-13 14:32 ` Eli Zaretskii 1 sibling, 1 reply; 14+ messages in thread From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-12-13 2:20 UTC (permalink / raw) To: help-gnu-emacs Po Lu wrote: > I don't know how to make > `pixel-point-and-height-at-unseen-line' work correctly: if > I use `line-pixel-height', it will only report the height > the first individual line inside a display string if there > is one above window start, but if I use > `window-text-pixel-size', I have to determine the region to > measure, which is quite troublesome. > > For example, window start is often not the beginning of > a visual line `window-start', `beginning-of-visual-line' ... You can post the code instead ... that way you don't have to remove the dashes. > This works okay until there is a `line-prefix' property at > window start: in this case, window start is the beginning of > a visual line, but it does not display at the beginning of > the line, which means `window-text-pixel-size' will add the > height of the current line to that of the previous line. > I will add a workaround to pixel-scroll.el, but there must > be a cleaner way to implement this. Sounds pretty clean to me but difficult to say since you are not posting the actual code. -- underground experts united https://dataswamp.org/~incal ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Correct way to implement `pixel-point-and-height-at-unseen-line'? 2021-12-13 2:20 ` Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-12-13 2:49 ` Po Lu 2021-12-13 3:04 ` Emanuel Berg via Users list for the GNU Emacs text editor 0 siblings, 1 reply; 14+ messages in thread From: Po Lu @ 2021-12-13 2:49 UTC (permalink / raw) To: help-gnu-emacs Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> writes: > Po Lu wrote: > >> I don't know how to make >> `pixel-point-and-height-at-unseen-line' work correctly: if >> I use `line-pixel-height', it will only report the height >> the first individual line inside a display string if there >> is one above window start, but if I use >> `window-text-pixel-size', I have to determine the region to >> measure, which is quite troublesome. >> >> For example, window start is often not the beginning of >> a visual line > > `window-start', `beginning-of-visual-line' ... > > You can post the code instead ... that way you don't have to > remove the dashes. > >> This works okay until there is a `line-prefix' property at >> window start: in this case, window start is the beginning of >> a visual line, but it does not display at the beginning of >> the line, which means `window-text-pixel-size' will add the >> height of the current line to that of the previous line. >> I will add a workaround to pixel-scroll.el, but there must >> be a cleaner way to implement this. > > Sounds pretty clean to me but difficult to say since you are > not posting the actual code. It's in pixel-scroll.el inside the lisp folder on master. See `pixel-point-and-height-at-unseen-lie'. Thanks. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Correct way to implement `pixel-point-and-height-at-unseen-line'? 2021-12-13 2:49 ` Po Lu @ 2021-12-13 3:04 ` Emanuel Berg via Users list for the GNU Emacs text editor 2021-12-13 3:18 ` Po Lu 0 siblings, 1 reply; 14+ messages in thread From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-12-13 3:04 UTC (permalink / raw) To: help-gnu-emacs Po Lu wrote: >> Sounds pretty clean to me but difficult to say since you >> are not posting the actual code. > > It's in pixel-scroll.el inside the lisp folder on master. > See `pixel-point-and-height-at-unseen-lie'. Don't have that ... GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, cairo version 1.16.0) of 2021-10-04 -- underground experts united https://dataswamp.org/~incal ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Correct way to implement `pixel-point-and-height-at-unseen-line'? 2021-12-13 3:04 ` Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-12-13 3:18 ` Po Lu 2021-12-13 23:41 ` Emanuel Berg via Users list for the GNU Emacs text editor 0 siblings, 1 reply; 14+ messages in thread From: Po Lu @ 2021-12-13 3:18 UTC (permalink / raw) To: help-gnu-emacs Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> writes: > Po Lu wrote: > >>> Sounds pretty clean to me but difficult to say since you >>> are not posting the actual code. >> >> It's in pixel-scroll.el inside the lisp folder on master. >> See `pixel-point-and-height-at-unseen-lie'. > > Don't have that ... > > GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, cairo version > 1.16.0) of 2021-10-04 10th Oct is a bit early. It was introduced in late November, but the version that is relevant to this discussion is today's revision. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Correct way to implement `pixel-point-and-height-at-unseen-line'? 2021-12-13 3:18 ` Po Lu @ 2021-12-13 23:41 ` Emanuel Berg via Users list for the GNU Emacs text editor 2021-12-14 0:41 ` Po Lu 0 siblings, 1 reply; 14+ messages in thread From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-12-13 23:41 UTC (permalink / raw) To: help-gnu-emacs Po Lu wrote: > 10th Oct is a bit early. It was introduced in late November, > but the version that is relevant to this discussion is > today's revision. Okay, what's your suggestion then? -- underground experts united https://dataswamp.org/~incal ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Correct way to implement `pixel-point-and-height-at-unseen-line'? 2021-12-13 23:41 ` Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-12-14 0:41 ` Po Lu 0 siblings, 0 replies; 14+ messages in thread From: Po Lu @ 2021-12-14 0:41 UTC (permalink / raw) To: help-gnu-emacs Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> writes: > Po Lu wrote: > >> 10th Oct is a bit early. It was introduced in late November, >> but the version that is relevant to this discussion is >> today's revision. > > Okay, what's your suggestion then? To look at today's master then? ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Correct way to implement `pixel-point-and-height-at-unseen-line'? 2021-12-13 1:38 ` Correct way to implement `pixel-point-and-height-at-unseen-line'? Po Lu 2021-12-13 2:20 ` Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-12-13 14:32 ` Eli Zaretskii 2021-12-14 0:41 ` Po Lu 1 sibling, 1 reply; 14+ messages in thread From: Eli Zaretskii @ 2021-12-13 14:32 UTC (permalink / raw) To: help-gnu-emacs > From: Po Lu <luangruo@yahoo.com> > Date: Mon, 13 Dec 2021 09:38:30 +0800 > > I don't know how to make `pixel-point-and-height-at-unseen-line' work > correctly: if I use `line-pixel-height', it will only report the height > the first individual line inside a display string if there is one above > window start, but if I use `window-text-pixel-size', I have to determine > the region to measure, which is quite troublesome. > > For example, window start is often not the beginning of a visual line in > Info buffers, so in order to measure the height of the previous line (or > object), I have to find the beginning of the visual line at window > start, and pass that as the `to' argument to window-text-pixel-size > instead. > > This works okay until there is a `line-prefix' property at window start: > in this case, window start is the beginning of a visual line, but it > does not display at the beginning of the line, which means > `window-text-pixel-size' will add the height of the current line to that > of the previous line. I will add a workaround to pixel-scroll.el, but > there must be a cleaner way to implement this. The correct way is to use window-text-pixel-size. Whatever problems that gives you in some corner use cases, we'd need to teach window-text-pixel-size to handle those at least optionally. And you didn't describe why do you need pixel-point-and-height-at-unseen-line's data in the first place, so maybe there's a different solution to whatever you are trying to do that doesn't involve such a function. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Correct way to implement `pixel-point-and-height-at-unseen-line'? 2021-12-13 14:32 ` Eli Zaretskii @ 2021-12-14 0:41 ` Po Lu 2021-12-14 13:30 ` Eli Zaretskii 0 siblings, 1 reply; 14+ messages in thread From: Po Lu @ 2021-12-14 0:41 UTC (permalink / raw) To: Eli Zaretskii; +Cc: help-gnu-emacs Eli Zaretskii <eliz@gnu.org> writes: > And you didn't describe why do you need > pixel-point-and-height-at-unseen-line's data in the first place, so > maybe there's a different solution to whatever you are trying to do > that doesn't involve such a function. It's used to find a suitable new start position that's N pixels above window start, so vscroll can then be set to compensate for the difference. For instance, scrolling up by a delta of 1 pixel if vscroll is already zero will move to such a start position, and set vscroll to the returned height - 1. Thanks. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Correct way to implement `pixel-point-and-height-at-unseen-line'? 2021-12-14 0:41 ` Po Lu @ 2021-12-14 13:30 ` Eli Zaretskii 2021-12-14 13:48 ` Po Lu 0 siblings, 1 reply; 14+ messages in thread From: Eli Zaretskii @ 2021-12-14 13:30 UTC (permalink / raw) To: help-gnu-emacs > From: Po Lu <luangruo@yahoo.com> > Cc: help-gnu-emacs@gnu.org > Date: Tue, 14 Dec 2021 08:41:06 +0800 > > Eli Zaretskii <eliz@gnu.org> writes: > > > And you didn't describe why do you need > > pixel-point-and-height-at-unseen-line's data in the first place, so > > maybe there's a different solution to whatever you are trying to do > > that doesn't involve such a function. > > It's used to find a suitable new start position that's N pixels above > window start, so vscroll can then be set to compensate for the > difference. Did you try something like this: (save-excursion (goto-char (window-start)) (vertical-motion (- (ceiling N (frame-char-height)))) (point)) where N is your number of pixels? ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Correct way to implement `pixel-point-and-height-at-unseen-line'? 2021-12-14 13:30 ` Eli Zaretskii @ 2021-12-14 13:48 ` Po Lu 2021-12-14 14:26 ` Eli Zaretskii 0 siblings, 1 reply; 14+ messages in thread From: Po Lu @ 2021-12-14 13:48 UTC (permalink / raw) To: Eli Zaretskii; +Cc: help-gnu-emacs Eli Zaretskii <eliz@gnu.org> writes: > Did you try something like this: > > (save-excursion > (goto-char (window-start)) > (vertical-motion (- (ceiling N (frame-char-height)))) > (point)) > > where N is your number of pixels? That won't always work correctly with lines of different height: for example, if the line above start is smaller than the default character height of the frame, the number of lines by which to move upwards could be too small. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Correct way to implement `pixel-point-and-height-at-unseen-line'? 2021-12-14 13:48 ` Po Lu @ 2021-12-14 14:26 ` Eli Zaretskii 2021-12-15 0:40 ` Po Lu 0 siblings, 1 reply; 14+ messages in thread From: Eli Zaretskii @ 2021-12-14 14:26 UTC (permalink / raw) To: help-gnu-emacs > From: Po Lu <luangruo@yahoo.com> > Cc: help-gnu-emacs@gnu.org > Date: Tue, 14 Dec 2021 21:48:35 +0800 > > Eli Zaretskii <eliz@gnu.org> writes: > > > Did you try something like this: > > > > (save-excursion > > (goto-char (window-start)) > > (vertical-motion (- (ceiling N (frame-char-height)))) > > (point)) > > > > where N is your number of pixels? > > That won't always work correctly with lines of different height: for > example, if the line above start is smaller than the default character > height of the frame, the number of lines by which to move upwards could > be too small. But if you always need the line before window-start, i.e. use N = 1, then why is that a problem? ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Correct way to implement `pixel-point-and-height-at-unseen-line'? 2021-12-14 14:26 ` Eli Zaretskii @ 2021-12-15 0:40 ` Po Lu 2021-12-15 13:11 ` Eli Zaretskii 0 siblings, 1 reply; 14+ messages in thread From: Po Lu @ 2021-12-15 0:40 UTC (permalink / raw) To: Eli Zaretskii; +Cc: help-gnu-emacs Eli Zaretskii <eliz@gnu.org> writes: > But if you always need the line before window-start, i.e. use N = 1, > then why is that a problem? Ah, I think we're misunderstanding things: `pixel-point-and-height-at-unseen-line' is part of a much larger system that tries to find the line (and pixel distance) for N = foo, by iterating through lines where N = 1. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Correct way to implement `pixel-point-and-height-at-unseen-line'? 2021-12-15 0:40 ` Po Lu @ 2021-12-15 13:11 ` Eli Zaretskii 0 siblings, 0 replies; 14+ messages in thread From: Eli Zaretskii @ 2021-12-15 13:11 UTC (permalink / raw) To: help-gnu-emacs > From: Po Lu <luangruo@yahoo.com> > Cc: help-gnu-emacs@gnu.org > Date: Wed, 15 Dec 2021 08:40:37 +0800 > > Eli Zaretskii <eliz@gnu.org> writes: > > > But if you always need the line before window-start, i.e. use N = 1, > > then why is that a problem? > > Ah, I think we're misunderstanding things: > `pixel-point-and-height-at-unseen-line' is part of a much larger system > that tries to find the line (and pixel distance) for N = foo, by > iterating through lines where N = 1. Well, I did ask you to describe what you need to do, and responded to the only description you gave ;-) ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2021-12-15 13:11 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <87pmq1wag9.fsf.ref@yahoo.com> 2021-12-13 1:38 ` Correct way to implement `pixel-point-and-height-at-unseen-line'? Po Lu 2021-12-13 2:20 ` Emanuel Berg via Users list for the GNU Emacs text editor 2021-12-13 2:49 ` Po Lu 2021-12-13 3:04 ` Emanuel Berg via Users list for the GNU Emacs text editor 2021-12-13 3:18 ` Po Lu 2021-12-13 23:41 ` Emanuel Berg via Users list for the GNU Emacs text editor 2021-12-14 0:41 ` Po Lu 2021-12-13 14:32 ` Eli Zaretskii 2021-12-14 0:41 ` Po Lu 2021-12-14 13:30 ` Eli Zaretskii 2021-12-14 13:48 ` Po Lu 2021-12-14 14:26 ` Eli Zaretskii 2021-12-15 0:40 ` Po Lu 2021-12-15 13:11 ` 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.