From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#5718: scroll-margin in buffer with small line count. Date: Mon, 16 Jan 2017 19:08:37 +0200 Message-ID: <83a8ar9bl6.fsf@gnu.org> References: <4B9D1C61.70903@gmail.com> <87mvkjy0l5.fsf@users.sourceforge.net> <83fuqbfhpb.fsf@gnu.org> <87a8ggwcoo.fsf@users.sourceforge.net> <83inv4cc0s.fsf@gnu.org> <87d1ka17dr.fsf@users.sourceforge.net> <834m5l9g1d.fsf@gnu.org> <874m5j19wi.fsf@users.sourceforge.net> <83zina75pa.fsf@gnu.org> <87pok555q4.fsf@users.sourceforge.net> <831swfcmhz.fsf@gnu.org> <871sw6z32n.fsf@users.sourceforge.net> <83o9zaax8x.fsf@gnu.org> <87k29wxam1.fsf@users.sourceforge.net> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1484588377 25930 195.159.176.226 (16 Jan 2017 17:39:37 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 16 Jan 2017 17:39:37 +0000 (UTC) Cc: ahyatt@gmail.com, 5718@debbugs.gnu.org, gavenkoa@gmail.com To: npostavs@users.sourceforge.net Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jan 16 18:39:30 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1cTBFg-0005zx-N6 for geb-bug-gnu-emacs@m.gmane.org; Mon, 16 Jan 2017 18:39:28 +0100 Original-Received: from localhost ([::1]:58427 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cTBFl-0003QG-D3 for geb-bug-gnu-emacs@m.gmane.org; Mon, 16 Jan 2017 12:39:33 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60726) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cTAnH-0001qs-8n for bug-gnu-emacs@gnu.org; Mon, 16 Jan 2017 12:10:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cTAnC-0003rI-6w for bug-gnu-emacs@gnu.org; Mon, 16 Jan 2017 12:10:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40489) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cTAnC-0003r9-2z for bug-gnu-emacs@gnu.org; Mon, 16 Jan 2017 12:10:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cTAnB-0008Vh-Rh for bug-gnu-emacs@gnu.org; Mon, 16 Jan 2017 12:10:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 16 Jan 2017 17:10:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 5718 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 5718-submit@debbugs.gnu.org id=B5718.148458655232650 (code B ref 5718); Mon, 16 Jan 2017 17:10:01 +0000 Original-Received: (at 5718) by debbugs.gnu.org; 16 Jan 2017 17:09:12 +0000 Original-Received: from localhost ([127.0.0.1]:55888 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cTAmO-0008UY-59 for submit@debbugs.gnu.org; Mon, 16 Jan 2017 12:09:12 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:41245) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cTAmM-0008UL-QB for 5718@debbugs.gnu.org; Mon, 16 Jan 2017 12:09:11 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cTAmC-0003IX-Gc for 5718@debbugs.gnu.org; Mon, 16 Jan 2017 12:09:05 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:53044) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cTAm0-0003Ei-CA; Mon, 16 Jan 2017 12:08:48 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3452 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1cTAly-0007UA-T5; Mon, 16 Jan 2017 12:08:48 -0500 In-reply-to: <87k29wxam1.fsf@users.sourceforge.net> (npostavs@users.sourceforge.net) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:128148 Archived-At: > From: npostavs@users.sourceforge.net > Cc: 5718@debbugs.gnu.org, ahyatt@gmail.com, gavenkoa@gmail.com > Date: Sun, 15 Jan 2017 16:43:34 -0500 > > Yeah, I'm still a bit lost in all the different structures. It seems > (it.last_visible_y % frame_line_height) might work. That would only be correct if all the screen lines use the default font. Otherwise, the last line could be only partially visible even if the above is zero. > The matrix row stuff in xdisp seems a more direct way of getting it, > though I guess that's not really usable from window.c? If by "matrix row" you meant the glyph matrix prepared by the previous redisplay, then using that is unreliable, because that matrix might not be up to date. You can see that window_scroll_pixel_based already uses the move_it_* family of functions, which is the right way of doing this stuff -- these functions simulate redisplay without actually displaying anything, so you can compute the metrics of anything on display using them. > What would be the idiomatic way of doing this? > > #define MR_PARTIALLY_VISIBLE(ROW) \ > ((ROW)->height != (ROW)->visible_height) There's already such a calculation in window_scroll_pixel_based: /* See if point is on a partially visible line at the end. */ if (it.what == IT_EOB) partial_p = it.current_y + it.ascent + it.descent > it.last_visible_y; else { move_it_by_lines (&it, 1); partial_p = it.current_y > it.last_visible_y; } (This is preceded by moving the iterator to the point's screen line or to EOB, whichever comes first.) The value it.current_y is the Y coordinate of the top edge of a glyph row (the value is zero for the first screen line), so if it.last_visible_y is farther away from that than the height of the glyph row, that glyph row is fully visible; otherwise it isn't. > By the way, in window_scroll_pixel_based (lines 5139 to 5158) the > position of "it" is saved twice, and it looks like the first one of > these can never be used (because the second overwrites it), correct? Yep, good catch. Thanks.