summaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
authorChristoph Lohmann <20h@r-36.net>2014-09-29 15:38:21 +0200
committerChristoph Lohmann <20h@r-36.net>2014-09-29 15:38:21 +0200
commitdc8c5c82aa14e75305bd5b0e42b4f8bba45702a8 (patch)
tree1a9646f18265125a2cc0e3b82d6f34f3a578676f /st.c
parentc7a945c4086ab913cd8a05997bfbc1906645eff4 (diff)
Implementing xzoomreset.
Thanks mvdan@mvdan.cc for proposing this.
Diffstat (limited to 'st.c')
-rw-r--r--st.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/st.c b/st.c
index 83293f4..2b4d52c 100644
--- a/st.c
+++ b/st.c
@@ -317,6 +317,8 @@ static void clippaste(const Arg *);
static void numlock(const Arg *);
static void selpaste(const Arg *);
static void xzoom(const Arg *);
+static void xzoomabs(const Arg *);
+static void xzoomreset(const Arg *);
static void printsel(const Arg *);
static void printscreen(const Arg *) ;
static void toggleprinter(const Arg *);
@@ -503,6 +505,7 @@ static int oldbutton = 3; /* button event on startup: 3 = release */
static char *usedfont = NULL;
static double usedfontsize = 0;
+static double defaultfontsize = 0;
static uchar utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
static uchar utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
@@ -2993,6 +2996,7 @@ xloadfonts(char *fontstr, double fontsize) {
FcPatternAddDouble(pattern, FC_PIXEL_SIZE, 12);
usedfontsize = 12;
}
+ defaultfontsize = usedfontsize;
}
FcConfigSubstitute(0, pattern, FcMatchPattern);
@@ -3005,6 +3009,8 @@ xloadfonts(char *fontstr, double fontsize) {
FcPatternGetDouble(dc.font.match->pattern,
FC_PIXEL_SIZE, 0, &fontval);
usedfontsize = fontval;
+ if(fontsize == 0)
+ defaultfontsize = fontval;
}
/* Setting character width and height. */
@@ -3058,16 +3064,33 @@ xunloadfonts(void) {
xunloadfont(&dc.ibfont);
}
+
void
xzoom(const Arg *arg) {
+ Arg larg;
+ larg.i = usedfontsize + arg->i;
+ xzoomabs(&larg);
+}
+
+void
+xzoomabs(const Arg *arg) {
xunloadfonts();
- xloadfonts(usedfont, usedfontsize + arg->i);
+ xloadfonts(usedfont, arg->i);
cresize(0, 0);
redraw(0);
xhints();
}
void
+xzoomreset(const Arg *arg) {
+ Arg larg;
+ if(defaultfontsize > 0) {
+ larg.i = defaultfontsize;
+ xzoomabs(&larg);
+ }
+}
+
+void
xinit(void) {
XGCValues gcvalues;
Cursor cursor;