Re: tree view, more tweaking - switching to mc HEAD version.

2010-05-19 Thread Janek Kozicki
Yury V. Zaytsev said: (by the date of Tue, 18 May 2010 17:11:14 +0200)

 On Tue, 2010-05-18 at 16:56 +0200, Janek Kozicki wrote:
 
  During the course I have learned a bit of how that tree-view code
  works, and I already have an idea how to optimize the current patch a
  little bit more. Depending on your patience you can either apply this
  patch or wait for the next one.
 
 That depends on how much time you would want to invest into this
 venture. Either you come up with a patch, attach it to the Trac ticket,
 we create a branch, review it and merge into the current master tree or
 you can checkout the latest source from git and then push your branch to
 github or somewhere else so that we can pull from you.

I'm unfamiliar with git - never used it, except for mc. I used svn
and bzr, but not git.

If you care to tell me how to commit my patches to your repository I
could do that. I have no idea how to set a git hub, so that you could
pull from it. And my IP address is behind a firewall, so you couldn't
reach my PC anyway.

I am fine with sending patches, OTOH I'm afraid that *if* I continue to
improve a tree-view code I might want to send more patches, so write
access to repo might be useful. OTOH My limited time is conflicting with
this obviously and I'm really unable to decide how dedicated to it
I can be.

But just for now, I am trying to update my branch as you suggested,
to use the latest version, so I do:

  git reset --hard
  git checkout master
  git pull

like this:

  ja...@atak:~/usr/deb-src/mc/mc-ORIGINAL-COPY$ git reset --hard
  HEAD is now at 70c0c3d Merge branch '2157_ncurses_fill_region'
  ja...@atak:~/usr/deb-src/mc/mc-ORIGINAL-COPY$ git checkout master
  Already on 'master'
  ja...@atak:~/usr/deb-src/mc/mc-ORIGINAL-COPY$ git pull
  Already up-to-date.

Does it mean that I am at release 5.0 ? I see that version.h says:
4.7.2-48-g70c0c3d, but maybe it's filled in during compilation, and
I couldn't compile the HEAD, read on.

I am stuck with debian packages. I mean - I don't want to run 'mc'
in any different way than by ending the compilation process by making
a .deb package and installing it.

I mean - everytime when I modify a source file, I compile to generate
a .deb and install it, just to run mc. This is maybe longer, but it's
the safest/laziest way for me.

So, inside that directory with git branch have a /debian/
subdirectory so I just did:

  cd debian 
  svn up
  svn info

like this:

  ja...@atak:~/usr/deb-src/mc/mc-ORIGINAL-COPY$ cd debian 
  ja...@atak:~/usr/deb-src/mc/mc-ORIGINAL-COPY/debian$ svn up
  At revision 408.
  ja...@atak:~/usr/deb-src/mc/mc-ORIGINAL-COPY/debian$ svn info
  Path: .
  URL: svn://svn.debian.org/svn/pkg-mc/trunk/debian
  Repository Root: svn://svn.debian.org/svn/pkg-mc
  Repository UUID: 1da7b59f-b76e-4e7a-8c78-615837a07e4c
  Revision: 408
  Node Kind: directory
  Schedule: normal
  Last Changed Author: zaytsev-guest
  Last Changed Rev: 408
  Last Changed Date: 2010-05-18 10:52:59 +0200 (wto, 18 maj 2010)

So, with the latest version of debian build system in place, I want
to compile, so I proceed in following manner:

  cd ..
  fakeroot debian/rules binary


