Skip to content

Commit 5bafff7

Browse files
committed
Merge pull request #21 from AdrieanKhisbe/faces
Add face support and Basic regression Test
2 parents ec9ba72 + f3808d1 commit 5bafff7

File tree

5 files changed

+89
-60
lines changed

5 files changed

+89
-60
lines changed

README.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,17 @@ Key bind Function
4444

4545
Use ``M-x customize-group RET fireplace RET`` to view and change the user defined variables and read their documentation.
4646

47+
Configuration
48+
-------------
49+
50+
You can tweak the setting of `fireplace` the way you please with the ``customize-group``
51+
`fireplace` and `fireplace-faces`.
52+
53+
Among the options, the name of the buffer, the frequency of refresh, the smoke char,
54+
or the faces used in the fireplace.
55+
4756
Manual Installation
48-
------------
57+
-------------------
4958

5059
If you don't want to use melpa to install this package, follow these steps:
5160

@@ -73,6 +82,5 @@ or on twitter @johanvts.
7382
To-Do
7483
-----
7584
- Better status bar
76-
- Custom faces support
7785
- Locally override some of the offending settings from `Issue #10 <https://github.com/johanvts/emacs-fireplace/issues/10>`_
7886
- Automatically scale fire if the user alters the window size after starting the fire, see `Issue #20 <https://github.com/johanvts/emacs-fireplace/issues/20>`_

features/emacs-fireplace.feature

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
1-
Feature: Do Some things
2-
In order to do something
3-
As a user
4-
I want to do something
5-
6-
Scenario: Do Something
7-
Given I have "something"
8-
When I have "something"
9-
Then I should have "something"
10-
And I should have "something"
11-
But I should not have "something"
1+
Feature: Putting Emacs on Fire
2+
In order to do get warm in the winter
3+
As a cool emacs users
4+
I want to get some warmth from my favorite editor
5+
6+
Scenario: Turn on the fire
7+
When I call "fireplace"
8+
Then there is a "*fireplace*" buffer
9+
10+
11+
Scenario: Turn on the fire and then off
12+
When I call "fireplace"
13+
And I call "fireplace-off"
14+
Then I should be in buffer "*scratch*"
15+
16+
Scenario: I can customize general setting
17+
When I try to configure "fireplace"
18+
Then I should be in buffer "*Customize Group: Fireplace*"
19+
And I should see "Fireplace Background Char"
20+
And I should see "Fireplace Buffer Name"
21+
And I should see "Fireplace Fury"
22+
And I should see "Fireplace Smoke Char"
23+
24+
25+
Scenario: I can customize faces
26+
When I try to configure "fireplace-faces"
27+
Then I should be in buffer "*Customize Group: Fireplace Faces*"
28+
And I should see "Fireplace Inner Flame Face"
29+
And I should see "Fireplace Outter Flame Face"
30+
And I should see "Fireplace Smoke Face"

features/step-definitions/emacs-fireplace-steps.el

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,11 @@
22
;; files in this directory whose names end with "-steps.el" will be
33
;; loaded automatically by Ecukes.
44

5-
(Given "^I have \"\\(.+\\)\"$"
6-
(lambda (something)
7-
;; ...
8-
))
9-
10-
(When "^I have \"\\(.+\\)\"$"
11-
(lambda (something)
12-
;; ...
13-
))
14-
15-
(Then "^I should have \"\\(.+\\)\"$"
16-
(lambda (something)
17-
;; ...
18-
))
19-
20-
(And "^I have \"\\(.+\\)\"$"
21-
(lambda (something)
22-
;; ...
23-
))
24-
25-
(But "^I should not have \"\\(.+\\)\"$"
26-
(lambda (something)
27-
;; ...
28-
))
5+
(When "^I try to configure \"\\([^\"]+\\)\"$"
6+
(lambda (group)
7+
(shut-up
8+
(customize-group group))))
9+
10+
(Then "^there is a \"\\([^\"]+\\)\" buffer$"
11+
(lambda (buffer-name)
12+
(get-buffer buffer-name)))

features/support/env.el

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
(After
3131
;; After each scenario is run
32+
(get-buffer-create "*fireplace*")
33+
(fireplace-off) ; so far it break if no fireplace buffer
3234
)
3335

3436
(Teardown

fireplace.el

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
;;; fireplace.el --- A cozy fireplace for emacs -*- lexical-binding: t; -*-
22

33
;; Copyright (C) 2015 Johan Sivertsen
4-
;;; Version: 1.0
4+
;;; Version: 1.1
55
;;; Author: Johan Sivertsen <[email protected]>
66
;;; URL: https://github.com/johanvts/emacs-fireplace
77
;;; Released: December 2015
@@ -62,14 +62,32 @@
6262
"Default name for fireplace buffer."
6363
:type 'string :group 'fireplace)
6464

