shithub: neatroff

Download patch

ref: 2a1f13657e6ae1eb707f00f5af95a9f4164e35fd
parent: 8c8d21bd37126715c33a0ce5e3d04aa3b0a2b69a
author: Ali Gholami Rudi <ali@rudi.ir>
date: Wed Apr 17 19:06:43 EDT 2013

ren: add \k

--- a/adj.c
+++ b/adj.c
@@ -230,5 +230,5 @@
 
 int adj_wid(struct adj *adj)
 {
-	return adj->wid;
+	return adj->wid + (adj->nls ? adj->swid : adj->gap);
 }
--- a/eval.c
+++ b/eval.c
@@ -142,7 +142,7 @@
 	if (unit == 'v')
 		abspos = -n_d;
 	if (unit == 'm')
-		abspos = n_lb - n_k;
+		abspos = n_lb - f_hpos();
 	n = evalexpr(&s);
 	if (rel)
 		return rel > 0 ? orig + n : orig - n;
--- a/ren.c
+++ b/ren.c
@@ -422,8 +422,6 @@
 	struct glyph *g;
 	int esc = 0, n, w;
 	nextchar(c);
-	if (c[0] == '\n')
-		n_lb = adj_wid(cadj);
 	if (c[0] == ' ' || c[0] == '\n') {
 		adj_put(adj, charwid(dev_spacewid(), n_s), c);
 		return 0;
@@ -435,7 +433,7 @@
 			int l = nextchar(c);
 			l += nextchar(c + l);
 			c[l] = '\0';
-		} else if (strchr("Dfhsvwx", c[0])) {
+		} else if (strchr("Dfhksvwx", c[0])) {
 			if (c[0] == 'w') {
 				render_wid();
 				return 0;
@@ -451,6 +449,8 @@
 				n = eval(arg, 0, 'm');
 				adj_put(adj, n, "\\h'%du'", n);
 			}
+			if (c[0] == 'k')
+				num_set(REG(arg[0], arg[1]), f_hpos() - n_lb);
 			if (c[0] == 's')
 				ren_ps(arg);
 			if (c[0] == 'v')
@@ -514,6 +514,8 @@
 		}
 		while (adj_full(cadj, n_u))
 			ren_br(0);
+		if (c == '\n')
+			n_lb = adj_wid(cadj);
 		if (c != ' ' && c != '\n') {
 			ren_back(c);
 			render_char(cadj);
--- a/xroff.h
+++ b/xroff.h
@@ -192,7 +192,6 @@
 #define n_h		(*nreg(REG('.', 'h')))
 #define n_i		(*nreg(REG('.', 'i')))
 #define n_j		(*nreg(REG('.', 'j')))
-#define n_k		(*nreg(REG('.', 'k')))
 #define n_l		(*nreg(REG('.', 'l')))
 #define n_n		(*nreg(REG('.', 'n')))
 #define n_o		(*nreg(REG('.', 'o')))