all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Sébastien Chapuis" <sebastien@chapu.is>
To: martin rudalics <rudalics@gmx.at>
Cc: emacs-devel@gnu.org
Subject: Re: [PATCH] Add function window-line-width
Date: Fri, 8 Nov 2019 12:54:30 +0800	[thread overview]
Message-ID: <CAN2Hsvx1mTHCv8dQOaofnYOOe=sX1wzM-OP3Ja+Lqz6N8wS5Jw@mail.gmail.com> (raw)
In-Reply-To: <8846a8ad-0299-1ff7-cc9a-0aaed18e76c0@gmx.at>

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

Ah, I didn't know about 'window-lines-pixel-dimensions'.
I knew 'window-line-height' and thought there was no equivalent for the
width.

However 'window-lines-pixel-dimensions' has differences with the
implementation I proposed:
- It counts the glyphs 'inserted by redisplay for its own purposes' [1].
  On a line with no characters, the function often return a width > 0 (1 or
2 characters, in my tests).
  Similarly, on a line with characters it returns more pixels than there
really is.
- It allocates a cons and 2 integer for each line.
  In my use case, I have to get the width of _all_ the lines on the current
window every time the cursor is
  changing line or when a character is inserted/removed in the buffer. So
it occurs quite often.
  But that's micro optimization and I am not sure if there is a big impact.
- We can't choose the area in the window (left_margin_area, text_area or
right_margin_area),
  but I don't need this for my use case, so it's not important to me.

The first point is important for my use case, so if 'window-line-width' is
not accepted, would you agree for a patch
adding a parameter to 'window-lines-pixel-dimensions' controlling this
behavior ?

'window-text-pixel-size' uses a display iterator to compute values, I don't
know the details of this iterator but it seems to
be slower than fetching values directly from the glyph matrix. As
mentioned, I need the width of all lines on window.

[1]
https://github.com/emacs-mirror/emacs/blob/a070bd1c8b5213ad469d41dd80d392f924644aed/src/dispextern.h#L426-L428

Thanks,
Sebastien Chapuis.

Le jeu. 7 nov. 2019 à 16:50, martin rudalics <rudalics@gmx.at> a écrit :

> And I obviously forgot to mention 'window-lines-pixel-dimensions' and
> 'line-pixel-height'.
>
> martin
>

[-- Attachment #2: Type: text/html, Size: 2530 bytes --]

  reply	other threads:[~2019-11-08  4:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-06 22:49 [PATCH] Add function window-line-width Sébastien Chapuis
2019-11-07  8:40 ` martin rudalics
2019-11-07  8:50   ` martin rudalics
2019-11-08  4:54     ` Sébastien Chapuis [this message]
2019-11-08  9:21       ` martin rudalics
2019-11-08 13:18         ` Eli Zaretskii
2019-11-08 18:27           ` martin rudalics
2019-11-09 22:09             ` Sébastien Chapuis
2019-11-10  9:46               ` martin rudalics
2019-11-10 19:02                 ` Sébastien Chapuis
2019-11-14 10:08                   ` Eli Zaretskii
2019-11-14  9:11               ` Eli Zaretskii
2019-11-07  9:23 ` Robert Pluim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAN2Hsvx1mTHCv8dQOaofnYOOe=sX1wzM-OP3Ja+Lqz6N8wS5Jw@mail.gmail.com' \
    --to=sebastien@chapu.is \
    --cc=emacs-devel@gnu.org \
    --cc=rudalics@gmx.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.