st-defaultfontsize-20210225-4ef0cbd.diff - sites - public wiki contents of suckless.org
 (HTM) git clone git://git.suckless.org/sites
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       st-defaultfontsize-20210225-4ef0cbd.diff (1704B)
       ---
            1 From e3c97b85f0e94011e77af9259d379c956f9d6d64 Mon Sep 17 00:00:00 2001
            2 From: Randy Palamar <palamar@ualberta.ca>
            3 Date: Thu, 25 Feb 2021 23:53:47 -0700
            4 Subject: [PATCH] support setting the default font size on invocation
            5 
            6 ---
            7  st.1 | 8 ++++++++
            8  x.c  | 8 +++++++-
            9  2 files changed, 15 insertions(+), 1 deletion(-)
           10 
           11 diff --git a/st.1 b/st.1
           12 index 39120b4..57ddfb8 100644
           13 --- a/st.1
           14 +++ b/st.1
           15 @@ -22,6 +22,8 @@ st \- simple terminal
           16  .IR line ]
           17  .RB [ \-w
           18  .IR windowid ]
           19 +.RB [ \-z
           20 +.IR fontsize ]
           21  .RB [[ \-e ]
           22  .IR command
           23  .RI [ arguments ...]]
           24 @@ -44,6 +46,8 @@ st \- simple terminal
           25  .IR title ]
           26  .RB [ \-w
           27  .IR windowid ]
           28 +.RB [ \-z
           29 +.IR fontsize ]
           30  .RB \-l
           31  .IR line
           32  .RI [ stty_args ...]
           33 @@ -91,6 +95,10 @@ defines the window title (default 'st').
           34  embeds st within the window identified by
           35  .I windowid
           36  .TP
           37 +.BI \-z " fontsize"
           38 +sets the default fontsize to
           39 +.I fontsize
           40 +.TP
           41  .BI \-l " line"
           42  use a tty
           43  .I line
           44 diff --git a/x.c b/x.c
           45 index 120e495..224f26e 100644
           46 --- a/x.c
           47 +++ b/x.c
           48 @@ -4,6 +4,7 @@
           49  #include <limits.h>
           50  #include <locale.h>
           51  #include <signal.h>
           52 +#include <stdlib.h>
           53  #include <sys/select.h>
           54  #include <time.h>
           55  #include <unistd.h>
           56 @@ -1114,7 +1115,7 @@ xinit(int cols, int rows)
           57                  die("could not init fontconfig.\n");
           58  
           59          usedfont = (opt_font == NULL)? font : opt_font;
           60 -        xloadfonts(usedfont, 0);
           61 +        xloadfonts(usedfont, defaultfontsize);
           62  
           63          /* colors */
           64          xw.cmap = XDefaultColormap(xw.dpy, xw.scr);
           65 @@ -2038,6 +2039,11 @@ main(int argc, char *argv[])
           66          case 'v':
           67                  die("%s " VERSION "\n", argv0);
           68                  break;
           69 +        case 'z':
           70 +                defaultfontsize = strtod(EARGF(usage()), NULL);
           71 +                if (!(defaultfontsize > 0))
           72 +                        usage();
           73 +                break;
           74          default:
           75                  usage();
           76          } ARGEND;
           77 -- 
           78 2.26.2
           79