attached patch fixes X2COL and Y2ROW
(not the cleanest possible)

borderpx changed to signed int in the default config
(other coords are signed and mixing unsigned in can
cause surprises)

diff -r 88ca50b8e7f7 config.def.h
--- a/config.def.h	Fri Nov 02 23:19:56 2012 +0100
+++ b/config.def.h	Sat Nov 03 03:12:12 2012 +0100
@@ -2,7 +2,7 @@
 
 /* appearance */
 static char font[] = "Liberation Mono:pixelsize=12:antialias=false:autohint=false";
-static unsigned int borderpx = 2;
+static int borderpx = 2;
 static char shell[] = "/bin/sh";
 
 /* double-click timeout (in milliseconds) between clicks for selection */
diff -r 88ca50b8e7f7 st.c
--- a/st.c	Fri Nov 02 23:19:56 2012 +0100
+++ b/st.c	Sat Nov 03 03:12:12 2012 +0100
@@ -72,8 +72,6 @@
 #define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || (a).bg != (b).bg)
 #define IS_SET(flag) (term.mode & (flag))
 #define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + (t1.tv_usec-t2.tv_usec)/1000)
-#define X2COL(x) (((x) - borderpx)/xw.cw)
-#define Y2ROW(y) (((y) - borderpx)/xw.ch)
 
 #define VT102ID "\033[?6c"
 
@@ -404,6 +402,9 @@
 static char *usedfont = NULL;
 static int usedfontsize = 0;
 
+static int X2COL(int x) { x -= borderpx; x /= xw.cw; return LIMIT(x, 0, term.col-1); }
+static int Y2ROW(int y) { y -= borderpx; y /= xw.ch; return LIMIT(y, 0, term.row-1); }
+
 ssize_t
 xwrite(int fd, char *s, size_t len) {
 	size_t aux = len;

Reply via email to