shithub: neatroff

Download patch

ref: dcb69af7ed90daff59d8ae100e8d1d2c77b1c42c
parent: ecd4ac1a64261514c8ed69e0dc31cf48d7ee0495
author: Ali Gholami Rudi <ali@rudi.ir>
date: Fri May 26 05:55:18 EDT 2017

reg: .tabs register

Suggested and tested by aksr <aksr@t-com.me>.

--- a/reg.c
+++ b/reg.c
@@ -64,6 +64,16 @@
 	return dst;
 }
 
+static char *num_tabs(void)
+{
+	static char tabs[16 * NTABS];
+	int i;
+	char *s = tabs;
+	for (i = 0; i < NTABS && env->tabs_type[i]; i++)
+		s += sprintf(s, "%du%c ", env->tabs[i], env->tabs_type[i]);
+	return tabs;
+}
+
 static int num_fmt(char *s, int n, int fmt);
 
 /* the contents of a number register (returns a static buffer) */
@@ -119,6 +129,8 @@
 		sprintf(numbuf, "%02d", *nreg(id));
 		return numbuf;
 	}
+	if (s[0] == '.' && !strcmp(".tabs", s))
+		return num_tabs();
 	if (!nregs_fmt[id] || num_fmt(numbuf, *nreg(id), nregs_fmt[id]))
 		sprintf(numbuf, "%d", *nreg(id));
 	return numbuf;