From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#5718: scroll-margin in buffer with small line count. Date: Sat, 21 Jan 2017 13:46:37 -0500 Message-ID: <87pojguu7m.fsf@users.sourceforge.net> 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> <83a8ar9bl6.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1485024390 27088 195.159.176.226 (21 Jan 2017 18:46:30 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 21 Jan 2017 18:46:30 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) Cc: ahyatt@gmail.com, 5718@debbugs.gnu.org, gavenkoa@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jan 21 19:46:25 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 1cV0g2-0005aR-LH for geb-bug-gnu-emacs@m.gmane.org; Sat, 21 Jan 2017 19:46:14 +0100 Original-Received: from localhost ([::1]:32953 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cV0g5-0001Gu-VB for geb-bug-gnu-emacs@m.gmane.org; Sat, 21 Jan 2017 13:46:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39077) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cV0fv-0001Fo-3z for bug-gnu-emacs@gnu.org; Sat, 21 Jan 2017 13:46:11 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cV0fq-0005IR-8k for bug-gnu-emacs@gnu.org; Sat, 21 Jan 2017 13:46:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:39546) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cV0fq-0005IG-5N for bug-gnu-emacs@gnu.org; Sat, 21 Jan 2017 13:46:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cV0fp-0007Qd-QV for bug-gnu-emacs@gnu.org; Sat, 21 Jan 2017 13:46:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 21 Jan 2017 18:46: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.148502433828519 (code B ref 5718); Sat, 21 Jan 2017 18:46:01 +0000 Original-Received: (at 5718) by debbugs.gnu.org; 21 Jan 2017 18:45:38 +0000 Original-Received: from localhost ([127.0.0.1]:37745 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cV0fR-0007Pv-MA for submit@debbugs.gnu.org; Sat, 21 Jan 2017 13:45:37 -0500 Original-Received: from mail-io0-f176.google.com ([209.85.223.176]:33167) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cV0fP-0007Ph-Rx for 5718@debbugs.gnu.org; Sat, 21 Jan 2017 13:45:36 -0500 Original-Received: by mail-io0-f176.google.com with SMTP id v96so21310156ioi.0 for <5718@debbugs.gnu.org>; Sat, 21 Jan 2017 10:45:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=rFAnjbRCxGYWEbi/5bRbNFGji3PeJc6PbtS4E9Qu+QM=; b=TT2Vzl2GfGW8l6Wyk5SSGeNSZNSMMl8+kX4KWw8M9M9OSH/aIH7Epgbuyf4x+XWniG 702G9YrjVZXKMcIzb279wYh6576vy2O+ZqobZJ56GiHeRglOr7hJsOTuqMrxLqmmjbaO 0guM6JNN3LFuYjLSOGEuCm89rmQH+ddDoQFpRiRce7TYsSfJs6tw5n45LS64VuJKZQoh 7+5ZgvwdtdiP08sgRclVDGAHXJcpqUnFwk3apqZCq3mfU+RlOWCKu9z+fSrwVTg6xvh1 oeFIZ2+PXjs/QRKxH+vBmUBaNrRIy09XiF+TVO5x3yUuNZ/6uUXTUVmWfviss44NPTge 24/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=rFAnjbRCxGYWEbi/5bRbNFGji3PeJc6PbtS4E9Qu+QM=; b=uVVPgkwv5RIYA8cg0IX2Fljy7c3LC1iBPSvnvQgNI3FwJJkZXu+iJHYGvIcjGa2Pk5 ibrEX8s1r7DudHr9oEQ64NqeGgk+SxXYyqmFRGeKS9vd4uAmqIoZ+kSboiKJhZ3OYoVs 2dKTG0OLLvgZ8MPCzZBYWsjupx7/TMgjBuyVtINyFqf7SIe9tc47FwHUPYRWIYyQzHyJ 8X1mWtOx2vkWO2LicqlE1kJSsWXyLUgcEUWX/PkEcg9zHwSLLpxFO6Q/IrUyjZNcf5Do LrPwoJMhwJ2aQchWMR2xqerAkNDJLt4njWzmlqphyw0bk5f+q4vD+XpwdLxb9P757PJy A3rQ== X-Gm-Message-State: AIkVDXJW3Pte3HZd6drUEaF3LIBMmanbWbr9Qr5IzH3k547ZH2um7y0QFn4Ql2icxhVYBQ== X-Received: by 10.107.134.36 with SMTP id i36mr18344424iod.168.1485024330253; Sat, 21 Jan 2017 10:45:30 -0800 (PST) Original-Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id p20sm5825153itc.2.2017.01.21.10.45.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 21 Jan 2017 10:45:29 -0800 (PST) In-Reply-To: <83a8ar9bl6.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 16 Jan 2017 19:08:37 +0200") 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:128299 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: > > 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. I'm not entirely clear why there is a branch in that code. I came up with this; it works, though I'm not sure if it's the best way: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v3-0001-Fix-scrolling-with-partial-lines.patch Content-Description: patch >From 6944c7badade2477f381acf3b0922e5309e063d8 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 21 Jan 2017 13:24:47 -0500 Subject: [PATCH v3] Fix scrolling with partial lines * src/xdisp.c (partial_line_height): New function. (try_scrolling): * src/window.c (window_scroll_pixel_based): Use it for calculating the pixel scroll margin correctly in a window with partial lines. --- src/dispextern.h | 1 + src/window.c | 2 +- src/xdisp.c | 14 +++++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/dispextern.h b/src/dispextern.h index 51222e6..470330a 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -3263,6 +3263,7 @@ void move_it_past_eol (struct it *); void move_it_in_display_line (struct it *it, ptrdiff_t to_charpos, int to_x, enum move_operation_enum op); +int partial_line_height (const struct it *it_origin); bool in_display_vector_p (struct it *); int frame_mode_line_height (struct frame *); extern bool redisplaying_p; diff --git a/src/window.c b/src/window.c index f664597..300472e 100644 --- a/src/window.c +++ b/src/window.c @@ -5148,7 +5148,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, bool noerror) in the scroll margin at the bottom. */ move_it_to (&it, PT, -1, (it.last_visible_y - WINDOW_HEADER_LINE_HEIGHT (w) - - this_scroll_margin - 1), + - partial_line_height (&it)- this_scroll_margin - 1), -1, MOVE_TO_POS | MOVE_TO_Y); diff --git a/src/xdisp.c b/src/xdisp.c index 55bb34a..9dc65b8 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -9859,6 +9859,17 @@ move_it_by_lines (struct it *it, ptrdiff_t dvpos) } } +int +partial_line_height (const struct it *it_origin) +{ + struct it it = *it_origin; + move_it_to (&it, ZV, -1, it.last_visible_y, -1, + MOVE_TO_POS | MOVE_TO_Y); + int vis_height = it.last_visible_y - it.current_y; + int log_height = it.ascent + it.descent; + return max (0, log_height - vis_height); +} + /* Return true if IT points into the middle of a display vector. */ bool @@ -15368,7 +15379,8 @@ try_scrolling (Lisp_Object window, bool just_this_one_p, /* Compute the pixel ypos of the scroll margin, then move IT to either that ypos or PT, whichever comes first. */ start_display (&it, w, startp); - scroll_margin_y = it.last_visible_y - this_scroll_margin + scroll_margin_y = it.last_visible_y - partial_line_height (&it) + - this_scroll_margin - frame_line_height * extra_scroll_margin_lines; move_it_to (&it, PT, -1, scroll_margin_y - 1, -1, (MOVE_TO_POS | MOVE_TO_Y)); -- 2.9.3 --=-=-=--