Re: Xterm window title enhancement to hostname:/path II.



Hello Pavel,

On Fri, 2005-03-18 at 16:55 +0100, Pavel V�a wrote:
> Sorry - I've attached wrong file so now it has to be a bit better.
> 
> Hi developers,
>   I've found a feature in last version of mc. It is really nice to change xterm window title to current path. One can check Window List in its Window Manager and find the right window there. It is really nice. But it is not enough if one is logged on another machines via ssh. Then Window list can look like:
> mc - /etc
> mc - /etc
> mc - /etc
> mc - /usr/src
> 
> Well, but what is the right window what I am looking for? I want to switch to configuration window of my firewall. I need a bit different list:
> 
> mc - debi:/etc
> mc - Firewall:/etc
> mc - Planet:/etc
> mc - workstation:/usr/src
> 

I like the idea you presented, so I reimplemented the hostname addition
to xterm window title so that it can be committed.

Please avoid using C++ comments in patches for the next time.

Cheers,
Jindrich

-- 
Jindrich Novy <jnovy redhat com>, http://people.redhat.com/jnovy/
--- mc-4.6.1a/src/main.c.hostname	2005-03-23 13:53:59.624154928 +0100
+++ mc-4.6.1a/src/main.c	2005-03-23 13:55:15.531615240 +0100
@@ -1612,9 +1612,16 @@ void
 update_xterm_title_path (void)
 {
     unsigned char *p, *s;
+    char h[64];
 
     if (xterm_flag && xterm_title) {
 	p = s = g_strdup (strip_home_and_password (current_panel->cwd));
+	if ( !gethostname(h, 64) ) {
+		h[63] = '\0'; /* Be sure the hostname is NUL terminated */
+		s = g_strdup_printf("%s:%s", h, s);
+		g_free(p);
+		p = s;
+	}
 	do {
 	    if (*s < ' ')
 		*s = '?';


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]