shithub: neatroff

Download patch

ref: 62e35b0cbb72f98624811466fa9dffafa58a0fde
parent: a34728b41ee63da09f2314ae44cb01580135c512
author: Ali Gholami Rudi <ali@rudi.ir>
date: Sat Apr 13 15:29:56 EDT 2013

reg: add \n(.k

--- a/reg.c
+++ b/reg.c
@@ -52,6 +52,9 @@
 	static char numbuf[128];
 	numbuf[0] = '\0';
 	switch (id) {
+	case REG('.', 'k'):
+		sprintf(numbuf, "%d", f_hpos());
+		break;
 	case REG('.', 't'):
 		sprintf(numbuf, "%d", f_nexttrap());
 		break;
--- a/ren.c
+++ b/ren.c
@@ -88,6 +88,11 @@
 	return cdiv ? cdiv->reg : -1;
 }
 
+int f_hpos(void)
+{
+	return adj_wid(cadj);
+}
+
 void tr_divbeg(char **args)
 {
 	odiv_beg();
--- a/xroff.h
+++ b/xroff.h
@@ -170,6 +170,7 @@
 #define n_f		(*nreg(REG('.', 'f')))
 #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')))
@@ -177,14 +178,15 @@
 #define n_s		(*nreg(REG('.', 's')))
 #define n_u		(*nreg(REG('.', 'u')))
 #define n_v		(*nreg(REG('.', 'v')))
+#define n_ct		(*nreg(REG('c', 't')))
 #define n_dl		(*nreg(REG('d', 'l')))
 #define n_dn		(*nreg(REG('d', 'n')))
 #define n_nl		(*nreg(REG('n', 'l')))
-#define n_ct		(*nreg(REG('c', 't')))
 #define n_pg		(*nreg(REG('%', '\0')))	/* % */
 #define n_f0		(*nreg(REG(0, 'f')))	/* last font */
 #define n_s0		(*nreg(REG(0, 's')))	/* last size */
 
 /* functions for implementing read-only registers */
-int f_nexttrap(void);
-int f_divreg(void);
+int f_nexttrap(void);	/* .t */
+int f_divreg(void);	/* .z */
+int f_hpos(void);	/* .k */