st


Logs | Files | LICENSE | LICENSE | GitLab


1
commit 656b1d4d97134254bda560a06e6ff241a6b5da62
2
Author: Connor Etherington <[email protected]>
3
Date:   Tue Mar 22 06:22:18 2022 +0200
4
5
    Update.
6
---
7
 Xappearance.h | 117 +++++++++++++++++++++++++++++++++++++++
8
 Xdefaults     | 128 ------------------------------------------
9
 config.h      | 174 ++++++----------------------------------------------------
10
 x.c           |  17 +++++-
11
 4 files changed, 150 insertions(+), 286 deletions(-)
12
13
diff --git a/Xappearance.h b/Xappearance.h
14
new file mode 100644
15
index 0000000..c4ae988
16
--- /dev/null
17
+++ b/Xappearance.h
18
@@ -0,0 +1,117 @@
19
+
20
+// * Default colors (colorname index)
21
+// * foreground, background, cursor, reverse cursor
22
+
23
+unsigned int defaultfg = 259;
24
+unsigned int defaultbg = 258;
25
+unsigned int defaultcs = 256;
26
+unsigned int defaultrcs = 257;
27
+unsigned int background = 258;
28
+
29
+// Xresources preference
30
+// Terminal colors (16 first used in escape sequence)
31
+
32
+static const char *colorname[] = {
33
+  "#040303",
34
+  "#0F0B0A",
35
+  "#2C0706",
36
+  "#1B1C20",
37
+  "#541314",
38
+  "#CE3804",
39
+  "#55747B",
40
+  "#E2611B",
41
+  "#AD3F42",
42
+  "#E3B036",
43
+  "#FEEB00",
44
+  "#45A59A",
45
+  "#45A59A",
46
+  "#67D0A8",
47
+  "#97E4B0",
48
+  "#CBD9A4",
49
+  [255] = 0,
50
+  "#add8e6",
51
+  "#555555",
52
+  "#1C1A1A", 
53
+  "#67D0A8",
54
+};
55
+
56
+ResourcePref resources[] = {
57
+  { "termname",     STRING,  &termname },
58
+  { "shell",        STRING,  &shell },
59
+  { "minlatency",   INTEGER, &minlatency },
60
+  { "maxlatency",   INTEGER, &maxlatency },
61
+  { "blinktimeout", INTEGER, &blinktimeout },
62
+  { "bellvolume",   INTEGER, &bellvolume },
63
+  { "tabspaces",    INTEGER, &tabspaces },
64
+  { "borderpx",     INTEGER, &borderpx },
65
+  { "cwscale",      FLOAT,   &cwscale },
66
+  { "chscale",      FLOAT,   &chscale },
67
+  { "alpha",        FLOAT,   &alpha },
68
+  { "alphaOffset",  FLOAT,   &alphaOffset },
69
+  { "color0",       STRING,  &colorname[0] },
70
+  { "color1",       STRING,  &colorname[1] },
71
+  { "color2",       STRING,  &colorname[2] },
72
+  { "color3",       STRING,  &colorname[3] },
73
+  { "color4",       STRING,  &colorname[4] },
74
+  { "color5",       STRING,  &colorname[5] },
75
+  { "color6",       STRING,  &colorname[6] },
76
+  { "color7",       STRING,  &colorname[7] },
77
+  { "color8",       STRING,  &colorname[8] },
78
+  { "color9",       STRING,  &colorname[9] },
79
+  { "color10",      STRING,  &colorname[10] },
80
+  { "color11",      STRING,  &colorname[11] },
81
+  { "color12",      STRING,  &colorname[12] },
82
+  { "color13",      STRING,  &colorname[13] },
83
+  { "color14",      STRING,  &colorname[14] },
84
+  { "color15",      STRING,  &colorname[15] },
85
+  { "background",   STRING,  &colorname[258] },
86
+  { "foreground",   STRING,  &colorname[259] },
87
+  { "cursorColor",  STRING,  &colorname[256] }
88
+};
89
+
90
+//"#010101",
91
+//"#110C0F",
92
+//"#131313",
93
+//"#23181D",
94
+//"#45313A",
95
+//"#CE3804",
96
+//"#FA3C00",
97
+//"#E8781E",
98
+//"#D12F5E",
99
+//"#ED8B21",
100
+//"#FEEB00",
101
+//"#AB47BB",
102
+//"#B94CCA",
103
+//"#1ABADD",
104
+//"#1393E4",
105
+//"#B2C8DB",
106
+//"255] = 0,
107
+//"#add8e6",
108
+//"#555555",
109
+//"#1C1A1A", 
110
+//"#67D0A8",
111
+
112
+//"#040303",
113
+//"#0F0B0A",
114
+//"#2C0706",
115
+//"#1B1C20",
116
+//"#541314",
117
+//"#513F4E",
118
+//"#55747B",
119
+//"#E2611B",
120
+//"#AD3F42",
121
+//"#E3B036",
122
+//"#EEDC5E",
123
+//"#B8118C",
124
+//"#45A59A",
125
+//"#67D0A8",
126
+//"#97E4B0",
127
+//"#CBD9A4",
128
+//"255] = 0,
129
+//"#add8e6",
130
+//"#555555",
131
+//"#1C1A1A", 
132
+//"#67D0A8",
133
+
134
+
135
+
136
diff --git a/Xdefaults b/Xdefaults
137
deleted file mode 100644
138
index eecfff1..0000000
139
--- a/Xdefaults
140
+++ /dev/null
141
@@ -1,128 +0,0 @@
142
-!! Transparency (0-1):
143
-st.alpha: 0.9
144
-st.alphaOffset: 0.3
145
-
146
-!! Set a default font and font size as below:
147
-st.font: Monospace-11;
148
-
149
-! st.termname: st-256color
150
-! st.borderpx: 2
151
-
152
-!! Set the background, foreground and cursor colors as below:
153
-
154
-!! gruvbox:
155
-*.color0: #1d2021
156
-*.color1: #cc241d
157
-*.color2: #98971a
158
-*.color3: #d79921
159
-*.color4: #458588
160
-*.color5: #b16286
161
-*.color6: #689d6a
162
-*.color7: #a89984
163
-*.color8: #928374
164
-*.color9: #fb4934
165
-*.color10: #b8bb26
166
-*.color11: #fabd2f
167
-*.color12: #83a598
168
-*.color13: #d3869b
169
-*.color14: #8ec07c
170
-*.color15: #ebdbb2
171
-*.background: #282828
172
-*.foreground: white
173
-*.cursorColor: white
174
-
175
-/* /1* !! gruvbox light: *1/ */
176
-/* *.color0: #fbf1c7 */
177
-/* *.color1: #cc241d */
178
-/* *.color2: #98971a */
179
-/* *.color3: #d79921 */
180
-/* *.color4: #458588 */
181
-/* *.color5: #b16286 */
182
-/* *.color6: #689d6a */
183
-/* *.color7: #7c6f64 */
184
-/* *.color8: #928374 */
185
-/* *.color9: #9d0006 */
186
-/* *.color10: #79740e */
187
-/* *.color11: #b57614 */
188
-/* *.color12: #076678 */
189
-/* *.color13: #8f3f71 */
190
-/* *.color14: #427b58 */
191
-/* *.color15: #3c3836 */
192
-/* *.background: #fbf1c7 */
193
-/* *.foreground: #282828 */
194
-/* *.cursorColor: #282828 */
195
-
196
-/* !! brogrammer: */
197
-/* *.foreground:  #d6dbe5 */
198
-/* *.background:  #131313 */
199
-/* *.color0:      #1f1f1f */
200
-/* *.color8:      #d6dbe5 */
201
-/* *.color1:      #f81118 */
202
-/* *.color9:      #de352e */
203
-/* *.color2:      #2dc55e */
204
-/* *.color10:     #1dd361 */
205
-/* *.color3:      #ecba0f */
206
-/* *.color11:     #f3bd09 */
207
-/* *.color4:      #2a84d2 */
208
-/* *.color12:     #1081d6 */
209
-/* *.color5:      #4e5ab7 */
210
-/* *.color13:     #5350b9 */
211
-/* *.color6:      #1081d6 */
212
-/* *.color14:     #0f7ddb */
213
-/* *.color7:      #d6dbe5 */
214
-/* *.color15:     #ffffff */
215
-/* *.colorBD:     #d6dbe5 */
216
-
217
-/* ! base16 */
218
-/* *.color0:       #181818 */
219
-/* *.color1:       #ab4642 */
220
-/* *.color2:       #a1b56c */
221
-/* *.color3:       #f7ca88 */
222
-/* *.color4:       #7cafc2 */
223
-/* *.color5:       #ba8baf */
224
-/* *.color6:       #86c1b9 */
225
-/* *.color7:       #d8d8d8 */
226
-/* *.color8:       #585858 */
227
-/* *.color9:       #ab4642 */
228
-/* *.color10:      #a1b56c */
229
-/* *.color11:      #f7ca88 */
230
-/* *.color12:      #7cafc2 */
231
-/* *.color13:      #ba8baf */
232
-/* *.color14:      #86c1b9 */
233
-/* *.color15:      #f8f8f8 */
234
-
235
-/* !! solarized */
236
-/* *.color0:	#073642 */
237
-/* *.color1:	#dc322f */
238
-/* *.color2:	#859900 */
239
-/* *.color3:	#b58900 */
240
-/* *.color4:	#268bd2 */
241
-/* *.color5:	#d33682 */
242
-/* *.color6:	#2aa198 */
243
-/* *.color7:	#eee8d5 */
244
-/* *.color9:	#cb4b16 */
245
-/* *.color8:	#fdf6e3 */
246
-/* *.color10:	#586e75 */
247
-/* *.color11:	#657b83 */
248
-/* *.color12:	#839496 */
249
-/* *.color13:	#6c71c4 */
250
-/* *.color14:	#93a1a1 */
251
-/* *.color15:	#fdf6e3 */
252
-
253
-/* !! xterm */
254
-/* *.color0:   #000000 */
255
-/* *.color1:   #cd0000 */
256
-/* *.color2:   #00cd00 */
257
-/* *.color3:   #cdcd00 */
258
-/* *.color4:   #0000cd */
259
-/* *.color5:   #cd00cd */
260
-/* *.color6:   #00cdcd */
261
-/* *.color7:   #e5e5e5 */
262
-/* *.color8:   #4d4d4d */
263
-/* *.color9:   #ff0000 */
264
-/* *.color10:  #00ff00 */
265
-/* *.color11:  #ffff00 */
266
-/* *.color12:  #0000ff */
267
-/* *.color13:  #ff00ff */
268
-/* *.color14:  #00ffff */
269
-/* *.color15:  #aabac8 */
270
diff --git a/config.h b/config.h
271
index 45f1579..0d3fdbb 100644
272
--- a/config.h
273
+++ b/config.h
274
@@ -1,29 +1,22 @@
275
 /* See LICENSE file for copyright and license details. */
