Browse Source

Implementing xzoomreset.

Thanks mvdan@mvdan.cc for proposing this.
master
Christoph Lohmann 10 years ago
parent
commit
dc8c5c82aa
2 changed files with 25 additions and 1 deletions
  1. +1
    -0
      config.def.h
  2. +24
    -1
      st.c

+ 1
- 0
config.def.h View File

@ -116,6 +116,7 @@ static Shortcut shortcuts[] = {
{ XK_ANY_MOD, XK_Print, printsel, {.i = 0} }, { XK_ANY_MOD, XK_Print, printsel, {.i = 0} },
{ MODKEY|ShiftMask, XK_Prior, xzoom, {.i = +1} }, { MODKEY|ShiftMask, XK_Prior, xzoom, {.i = +1} },
{ MODKEY|ShiftMask, XK_Next, xzoom, {.i = -1} }, { MODKEY|ShiftMask, XK_Next, xzoom, {.i = -1} },
{ MODKEY|ShiftMask, XK_Home, xzoomreset, {.i = 0} },
{ ShiftMask, XK_Insert, selpaste, {.i = 0} }, { ShiftMask, XK_Insert, selpaste, {.i = 0} },
{ MODKEY|ShiftMask, XK_Insert, clippaste, {.i = 0} }, { MODKEY|ShiftMask, XK_Insert, clippaste, {.i = 0} },
{ MODKEY, XK_Num_Lock, numlock, {.i = 0} }, { MODKEY, XK_Num_Lock, numlock, {.i = 0} },


+ 24
- 1
st.c View File

@ -317,6 +317,8 @@ static void clippaste(const Arg *);
static void numlock(const Arg *); static void numlock(const Arg *);
static void selpaste(const Arg *); static void selpaste(const Arg *);
static void xzoom(const Arg *); static void xzoom(const Arg *);
static void xzoomabs(const Arg *);
static void xzoomreset(const Arg *);
static void printsel(const Arg *); static void printsel(const Arg *);
static void printscreen(const Arg *) ; static void printscreen(const Arg *) ;
static void toggleprinter(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 char *usedfont = NULL;
static double usedfontsize = 0; static double usedfontsize = 0;
static double defaultfontsize = 0;
static uchar utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0}; static uchar utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
static uchar utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8}; 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); FcPatternAddDouble(pattern, FC_PIXEL_SIZE, 12);
usedfontsize = 12; usedfontsize = 12;
} }
defaultfontsize = usedfontsize;
} }
FcConfigSubstitute(0, pattern, FcMatchPattern); FcConfigSubstitute(0, pattern, FcMatchPattern);
@ -3005,6 +3009,8 @@ xloadfonts(char *fontstr, double fontsize) {
FcPatternGetDouble(dc.font.match->pattern, FcPatternGetDouble(dc.font.match->pattern,
FC_PIXEL_SIZE, 0, &fontval); FC_PIXEL_SIZE, 0, &fontval);
usedfontsize = fontval; usedfontsize = fontval;
if(fontsize == 0)
defaultfontsize = fontval;
} }
/* Setting character width and height. */ /* Setting character width and height. */
@ -3058,15 +3064,32 @@ xunloadfonts(void) {
xunloadfont(&dc.ibfont); xunloadfont(&dc.ibfont);
} }
void void
xzoom(const Arg *arg) { xzoom(const Arg *arg) {
Arg larg;
larg.i = usedfontsize + arg->i;
xzoomabs(&larg);
}
void
xzoomabs(const Arg *arg) {
xunloadfonts(); xunloadfonts();
xloadfonts(usedfont, usedfontsize + arg->i);
xloadfonts(usedfont, arg->i);
cresize(0, 0); cresize(0, 0);
redraw(0); redraw(0);
xhints(); xhints();
} }
void
xzoomreset(const Arg *arg) {
Arg larg;
if(defaultfontsize > 0) {
larg.i = defaultfontsize;
xzoomabs(&larg);
}
}
void void
xinit(void) { xinit(void) {
XGCValues gcvalues; XGCValues gcvalues;


Loading…
Cancel
Save