Skip to content

Commit

Permalink
Fix text align for buffer-face-mode (#20)
Browse files Browse the repository at this point in the history
* Fix text align for buffer-face-mode

* Use sideline--str-len instead of length

---------

Co-authored-by: Jen-Chieh Shen <jcs090218@gmail.com>
  • Loading branch information
chuxubank and jcs090218 committed Mar 19, 2024
1 parent f3f5a40 commit 04a525f
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions sideline.el
Original file line number Diff line number Diff line change
Expand Up @@ -298,20 +298,22 @@
"Align sideline STR from the right of the window.
Argument OFFSET is additional calculation from the right alignment."
(list (+
;; If the sideline text is displayed without at least 1 pixel gap from the right fringe and
;; overflow-newline-into-fringe is not true, emacs will line wrap it.
(if (and (display-graphic-p)
(> (nth 1 (window-fringes)) 0)
(not overflow-newline-into-fringe))
1
0)
(* (window-font-width)
(+ offset (if (display-graphic-p)
;; If right fringe deactivated add 1 offset
(if (= 0 (nth 1 (window-fringes))) 1 0)
1)))
(sideline--string-pixel-width str))))
(let ((graphic-p (display-graphic-p))
(fringes (window-fringes)))
(list (+
;; If the sideline text is displayed without at least 1 pixel gap from the right fringe and
;; overflow-newline-into-fringe is not true, emacs will line wrap it.
(if (and graphic-p
(> (nth 1 fringes) 0)
(not overflow-newline-into-fringe))
1
0)
(* (window-font-width)
(+ offset (if graphic-p
;; If right fringe deactivated add 1 offset
(if (= 0 (nth 1 fringes)) 1 0)
1)
(sideline--str-len str)))))))

(defun sideline--get-line ()
"Return current line."
Expand Down

0 comments on commit 04a525f

Please sign in to comment.