276
 
277
-/*
278
- * appearance
279
- *
280
- * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
281
- */
282
+static char *fonts[] = {
283
+  "Hack:pixelsize=16:antialias=true:autohint=true",                            
284
+  "Mono:pixelsize=16:antialias=true:autohint=true",                            
285
+};
286
 
287
-// static char *font = "mono:pixelsize=16:antialias=true:autohint=true";
288
-//static char *font = "Anonymice Nerd Font Mono:pixelsize=18:antialias=true:autohint=true";
289
-static char *font = "Mononoki Nerd Font:pixelsize=18:antialias=true:autohint=true";
290
-static char *font2[] = { "JoyPixels:pixelsize=10:antialias=true:autohint=true" };
291
+static char *font2[] = { 
292
+  "JoyPixels:pixelsize=18:antialias=true:autohint=true",
293
+  "Devicons:pixelsize=16:antialias=true:autohint=true",
294
+  "FontAwesome:pixelsize=16:antialias=true:autohint=true",
295
+};
296
 
297
-static int borderpx = 5;
298
+static int fonts_current = 0;
299
+static int borderpx = 18;
300
 
301
-/*
302
- * What program is execed by st depends of these precedence rules:
303
- * 1: program passed with -e
304
- * 2: scroll and/or utmp
305
- * 3: SHELL environment variable
306
- * 4: value of shell in /etc/passwd
307
- * 5: value of shell in config.h
308
- */
309
 static char *shell = "/bin/sh";
