shithub: neatroff

Download patch

ref: 819f4ebfd4fd33e20815761664f8c3e1c34bada8
parent: 2cc01b1379ddcdf9b9d5e5b73e72df9bbeb223a6
author: Ali Gholami Rudi <[email protected]>
date: Mon Jul 8 15:37:40 EDT 2013

out: output m command only when output color changes

--- a/out.c
+++ b/out.c
@@ -64,6 +64,7 @@
 
 static int o_s = 10;
 static int o_f = 1;
+static int o_m = 0;
 
 static void out_ps(int n)
 {
@@ -81,6 +82,14 @@
 	}
 }
 
+static void out_clr(int n)
+{
+	if (n >= 0 && o_m != n) {
+		o_m = n;
+		out("m%s\n", clr_str(o_m));
+	}
+}
+
 static void escarg(char **sp, char *d, int cmd)
 {
 	char *s = *sp;
@@ -234,7 +243,7 @@
 			break;
 		case 'm':
 			if (!n_cp)
-				out("m%s\n", clr_str(clr_get(c)));
+				out_clr(clr_get(c));
 			break;
 		case 's':
 			out_ps(eval_re(c, o_s, '\0'));