From 06138acd8a91bd01bc70af03910d6557cc0b078e Mon Sep 17 00:00:00 2001 From: "George V. Kouryachy (Fr. Br. George)" Date: Thu, 4 May 2023 18:31:29 +0300 Subject: [PATCH 5/5] Introduce runtime font selection --- config.def.h | 2 +- tabbed.1 | 5 +++++ tabbed.c | 9 ++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/config.def.h b/config.def.h index defa426..e454a43 100644 --- a/config.def.h +++ b/config.def.h @@ -1,7 +1,7 @@ /* See LICENSE file for copyright and license details. */ /* appearance */ -static const char font[] = "monospace:size=9"; +static const char default_font[]= "monospace:size=12"; static const char* normbgcolor = "#222222"; static const char* normfgcolor = "#cccccc"; static const char* selbgcolor = "#555555"; diff --git a/tabbed.1 b/tabbed.1 index 07bdbd7..a3bb393 100644 --- a/tabbed.1 +++ b/tabbed.1 @@ -8,6 +8,8 @@ tabbed \- generic tabbed interface .RB [ \-k ] .RB [ \-s ] .RB [ \-v ] +.RB [ \-F +.IR font ] .RB [ \-g .IR geometry ] .RB [ \-n @@ -48,6 +50,9 @@ detaches tabbed from the terminal and prints its XID to stdout. fill up tabbed again by spawning the provided command, when the last tab is closed. Mutually exclusive with -c. .TP +.BI \-F " font" +defines custom font. +.TP .BI \-g " geometry" defines the X11 geometry string, which will fixate the height and width of tabbed. diff --git a/tabbed.c b/tabbed.c index d228a77..8fcaa04 100644 --- a/tabbed.c +++ b/tabbed.c @@ -171,6 +171,7 @@ static char winid[64]; static char **cmd; static char *wmname = "tabbed"; static const char *geometry; +static const char *font = NULL; char *argv0; @@ -1321,7 +1322,7 @@ xsettitle(Window w, const char *str) void usage(void) { - die("usage: %s [-dfksv] [-g geometry] [-n name] [-p [s+/-]pos]\n" + die("usage: %s [-dfksv] [-F font] [-g geometry] [-n name] [-p [s+/-]pos]\n" " [-r narg] [-o color] [-O color] [-t color] [-T color]\n" " [-u color] [-U color] command...\n", argv0); } @@ -1344,6 +1345,9 @@ main(int argc, char *argv[]) case 'f': fillagain = True; break; + case 'F': + font = EARGF(usage()); + break; case 'g': geometry = EARGF(usage()); break; @@ -1400,6 +1404,9 @@ main(int argc, char *argv[]) fillagain = False; } + if (font == NULL) + font = default_font; + setcmd(argc, argv, replace); if (!setlocale(LC_CTYPE, "") || !XSupportsLocale()) -- 2.33.8