310
+
311
 char *utmp = NULL;
312
-/* scroll program: to enable use a string like "scroll" */
313
 char *scroll = NULL;
314
 char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400";
315
 
316
@@ -34,124 +27,39 @@ char *vtiden = "\033[?6c";
317
 static float cwscale = 1.0;
318
 static float chscale = 1.0;
319
 
320
-/*
321
- * word delimiter string
322
- *
323
- * More advanced example: L" `'\"()[]{}"
324
- */
325
 wchar_t *worddelimiters = L" ";
326
 
327
-/* selection timeouts (in milliseconds) */
328
 static unsigned int doubleclicktimeout = 300;
329
 static unsigned int tripleclicktimeout = 600;
330
 
331
-/* alt screens */
332
 int allowaltscreen = 1;
333
-
334
-/* allow certain non-interactive (insecure) window operations such as:
335
-   setting the clipboard text */
336
 int allowwindowops = 1;
337
 
338
-/*
339
- * draw latency range in ms - from new content/keypress/etc until drawing.
340
- * within this range, st draws when content stops arriving (idle). mostly it's
341
- * near minlatency, but it waits longer for slow updates to avoid partial draw.
342
- * low minlatency will tear/flicker more, as it can "detect" idle too early.
343
- */
344
 static double minlatency = 8;
