Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions beacon.el
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ trigger false positives on some systems."
"Size of the beacon in characters."
:type 'number)

(defcustom beacon-can-go-backwards t
"If set, beacon animation will go backward if there is not
enough space at the end of the line to display it."
:type 'boolean)

(defcustom beacon-color 0.5
"Color of the beacon.
This can be a string or a number.
Expand Down Expand Up @@ -302,15 +307,31 @@ Only returns `beacon-size' elements."
;;; Blinking
(defun beacon--shine ()
"Shine a beacon at point."
(let ((colors (beacon--color-range)))
;; if there is enough space we go forward, else backward
;; Available space is:
;; (last-column - current column) + (window-width - last-column-position)
(let* ((colors (beacon--color-range))
(end (save-excursion (end-of-line) (current-column)))
(available (+ (- end (current-column))
(- (window-body-width)
(mod end (window-body-width)))))
(forward (if (or (not beacon-can-go-backwards)
(> available beacon-size))
t
nil)))
(save-excursion
(while colors
(if (looking-at "$")
(progn
(beacon--after-string-overlay colors)
(setq colors nil))
(beacon--colored-overlay (pop colors))
(forward-char 1))))))
(if forward
(if (looking-at "$")
(progn
(beacon--after-string-overlay colors)
(setq colors nil))
(beacon--colored-overlay (pop colors))
(forward-char))
(if (looking-at "$")
(beacon--after-string-overlay (list (pop colors)))
(beacon--colored-overlay (pop colors)))
(backward-char))))))

(defun beacon--dec ()
"Decrease the beacon brightness by one."
Expand Down