Repository navigation
Expand file tree
/
Copy pathforge-cursor.el
More file actions
114 lines (103 loc) · 4.57 KB
/
Copy pathforge-cursor.el
File metadata and controls
114 lines (103 loc) · 4.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
;;; forge-cursor.el --- welding sparks + comet streak + pulsar flash (standalone) -*- lexical-binding: t; -*-
;;
;; Author: Barrulus
;; Version: 1.0
;; URL: https://github.com/barrulus/forge-cursor
;; Package-Requires: ((emacs "29.1"))
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
;;; Commentary:
;;
;; A self-contained bundle of three independent cursor effects sharing one
;; "forge" palette (white-hot core -> amber -> cooling ember):
;;
;; | Effect | Source | Triggers on |
;; |----------------+-------------------------+----------------------------------|
;; | welding sparks | welding-cursor.el (here)| every self-inserted character |
;; | comet streak | comet-trail.el (here) | cursor jumps (movement) |
;; | pulsar flash | pulsar (GNU ELPA) | big commands, scroll, win-change |
;;
;; This is the *standalone* version of my-forge-cursor.el: it bootstraps its
;; own load-path, package archives, and dependencies, so you can drop the
;; whole folder anywhere and load this one file. See README.md.
;;
;; All three effects are GUI-best; in `emacs -nw' they degrade to flat cell
;; backgrounds (no sub-cell glow). Wayland/PGTK and X both work.
;;
;; Usage (one of):
;; (load "/path/to/forge-cursor-dist/forge-cursor.el")
;; or add the folder to load-path yourself and:
;; (add-to-list 'load-path "/path/to/forge-cursor-dist")
;; (require 'forge-cursor)
;;; Code:
;;; --- 0. Self-bootstrap: load-path, archives, use-package -------------
;; Find the directory this file lives in, whether loaded or required.
(defconst forge-cursor--dir
(file-name-directory (or load-file-name
(bound-and-true-p byte-compile-current-file)
buffer-file-name))
"Directory containing forge-cursor.el and welding-cursor.el.")
(add-to-list 'load-path forge-cursor--dir)
(require 'package)
;; Ensure pulsar's home (GNU ELPA) is reachable. Don't clobber a user's
;; existing archive list — just add what's missing.
(dolist (a '(("gnu" . "https://elpa.gnu.org/packages/")
("nongnu" . "https://elpa.nongnu.org/nongnu/")
("melpa" . "https://melpa.org/packages/")))
(unless (assoc (car a) package-archives)
(add-to-list 'package-archives a t)))
(unless package--initialized (package-initialize))
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(require 'use-package)
;;; --- Forge palette: single source of truth --------------------------
(defconst forge-cursor-core "#fff7e6" "White-hot core.")
(defconst forge-cursor-amber "#ff9b3d" "Amber mid-glow.")
(defconst forge-cursor-ember "#c81e0a" "Dark-red cooling tail.")
;;; --- 1. Per-keystroke welding sparks (bundled local package) --------
(use-package welding-cursor
:ensure nil ; bundled file, already on load-path
:demand t
:bind ("C-c t w" . welding-cursor-mode)
:custom
(welding-cursor-step 0.045)
(welding-cursor-foreground "black")
(welding-cursor-ramp
(vector forge-cursor-core "#ffd27a" forge-cursor-amber "#ff5a1f" forge-cursor-ember))
:config
(global-welding-cursor-mode 1))
;;; --- 2. Comet streak on cursor jumps --------------------------------
;; Bundled here (comet-trail.el, GPL-3.0, by Andros Fenollosa) so there is
;; no network dependency. To track upstream instead, delete the local file
;; and swap `:ensure nil' for `:vc (:url "https://git.andros.dev/andros/comet-trail.el")'
;; (the latter needs Emacs 30+).
(use-package comet-trail
:ensure nil ; bundled file, already on load-path
:hook ((prog-mode text-mode) . comet-trail-mode)
:custom
(comet-trail-minimum-distance 1) ; streak on any cursor move, incl. C-n/C-p
(comet-trail-tick-interval 0.016) ; ~60fps
:config
(set-face-foreground 'comet-trail-highlight forge-cursor-amber))
;;; --- 3. Pulsar forge-flash on big commands --------------------------
(use-package pulsar
:ensure t
:custom
(pulsar-pulse t)
(pulsar-delay 0.055)
(pulsar-iterations 12)
(pulsar-face 'pulsar-yellow)
(pulsar-highlight-face 'pulsar-yellow)
(pulsar-pulse-on-window-change t)
:config
(set-face-attribute 'pulsar-yellow nil :background forge-cursor-amber)
(dolist (fn '(recenter-top-bottom
scroll-up-command scroll-down-command
other-window delete-window delete-other-windows
forward-page backward-page
beginning-of-buffer end-of-buffer))
(add-to-list 'pulsar-pulse-functions fn))
(pulsar-global-mode 1))
(provide 'forge-cursor)
;;; forge-cursor.el ends here