345
 static double maxlatency = 33;
346
 
347
-/*
348
- * blinking timeout (set to 0 to disable blinking) for the terminal blinking
349
- * attribute.
350
- */
351
 static unsigned int blinktimeout = 800;
352
-
353
-/*
354
- * thickness of underline and bar cursors
355
- */
356
 static unsigned int cursorthickness = 2;
357
 
358
-/*
359
- * 1: render most of the lines/blocks characters without using the font for
360
- *    perfect alignment between cells (U2500 - U259F except dashes/diagonals).
361
- *    Bold affects lines thickness if boxdraw_bold is not 0. Italic is ignored.
362
- * 0: disable (render all U25XX glyphs normally from the font).
363
- */
364
 const int boxdraw = 12;
365
-const int boxdraw_bold = 4;
366
-
367
-/* braille (U28XX):  1: render as adjacent "pixels",  0: use font */
368
+const int boxdraw_bold = 8;
369
 const int boxdraw_braille = 0;
370
 
371
-/*
372
- * bell volume. It must be a value between -100 and 100. Use 0 for disabling
373
- * it
374
- */
375
 static int bellvolume = 0;
376
 
377
-/* default TERM value */
378
 char *termname = "st-256color";
379
 
380
-/*
381
- * spaces per tab
382
- *
383
- * When you are changing this value, don't forget to adapt the »it« value in
384
- * the st.info and appropriately install the st.info in the environment where
385
- * you use this st version.
386
- *
387
- *	it#$tabspaces,
388
- *
389
- * Secondly make sure your kernel is not expanding tabs. When running `stty
390
- * -a` »tab0« should appear. You can tell the terminal to not expand tabs by
391
- *  running following command:
392
- *
393
- *	stty tabs
394
- */
395
 unsigned int tabspaces = 4;
396
 
397
 /* bg opacity */
398
-float alpha = 0.9;
399
+float alpha = 0.95;
400
 float alphaOffset = 0.0;
401
 float alphaUnfocus;
402
 
403
-/* Terminal colors (16 first used in escape sequence) */
404
-static const char *colorname[] = {
405
-  "#040303",
406
-  "#0F0B0A",
407
-  "#2C0706",
408
-  "#1B1C20",
409
-  "#541314",
410
-  "#513F4E",
411
-  "#55747B",
412
-  "#E2611B",
413
-  "#AD3F42",
414
-  "#E3B036",
415
-  "#EEDC5E",
416
-  "#B8118C",
417
-  "#45A59A",
418
-  "#67D0A8",
419
-  "#97E4B0",
420
-  "#CBD9A4",
421
-	[255] = 0,
422
-	/* more colors can be added after 255 to use with DefaultXX */
423
-	"#add8e6", /* 256 -> cursor */
424
-	"#555555", /* 257 -> rev cursor*/
425
-  "#1C1A1A", 
426
-  "#67D0A8",
427
-};
428
-
429
-
430
-/*
431
- * Default colors (colorname index)
432
- * foreground, background, cursor, reverse cursor
433
- */
434
-unsigned int defaultfg = 259;
435
-unsigned int defaultbg = 258;
436
-unsigned int defaultcs = 256;
437
-unsigned int defaultrcs = 257;
438
-unsigned int background = 258;
439
+/* Xresources preferences to load at startup */
440
+#include "Xappearance.h"
441
 
442
+/* default TERM value */
443
 /*
444
  * Default shape of cursor
445
  * 2: Block ("█")
446
@@ -160,17 +68,8 @@ unsigned int background = 258;
447
  * 7: Snowman ("☃")
448
  */
449
 static unsigned int cursorshape = 2;
450
-
451
-/*
452
- * Default columns and rows numbers
453
- */
454
-
455
 static unsigned int cols = 70;
456
 static unsigned int rows = 20;
457
-
458
-/*
459
- * Default colour and shape of the mouse cursor
460
- */
461
 static unsigned int mouseshape = XC_xterm;
462
 static unsigned int mousefg = 7;
463
 static unsigned int mousebg = 0;
464
@@ -188,44 +87,6 @@ static unsigned int defaultattr = 0;
465
  */
466
 static uint forcemousemod = ShiftMask;
467
 
