My changes in MC source and some questions



Hello everybody.
Having downloading the source of MC mc-4.6.0-src.tar.gz I am trying to
tune this software for my needs. One of them is displaying directories
size (some of them, not all as implemented now in MC). I changed the
src/cmd.c in order to show directory size under cursor (if no one
directories selected by <Insert> key or by any other methods) and selected
only directories (if any selected) when pressing F3 (does anybody use F3
to go into directories?). For example see attachment my-mc.png. The changed
code in do_view_cmd function. Here new code
/*
 * Run viewer (internal or external) on the currently selected file.
 * If normal is 1, force internal viewer and raw mode (used for F13).
 */
static void
do_view_cmd (int normal)
{
    int dir, file_idx;

    if (S_ISDIR (selection (cpanel)->buf.st_mode)
        || link_isdir (selection (cpanel))) 
    {
        WPanel *panel = cpanel;
        int i;
        off_t marked;
        double total;

        for (i = 0; i < panel->count; i++) 
            if (S_ISDIR (panel->dir.list [i].buf.st_mode) && strcmp (panel->dir.list [i].fname, "..") != 0) 
        {
            if (!panel->dir.list[i].f.marked && panel->dirs_marked)
                continue;       /* Skip the unmarked ones */
            if(!panel->dirs_marked && strcmp (panel->dir.list [i].fname, selection (cpanel)->fname ) )
                continue;
                 
            total = 0.0l;
            compute_dir_size (panel->dir.list [i].fname, &marked, &total);
            panel->dir.list [i].buf.st_size = (off_t) total;
            panel->dir.list [i].f.dir_size_computed = 1;
        }
        
        recalculate_panel_summary (panel);
        paint_panel (panel);

        return;
    }

    file_idx = cpanel->selected;
    while (1) {
        char *filename;

        filename = cpanel->dir.list[file_idx].fname;

        dir = view_file (filename, normal, use_internal_view);
        if (dir == 0)
            break;
        file_idx = scan_for_file (cpanel, file_idx, dir);
    }
}

All changes are done in the first if(… . I take this code from
src/cmd.c function dirsizes_cmd. 

Some other changes I've done in MC:
1) current time in right upper corner of MC (see attacment my-mc.png);
2) in view and edit Shift+F8 switches the code page "on the fly";
3) Shift + F1 and Shift + F2 launches quick directory change (directories
   and it's labels are stored in ~/.mc/folders (see my-mc.png in attachment):
A: Floppy
/mnt/floppy/
C: Root
/
D: CD-ROM
/mnt/cdrom/
E: Windows
/mnt/windows/
F: C-docs
/usr/X11R6/man/man3/
G: Icons
/usr/local/icons/
     
     
1: net Music
/mnt/igor-music/
2: net Films
/mnt/igor-films/
3: net Home
/mnt/igor-srv-home/

Unfortunately I can't insert separator to menu (two empty lines are
rather fiction than real separator).
I know the similar feature is implemented on Ctrl+\ key combination,
but due to my long working with Far I formed some habits.
4) Ctrl + L shows info (as in Far).

It seems to be all. I hope someone find this useful. 

Now I'd like to ask some questions:
1) Can I make nested (or embedded - I don't know how is correct)
   user menu on F2?
2) Can I change the behavior of MC on Ctrl+C key in mcedit? I want
   to use Ctrl+C to copy selected text into clipboard, not to abort
   actions.


Thanks in advance
Vyacheslav

Attachment: my-mc.png
Description: PNG image

Scanned by evaluation version of Dr.Web antivirus Daemon 
http://drweb.ru/unix/



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