~ninjin/st

06332cfb1ad5512263144ef64637377e4bd183ce — Pontus Stenetorp 4 months ago baa9357 fixcolsdynfontsz
Fixed number of columns and dynamic font size

XXX: TODO: Write sensible commit message
2 files changed, 16 insertions(+), 3 deletions(-)

M config.def.h
M x.c
M config.def.h => config.def.h +5 -1
@@ 5,8 5,12 @@
 *
 * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
 */
static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true";
static char *font = "Liberation Mono:antialias=true:autohint=true";
static int borderpx = 2;
// TODO: Conflicts, in a way, with cols, which is further down.
static const int numcols = 110;
static const double maxfontsz = 18.5;
static const double fontstepsz = 2;

/*
 * What program is execed by st depends of these precedence rules:

M x.c => x.c +11 -2
@@ 304,6 304,7 @@ zoom(const Arg *arg)
void
zoomabs(const Arg *arg)
{
	return; // XXX: I do not want to deal with this just yet.
	xunloadfonts();
	xloadfonts(usedfont, arg->f);
	cresize(0, 0);


@@ 314,6 315,7 @@ zoomabs(const Arg *arg)
void
zoomreset(const Arg *arg)
{
	return; // XXX: I do not want to deal with this just yet.
	Arg larg;

	if (defaultfontsize > 0) {


@@ 727,6 729,7 @@ bmotion(XEvent *e)
void
cresize(int width, int height)
{
	double f;
	int col, row;

	if (width != 0)


@@ 734,9 737,15 @@ cresize(int width, int height)
	if (height != 0)
		win.h = height;

	col = (win.w - 2 * borderpx) / win.cw;
	for (f = maxfontsz; f >= 1; f -= fontstepsz) {
		xunloadfonts();
		xloadfonts(usedfont, f);
		if (win.cw <= 1 || (numcols * win.cw + 2 * borderpx <= win.w))
			break;
	}

	col = numcols;
	row = (win.h - 2 * borderpx) / win.ch;
	col = MAX(1, col);
	row = MAX(1, row);

	tresize(col, row);