468
-/*
469
- * Xresources preferences to load at startup
470
- */
471
-ResourcePref resources[] = {
472
-		{ "font",         STRING,  &font },
473
-		{ "color0",       STRING,  &colorname[0] },
474
-		{ "color1",       STRING,  &colorname[1] },
475
-		{ "color2",       STRING,  &colorname[2] },
476
-		{ "color3",       STRING,  &colorname[3] },
477
-		{ "color4",       STRING,  &colorname[4] },
478
-		{ "color5",       STRING,  &colorname[5] },
479
-		{ "color6",       STRING,  &colorname[6] },
480
-		{ "color7",       STRING,  &colorname[7] },
481
-		{ "color8",       STRING,  &colorname[8] },
482
-		{ "color9",       STRING,  &colorname[9] },
483
-		{ "color10",      STRING,  &colorname[10] },
484
-		{ "color11",      STRING,  &colorname[11] },
485
-		{ "color12",      STRING,  &colorname[12] },
486
-		{ "color13",      STRING,  &colorname[13] },
487
-		{ "color14",      STRING,  &colorname[14] },
488
-		{ "color15",      STRING,  &colorname[15] },
489
-		{ "background",   STRING,  &colorname[258] },
490
-		{ "foreground",   STRING,  &colorname[259] },
491
-		{ "cursorColor",  STRING,  &colorname[256] },
492
-		{ "termname",     STRING,  &termname },
493
-		{ "shell",        STRING,  &shell },
494
-		{ "minlatency",   INTEGER, &minlatency },
495
-		{ "maxlatency",   INTEGER, &maxlatency },
496
-		{ "blinktimeout", INTEGER, &blinktimeout },
497
-		{ "bellvolume",   INTEGER, &bellvolume },
498
-		{ "tabspaces",    INTEGER, &tabspaces },
499
-		{ "borderpx",     INTEGER, &borderpx },
500
-		{ "cwscale",      FLOAT,   &cwscale },
501
-		{ "chscale",      FLOAT,   &chscale },
502
-		{ "alpha",        FLOAT,   &alpha },
503
-		{ "alphaOffset",  FLOAT,   &alphaOffset },
504
-};
505
-
506
 /*
507
  * Internal mouse shortcuts.
508
  * Beware that overloading Button1 will disable the selection.
509
@@ -256,6 +117,7 @@ static char *copyoutput[] = { "/bin/sh", "-c", "st-copyout", "externalpipe", NUL
510
 
511
 static Shortcut shortcuts[] = {
512
 	/* mask                 keysym          function        argument */
513
+	{ TERMMOD,              XK_S,           cyclefonts,     {       } },
514
 	{ XK_ANY_MOD,           XK_Break,       sendbreak,      {.i =  0} },
515
 	{ ControlMask,          XK_Print,       toggleprinter,  {.i =  0} },
516
 	{ ShiftMask,            XK_Print,       printscreen,    {.i =  0} },
517
diff --git a/x.c b/x.c
518
index 2580d2a..5239728 100644
519
--- a/x.c
520
+++ b/x.c
521
@@ -75,6 +75,7 @@ static void zoom(const Arg *);
522
 static void zoomabs(const Arg *);
523
 static void zoomreset(const Arg *);
524
 static void ttysend(const Arg *);
525
+static void cyclefonts(const Arg *);
526
 
527
 /* config.h for applying patches and the configuration. */
528
 #include "config.h"
529
@@ -1006,6 +1007,18 @@ xloadfont(Font *f, FcPattern *pattern)
530
 	return 0;
531
 }
532
 
533
+void
534
+cyclefonts(const Arg *dummy)
535
+{
536
+	fonts_current++;
537
+	if (fonts_current > (sizeof fonts / sizeof fonts[0]) - 1) {
538
+		fonts_current = 0;
539
+	}
540
+	usedfont = fonts[fonts_current];
541
+	xloadfonts(fonts[fonts_current], 0);
542
+	redraw();
543
+}
544
+
545
 void
546
 xloadfonts(char *fontstr, double fontsize)
547
 {
548
@@ -1278,8 +1291,8 @@ xinit(int cols, int rows)
549
 	if (!FcInit())
550
 		die("could not init fontconfig.\n");
551
 
552
-	usedfont = (opt_font == NULL)? font : opt_font;
553
-	xloadfonts(usedfont, 0);
554
+	usedfont = fonts[fonts_current];
555
+	xloadfonts(fonts[fonts_current], 0);
556
 
557
 	/* spare fonts */
558
 	xloadsparefonts();