-
-
Notifications
You must be signed in to change notification settings - Fork 196
/
nano-faces.el
350 lines (299 loc) · 13.2 KB
/
nano-faces.el
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
;;; nano-faces --- Face settings for nano-emacs
;;; License:
;; ---------------------------------------------------------------------
;; GNU Emacs / N Λ N O - Emacs made simple
;; Copyright (C) 2020 - N Λ N O developers
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;; ---------------------------------------------------------------------
;;; Commentary:
;;
;; This file defines the 6 basic nano faces:
;;
;; - nano-face-critical - nano-face-popout - nano-face-salient
;; - nano-face-default - nano-face-faded - nano-face-subtle
;;
;; Several nano modules require
;;
;; ---------------------------------------------------------------------
;;; Code:
(require 'nano-base-colors)
(defcustom nano-font-family-monospaced "Roboto Mono"
"Name of the font-family to use for nano.
Defaults to Roboto Mono. Customizing this might lead to conflicts
if the family does not have sufficient bold/light etc faces."
:group 'nano
:type 'string)
(defcustom nano-font-family-proportional nil
"Font to use for variable pitch faces.
Setting this allows nano to display variable pitch faces when,
for instance, 'variable-pitch-mode' or 'mixed-pitch-mode' is active in a buffer.
Defaults to nil."
:group 'nano
:type 'string)
(defcustom nano-font-size 14
"Default value for the font size of nano-theme in pt units.
Note: to change this after startup, call
\(nano-faces\) and \(nano-themes\)."
:group 'nano
:type 'integer)
;; A theme is fully defined by these seven faces
(defface nano-face-default nil
"Default face is used for regular information."
:group 'nano)
(defface nano-face-variable-pitch nil
"Default variable-pitch face is used for variable pitch mode."
:group 'nano)
(defface nano-face-critical nil
"Critical face is for information that requires immediate action.
It should be of high constrast when compared to other faces. This
can be realized (for example) by setting an intense background
color, typically a shade of red. It must be used scarcely."
:group 'nano)
(defface nano-face-popout nil
"Popout face is used for information that needs attention.
To achieve such effect, the hue of the face has to be
sufficiently different from other faces such that it attracts
attention through the popout effect."
:group 'nano)
(defface nano-face-strong nil
"Strong face is used for information of a structural nature.
It has to be the same color as the default color and only the
weight differs by one level (e.g., light/regular or
regular/bold). IT is generally used for titles, keywords,
directory, etc."
:group 'nano)
(defface nano-face-salient nil
"Salient face is used for information that are important.
To suggest the information is of the same nature but important,
the face uses a different hue with approximately the same
intensity as the default face. This is typically used for links."
:group 'nano)
(defface nano-face-faded nil
"Faded face is for information that are less important.
It is made by using the same hue as the default but with a lesser
intensity than the default. It can be used for comments,
secondary information and also replace italic (which is generally
abused anyway)."
:group 'nano)
(defface nano-face-subtle nil
"Subtle face is used to suggest a physical area on the screen.
It is important to not disturb too strongly the reading of
information and this can be made by setting a very light
background color that is barely perceptible."
:group 'nano)
(defface nano-face-header-default nil
"Default face for ther header line."
:group 'nano)
(defface nano-face-header-critical nil
"Critical face for ther header line."
:group 'nano)
(defface nano-face-header-popout nil
"Popout face for ther header line."
:group 'nano)
(defface nano-face-header-strong nil
"Strong face for ther header line."
:group 'nano)
(defface nano-face-header-salient nil
"Salient face for ther header line."
:group 'nano)
(defface nano-face-header-faded nil
"Faded face for ther header line."
:group 'nano)
(defface nano-face-header-subtle nil
"Subtle face for ther header line."
:group 'nano)
(defface nano-face-header-highlight nil
"Highlight face for ther header line."
:group 'nano)
(defface nano-face-header-separator nil
"Face for separating item in the header line (internal use)"
:group 'nano)
(defface nano-face-header-filler nil
"Face compsenting spaces in the header line (internal use) "
:group 'nano)
(defface nano-face-tag-default nil
"Default face for tags"
:group 'nano)
(defface nano-face-tag-faded nil
"Faded face for tags"
:group 'nano)
(defface nano-face-tag-strong nil
"Strong face for tags"
:group 'nano)
(defface nano-face-tag-salient nil
"Salient face for tags"
:group 'nano)
(defface nano-face-tag-popout nil
"Popout face for tags"
:group 'nano)
(defface nano-face-tag-critical nil
"Critical face for tags"
:group 'nano)
(defun nano-what-faces (pos)
"Get the font faces at POS."
(interactive "d")
(let ((faces (remq nil
(list
(get-char-property pos 'read-face-name)
(get-char-property pos 'face)
(plist-get (text-properties-at pos) 'face)))))
(message "Faces: %s" faces)))
(defun nano-faces ()
"Derive face attributes for nano-faces using nano-theme values."
(set-face-attribute 'nano-face-default nil
:foreground nano-color-foreground
:background nano-color-background
:family nano-font-family-monospaced
:height (* nano-font-size 10))
(set-face-attribute 'nano-face-critical nil
:foreground nano-color-foreground
:background nano-color-critical)
(set-face-attribute 'nano-face-popout nil
:foreground nano-color-popout)
(set-face-attribute 'nano-face-variable-pitch nil
:foreground (face-foreground 'nano-face-default)
:background (face-background 'nano-face-default)
:family nano-font-family-proportional
:height (* nano-font-size 10))
(if (display-graphic-p)
(set-face-attribute 'nano-face-strong nil
:foreground nano-color-strong
:weight 'medium)
(set-face-attribute 'nano-face-strong nil
:foreground nano-color-strong
:weight 'bold))
(set-face-attribute 'nano-face-salient nil
:foreground nano-color-salient
:weight 'light)
(set-face-attribute 'nano-face-faded nil
:foreground nano-color-faded
:weight 'light)
(set-face-attribute 'nano-face-subtle nil
:background nano-color-subtle)
(set-face-attribute 'nano-face-header-default nil
:foreground nano-color-foreground
:background nano-color-subtle
:box `(:line-width 1
:color ,nano-color-background
:style nil))
(set-face-attribute 'nano-face-tag-default nil
:foreground nano-color-foreground
:background nano-color-background
:weight 'regular
:height (if (display-graphic-p)
(round
(* 0.85 (* 10 nano-font-size)))
1)
:box `(:line-width 1
:color ,nano-color-foreground
:style nil))
(set-face-attribute 'nano-face-header-strong nil
:foreground nano-color-strong
:background nano-color-subtle
:inherit 'nano-face-strong
:box `(:line-width 1
:color ,nano-color-background
:style nil))
(set-face-attribute 'nano-face-tag-strong nil
:foreground nano-color-strong
:background nano-color-subtle
:weight 'regular
:height (if (display-graphic-p)
(round
(* 0.85 (* 10 nano-font-size)))
1)
:box `(:line-width 1
:color ,nano-color-strong
:style nil))
(set-face-attribute 'nano-face-header-salient nil
:foreground nano-color-background
:background nano-color-salient
:box `(:line-width 1
:color ,nano-color-background
:style nil))
(set-face-attribute 'nano-face-tag-salient nil
:foreground nano-color-background
:background nano-color-salient
:weight 'regular
:height (if (display-graphic-p)
(round
(* 0.85 (* 10 nano-font-size)))
1)
:box `(:line-width 1
:color ,nano-color-salient
:style nil))
(set-face-attribute 'nano-face-header-popout nil
:foreground nano-color-background
:background nano-color-popout
:box `(:line-width 1
:color ,nano-color-background
:style nil))
(set-face-attribute 'nano-face-tag-popout nil
:foreground nano-color-background
:background nano-color-popout
:weight 'regular
:height (if (display-graphic-p)
(round
(* 0.85 (* 10 nano-font-size)))
1)
:box `(:line-width 1
:color ,nano-color-popout
:style nil))
(set-face-attribute 'nano-face-header-faded nil
:foreground nano-color-background
:background nano-color-faded
:box `(:line-width 1
:color ,nano-color-background
:style nil))
(set-face-attribute 'nano-face-tag-faded nil
:foreground nano-color-background
:background nano-color-faded
:weight 'regular
:height (if (display-graphic-p)
(round
(* 0.85 (* 10 nano-font-size)))
1)
:box `(:line-width 1
:color ,nano-color-faded
:style nil))
(set-face-attribute 'nano-face-header-subtle nil)
(set-face-attribute 'nano-face-header-critical nil
:foreground nano-color-background
:background nano-color-critical
:box `(:line-width 1
:color ,nano-color-background
:style nil))
(set-face-attribute 'nano-face-tag-critical nil
:foreground nano-color-background
:background nano-color-critical
:weight 'regular
:height (if (display-graphic-p)
(round
(* 0.85 (* 10 nano-font-size)))
1)
:box `(:line-width 1
:color ,nano-color-critical
:style nil))
(set-face-attribute 'nano-face-header-separator nil
:inherit 'nano-face-default
:height 0.1)
(set-face-attribute 'nano-face-header-filler nil
:inherit 'nano-face-header-default
:height 0.1)
(set-face-attribute 'nano-face-header-highlight nil
:inherit 'nano-face-header-faded
:box nil))
(provide 'nano-faces)
;;; nano-faces.el ends here