Dear mc developers,

Please find attached my contribution to mc: tabs like Total Commander has.

I am a regular midnight commander user. I use it for all my file exploring
needs on several systems. I use it under Arch Linux and Ubuntu at home,
under Red Hat on various servers that I administer and under Cygwin on
Windows 7 at work.

One of the things that was missing were the tabs and I hated all the time,
when I needed to copy some files from a location to several locations to
have to change the folder so many times.

You will find an archive containing several patches that will add tabs to
MC and a keymap file to map some shortcuts for the tabs. Another message
will follow with some screen shots.

Inside the archive there is an executable file called apply-patch that will
apply all the pathes on the required files. To install the patch, just
un-archive the patch.tar.gz inside the root folder of mc-4.8.10 archive, cd
to patch and run ./apply-patch.

I've implemented the following:

* Create tab (creates a new tab)
* Close tab (closes an existing tab, if the tab is not the only one)
* Rename tab (changes the title of the current tab)
* Next tab (changes the current tab)
* Previous tab (changes the current tab)
* Go to tab (displays a list of tabs from which the user can select one to
switch to)
* Tabs options (some tabs options)
* Tabs sessions (the current opened tabs can be saved into sessions that
can be later restored).

In the tabs options there is an option to restore the last tabs session.
Please note that if this is checked, the current opened folder in the
current panel will not be the folder from which mc is launched, but the
folder that was last current when mc was closed.

>From a technical point of view, the tabs are a simple list of structures
containing a name (which can be NULL in which case the name of the current
tab is the name of the current folder) and a path (a vfs_path_t structure)
containing the current path of the tab. Whenever a tab is created, a new
tab structure is added in the list. When a tab is changing the mc will do a
simple cd by calling the do_cd function. I think that the implementation is
pretty much straight forward.

The only thing a little bit complex might be the display_info function.
That function will determine if all the tabs can be displayed, if not will
calculate which can be displayed starting from the current tab to the left
and then to the right if there is still space.

All my code is added between #ifdef WITH_TABS and #endif directives. The
WITH_TABS can be set at configure time. By default the tabs will be
compiled in, but can be deactivated by configure with "--disable-tabs"
option.

I also added a small implementation for "string_file_ext" function. I
needed it for my day to day work. It is added between the #ifdef WITH_EXT
and #endif directives. The WITH_EXT is defined in the
src/filemanager/panel.c file. If you don't want to use it, you can undefine
the WITH_EXT.

Also, please note that in the src/filemanager/filegui.c you have a small
bug at the line 288. The closing bracket of the function is inside the
#ifdef directive, while the opening one is outside. The program will of
course fail to compile under cygwin, so I've corrected it.

In the src/filemanager/mountlist.c, on the line 245 you are using the
_GL_UNUSED macro. This will also fail to compile on my version of cygwin.
Although I know that probably I have to add a dev package to have the macro
defined, I don't think that it should be the case to do that just to avoid
a warning (to add a dependency). I would do that with something like #ifdef
_CYGWIN_ directive, but since this might be because of my installation of
cygwin, I didn't modify it in the patch that I've sent you.

The patch is applied against the mc-4.8.10 downloaded from here:
http://ftp.midnight-commander.org/mc-4.8.10.tar.xz

I've compiled the mc-4.8.10 with tabs on the following platforms:

* Arch Linux
* Red Hat 5
* Ubuntu
* Cygwin (win 7)

Please let me know if you would like to include the tabs in your main
source repository. If not, do you have something against me posting the
patch on sourceforce and github?

Thank you very much for maintaining MC.

Regards,
Cosmin Popescu.

Attachment: tabs.keymap
Description: Binary data

Attachment: tabs-patch.tar.gz
Description: GNU Zip compressed data

_______________________________________________
mc-devel mailing list
https://mail.gnome.org/mailman/listinfo/mc-devel

Reply via email to