aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README3
-rw-r--r--README.org3
-rw-r--r--config.h13
-rw-r--r--x.c31
-rw-r--r--x.h5
5 files changed, 49 insertions, 6 deletions
diff --git a/README b/README
index d35c76d..cac5079 100644
--- a/README
+++ b/README
@@ -32,11 +32,12 @@ You can find a list of patches and check what those I've applied are
doing on st's patches page.
Here is my list:
+ - anygeometry
+ - clipboard
- bold is not bright
- hidecursor
- keyboard select
- scrollback
- - clipboard
Settings
--------
diff --git a/README.org b/README.org
index ec0c236..67a1764 100644
--- a/README.org
+++ b/README.org
@@ -29,11 +29,12 @@ You can find a list of patches and check what those I've applied are
doing on *st*'s [[https://st.suckless.org/patches/][patches]] page.
Here is my list:
+- /anygeometry/
- /bold is not bright/
+- /clipboard/
- /hidecursor/
- /keyboard select/
- /scrollback/
-- /clipboard/
* Settings
Most settings are done by editing ~config.h~ and recompiling.
diff --git a/config.h b/config.h
index ca1040a..fa87abb 100644
--- a/config.h
+++ b/config.h
@@ -140,6 +140,12 @@ const char *colorname[] = {
/*
+ * Whether to use pixel geometry or cell geometry
+ */
+
+static Geometry geometry = CellGeometry;
+
+/*
* Default colors (colorname index)
* foreground, background, cursor, reverse cursor
*/
@@ -149,6 +155,13 @@ unsigned int defaultcs = 258;
unsigned int defaultrcs = 257;
/*
+ * Default width and height (including borders!)
+ */
+
+static unsigned int width = 564;
+static unsigned int height = 364;
+
+/*
* Default shape of cursor
* 2: Block ("█")
* 4: Underline ("_")
diff --git a/x.c b/x.c
index 2272461..1e6852f 100644
--- a/x.c
+++ b/x.c
@@ -1009,7 +1009,7 @@ xicdestroy(XIC xim, XPointer client, XPointer call)
}
void
-xinit(int cols, int rows)
+xinit(int w, int h)
{
XGCValues gcvalues;
Window parent;
@@ -1034,8 +1034,16 @@ xinit(int cols, int rows)
xloadcols();
/* adjust fixed window geometry */
- win.w = 2 * borderpx + cols * win.cw;
- win.h = 2 * borderpx + rows * win.ch;
+ switch (geometry) {
+ case CellGeometry:
+ win.w = 2 * borderpx + w * win.cw;
+ win.h = 2 * borderpx + h * win.ch;
+ break;
+ case PixelGeometry:
+ win.w = w;
+ win.h = h;
+ break;
+ }
if (xw.gm & XNegative)
xw.l += DisplayWidth(xw.dpy, xw.scr) - win.w - 2;
if (xw.gm & YNegative)
@@ -1956,6 +1964,12 @@ main(int argc, char *argv[])
case 'g':
xw.gm = XParseGeometry(EARGF(usage()),
&xw.l, &xw.t, &cols, &rows);
+ geometry = CellGeometry;
+ break;
+ case 'G':
+ xw.gm = XParseGeometry(EARGF(usage()),
+ &xw.l, &xw.t, &width, &height);
+ geometry = PixelGeometry;
break;
case 'i':
xw.isfixed = 1;
@@ -1992,10 +2006,19 @@ run:
setlocale(LC_CTYPE, "");
XSetLocaleModifiers("");
+ switch (geometry) {
+ case CellGeometry:
+ xinit(cols, rows);
+ break;
+ case PixelGeometry:
+ xinit(width, height);
+ cols = (win.w - 2 * borderpx) / win.cw;
+ rows = (win.h - 2 * borderpx) / win.ch;
+ break;
+ }
cols = MAX(cols, 1);
rows = MAX(rows, 1);
tnew(cols, rows);
- xinit(cols, rows);
xsetenv();
selinit();
run();
diff --git a/x.h b/x.h
index 1fb3fd9..e5baa8b 100644
--- a/x.h
+++ b/x.h
@@ -46,6 +46,11 @@ typedef struct {
signed char appcursor; /* application cursor */
} Key;
+typedef enum {
+ PixelGeometry,
+ CellGeometry
+} Geometry;
+
/* X modifiers */
#define XK_ANY_MOD UINT_MAX
#define XK_NO_MOD 0