[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/topspace 4eb27abaa1 034/181: Prevent top space from all
From: |
ELPA Syncer |
Subject: |
[elpa] externals/topspace 4eb27abaa1 034/181: Prevent top space from all suddenly disappearing when visual-line-mode is enabled and cursor scrolls bellow screen with top space present |
Date: |
Tue, 23 Aug 2022 12:58:31 -0400 (EDT) |
branch: externals/topspace
commit 4eb27abaa182e856ba3f3c8e1e84fdd2e1f009af
Author: Trevor Pogue <poguete@mcmaster.ca>
Commit: Trevor Pogue <poguete@mcmaster.ca>
Prevent top space from all suddenly disappearing when visual-line-mode is
enabled and cursor scrolls bellow screen with top space present
---
README.md | 2 +-
topspace.el | 31 +++++++++++++++----------------
2 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/README.md b/README.md
index ad1ac69100..82ad16d6a2 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@
![topspace](https://user-images.githubusercontent.com/12535207/155176914-87390537-10f0-4ee5-9b37-cd798f07df27.gif)
-TopSpace is an Emacs minor mode that lets you scroll above the top line to
vertically center top text with a scrollable top margin/padding. In particular,
it is useful when using Emacs in full-screen/on large monitors.
+TopSpace is an Emacs minor mode that lets you scroll above the top line to
vertically center top text or cursor with a scrollable top margin/padding. In
particular, it is useful when using Emacs in full-screen/on large monitors.
### Just install and go:
diff --git a/topspace.el b/topspace.el
index 48d3a276d8..e18ef53ac9 100644
--- a/topspace.el
+++ b/topspace.el
@@ -1,11 +1,11 @@
-;;; topspace.el --- Scroll above the top line to vertically center top text
with a scrollable top margin/padding -*- lexical-binding: t -*-
+;;; topspace.el --- Scroll above the top line to vertically center top text or
cursor with a scrollable top margin/padding -*- lexical-binding: t -*-
;; Copyright (C) 2021-2022 Trevor Edwin Pogue
;; Author: Trevor Edwin Pogue <trevor.pogue@gmail.com>
;; Maintainer: Trevor Edwin Pogue <trevor.pogue@gmail.com>
;; URL: https://github.com/trevorpogue/topspace
-;; Keywords: convenience, scrolling, center, margin, padding
+;; Keywords: convenience, scrolling, center, cursor, margin, padding
;; Version: 0.1.0
;; Package-Requires: ((emacs "25.1"))
@@ -23,11 +23,10 @@
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
-;; Scroll above the top line to vertically center top text
-;; with a scrollable top margin/padding.
-;; An overlay is automatically drawn above the top text line
-;; as you scroll above,
-;; giving the equivalent effect of being able to scroll above the top line.
+;; Scroll above the top line to vertically center top text or cursor with a
+;; scrollable top margin/padding. An overlay is automatically drawn above the
+;; top text line as you scroll above, giving the equivalent effect of being
able
+;; to scroll above the top line.
;; No new keybindings are required as topspace automatically works for any
;; commands or subsequent function calls which use `scroll-up', `scroll-down',
@@ -159,7 +158,7 @@ The reason this is needed is because `topspace--put' only
draws the overlay when
in the described case above."
(setq total-lines topspace--total-lines-scrolling)
(when (and (> topspace--window-start-before-scroll 1) (= (window-start) 1))
- (let ((lines-already-scrolled (topspace--count-lines
+ (let ((lines-already-scrolled (count-screen-lines
1 topspace--window-start-before-scroll)))
(setq total-lines (abs total-lines))
(set-window-start (selected-window) 1)
@@ -176,8 +175,8 @@ LINE-OFFSET and REDISPLAY are used in the same way as in
`recenter'."
(setq line-offset (round (/ (topspace--window-height) 2))))
(when (< line-offset 0)
(setq line-offset (- (topspace--window-height) line-offset)))
- (topspace--put (- line-offset (topspace--count-lines (window-start)
- (point))))))
+ (topspace--put (- line-offset (topspace--count-screen-lines (window-start)
+ (point))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Top space line height calculation
@@ -227,12 +226,12 @@ Any value above 0 flags that the target TOPSPACE-HEIGHT
is too large."
(defun topspace--current-line-plus-topspace (&optional topspace-height)
"Used when making sure top space height does not push cursor off-screen.
Return the current line plus the top space height TOPSPACE-HEIGHT."
- (+ (topspace--count-lines (window-start) (point))
+ (+ (count-screen-lines (window-start) (point))
(or topspace-height (topspace--height))))
(defun topspace--height-to-make-buffer-centered ()
"Return the necessary top space height to center selected window's buffer."
- (let ((buffer-height (topspace--count-lines (window-start) (window-end)))
+ (let ((buffer-height (count-screen-lines (window-start) (window-end)))
(result)
(window-height (topspace--window-height)))
(setq result (- (- (topspace--center-frame-line)
@@ -264,14 +263,14 @@ or if the selected window is in a child-frame."
"Return the number of screen lines in the selected window rounded up."
(ceiling (window-screen-lines)))
-(defun topspace--count-lines (start end)
+(defun topspace--count-screen-lines (start end)
"Return screen lines between START and END.
Like `count-screen-lines' except `count-screen-lines' will
return unexpected value when END is in column 0. This fixes that issue."
- (let ((adjustment 0) (column))
+ (let ((adjustment 0) (column 0))
(save-excursion
(goto-char end)
- (setq column (mod (current-column) (window-text-width)))
+ (setq column (car (nth 6 (posn-at-point))))
(unless (= column 0) (setq adjustment -1)))
(+ (count-screen-lines start end) adjustment)))
@@ -411,7 +410,7 @@ Topspace will not be enabled for:
;;;###autoload
(define-minor-mode topspace-mode
- "Scroll above the top line to vertically center top text.
+ "Scroll above the top line to vertically center top text or cursor.
It is like having a scrollable top margin/padding.
An overlay is automatically drawn above the top text line as you scroll above,
giving the effect of being able to scroll above the top line.
- [elpa] externals/topspace 50aae1cbdd 011/181: Update README.md, (continued)
- [elpa] externals/topspace 50aae1cbdd 011/181: Update README.md, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace d8ba41b20e 020/181: Make topspace-enable and topspace-disable private functions, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace 694c10574c 012/181: Update topspace.el, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace 09d47d32b8 023/181: Add MELPA badge and installation instructions, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace 512893f002 021/181: Provide documentation strings for private variables, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace 976971f4a9 024/181: Add clarification to Installation steps, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace f36c0e28af 025/181: Add MELPA Stable badge, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace 73cb30dc10 028/181: Add more info on how it works to README, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace 8591032298 029/181: Add to package motivation in README, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace a76d4f3612 031/181: Update to more clear GIF in README, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace 4eb27abaa1 034/181: Prevent top space from all suddenly disappearing when visual-line-mode is enabled and cursor scrolls bellow screen with top space present,
ELPA Syncer <=
- [elpa] externals/topspace 7a3c9703a5 041/181: Fix links in README, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace c6bc481049 042/181: Fix links in README, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace 7303661244 043/181: Update headers in README, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace d19151de61 044/181: Refine README, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace ba7eba3d49 046/181: Make README more concise, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace 66373896ec 047/181: Update README.md, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace 1b08e734ec 049/181: Update README.md, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace cbdcdff484 051/181: Fix `recenter-top-bottom` bug, add .md files, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace 0d5a7cbc63 055/181: Update README.md, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace cb918d1c44 057/181: Create PULL_REQUEST_TEMPLATE.md, ELPA Syncer, 2022/08/23