[PATCH][Fwd: Re: Xterm window title enhancement to hostname:/path II.]
Hello mc-devel, I haven't noticed any objection against this patch and many people consider it helpful. Any chance to see it committed? Thanks, Jindrich -- Jindrich Novy [EMAIL PROTECTED], http://people.redhat.com/jnovy/ The worst evil in the world is refusal to think. ---BeginMessage--- Hello Pavel, here is the patch where both hostname and username are printed in the xterm window title. Cheers, Jindrich -- Jindrich Novy [EMAIL PROTECTED], http://people.redhat.com/jnovy/ --- mc-4.6.1a/src/main.c.hostname 2005-03-23 13:59:31.198747928 +0100 +++ mc-4.6.1a/src/main.c 2005-03-23 16:00:49.13592 +0100 @@ -32,6 +32,7 @@ #include sys/types.h #include sys/stat.h #include unistd.h +#include pwd.h #include global.h #include tty.h @@ -1612,9 +1613,22 @@ void update_xterm_title_path (void) { unsigned char *p, *s; +char h[64]; +struct passwd *pw; 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; + } + if ( (pw = getpwuid(getuid())) ) { + s = g_strdup_printf ([EMAIL PROTECTED], pw-pw_name, s); + g_free (p); + p = s; + } do { if (*s ' ') *s = '?'; ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel ---End Message--- ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
Re: Fw: Re: Xterm window title enhancement to hostname:/path II.
Hello Pavel, On Wed, 2005-03-23 at 17:06 +0100, Pavel Vvra wrote: What do you think about restoring of original title when mc ends? I usually open xterm with some title, then I run ssh client and then I run commander. When I run mc, title of window is changed, but when I exit mc last used title is still displayed as permanent title. Unfortunately I cannot reproduce your case. I see the xterm title correctly restored after I quit mc even if I ssh somewhere and launch mc there. Did I miss something? (using the latest CVS mc) Jindrich -- Jindrich Novy [EMAIL PROTECTED], http://people.redhat.com/jnovy/ ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
Re: Xterm window title enhancement to hostname:/path II.
Hello Pavel, On Fri, 2005-03-18 at 16:55 +0100, Pavel Vvra 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 [EMAIL PROTECTED], 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 = '?'; ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
Re: Xterm window title enhancement to hostname:/path II.
Hi Jindrich, now 2nd part of this patch is done so xterminal window can display [EMAIL PROTECTED]:/path. I think it will be better implement both parts of this patch just once. My code is now a bit cleaner but I am testing now this feature so patch is not prepared just now. I'll send it during today. Thank you Pavel On Wed, 23 Mar 2005 14:28:48 +0100 Jindrich Novy [EMAIL PROTECTED] wrote: Hello Pavel, On Fri, 2005-03-18 at 16:55 +0100, Pavel Vvra 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 [EMAIL PROTECTED], http://people.redhat.com/jnovy/ ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
Re: Xterm window title enhancement to hostname:/path II.
Well, I look to your patch and I decide that it has no sense to send my patch. this one is really nice and I cannot write it better. Just an idea how to get username (sorry if you know better solution): register struct passwd *pw; register uid_t uid; uid = getuid(); pw = getpwuid(uid); /* OK, you'll write pw = getpwuid(getuid()) */ /* now pw-pw_name contains user name */ -- On Wed, 23 Mar 2005 14:28:48 +0100 Jindrich Novy [EMAIL PROTECTED] wrote: Hello Pavel, On Fri, 2005-03-18 at 16:55 +0100, Pavel Vvra 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 [EMAIL PROTECTED], http://people.redhat.com/jnovy/ ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
Re: Xterm window title enhancement to hostname:/path II.
Hello Pavel, here is the patch where both hostname and username are printed in the xterm window title. Cheers, Jindrich -- Jindrich Novy [EMAIL PROTECTED], http://people.redhat.com/jnovy/ --- mc-4.6.1a/src/main.c.hostname 2005-03-23 13:59:31.198747928 +0100 +++ mc-4.6.1a/src/main.c 2005-03-23 16:00:49.13592 +0100 @@ -32,6 +32,7 @@ #include sys/types.h #include sys/stat.h #include unistd.h +#include pwd.h #include global.h #include tty.h @@ -1612,9 +1613,22 @@ void update_xterm_title_path (void) { unsigned char *p, *s; +char h[64]; +struct passwd *pw; 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; + } + if ( (pw = getpwuid(getuid())) ) { + s = g_strdup_printf ([EMAIL PROTECTED], pw-pw_name, s); + g_free (p); + p = s; + } do { if (*s ' ') *s = '?'; ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
Fw: Re: Xterm window title enhancement to hostname:/path II.
Yes, it is. My patch is quite long when I compare it with your one. I am not able to write compact C code :-(. Next time I'll add item into wishlist and I'll save a lot of time. What do you think about restoring of original title when mc ends? I usually open xterm with some title, then I run ssh client and then I run commander. When I run mc, title of window is changed, but when I exit mc last used title is still displayed as permanent title. This title is wrong - in Window List I see that mc is running but only (ba)sh prompt is present there. I have no suggestion how to do it but it is possible that you can do it during 5 minutes and your patch will be about 10 lines long. Regards, Pavel and next item into wishlist will be to configure xterm title, e.g. mc - [EMAIL PROTECTED]:%d :-) P. Dne Wed, 23 Mar 2005 16:10:01 +0100 Jindrich Novy [EMAIL PROTECTED] pe: Hello Pavel, here is the patch where both hostname and username are printed in the xterm window title. Cheers, Jindrich -- Jindrich Novy [EMAIL PROTECTED], http://people.redhat.com/jnovy/ ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
Re: Xterm window title enhancement to hostname:/path II.
Hello Pavel, On Sat, 2005-03-19 at 13:10, Pavel Vávra wrote: On Sat, 19 Mar 2005 09:47:51 +0100 Stefano Melchior [EMAIL PROTECTED] wrote: In the patch file you should have put: --- src/main.c Fri Nov 14 21:43:12 2003 +++ src/main.c Fri Mar 18 15:36:41 2005 And most people prefer a unified diff (diff -up). Leonard. -- mount -t life -o ro /dev/dna /genetic/research ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
Re: Xterm window title enhancement to hostname:/path II.
On Sat, 19 Mar 2005 09:47:51 +0100 Stefano Melchior [EMAIL PROTECTED] wrote: In the patch file you should have put: --- src/main.c Fri Nov 14 21:43:12 2003 +++ src/main.c Fri Mar 18 15:36:41 2005 instead of: --- main.c Fri Nov 14 21:43:12 2003 +++ main.c Fri Mar 18 15:36:41 2005 otherwise the patch application can not understand what file to patch. This is a simple correction (look at the attachment) Bye SteX OK, I will keep it in my mind and next time it will be better :-) Thank you for this info. Pavel ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
Re: Xterm window title enhancement to hostname:/path II.
On Fri, Mar 18, 2005 at 04:55:16PM +0100, Pavel V?vra wrote: Hi Pavel, mc - [EMAIL PROTECTED]:/etc mc - [EMAIL PROTECTED]:/etc mc - [EMAIL PROTECTED]:/etc mc - [EMAIL PROTECTED]:/usr/src This patch adds hostname to current path in x-terminal window with minimal source code changes into existing code. It works for me and I hope it will be useful for many network administrators too. I hope this patch is safe. It is restricted to hostnames up to 63 bytes long. Please include it into upstream if you'll find it useful. It is possible that during some days I'll add username to make information more complete and if it will be welcomed I'll sent it too. The best way is - of course - to make this feature configurable, but I am not experienced C programmer so I cannot do it :-( In the patch file you should have put: --- src/main.c Fri Nov 14 21:43:12 2003 +++ src/main.c Fri Mar 18 15:36:41 2005 instead of: --- main.c Fri Nov 14 21:43:12 2003 +++ main.c Fri Mar 18 15:36:41 2005 otherwise the patch application can not understand what file to patch. This is a simple correction (look at the attachment) Bye SteX -- GPG key = D52DF829--SteX--[EMAIL PROTECTED] Keyserver: http://keyserver.kjsl.com, User#324592, http://counter.li.org http://www.openlabs.it/~stex --http://www.stex.name --- src/main.c.orig Fri Nov 14 21:43:12 2003 +++ src/main.c Fri Mar 18 15:36:41 2005 @@ -1597,21 +1597,45 @@ #define xtoolkit_panel_setup() -/* Show current directory in the xterm title */ +/* Show hostname and current directory in the xterm title */ void update_xterm_title_path (void) { unsigned char *p, *s; +char *pvp; +size_t pvlen; +int pvresult; if (xterm_flag xterm_title) { + // currrent path p = s = g_strdup (strip_home_and_password (current_panel-cwd)); + // hostname + pvlen = strlen(p); + pvp = g_malloc (pvlen + 64);//approach - max hostname length +pvresult = gethostname(pvp, 63); + if (pvresult) { // print just current path + g_free (pvp); + pvp = p; + } else { + s = pvp; + do {// merge hostname with path + if (!is_printable (*s)) + *s = '?'; + } while (*++s!=0x00); + *s++=':'; + strcpy (s, p); + g_free (p); + } + do { if (!is_printable (*s)) *s = '?'; } while (*++s); - fprintf (stdout, \33]0;mc - %s\7, p); +// fprintf (stdout, \33]0;mc - %s\7, p); + fprintf (stdout, \33]0;mc - %s\7, pvp); fflush (stdout); - g_free (p); +// g_free (p); + g_free (pvp); } } signature.asc Description: Digital signature ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel