From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: move_it_vertically_backward question Date: Wed, 15 Dec 2021 16:50:08 +0200 Message-ID: <83mtl1j527.fsf@gnu.org> References: <87lf0pw78r.fsf.ref@yahoo.com> <87lf0pw78r.fsf@yahoo.com> <837dc8mue3.fsf@gnu.org> <874k7cuhv4.fsf@yahoo.com> <83lf0nl56t.fsf@gnu.org> <875yrrtiwj.fsf@yahoo.com> <837dc7l2pa.fsf@gnu.org> <87ilvqty24.fsf@yahoo.com> <8335muj8zk.fsf@gnu.org> <87h7bang3d.fsf@yahoo.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30035"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Po Lu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Dec 15 15:55:34 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mxVgq-0007bk-53 for ged-emacs-devel@m.gmane-mx.org; Wed, 15 Dec 2021 15:55:32 +0100 Original-Received: from localhost ([::1]:41406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxVgp-0005jx-5b for ged-emacs-devel@m.gmane-mx.org; Wed, 15 Dec 2021 09:55:31 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:57350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxVbv-0006te-Il for emacs-devel@gnu.org; Wed, 15 Dec 2021 09:50:27 -0500 Original-Received: from [2001:470:142:3::e] (port=52364 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxVbv-00082s-8q; Wed, 15 Dec 2021 09:50:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=TgHK8a66xczxECdNTmc6USNB2l0wrmGJoZ1PFwuaycE=; b=NrxpMOg5498Z VJzMaeGaJ3IYUtm9uwOSA1zfaCpc1WGzIIxrcyDGhr8Z0PVpzAqvsBqIVOFXPL3pfwEc4yG4qvupR CTXFVDjUQGtxwD6AtXFIY1HXWH742JF62nKNA5gclGJrx2oFr+7dfw0qJZqwCIEmqlkm9VRD+6TJH Hleg36dB85lVn+SOo0KfT5JyXLRmtcc4h9zbIlslPVa7VgWtBwQPFbHMJ+PQnvCClpgQHRjn8AwbJ XpwvFKqD3+oTRXes8uivMe62MFvhpycSx3R2aUswCvJJh+MlTqPAesB+rDLDo5D/f6kyPasp6lfmU 5QleyXS2pNO1/oH05Q7cJg==; Original-Received: from [87.69.77.57] (port=3215 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxVbv-00087Y-1f; Wed, 15 Dec 2021 09:50:27 -0500 In-Reply-To: <87h7bang3d.fsf@yahoo.com> (message from Po Lu on Wed, 15 Dec 2021 21:38:14 +0800) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:282050 Archived-At: > From: Po Lu > Cc: emacs-devel@gnu.org > Date: Wed, 15 Dec 2021 21:38:14 +0800 > > The requirement is basically to find the start of a line that is at > least above window start by a given number of pixels, and to also find > the vertical distance between the top of that line and the start of the > window. > > For instance, if we're scrolling upwards (upwards in this context is > opposite to the terminology we use for line-based scrolling: it means > moving the display downwards, like scroll-down) by 17 pixels, and there > are two lines each 14 pixels in height above window start, the new > window start will be set to the start position of the second line above > window start (which this function should return), and vscroll will be > set to 7 (which is 24 - 17, where the 24 is the aformentioned vertical > distance that this function should also return). We have code in the display engine that does this in several places. For example, look at what we do when we recenter the window in redisplay_window. We could factor that code out of there, put it in a separate function, and teach window-text-pixel-size to find the FROM position using that new function. Then the value of the TO argument for window-text-pixel-size is of course well known, and you could run the rest of the function to provide you with the pixel dimensions of the text in-between. Would that fit the bill?