Re: mc Digest, Vol 116, Issue 5

2013-12-19 Thread /dev/rob0
Mike, when replying to the mailing list, please change the Subject to 
something relevant, generally to the one set by the original poster.

Frankly, as low as the volume is on this list, I don't understand why 
anyone would need to take it in digest form, but anyway, Mailman also 
offers a nice little trick for you: you can get your digest in MIME 
format, wherein each list post is an attachment. Then in any sensible 
MUA, you can open and [list-]reply to the attached message. You then
preserve proper threading for the rest of us.

Thanks, and welcome to the list.
-- 
  http://rob0.nodns4.us/
  Offlist GMX mail is seen only if /dev/rob0 is in the Subject:
___
mc mailing list
https://mail.gnome.org/mailman/listinfo/mc


Re: mc Digest, Vol 116, Issue 6

2013-12-19 Thread Mike Smithson

On Thu, 19 Dec 2013 04:00:03 -0800, mc-requ...@gnome.org wrote:


Message: 1
Date: Thu, 19 Dec 2013 00:02:38 +0100
From: Konrad Vrba konrad.v...@gmail.com
To: mc@gnome.org
Subject: disk usage status in right bottom corner
Message-ID:
CAF2Nc0zH_Ew_tbEm44ZS9mJiUiqL0A=iyev1maj6krttyqu...@mail.gmail.com
Content-Type: text/plain; charset=iso-8859-1

hello,

I would like to ask whether it is possible to change the disk  
status/usage

information, which is displayed in the botom right corner in midnight
commander (sorry if I am not using the correct terminology).

The information displayed in my MC is free/total free%

I would prefer to have % of used space, rather than % of free space. It
might seem trivial, but I canot get used to the idea and it still  
confuses
me. It seems to me logical to see what *is*on my disk, rather than what  
*is

not*.

Is there some way to adjust this, so that I can for example see just the
%usage ?

thanks,
Konrad


You know, that confused me too. It shows free space instead of used space.
df shows size used avail and use%, but mc shows avail/size (free%).

Once again, src/filemanager/panels.c being hacked, around line :
[code]
static void
show_free_space (WPanel * panel)
{
/* Used to figure out how many free space we have */
static struct my_statfs myfs_stats;
/* Old current working directory for displaying free space */
static char *old_cwd = NULL;

/* Don't try to stat non-local fs */
if (!vfs_file_is_local (panel-cwd_vpath) || !free_space)
return;

if (old_cwd == NULL || strcmp (old_cwd, vfs_path_as_str  
(panel-cwd_vpath)) != 0)

{
char rpath[PATH_MAX];

init_my_statfs ();
g_free (old_cwd);
old_cwd = g_strdup (vfs_path_as_str (panel-cwd_vpath));

if (mc_realpath (old_cwd, rpath) == NULL)
return;

my_statfs (myfs_stats, rpath);
}

if (myfs_stats.avail != 0 || myfs_stats.total != 0)
{
Widget *w = WIDGET (panel);
char buffer1[6], buffer2[6], tmp[BUF_SMALL];

size_trunc_len (buffer1, sizeof (buffer1) - 1, myfs_stats.avail, 1,
panels_options.kilobyte_si);
size_trunc_len (buffer2, sizeof (buffer2) - 1, myfs_stats.total, 1,
panels_options.kilobyte_si);
g_snprintf (tmp, sizeof (tmp),  %s/%s (%d%%) , buffer1, buffer2,
myfs_stats.total == 0 ? 0 :
(int) (100 * (long double) myfs_stats.avail /  
myfs_stats.total));

widget_move (w, w-lines - 1, w-cols - 2 - (int) strlen (tmp));
tty_setcolor (NORMAL_COLOR);
tty_print_string (tmp);
}
}
[/code]
First, I'd rename the func to panel_show_disk_usage(). Then a bool whether
to show free space or used space. Then mod those size_trunc_len()s on the
bool.

But, in the meantime, for a quick and usable hack, I'd just change that
last bit to:
[code]
if (myfs_stats.avail != 0 || myfs_stats.total != 0)
{
Widget *w = WIDGET (panel);
char buffer1[6], buffer2[6], tmp[BUF_SMALL];
uintmax_t used = myfs_stats.total - myfs_stats.avail;

//size_trunc_len (buffer1, sizeof (buffer1) - 1, myfs_stats.avail,  
1,

//panels_options.kilobyte_si);
size_trunc_len (buffer1, sizeof (buffer1) - 1, used, 1,
panels_options.kilobyte_si);
size_trunc_len (buffer2, sizeof (buffer2) - 1, myfs_stats.total, 1,
panels_options.kilobyte_si);
//g_snprintf (tmp, sizeof (tmp),  %s/%s (%d%%) , buffer1,  
buffer2,

//myfs_stats.total == 0 ? 0 :
//(int) (100 * (long double) myfs_stats.avail /  
myfs_stats.total));
g_snprintf (tmp, sizeof (tmp),  Used %s/%s (%d%%) , buffer1,  
buffer2,

myfs_stats.total == 0 ? 0 :
(int) (100 * (long double) used / myfs_stats.total));
widget_move (w, w-lines - 1, w-cols - 2 - (int) strlen (tmp));
tty_setcolor (NORMAL_COLOR);
tty_print_string (tmp);
}
[/code]

Works for me. I think I'll clean it up and keep it.


--
Peace and Cheer
___
mc mailing list
https://mail.gnome.org/mailman/listinfo/mc