commit d23b7932aca482b4db403ee58eade5747ffdf332
parent 825a0c0d268cfe417b13d12b49468e2e8654cce4
Author: Jake Koroman <jakekoroman@gmail.com>
Date: Thu, 5 Sep 2024 15:58:19 -0400
added keybind to toggle between a normal and big font.
Diffstat:
3 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/config.def.h b/config.def.h
@@ -5,7 +5,11 @@
*
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
*/
-static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true";
+static char *fonts[] = {
+ "Liberation Mono:pixelsize=12:antialias=true:autohint=true", /* normal font */
+ "Liberation Mono:pixelsize=24:antialias=true:autohint=true" /* big font */
+};
+static int curfont = 0;
static int borderpx = 2;
/*
@@ -296,6 +300,7 @@ static Shortcut shortcuts[] = {
{ TERMMOD, XK_Y, selpaste, {.i = 0} },
{ ShiftMask, XK_Insert, selpaste, {.i = 0} },
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
+ { TERMMOD, XK_B, togglebigfont, {.i = 0 } },
};
/*
diff --git a/st.1 b/st.1
@@ -142,6 +142,9 @@ Print the full screen to the
Print the selection to the
.I iofile.
.TP
+.B Ctrl-Shift-B
+Toggle bigfont.
+.TP
.B Ctrl-Shift-Page Up
Increase font size.
.TP
diff --git a/x.c b/x.c
@@ -59,6 +59,7 @@ static void zoom(const Arg *);
static void zoomabs(const Arg *);
static void zoomreset(const Arg *);
static void ttysend(const Arg *);
+static void togglebigfont(const Arg *);
/* config.h for applying patches and the configuration. */
#include "config.h"
@@ -158,6 +159,7 @@ static void xhints(void);
static int xloadcolor(int, const char *, Color *);
static int xloadfont(Font *, FcPattern *);
static void xloadfonts(const char *, double);
+static void xreloadfont();
static void xunloadfont(Font *);
static void xunloadfonts(void);
static void xsetenv(void);
@@ -329,6 +331,17 @@ ttysend(const Arg *arg)
ttywrite(arg->s, strlen(arg->s), 1);
}
+void
+togglebigfont(const Arg *dummy)
+{
+ curfont = curfont ? 0 : 1;
+ xunloadfonts();
+ xloadfonts(fonts[curfont], 0);
+ cresize(0, 0);
+ redraw();
+ xhints();
+}
+
int
evcol(XEvent *e)
{
@@ -1131,6 +1144,14 @@ xicdestroy(XIC xim, XPointer client, XPointer call)
}
void
+xreloadfont(void)
+{
+ usedfont = (opt_font == NULL)? fonts[curfont] : opt_font;
+ xunloadfonts();
+ xloadfonts(usedfont, 0);
+}
+
+void
xinit(int cols, int rows)
{
XGCValues gcvalues;
@@ -1148,7 +1169,7 @@ xinit(int cols, int rows)
if (!FcInit())
die("could not init fontconfig.\n");
- usedfont = (opt_font == NULL)? font : opt_font;
+ usedfont = (opt_font == NULL)? fonts[curfont] : opt_font;
xloadfonts(usedfont, 0);
/* colors */