Hello everyone.

I would like to submit this very simple patch that allows the n escape
to be qualified with a '0'. In other words, the same behavior as both
the 'c' and 'C' escape.

The patch also includes new escapes: j, k, and K.

j, displays the minutes;
k, displays the hour in 24h format; and
K displays the hour in 12h format.

I have also updated the man page.

While the j, k, and K options seem redundant as both the c and C
escapes display both minutes and hours, I would like to have the
flexibility to be able to give each escape a color attribute.

Israel
diff --git src/doc/screen.1 src/doc/screen.1
index c175891..0eb17d3 100644
--- src/doc/screen.1
+++ src/doc/screen.1
@@ -3700,6 +3700,12 @@ sets %? to true if the window has the focus
 hardstatus of the window
 .IP H
 hostname of the system
+.IP j
+minute
+.IP k
+hour in 24h format
+.IP K
+hour in 12h format
 .IP l
 current load of the system
 .IP m
@@ -3758,7 +3764,7 @@ attribute/color modifier string terminated by the next \*Q}\*U
 Substitute with the output of a 'backtick' command. The length
 qualifier is misused to identify one of the commands.
 .P
-The 'c' and 'C' escape may be qualified with a '0' to make 
+The 'n', 'c', and 'C' escape may be qualified with a '0' to make 
 .I screen 
 use zero instead of space as fill character. The '0' qualifier
 also makes the '=' escape use absolute positions. The 'n' and '='
diff --git src/screen.c src/screen.c
index 3dde3b4..a6696c4 100644
--- src/screen.c
+++ src/screen.c
@@ -2610,7 +2610,8 @@ int rec;
 	    }
 	  break;
 	case 'd': case 'D': case 'm': case 'M': case 'y': case 'Y':
-	case 'a': case 'A': case 's': case 'c': case 'C':
+	case 'a': case 'A': case 's': case 'c': case 'C': case 'k':
+	case 'K': case 'j':
 	  if (l < 4)
 	    break;
 	  if (tm == 0)
@@ -2669,6 +2670,21 @@ int rec;
 	      if (!tick || tick > 60)
 		tick = 60;
 	      break;
+	    case 'k':
+	      sprintf(p, zeroflg ? "%02d" : "%2d", tm->tm_hour);
+	      if (!tick || tick > 60)
+		tick = 60;
+	      break;
+	    case 'K':
+	      sprintf(p, zeroflg ? "%02d" : "%2d", (tm->tm_hour + 11) % 12 + 1);
+	      if (!tick || tick > 60)
+		tick = 60;
+	      break;
+	    case 'j':
+	      sprintf(p, zeroflg ? "%02d" : "%2d", tm->tm_min);
+	      if (!tick || tick > 60)
+		tick = 60;
+	      break;
 	    default:
 	      break;
 	    }
@@ -2987,9 +3003,9 @@ int rec;
 	      if (num == 0)
 		num = 1;
 	      if (!win)
-	        sprintf(p, "%*s", num, num > 1 ? "--" : "-");
+	        sprintf(p, "%*s", num, ((num > 1) || zeroflg) ? "--" : "-");
 	      else
-	        sprintf(p, "%*d", num, win->w_number);
+	        sprintf(p, zeroflg ? "%02d" : "%*d", zeroflg ? win->w_number : num, win->w_number);
 	      qmflag = 1;
 	      p += strlen(p) - 1;
 	    }

Reply via email to