From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Is there a built-in way to tell how many lines are in a window in a given face? Date: Mon, 17 Apr 2017 12:05:36 +0300 Message-ID: <83k26je74v.fsf@gnu.org> References: <838tn2glmt.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1492419914 12129 195.159.176.226 (17 Apr 2017 09:05:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 17 Apr 2017 09:05:14 +0000 (UTC) Cc: emacs-devel@gnu.org To: Zachary Kanfer Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Apr 17 11:05:10 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d02ar-00034B-Qe for ged-emacs-devel@m.gmane.org; Mon, 17 Apr 2017 11:05:09 +0200 Original-Received: from localhost ([::1]:35549 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d02ax-00017u-S4 for ged-emacs-devel@m.gmane.org; Mon, 17 Apr 2017 05:05:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51457) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d02ar-00015a-PP for emacs-devel@gnu.org; Mon, 17 Apr 2017 05:05:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d02an-0003kt-FS for emacs-devel@gnu.org; Mon, 17 Apr 2017 05:05:09 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:42284) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d02an-0003kd-CV; Mon, 17 Apr 2017 05:05:05 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1146 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1d02am-0003PM-MW; Mon, 17 Apr 2017 05:05:05 -0400 In-reply-to: (message from Zachary Kanfer on Sat, 15 Apr 2017 16:27:12 -0400) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:214049 Archived-At: > From: Zachary Kanfer > Date: Sat, 15 Apr 2017 16:27:12 -0400 > Cc: emacs-devel@gnu.org > > What I'm doing is making a presentation mode (https://bitbucket.org/zck/zpresent.el;, available on Melpa) that > presents from Emacs. I want to be able to, for example, make a title slide that looks like this (monospaced > font required for this to look right): > > +--------------------------------+ > | | > | | > | | > | Title goes here! | > | | > | $DATE by $PERSON | > | | > | | > +--------------------------------+ > > I'm certainly open to other ways of making this look right. I don't think doing calculations in pixels would work, > unless there's a way to insert text at a specific pixel inside Emacs. And even if there were, that seems like a > bunch more work to basically reproduce LaTeX. Thanks, but I don't think I have a clear understanding how the above is related to your zck--window-max-lines-per-window. Let me guess: Is it correct that you want to calculate how many empty lines to insert before inserting the Title line, such that the text is vertically centered in the window? If so, then I'd begin by inserting newlines until pos-at-point tells me I'm at the right vertical pixel coordinate, which can be calculated given the pixel height of the window and the number of lines you want to be centered in the window multiplied by what window-font-height returns. Does this work for you?