|
1 | 1 | ;;; fireplace.el --- A cozy fireplace for emacs -*- lexical-binding: t; -*- |
2 | 2 |
|
3 | 3 | ;; Copyright (C) 2015 Johan Sivertsen |
4 | | -;;; Version: 0.1 |
| 4 | +;;; Version: 0.2 |
5 | 5 | ;;; Author: Johan Sivertsen <[email protected]> |
6 | 6 | ;;; URL: https://github.com/johanvts/emacs-fireplace |
7 | 7 | ;;; Released: December 2015 |
|
23 | 23 |
|
24 | 24 | ;;; Commentary: |
25 | 25 |
|
26 | | -;; Puts your emacs on fire |
| 26 | +;; Puts your Emacs on fire |
27 | 27 |
|
28 | 28 | ;;; Code: |
29 | 29 |
|
|
72 | 72 | ;; Helper routines |
73 | 73 |
|
74 | 74 | (defun fireplace--make-grid () |
| 75 | + "Redraw backgound of buffer." |
75 | 76 | (erase-buffer) |
76 | 77 | (dotimes (i fireplace--bkgd-height) |
77 | 78 | (insert-char fireplace-background-char fireplace--bkgd-width) |
78 | 79 | (newline))) |
79 | 80 |
|
80 | 81 | (defun fireplace--gotoxy(x y) |
81 | | - (goto-char (+ 1 x (* (- fireplace--bkgd-height (+ 1 y)) (+ 1 fireplace--bkgd-width))))) |
| 82 | + "Move pointer to position X Y." |
| 83 | + (goto-char (+ 1 x (* (- fireplace--bkgd-height (+ 1 y)) |
| 84 | + (+ 1 fireplace--bkgd-width))))) |
82 | 85 |
|
83 | 86 |
|
84 | 87 | (defun draw-flame-stripe (x y width) |
| 88 | + "Draw fire stripes." |
85 | 89 | (fireplace--gotoxy x y) |
86 | 90 | (let* ((actual-width (min width (1+ (- fireplace--bkgd-width x)))) |
87 | 91 | (hot-core (/ actual-width 2))) |
|
95 | 99 | 'face `(:background ,"dark orange")))))) |
96 | 100 |
|
97 | 101 | (defun fireplace--smoke (x height) |
| 102 | + "Draw fire smoke." |
98 | 103 | (fireplace--gotoxy (if (>(random 3) 1) |
99 | 104 | (+ x (random (/ fireplace--bkgd-width 5))) |
100 | 105 | (max 0 (- x (random (/ fireplace--bkgd-width 5))))) |
|
104 | 109 | 'face `(:foreground, "slate grey")))) |
105 | 110 |
|
106 | 111 | (defun fireplace--flame (middle h) |
| 112 | + "Draw fire flames." |
107 | 113 | (setq cursor-type nil) |
108 | 114 | (let* ((width h) |
109 | 115 | (lower (truncate(* 0.2 h))) |
|
132 | 138 | (when fireplace-smoke-on (fireplace--smoke x h))))) |
133 | 139 |
|
134 | 140 | (defun draw-fireplace (buffer-name flame-pos flame-width) |
| 141 | + "Draw the whole fireplace in BUFFER-NAME from FLAME-POS with FLAME-WIDTH." |
135 | 142 | (with-current-buffer (get-buffer-create buffer-name) |
136 | 143 | (setq buffer-read-only nil) |
137 | 144 | (fireplace--make-grid) |
|
169 | 176 | (kill-buffer fireplace-buffer-name))) |
170 | 177 |
|
171 | 178 | (defun fireplace-down () |
172 | | - (interactive) |
173 | 179 | "Push the fire further down" |
| 180 | + (interactive) |
174 | 181 | (setq fireplace--bkgd-height (+ fireplace--bkgd-height 1))) |
175 | 182 |
|
176 | 183 |
|
177 | 184 | (defun fireplace-up () |
| 185 | + "Move the fire further up." |
178 | 186 | (interactive) |
179 | | - "Move the fire further up" |
180 | 187 | (setq fireplace--bkgd-height (max 0 (- fireplace--bkgd-height 1)))) |
181 | 188 |
|
182 | 189 | (defun fireplace-toggle-smoke () |
| 190 | + "Toggle smoke on/off." |
183 | 191 | (interactive) |
184 | | - "Toggle smoke on/off" |
185 | 192 | (if fireplace-smoke-on |
186 | 193 | (setq fireplace-smoke-on nil) |
187 | 194 | (setq fireplace-smoke-on t))) |
188 | 195 |
|
189 | | -;;Key-bindings |
| 196 | +;;; Key-bindings |
190 | 197 |
|
191 | | -(define-derived-mode fireplace-mode special-mode "A cozy fireplace") |
| 198 | +(define-derived-mode fireplace-mode special-mode "A cozy fireplace.") |
192 | 199 |
|
193 | 200 | (define-key fireplace-mode-map (kbd "C-+") 'fireplace-down) |
194 | 201 | (define-key fireplace-mode-map (kbd "C--") 'fireplace-up) |
|
0 commit comments