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

2005-03-23 Thread Jindrich Novy
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.

2005-03-23 Thread Pavel Vávra
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.

2005-03-23 Thread Pavel Vávra
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.

2005-03-23 Thread Jindrich Novy
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.

2005-03-23 Thread Pavel Vávra
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


Proposed patch: Alt-O on files to select current directory

2005-03-23 Thread Pavel Roskin
Hello, Miguel and everybody!

I'm sorry, I was too busy to do anything about the issue with Alt-O,
even to argue about it.  But I'd like to fix the current code a bit to
make it less annoying to me.

Alt-O on a file makes the inactive panel change to the parent directory
of the one in the active panel.  It would be great to move selection on
the inactive panel to select the entry corresponding to the current
directory on the active panel.

This way, I could use Alt-O, Tab, Enter to emulate the behavior of Alt-O
in mc 4.6.0.  Also, I could press Tab and use Alt-O or cursor keys to
navigate directories with similar names.

Miguel, since you wanted the old behavior, I'd like you to see the patch
so you don't complain again that I broke something you liked.

ChangeLog:

* screen.c (chdir_other_panel): When used on a file
entry, move selection on the inactive panel to select
the entry for the current directory on the active panel.

-- 
Regards,
Pavel Roskin

--- src/screen.c
+++ src/screen.c
@@ -2017,18 +2017,22 @@ static void
 chdir_other_panel (WPanel *panel)
 {
 char *new_dir;
+char *sel_entry = NULL;
 
 if (get_other_type () != view_listing) {
 	set_display_type (get_other_index (), view_listing);
 }
 
-if (!S_ISDIR (panel-dir.list [panel-selected].st.st_mode))
+if (!S_ISDIR (panel-dir.list [panel-selected].st.st_mode)) {
 new_dir = concat_dir_and_file (panel-cwd, ..);
-else
+	sel_entry = strrchr(panel-cwd, PATH_SEP);
+} else
 new_dir = concat_dir_and_file (panel-cwd, panel-dir.list [panel-selected].fname);
 
 change_panel ();
 do_cd (new_dir, cd_exact);
+if (sel_entry)
+	try_to_select (current_panel, sel_entry);
 change_panel ();
  
 move_down (panel);
___
Mc-devel mailing list
http://mail.gnome.org/mailman/listinfo/mc-devel