[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RP] Patch to limit window's title width
From: |
Alexander Sashnov |
Subject: |
[RP] Patch to limit window's title width |
Date: |
Fri, 29 Apr 2005 10:16:43 +0700 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) |
Hello,
I wrote the patch for limit window's title width by winfmt.
For example,
:set winftm %n%s%55t
will limit window's title for 55 symbols.
diff -aur ratpoison-1.4.0-beta4/src/window.c ratpoison_titlelim/src/window.c
--- ratpoison-1.4.0-beta4/src/window.c 2004-12-04 09:33:24.000000000 +0600
+++ ratpoison_titlelim/src/window.c 2005-04-29 09:53:54.164135432 +0700
@@ -22,6 +22,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
#include "ratpoison.h"
@@ -622,6 +623,7 @@
{
int esc = 0;
char dbuf[10];
+ int width;
for(; *fmt; fmt++)
{
@@ -631,6 +633,18 @@
continue;
}
+ if (esc && isdigit(*fmt))
+ {
+ char numbuf[16];
+ int n;
+
+ for (n = 0 ; (n < sizeof(numbuf) - 1) && isdigit(*fmt) ; n++)
+ numbuf[n] = *fmt++;
+ numbuf[n] = '\0';
+ width = atoi(numbuf);
+ } else
+ width = 0;
+
if (esc)
{
switch (*fmt)
@@ -650,7 +664,14 @@
break;
case 't':
- sbuf_concat (buffer, window_name (win_elem->win));
+ if (width) {
+ char buf[1024];
+ if(width > (sizeof(buf) - 1))
+ width = sizeof(buf) - 1;
+ strncpy(buf, window_name (win_elem->win), width);
+ sbuf_concat (buffer, buf);
+ } else
+ sbuf_concat (buffer, window_name (win_elem->win));
break;
case 'a':
--
Alexander Sashnov
ICQ UIN: 79404252
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [RP] Patch to limit window's title width,
Alexander Sashnov <=