Which fails with error:

  config.status: error: cannot find input file: `vfs/extfs/a.in'

And now, I am unable to make a debian package. 

What's wrong?

I could try to download a fresh checkout of git repository, and put
in there a fresh checkout of debian built system from repository.
But I just forgot how I did that in the first place, and would need to
look it up. So it was easier to update the current one :)


So while HEAD isn't compiling, I'll continue today to tweak my
current version of tree view with older mc checkout.


 In fact, rebasing to the latest master is recommended as we are now
 applying auto-indent to every file we touch so that hopefully the crazy
 ad hoc indentation will finally go away without causing too much
 conflicts.

Which files did you already auto indent?

Currently it's PITA, because I am using TAB character which is
8 chars long. But whole mc code seems to be tabulated at 4 space
characters. Are you drifting away from this, or towards this?

I have no preference here (forget the TAB flame war), I'm just asking
for vim flags, so that vim will take care of this for me :)

 
 If you make a patch on top of an source file that has been subsequently
 auto-indented it will become essentially un-applicable for us.

of course :)
 
 P.S. We all should probably be doing something else... :-)

hell yeah :)

-- 
Janek Kozicki   http://janek.kozicki.pl/  |
___
mc-devel mailing list
http://mail.gnome.org/mailman/listinfo/mc-devel


Re: tree view, more tweaking

2010-05-18 Thread Janek Kozicki
Yury V. Zaytsev said: (by the date of Mon, 17 May 2010 14:24:08 +0200)

 On Fri, 2010-05-14 at 18:05 +0200, Janek Kozicki wrote:
  Hi,
  
  I was working to improve the tree view feature, please have a look at
  my video:
  
  http://janek.kozicki.pl/nn/mc-tree-view.mpg
 
 As a tangential note, what bothers me is the gray background. I think
 regular blue color scheme would be nicer.

yes, it is bothering me too. I think I've seen somewhere the code
that sets the color, I'll try to change it to blue background.

-- 
Janek Kozicki   http://janek.kozicki.pl/  |
___
mc-devel mailing list
http://mail.gnome.org/mailman/listinfo/mc-devel


Re: tree view, more tweaking

2010-05-18 Thread Janek Kozicki
Andrew Borodin said: (by the date of Sat, 15 May 2010 09:35:22 +0400)

 On Fri, 14 May 2010 18:05:41 +0200 Janek Kozicki wrote:
  I was working to improve the tree view feature
 
 Thanks! It seems that Tree widget is almost unused by MC users
 therefore it exists as is without any developing and improving.

Very nice! Thank you for your positive feedback :)

Sorry for late response, typically I have very little time during the
week. In fact that day when I produced that patch, I should have been
doing something else, but that tree view in mc was bothering me so
much, that I couldn't focus on my own work without fixing it ;)

During the course I have learned a bit of how that tree-view code
works, and I already have an idea how to optimize the current patch a
little bit more. Depending on your patience you can either apply this
patch or wait for the next one.

Also I'm thinking about adding symlinked directories to the display,
but I'm not sure if I'll achieve that. That is because in my dirtree
I am extensively using symlinked directories.

 
  I would be extremely happy however if you would consider applying
  this patch, after your review (and some cleaning perhaps).
 
 Would you create a ticket at the www.midniht-commander.org? Thanks.

I have just registered on the website. I'll try to investigate later
how this trac system works, I never used it :)

-- 
Janek Kozicki   http://janek.kozicki.pl/  |
___
mc-devel mailing list
http://mail.gnome.org/mailman/listinfo/mc-devel


Re: tree view, more tweaking

2010-05-18 Thread Yury V. Zaytsev
On Tue, 2010-05-18 at 16:56 +0200, Janek Kozicki wrote:

 During the course I have learned a bit of how that tree-view code
 works, and I already have an idea how to optimize the current patch a
 little bit more. Depending on your patience you can either apply this
 patch or wait for the next one.

That depends on how much time you would want to invest into this
venture. Either you come up with a patch, attach it to the Trac ticket,
we create a branch, review it and merge into the current master tree or
you can checkout the latest source from git and then push your branch to
github or somewhere else so that we can pull from you.

In fact, rebasing to the latest master is recommended as we are now
applying auto-indent to every file we touch so that hopefully the crazy
ad hoc indentation will finally go away without causing too much
conflicts.

If you make a patch on top of an source file that has been subsequently
auto-indented it will become essentially un-applicable for us.

P.S. We all should probably be doing something else... :-)
 
-- 
Sincerely yours,
Yury V. Zaytsev

___
mc-devel mailing list
http://mail.gnome.org/mailman/listinfo/mc-devel


Re: tree view, more tweaking

2010-05-18 Thread Janek Kozicki
Janek Kozicki said: (by the date of Tue, 18 May 2010 16:56:31 +0200)

  Would you create a ticket at the www.midniht-commander.org? Thanks.
 
 I have just registered on the website. I'll try to investigate later
 how this trac system works, I never used it :)

ok, trac ticket #2202 

the optimizations I had in mind were about calling 

  how_many_folded = tree_store_remove_entry 
(tree-selected_ptr-name,FALSE,FALSE);

by using the same method that I later applied in 

  does_it_have_subdirectories(..)

by this method such call can be made a bit faster. But it's not for
today. So I submitted the current patch.

-- 
Janek Kozicki   http://janek.kozicki.pl/  |
___
mc-devel mailing list
http://mail.gnome.org/mailman/listinfo/mc-devel


Re: tree view, more tweaking

2010-05-17 Thread Yury V. Zaytsev
On Fri, 2010-05-14 at 18:05 +0200, Janek Kozicki wrote:
 Hi,
 
 I was working to improve the tree view feature, please have a look at
 my video:
 
 http://janek.kozicki.pl/nn/mc-tree-view.mpg

As a tangential note, what bothers me is the gray background. I think
regular blue color scheme would be nicer.
 
-- 
Sincerely yours,
Yury V. Zaytsev

___
mc-devel mailing list
http://mail.gnome.org/mailman/listinfo/mc-devel


tree view, more tweaking

2010-05-14 Thread Janek Kozicki
Hi,

I was working to improve the tree view feature, please have a look at
my video:

http://janek.kozicki.pl/nn/mc-tree-view.mpg

It is now quite intuitive.

Problem is that my knowledge of mc code is weak and I have
implemented it, most likely, in a very inefficient way. I would be
extremely happy however if you would consider applying this patch,
after your review (and some cleaning perhaps).

I hope that this patch will apply to HEAD version, because I was
working on 4.7.0.1-42-g901def1

best regards
-- 
Janek Kozicki   http://janek.kozicki.pl/  |
diff -ur mc-ORIGINAL/src/tree.c TEN-mc-iproved-tree/src/tree.c
--- mc-ORIGINAL/src/tree.c	2010-01-10 15:19:51.0 +0100
+++ TEN-mc-iproved-tree/src/tree.c	2010-05-14 17:45:11.0 +0200
@@ -155,7 +155,7 @@
 tree_remove_entry (WTree *tree, char *name)
 {
 (void) tree;
-tree_store_remove_entry (name);
+tree_store_remove_entry (name,TRUE,TRUE);
 }
 
 static void
@@ -213,6 +213,47 @@
 }
 }
 
+static gboolean
+does_it_have_subdirectories (tree_entry *current)
+{
+DIR *dirp;
+struct dirent *dp;
+struct stat buf;
+const char *dir;
+dir=current-name;
+
+if(current-next  current-next-sublevel  current-sublevel)
+	return TRUE;
+
+/* scanning current dir for subdirectories */
+dirp = mc_opendir(dir);
+if (dirp) {
+	for (dp = mc_readdir(dirp); dp; dp = mc_readdir(dirp)) {
+	char *full_name;
+
+	if (dp-d_name[0] == '.') {
+		if (dp-d_name[1] == 0
+		|| (dp-d_name[1] == '.'  dp-d_name[2] == 0))
+		continue;
+	}
+
+	full_name = concat_dir_and_file(dir, dp-d_name);
+	if (mc_lstat(full_name, buf) != -1) {
+		if (S_ISDIR(buf.st_mode))
+		{
+	g_free(full_name);
+		mc_closedir(dirp);
+		return TRUE; /* return on first found */
+		}
+	}
+	g_free(full_name);
+	}
+	mc_closedir(dirp);
+}
+
+return FALSE;
+}
+
 static void
 show_tree (WTree *tree)
 {
@@ -221,6 +262,8 @@
 int i, j, topsublevel;
 int x, y;
 int tree_lines, tree_cols;
+gboolean has_subdirectories;
+has_subdirectories=FALSE;
 
 /* Initialize */
 x = y = 0;
@@ -324,7 +367,24 @@
 		tty_setcolor (SELECTED_COLOR);
 	}
 
+
 	/* Show sub-name */
+	has_subdirectories = does_it_have_subdirectories(current);
+
+	tty_set_alt_charset (TRUE);
+	tty_print_char (ACS_HLINE);
+	tty_set_alt_charset (FALSE);
+	if(has_subdirectories)
+	{
+		tty_print_char ('+');
+	}
+	else
+	{
+		tty_set_alt_charset (TRUE);
+		tty_print_char (ACS_HLINE);
+		tty_set_alt_charset (FALSE);
+	}
+
 	tty_print_char (' ');
 	tty_print_string (str_fit_to_term (current-subname, 
 		tree_cols - 2 - 4 - 3 * j, J_LEFT_FIT));
@@ -494,28 +554,137 @@
 }
 
 static void
-tree_chdir_sel (WTree *tree)
+tree_chdir_sel (WTree *tree, gboolean is_this_only_an_xtree_refresh__NOT_Pressing_Enter_key)
 {
+int how_many_folded;
+how_many_folded = -1;
 if (!tree-is_panel)
-	return;
+return;
+/* Folding or unfolding */
+if( xtree_mode   
+	/* this is xtree_mode and Enter was pressed */
+   ! is_this_only_an_xtree_refresh__NOT_Pressing_Enter_key) /* in xtree_mode pressing Enter means folding a tree */
+   /* so I want to either fold or unflod */
+{
+	/* I don't know whether to fold or unfold, so let's fold first, to see many of them were there: */
+if (tree-selected_ptr)
+how_many_folded = tree_store_remove_entry (tree-selected_ptr-name,FALSE,TRUE);
+
+	if(how_many_folded == 0) /* aha - there was nothing to fold, so we want to unfold it */
+	{
+change_panel ();
+
+if (do_cd (tree-selected_ptr-name, cd_exact))
+select_item (current_panel);
+else
+message (D_ERROR, MSG_ERROR, _( Cannot chdir to \%s\ \n %s ),
+   tree-selected_ptr-name, unix_error_string (errno));
 
-change_panel ();
+change_panel ();
+	}
+	else
+	/* aha, there was something and we have folded it, this is OK. We wanted to do this anyway*/
+	{
+	}
+show_tree (tree);
+}
+else if ( xtree_mode  
+	/* this is xtree_mode and Enter was NOT pressed */
+	is_this_only_an_xtree_refresh__NOT_Pressing_Enter_key)
+	/* so I want to refresh without unfolding */
+{
+
+
+	/* I don't want to fold or unfold. I want to keep it as it was. But, unfortunately refreshing means unfolding too. 
+	So
+	 First: I am checking whether it was folded or unfolded, by actually *NOT* FOLDING IT: really_remove=FALSE */
+if (tree-selected_ptr)
+how_many_folded = tree_store_remove_entry (tree-selected_ptr-name,FALSE,FALSE);
+
+	/* Second: I am refreshing the second panel */
+change_panel ();
+
+if (do_cd (tree-selected_ptr-name, cd_exact))
+select_item (current_panel);
+else
+message (D_ERROR, MSG_ERROR, _( Cannot chdir to \%s\ \n %s ),
+