65-
;; Program controlled variables
66-
65+
;;; Faces
66+
(defgroup fireplace-faces nil
67+
"Faces for `fireplace'."
68+
:group 'fireplace)
69+
70+
(defface fireplace-outter-flame-face
71+
'((t (:background "orange red")))
72+
"Color of the core of the flame."
73+
:group 'fireplace-faces)
74+
75+
(defface fireplace-inner-flame-face
76+
'((t (:background "dark orange")))
77+
"Color of the core of the flame."
78+
:group 'fireplace-faces)
79+
(defface fireplace-smoke-face
80+
'((t (:foreground "slate grey")))
81+
"Color of the smoke."
82+
:group 'fireplace-faces)
83+
84+
;;; Program controlled variables
6785
(defvar fireplace--bkgd-height "Used for fireplace height, will be set from windows size")
6886
(defvar fireplace--bkgd-width "Used for fireplace width, will be set from windows size")
6987
(defvar fireplace--timer "Holds the active fireplace, kill using fireplace-off")
7088
(defvar fireplace--flame-width "Calculated width of flames")
7189

72-
;; Helper routines
90+
;;; Helper routines
7391

7492
(defun fireplace--make-grid ()
7593
"Redraw backgound of buffer."
@@ -88,34 +106,35 @@
88106
"Draw flame stripe."
89107
(fireplace--gotoxy x y)
90108
(let* ((actual-width (min width (1+ (- fireplace--bkgd-width x))))
91-
(hot-core (/ actual-width 2)))
109+
(hot-core (/ actual-width 2)))
92110
(delete-char actual-width)
93111
(insert (propertize (make-string actual-width fireplace-fill-char)
94-
'face `(:background ,"orange red")))
112+
'face 'fireplace-outter-flame-face))
95113
(when (> hot-core 1)
96114
(fireplace--gotoxy (+ x (/ hot-core 2)) y)
97115
(delete-char hot-core)
98116
(insert (propertize (make-string hot-core fireplace-fill-char)
99-
'face `(:background ,"dark orange"))))))
117+
'face 'fireplace-inner-flame-face)))))
100118

101119
(defun fireplace--smoke (x height)
102120
"Draw one random smoke."
103-
(fireplace--gotoxy (if (>(random 3) 1)
121+
(fireplace--gotoxy
122+
(if (>(random 3) 1)
104123
(+ x (random (/ fireplace--bkgd-width 5)))
105-
(max 0 (- x (random (/ fireplace--bkgd-width 5)))))
124+
(max 0 (- x (random (/ fireplace--bkgd-width 5)))))
106125
(+ height (random (- fireplace--bkgd-height height))))
107126
(delete-char 1)
108127
(insert (propertize (make-string 1 fireplace-smoke-char)
109-
'face `(:foreground, "slate grey"))))
128+
'face 'fireplace-smoke-face)))
110129

111130
(defun fireplace--flame (middle h)
112131
"Draw a flame."
113132
(setq cursor-type nil)
114133
(let* ((width h)
115-
(lower (truncate(* 0.2 h)))
116-
(high (- h lower))
117-
x
118-
line)
134+
(lower (truncate (* 0.2 h)))
135+
(high (- h lower))
136+
x
137+
line)
119138
(dotimes (y lower)
120139
(setq width (+ width y)
121140
x (- middle (/ width 2)))
@@ -126,9 +145,9 @@
126145
(setq width (- fireplace--bkgd-width x)))
127146
(draw-flame-stripe x y width))
128147
(dotimes (y high)
129-
(setq line (+ lower y))
130-
(setq width (max 0 (- width 1 (random 3))))
131-
(setq x (- middle (/ width 2)))
148+
(setq line (+ lower y)
149+
width (max 0 (- width 1 (random 3)))
150+
x (- middle (/ width 2)))
132151
(when (< x 0)
133152
(setq width (+ width x)
134153
x 0))
@@ -144,9 +163,8 @@
144163
(fireplace--make-grid)
145164
(dolist (pos flame-pos)
146165
(fireplace--flame (round (* pos fireplace--bkgd-width))
147-
(+
148-
(round (* (+ 0.2 (min pos (- 1 pos))) flame-width))
149-
(random 3))))
166+
(+ (round (* (+ 0.2 (min pos (- 1 pos))) flame-width))
167+
(random 3))))
150168
(setq buffer-read-only t)))
151169

152170

@@ -188,9 +206,7 @@
188206
(defun fireplace-toggle-smoke ()
189207
"Toggle smoke on/off."
190208
(interactive)
191-
(if fireplace-smoke-on
192-
(setq fireplace-smoke-on nil)
193-
(setq fireplace-smoke-on t)))
209+
(setq fireplace-smoke-on (not fireplace-smoke-on)))
194210

195211
;;; Key-bindings
196212

0 commit comments

Comments
 (0)