Configuration dialogs reorganization.

Panel options are moved to new dialog.
Panel setup options are collected in a special structure.
Includes clean up.
Code indentation.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2010-03-09 22:03:51 +03:00
parent be622a9981
commit 2b167cbef0
21 changed files with 586 additions and 468 deletions

View File

@ -57,13 +57,6 @@
int easy_patterns = 1;
/*
* If true, SI units (1000 based) will be used for
* larger units (kilobyte, megabyte, ...).
* If false binary units (1024 based) will be used.
*/
int kilobyte_si = 0;
char *user_recent_timeformat = NULL; /* time format string for recent dates */
char *user_old_timeformat = NULL; /* time format string for older dates */
@ -289,7 +282,7 @@ path_trunc (const char *path, size_t trunc_len)
}
const char *
size_trunc (double size)
size_trunc (double size, gboolean use_si)
{
static char x[BUF_TINY];
long int divisor = 1;
@ -297,12 +290,12 @@ size_trunc (double size)
if (size > 999999999L)
{
divisor = kilobyte_si ? 1000 : 1024;
xtra = kilobyte_si ? "k" : "K";
divisor = use_si ? 1000 : 1024;
xtra = use_si ? "k" : "K";
if (size / divisor > 999999999L)
{
divisor = kilobyte_si ? (1000 * 1000) : (1024 * 1024);
xtra = kilobyte_si ? "m" : "M";
divisor = use_si ? (1000 * 1000) : (1024 * 1024);
xtra = use_si ? "m" : "M";
}
}
g_snprintf (x, sizeof (x), "%.0f%s", (size / divisor), xtra);
@ -310,14 +303,14 @@ size_trunc (double size)
}
const char *
size_trunc_sep (double size)
size_trunc_sep (double size, gboolean use_si)
{
static char x[60];
int count;
const char *p, *y;
char *d;
p = y = size_trunc (size);
p = y = size_trunc (size, use_si);
p += strlen (p) - 1;
d = x + sizeof (x) - 1;
*d-- = 0;
@ -348,7 +341,7 @@ size_trunc_sep (double size)
* 0=bytes, 1=Kbytes, 2=Mbytes, etc.
*/
void
size_trunc_len (char *buffer, unsigned int len, off_t size, int units)
size_trunc_len (char *buffer, unsigned int len, off_t size, int units, gboolean use_si)
{
/* Avoid taking power for every file. */
static const off_t power10[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000,
@ -367,7 +360,7 @@ size_trunc_len (char *buffer, unsigned int len, off_t size, int units)
* We can't just multiply by 1024 - that might cause overflow
* if off_t type is too small
*/
if (units && kilobyte_si)
if (units && use_si)
{
for (j = 0; j < units; j++)
{
@ -391,26 +384,22 @@ size_trunc_len (char *buffer, unsigned int len, off_t size, int units)
/* Use "~K" or just "K" if len is 1. Use "B" for bytes. */
g_snprintf (buffer, len + 1, (len > 1) ? "~%s" : "%s",
(j > 1) ? (kilobyte_si ? suffix_lc[j - 1] : suffix[j - 1]) : "B");
(j > 1) ? (use_si ? suffix_lc[j - 1] : suffix[j - 1]) : "B");
break;
}
if (size < power10[len - (j > 0)])
{
g_snprintf (buffer, len + 1, "%lu%s", (unsigned long) size,
kilobyte_si ? suffix_lc[j] : suffix[j]);
use_si ? suffix_lc[j] : suffix[j]);
break;
}
/* Powers of 1000 or 1024, with rounding. */
if (kilobyte_si)
{
if (use_si)
size = (size + 500) / 1000;
}
else
{
size = (size + 512) >> 10;
}
}
}

View File

@ -58,18 +58,18 @@ const char *path_trunc (const char *path, size_t trunc_len);
/* return a static string representing size, appending "K" or "M" for
* big sizes.
* NOTE: uses the same static buffer as size_trunc_sep. */
const char *size_trunc (double size);
const char *size_trunc (double size, gboolean use_si);
/* return a static string representing size, appending "K" or "M" for
* big sizes. Separates every three digits by ",".
* NOTE: uses the same static buffer as size_trunc. */
const char *size_trunc_sep (double size);
const char *size_trunc_sep (double size, gboolean use_si);
/* Print file SIZE to BUFFER, but don't exceed LEN characters,
* not including trailing 0. BUFFER should be at least LEN+1 long.
*
* Units: size units (0=bytes, 1=Kbytes, 2=Mbytes, etc.) */
void size_trunc_len (char *buffer, unsigned int len, off_t size, int units);
void size_trunc_len (char *buffer, unsigned int len, off_t size, int units, gboolean use_si);
int is_exe (mode_t mode);
const char *string_perm (mode_t mode_bits);

View File

@ -43,13 +43,12 @@
#include "widget.h"
/* Needed for the extern declarations of integer parameters */
#include "dir.h"
#include "panel.h" /* Needed for the externs */
#include "chmod.h"
#include "main.h" /* update_panels() */
#include "layout.h" /* repaint_screen() */
#include "chown.h"
#include "wtools.h" /* For init_box_colors */
#include "wtools.h" /* init_box_colors() */
#include "setup.h" /* panels_options */
#define UX 5
#define UY 2
@ -75,7 +74,8 @@ static int single_set;
static WListbox *l_user, *l_group;
/* *INDENT-OFF* */
static struct {
static struct
{
int ret_cmd, flags, y, x;
const char *text;
} chown_but[BUTTONS] = {
@ -91,11 +91,11 @@ static struct {
int y, x;
WLabel *l;
} chown_label [LABELS] = {
{ TY + 2, TX + 2, NULL },
{ TY + 4, TX + 2, NULL },
{ TY + 6, TX + 2, NULL },
{ TY + 8, TX + 2, NULL },
{ TY + 10,TX + 2, NULL }
{ TY + 2, TX + 2, NULL },
{ TY + 4, TX + 2, NULL },
{ TY + 6, TX + 2, NULL },
{ TY + 8, TX + 2, NULL },
{ TY + 10, TX + 2, NULL }
};
/* *INDENT-ON* */
@ -282,7 +282,7 @@ chown_cmd (void)
chown_label (0, str_trunc (fname, 15));
chown_label (1, str_trunc (get_owner (sf_stat.st_uid), 15));
chown_label (2, str_trunc (get_group (sf_stat.st_gid), 15));
size_trunc_len (buffer, 15, sf_stat.st_size, 0);
size_trunc_len (buffer, 15, sf_stat.st_size, 0, panels_options.kilobyte_si);
chown_label (3, buffer);
chown_label (4, string_perm (sf_stat.st_mode));

View File

@ -1340,8 +1340,8 @@ single_dirsize_cmd (void)
compute_dir_size_destroy_ui (ui);
}
if (mark_moves_down)
send_message (&(panel->widget), WIDGET_KEY, KEY_DOWN);
if (panels_options.mark_moves_down)
send_message (&panel->widget, WIDGET_KEY, KEY_DOWN);
recalculate_panel_summary (panel);

View File

@ -374,10 +374,11 @@
#define CK_UserMenuCmd 7070
#define CK_ViewCmd 7071
#define CK_ViewFileCmd 7072
#define CK_HelpCmd 7072
#define CK_HelpCmd 7073
#define CK_MenuCmd 7074
#define CK_TogglePanelsSplit 7075
#define CK_DiffViewCmd 7076
#define CK_PanelOptionsBox 7077
/* panels */
#define CK_PanelChdirOtherPanel 8001

View File

@ -37,15 +37,7 @@
#include "wtools.h"
#include "treestore.h"
#include "dir.h"
/* If true show files starting with a dot */
int show_dot_files = 1;
/* If true show files ending in ~ */
int show_backups = 1;
/* If false then directories are shown separately from files */
int mix_all_files = 0;
#include "setup.h" /* panels_options */
/* Reverse flag */
static int reverse = 1;
@ -84,13 +76,13 @@ sort_name (file_entry *a, file_entry *b)
int ad = MY_ISDIR (a);
int bd = MY_ISDIR (b);
if (ad == bd || mix_all_files) {
if (ad == bd || panels_options.mix_all_files) {
/* create key if does not exist, key will be freed after sorting */
if (a->sort_key == NULL)
if (a->sort_key == NULL)
a->sort_key = str_create_key_for_filename (a->fname, case_sensitive);
if (b->sort_key == NULL)
if (b->sort_key == NULL)
b->sort_key = str_create_key_for_filename (b->fname, case_sensitive);
return str_key_collate (a->sort_key, b->sort_key, case_sensitive)
* reverse;
}
@ -103,7 +95,7 @@ sort_vers (file_entry *a, file_entry *b)
int ad = MY_ISDIR (a);
int bd = MY_ISDIR (b);
if (ad == bd || mix_all_files) {
if (ad == bd || panels_options.mix_all_files) {
return str_verscmp(a->fname, b->fname) * reverse;
} else {
return bd - ad;
@ -117,10 +109,10 @@ sort_ext (file_entry *a, file_entry *b)
int ad = MY_ISDIR (a);
int bd = MY_ISDIR (b);
if (ad == bd || mix_all_files){
if (a->second_sort_key == NULL)
if (ad == bd || panels_options.mix_all_files) {
if (a->second_sort_key == NULL)
a->second_sort_key = str_create_key (extension (a->fname), case_sensitive);
if (b->second_sort_key == NULL)
if (b->second_sort_key == NULL)
b->second_sort_key = str_create_key (extension (b->fname), case_sensitive);
r = str_key_collate (a->second_sort_key, b->second_sort_key, case_sensitive);
@ -138,7 +130,7 @@ sort_time (file_entry *a, file_entry *b)
int ad = MY_ISDIR (a);
int bd = MY_ISDIR (b);
if (ad == bd || mix_all_files) {
if (ad == bd || panels_options.mix_all_files) {
int result = a->st.st_mtime < b->st.st_mtime ? -1 :
a->st.st_mtime > b->st.st_mtime;
if (result != 0)
@ -156,7 +148,7 @@ sort_ctime (file_entry *a, file_entry *b)
int ad = MY_ISDIR (a);
int bd = MY_ISDIR (b);
if (ad == bd || mix_all_files) {
if (ad == bd || panels_options.mix_all_files) {
int result = a->st.st_ctime < b->st.st_ctime ? -1 :
a->st.st_ctime > b->st.st_ctime;
if (result != 0)
@ -174,7 +166,7 @@ sort_atime (file_entry *a, file_entry *b)
int ad = MY_ISDIR (a);
int bd = MY_ISDIR (b);
if (ad == bd || mix_all_files) {
if (ad == bd || panels_options.mix_all_files) {
int result = a->st.st_atime < b->st.st_atime ? -1 :
a->st.st_atime > b->st.st_atime;
if (result != 0)
@ -192,7 +184,7 @@ sort_inode (file_entry *a, file_entry *b)
int ad = MY_ISDIR (a);
int bd = MY_ISDIR (b);
if (ad == bd || mix_all_files)
if (ad == bd || panels_options.mix_all_files)
return (a->st.st_ino - b->st.st_ino) * reverse;
else
return bd-ad;
@ -205,7 +197,7 @@ sort_size (file_entry *a, file_entry *b)
int bd = MY_ISDIR (b);
int result = 0;
if (ad != bd && !mix_all_files)
if (ad != bd && !panels_options.mix_all_files)
return bd - ad;
result = a->st.st_size < b->st.st_size ? -1 :
@ -300,10 +292,11 @@ handle_dirent (dir_list *list, const char *fltr, struct dirent *dp,
return 0;
if (dp->d_name[0] == '.' && dp->d_name[1] == '.' && dp->d_name[2] == 0)
return 0;
if (!show_dot_files && (dp->d_name[0] == '.'))
if (!panels_options.show_dot_files && (dp->d_name[0] == '.'))
return 0;
if (!show_backups && dp->d_name[NLENGTH (dp) - 1] == '~')
if (!panels_options.show_backups && dp->d_name[NLENGTH (dp) - 1] == '~')
return 0;
if (mc_lstat (dp->d_name, buf1) == -1) {
/*
* lstat() fails - such entries should be identified by
@ -362,7 +355,8 @@ get_dotdot_dir_stat (const char *path, struct stat *st)
}
/* handle_path is a simplified handle_dirent. The difference is that
handle_path doesn't pay attention to show_dot_files and show_backups.
handle_path doesn't pay attention to panels_options.show_dot_files
and panels_options.show_backups.
Moreover handle_path can't be used with a filemask.
If you change handle_path then check also handle_dirent. */
/* Return values: -1 = failure, 0 = don't add, 1 = add to the list */

View File

@ -66,9 +66,4 @@ int sort_inode (file_entry *a, file_entry *b);
int link_isdir (const file_entry *);
int if_link_is_exe (const char *full_name, const file_entry *file);
extern int show_backups;
extern int show_dot_files;
extern int mix_all_files;
extern int kilobyte_si;
#endif
#endif /* MC_DIR_H */

View File

@ -155,6 +155,7 @@ typedef struct
struct stat *s_stat, *d_stat;
} FileOpContextUI;
int classic_progressbar = 1;
/* Used to save the hint line */
static int last_hint_line;
@ -339,8 +340,7 @@ file_op_context_create_ui_without_init (FileOpContext * ctx, gboolean with_eta,
add_widget (ui->op_dlg, ui->file_string[0] = label_new (3, FCOPY_LABEL_X, ""));
add_widget (ui->op_dlg, ui->file_label[0] = label_new (2, FCOPY_LABEL_X, ""));
if ((right_panel == current_panel)
&& !mc_config_get_bool (mc_main_config, "Layout", "classic_progressbar", TRUE))
if ((right_panel == current_panel) && !classic_progressbar)
{
ui->progress_file_gauge->from_left_to_right = FALSE;
if (dialog_type == FILEGUI_DIALOG_MULTI_ITEM)
@ -543,8 +543,8 @@ file_progress_show_total (FileOpTotalContext * tctx, FileOpContext * ctx, double
g_snprintf (buffer, BUF_TINY, _("Time: %s %s (%s)"), buffer2, buffer3, buffer4);
label_set_text (ui->time_label, buffer);
size_trunc_len (buffer2, 5, tctx->copyed_bytes, 0);
size_trunc_len (buffer3, 5, ctx->progress_bytes, 0);
size_trunc_len (buffer2, 5, tctx->copyed_bytes, 0, panels_options.kilobyte_si);
size_trunc_len (buffer3, 5, ctx->progress_bytes, 0, panels_options.kilobyte_si);
g_snprintf (buffer, BUF_TINY, _(" Total: %s of %s "), buffer2, buffer3);

View File

@ -36,12 +36,11 @@
#include "dialog.h"
#include "widget.h" /* default_proc */
#include "main-widgets.h" /* the_menubar */
#include "dir.h" /* required by panel */
#include "panel.h" /* for the panel structure */
#include "main.h" /* other_panel, current_panel definitions */
#include "menu.h" /* menubar_visible */
#include "layout.h"
#include "mountlist.h"
#include "setup.h" /* panels_options */
#include "info.h"
#ifndef VERSION
@ -125,8 +124,8 @@ info_show_info (struct WInfo *info)
if (myfs_stats.avail > 0 || myfs_stats.total > 0)
{
char buffer1[6], buffer2[6];
size_trunc_len (buffer1, 5, myfs_stats.avail, 1);
size_trunc_len (buffer2, 5, myfs_stats.total, 1);
size_trunc_len (buffer1, 5, myfs_stats.avail, 1, panels_options.kilobyte_si);
size_trunc_len (buffer2, 5, myfs_stats.total, 1, panels_options.kilobyte_si);
tty_printf (_("Free space: %s (%d%%) of %s"), buffer1, myfs_stats.total ?
(int) (100 * (double) myfs_stats.avail / myfs_stats.total) : 0, buffer2);
}
@ -181,7 +180,7 @@ info_show_info (struct WInfo *info)
#endif
{
char buffer[10];
size_trunc_len (buffer, 9, st.st_size, 0);
size_trunc_len (buffer, 9, st.st_size, 0, panels_options.kilobyte_si);
tty_printf (_("Size: %s"), buffer);
#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
tty_printf (ngettext (" (%ld block)", " (%ld blocks)",

View File

@ -355,7 +355,7 @@ static name_keymap_t command_names[] = {
#ifdef WITH_BACKGROUND
{ "CmdJobs", CK_JobsCmd },
#endif
{ "CmdLayout", CK_LayoutCmd },
{ "CmdLayout", CK_LayoutBox },
{ "CmdLearnKeys", CK_LearnKeys },
{ "CmdLink", CK_LinkCmd },
{ "CmdChangeListing", CK_ChangeListingCmd },
@ -367,6 +367,7 @@ static name_keymap_t command_names[] = {
#if defined (USE_NETCODE) && defined (ENABLE_VFS_MCFS)
{ "CmdNetlink", CK_NetlinkCmd },
#endif
{ "CmdPanelOptions", CK_PanelOptionsBox },
{ "CmdQuickCd", CK_QuickCdCmd },
{ "CmdQuickChdir", CK_QuickChdirCmd },
{ "CmdQuickView", CK_QuickViewCmd },

View File

@ -141,8 +141,6 @@ static int _keybar_visible;
static int _message_visible;
static int _xterm_title;
static int _free_space;
static int _permission_mode;
static int _filetype_mode;
static int height;
@ -150,8 +148,6 @@ static int height;
#define MINWIDTH 12
#define MINHEIGHT 5
#define BY 12
#define B_2LEFT B_USER
#define B_2RIGHT (B_USER + 1)
#define B_PLUS (B_USER + 2)
@ -171,26 +167,22 @@ static struct {
int *variable;
WCheck *widget;
} check_options [] = {
{ N_("show free sp&Ace"), &free_space, 0 },
{ N_("&Xterm window title"), &xterm_title, 0 },
{ N_("h&Intbar visible"), &message_visible, 0 },
{ N_("&Keybar visible"), &keybar_visible, 0 },
{ N_("command &Prompt"), &command_prompt, 0 },
{ N_("show &Mini status"), &show_mini_info, 0 },
{ N_("menu&Bar visible"), &menubar_visible, 0 },
{ N_("&Equal split"), &equal_split, 0 },
{ N_("pe&Rmissions"), &permission_mode, 0 },
{ N_("&File types"), &filetype_mode, 0 },
{ 0, 0, 0 }
{ N_("show free sp&Ace"), &free_space, NULL },
{ N_("&Xterm window title"), &xterm_title, NULL },
{ N_("h&Intbar visible"), &message_visible, NULL },
{ N_("&Keybar visible"), &keybar_visible, NULL },
{ N_("command &Prompt"), &command_prompt, NULL },
{ N_("show &Mini status"), &show_mini_info, NULL },
{ N_("menu&Bar visible"), &menubar_visible, NULL },
{ N_("&Equal split"), &equal_split, NULL }
};
#define LAYOUT_OPTIONS_COUNT 10
#define HIGHLIGHT_OPTIONS_COUNT 2
#define SPLIT_OPTIONS_COUNT 1
#define OTHER_OPTIONS_COUNT 7
#define LAYOUT_OPTIONS_COUNT sizeof (check_options) / sizeof (check_options[0])
#define OTHER_OPTIONS_COUNT (LAYOUT_OPTIONS_COUNT - 1)
static gsize first_width, second_width;
static const char *output_lines_label;
static const char *output_lines_label = 0;
static int output_lines_label_len;
static WButton *bleft_widget, *bright_widget;
@ -308,17 +300,15 @@ layout_callback (Dlg_head *h, Widget *sender,
if (old_output_lines != _output_lines){
old_output_lines = _output_lines;
tty_setcolor (COLOR_NORMAL);
dlg_move (h, LAYOUT_OPTIONS_COUNT, 16 + first_width);
dlg_move (h, 9, 6);
tty_print_string (output_lines_label);
dlg_move (h, LAYOUT_OPTIONS_COUNT, 10 + first_width);
dlg_move (h, 9, 6 + 3 + output_lines_label_len);
tty_printf ("%02d", _output_lines);
}
}
return MSG_HANDLED;
case DLG_POST_KEY:
_filetype_mode = check_options [9].widget->state & C_BOOL;
_permission_mode = check_options [8].widget->state & C_BOOL;
_equal_split = check_options [7].widget->state & C_BOOL;
_menubar_visible = check_options [6].widget->state & C_BOOL;
_command_prompt = check_options [5].widget->state & C_BOOL;
@ -353,7 +343,7 @@ layout_callback (Dlg_head *h, Widget *sender,
if (old_output_lines != _output_lines){
old_output_lines = _output_lines;
tty_setcolor (COLOR_NORMAL);
dlg_move (h, LAYOUT_OPTIONS_COUNT, 10 + first_width);
dlg_move (h, 9, 6 + 3 + output_lines_label_len);
tty_printf ("%02d", _output_lines);
}
}
@ -381,9 +371,9 @@ init_layout (void)
first_width = 19; /* length of line with '<' '>' buttons */
title1 = _(" Panel split ");
title2 = _(" Highlight... ");
title2 = _(" Terminal output ");
title3 = _(" Other options ");
output_lines_label = _("output lines");
output_lines_label = _("Output lines: ");
while (i--) {
s_split_direction[i] = _(s_split_direction[i]);
@ -399,11 +389,11 @@ init_layout (void)
first_width = l1;
}
l1 = str_term_width1 (title1) + 1;
l1 = str_term_width1 (title1) + 1;
if (l1 > first_width)
first_width = l1;
l1 = str_term_width1 (title2) + 1;
l1 = str_term_width1 (title2) + 1;
if (l1 > first_width)
first_width = l1;
@ -415,7 +405,8 @@ init_layout (void)
second_width = l1;
}
if (console_flag) {
l1 = str_term_width1 (output_lines_label) + 13;
output_lines_label_len = str_term_width1 (output_lines_label);
l1 = output_lines_label_len + 13;
if (l1 > second_width)
second_width = l1;
}
@ -442,47 +433,33 @@ init_layout (void)
}
layout_dlg =
create_dlg (0, 0, 15, first_width + second_width + 9,
create_dlg (0, 0, 14, first_width + second_width + 9,
dialog_colors, layout_callback, "[Layout]",
_("Layout"), DLG_CENTER | DLG_REVERSE);
add_widget (layout_dlg, groupbox_new (2, 4, 6, first_width, title1));
add_widget (layout_dlg, groupbox_new (8, 4, 4, first_width, title2));
add_widget (layout_dlg,
groupbox_new (2, 5 + first_width, 10, second_width,
groupbox_new (2, 5 + first_width, 9, second_width,
title3));
add_widget (layout_dlg,
button_new (BY, b3, B_CANCEL, NORMAL_BUTTON, cancel_button,
button_new (11, b3, B_CANCEL, NORMAL_BUTTON, cancel_button,
0));
add_widget (layout_dlg,
button_new (BY, b2, B_EXIT, NORMAL_BUTTON, save_button,
button_new (11, b2, B_EXIT, NORMAL_BUTTON, save_button,
0));
add_widget (layout_dlg,
button_new (BY, b1, B_ENTER, DEFPUSH_BUTTON, ok_button,
button_new (11, b1, B_ENTER, DEFPUSH_BUTTON, ok_button,
0));
if (console_flag) {
add_widget (layout_dlg,
button_new (LAYOUT_OPTIONS_COUNT, 12 + first_width, B_MINUS,
NARROW_BUTTON, "&-", bminus_cback));
add_widget (layout_dlg,
button_new (LAYOUT_OPTIONS_COUNT, 7 + first_width, B_PLUS, NARROW_BUTTON,
"&+", bplus_cback));
}
#define XTRACT(i) *check_options[i].variable, check_options[i].text
for (i = 0; i < OTHER_OPTIONS_COUNT; i++) {
check_options[i].widget =
check_new (LAYOUT_OPTIONS_COUNT - i - 1, 7 + first_width, XTRACT (i));
check_new (OTHER_OPTIONS_COUNT - i + 2, 7 + first_width, XTRACT (i));
add_widget (layout_dlg, check_options[i].widget);
}
check_options[9].widget = check_new (10, 6, XTRACT (9));
add_widget (layout_dlg, check_options[9].widget);
check_options[8].widget = check_new (9, 6, XTRACT (8));
add_widget (layout_dlg, check_options[8].widget);
_filetype_mode = filetype_mode;
_permission_mode = permission_mode;
_equal_split = equal_split;
_menubar_visible = menubar_visible;
_command_prompt = command_prompt;
@ -490,6 +467,18 @@ init_layout (void)
_message_visible = message_visible;
_xterm_title = xterm_title;
_free_space = free_space;
if (console_flag) {
add_widget (layout_dlg, groupbox_new (8, 4, 3, first_width, title2));
add_widget (layout_dlg,
button_new (9, output_lines_label_len + 6 + 5, B_MINUS,
NARROW_BUTTON, "&-", bminus_cback));
add_widget (layout_dlg,
button_new (9, output_lines_label_len + 6, B_PLUS,
NARROW_BUTTON, "&+", bplus_cback));
}
bright_widget =
button_new (6, 15, B_2RIGHT, NARROW_BUTTON, "&>", b2right_cback);
add_widget (layout_dlg, bright_widget);
@ -497,12 +486,14 @@ init_layout (void)
button_new (6, 9, B_2LEFT, NARROW_BUTTON, "&<", b2left_cback);
add_widget (layout_dlg, bleft_widget);
check_options[7].widget = check_new (5, 6, XTRACT (7));
old_first_panel_size = -1;
old_horizontal_split = -1;
old_output_lines = -1;
_first_panel_size = first_panel_size;
_output_lines = output_lines;
add_widget (layout_dlg, check_options[7].widget);
radio_widget = radio_new (3, 6, 2, s_split_direction);
add_widget (layout_dlg, radio_widget);
@ -521,7 +512,7 @@ layout_change (void)
load_hint (1);
}
void layout_cmd (void)
void layout_box (void)
{
int result;
int i;
@ -532,7 +523,7 @@ void layout_cmd (void)
result = layout_dlg->ret_value;
if (result == B_ENTER || result == B_EXIT){
for (i = 0; check_options [i].text; i++)
for (i = 0; i < LAYOUT_OPTIONS_COUNT; i++)
if (check_options [i].widget)
*check_options [i].variable = check_options [i].widget->state & C_BOOL;
horizontal_split = radio_widget->sel;

View File

@ -10,7 +10,7 @@
#include "widget.h"
void layout_change (void);
void layout_cmd (void);
void layout_box (void);
void setup_panels (void);
void destroy_panels (void);
void sigwinch_handler (int dummy);

View File

@ -148,9 +148,6 @@ int cd_symlinks = 1;
/* they do a complete refresh, refreshing all the parts of the program */
int fast_refresh = 0;
/* If true, marking a files moves the cursor down */
int mark_moves_down = 1;
/* If true, at startup the user-menu is invoked */
int auto_menu = 0;
@ -191,15 +188,6 @@ int utf8_display = 0;
/* If true use the internal viewer */
int use_internal_view = 1;
/* Have we shown the fast-reload warning in the past? */
int fast_reload_w = 0;
/* Move page/item? When clicking on the top or bottom of a panel */
int mouse_move_pages = 1;
/* If true: l&r arrows are used to chdir if the input line is empty */
int navigate_with_arrows = 0;
/* The prompt */
const char *mc_prompt = NULL;
@ -302,7 +290,7 @@ mc_main_error_quark (void)
void
save_cwds_stat (void)
{
if (fast_reload)
if (panels_options.fast_reload)
{
mc_stat (current_panel->cwd, &(current_panel->dir_stat));
if (get_other_type () == view_listing)
@ -796,10 +784,11 @@ create_options_menu (void)
GList *entries = NULL;
entries = g_list_append (entries, menu_entry_create (_("&Configuration..."), CK_ConfigureBox));
entries = g_list_append (entries, menu_entry_create (_("&Layout..."), CK_LayoutCmd));
entries = g_list_append (entries, menu_entry_create (_("C&onfirmation..."), CK_ConfirmBox));
entries = g_list_append (entries, menu_entry_create (_("&Display bits..."), CK_DisplayBitsBox));
entries = g_list_append (entries, menu_entry_create (_("Learn &keys..."), CK_LearnKeys));
entries = g_list_append (entries, menu_entry_create (_("&Layout..."), CK_LayoutBox));
entries = g_list_append (entries, menu_entry_create (_("&Panel options..."), CK_PanelOptionsBox));
entries = g_list_append (entries, menu_entry_create (_("C&onfirmation..."), CK_ConfirmBox));
entries = g_list_append (entries, menu_entry_create (_("&Display bits..."), CK_DisplayBitsBox));
entries = g_list_append (entries, menu_entry_create (_("Learn &keys..."), CK_LearnKeys));
#ifdef ENABLE_VFS
entries = g_list_append (entries, menu_entry_create (_("&Virtual FS..."), CK_ConfigureVfs));
#endif
@ -876,41 +865,10 @@ midnight_get_shortcut (unsigned long command)
return NULL;
}
/* Flag toggling functions */
void
toggle_fast_reload (void)
{
fast_reload = !fast_reload;
if (fast_reload_w == 0 && fast_reload)
{
message (D_NORMAL, _(" Information "),
_
(" Using the fast reload option may not reflect the exact \n"
" directory contents. In this case you'll need to do a \n"
" manual reload of the directory. See the man page for \n"
" the details. "));
fast_reload_w = 1;
}
}
void
toggle_mix_all_files (void)
{
mix_all_files = !mix_all_files;
update_panels (UP_RELOAD, UP_KEEPSEL);
}
void
toggle_show_backup (void)
{
show_backups = !show_backups;
update_panels (UP_RELOAD, UP_KEEPSEL);
}
void
toggle_show_hidden (void)
{
show_dot_files = !show_dot_files;
panels_options.show_dot_files = !panels_options.show_dot_files;
update_panels (UP_RELOAD, UP_KEEPSEL);
}
@ -922,13 +880,6 @@ toggle_panels_split (void)
do_refresh ();
}
void
toggle_kilobyte_si (void)
{
kilobyte_si = !kilobyte_si;
update_panels (UP_RELOAD, UP_KEEPSEL);
}
/*
* Just a hack for allowing url-like pathnames to be accepted from the
* command line.
@ -1284,8 +1235,8 @@ midnight_execute_cmd (Widget * sender, unsigned long command)
jobs_cmd ();
break;
#endif
case CK_LayoutCmd:
layout_cmd ();
case CK_LayoutBox:
layout_box ();
break;
case CK_LearnKeys:
learn_keys ();
@ -1315,6 +1266,9 @@ midnight_execute_cmd (Widget * sender, unsigned long command)
netlink_cmd ();
break;
#endif
case CK_PanelOptionsBox:
panel_options_box ();
break;
#ifdef HAVE_CHARSET
case CK_PanelSetPanelEncoding:
encoding_cmd ();

View File

@ -34,12 +34,7 @@ extern char *mc_run_param0;
*/
extern char *mc_run_param1;
/* Toggling functions */
void toggle_fast_reload (void);
void toggle_mix_all_files (void);
void toggle_show_backup (void);
void toggle_show_hidden (void);
void toggle_kilobyte_si (void);
extern int quote;
extern volatile int quit;
@ -54,15 +49,12 @@ struct WButtonBar;
void midnight_set_buttonbar (struct WButtonBar *b);
/* See main.c for details on these variables */
extern int mark_moves_down;
extern int auto_menu;
extern int pause_after_run;
extern int auto_save_setup;
extern int use_internal_view;
extern int use_internal_edit;
extern int fast_reload_w;
extern int clear_before_exec;
extern int mouse_move_pages;
extern int option_tab_spacing;
@ -82,7 +74,6 @@ extern int full_eight_bits;
extern int utf8_display;
extern int fast_refresh;
extern int navigate_with_arrows;
extern int drop_menus;
extern int cd_symlinks;
extern int show_all_if_ambiguous;

View File

@ -1,6 +1,6 @@
/* Configure box module for the Midnight Commander
Copyright (C) 1994, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
2007, 2009 Free Software Foundation, Inc.
2007, 2009, 2010 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -18,7 +18,7 @@
*/
/** \file option.c
* \brief Source: configure box module
* \brief Source: configure boxes module
*/
#include <config.h>
@ -31,220 +31,286 @@
#include <unistd.h>
#include "lib/global.h"
#include "lib/tty/tty.h"
#include "lib/mcconfig.h" /* For mc_config_save_file */
#include "lib/strutil.h"
#include "lib/mcconfig.h" /* mc_config_save_file() */
#include "lib/strutil.h" /* str_term_width1() */
#include "dialog.h"
#include "widget.h"
#include "setup.h" /* For save_setup() */
#include "dialog.h" /* B_ constants */
#include "setup.h" /* panels_options */
#include "main.h"
#include "panel.h" /* Needed for the externs */
#include "file.h" /* safe_delete */
#include "layout.h" /* For nice_rotating_dash */
#include "file.h" /* file_op_compute_totals */
#include "layout.h" /* nice_rotating_dash */
#include "wtools.h" /* QuickDialog */
#include "option.h"
static Dlg_head *conf_dlg;
#define TOGGLE_VARIABLE 0
static int first_width, second_width;
static struct {
const char *text;
int *variable;
void (*toggle_function)(void);
WCheck *widget;
} check_options [] = {
/* other options */
{N_("safe de&Lete"), &safe_delete, TOGGLE_VARIABLE, 0 },
{N_("cd follows lin&Ks"), &cd_symlinks, TOGGLE_VARIABLE, 0 },
{N_("L&ynx-like motion"), &navigate_with_arrows,TOGGLE_VARIABLE, 0 },
{N_("rotatin&G dash"), &nice_rotating_dash,TOGGLE_VARIABLE, 0 },
{N_("co&Mplete: show all"),&show_all_if_ambiguous,TOGGLE_VARIABLE, 0 },
{N_("&Use internal view"), &use_internal_view, TOGGLE_VARIABLE, 0 },
{N_("use internal ed&It"), &use_internal_edit, TOGGLE_VARIABLE, 0 },
{N_("auto m&Enus"), &auto_menu, TOGGLE_VARIABLE, 0 },
{N_("&Auto save setup"), &auto_save_setup, TOGGLE_VARIABLE, 0 },
{N_("shell &Patterns"), &easy_patterns, TOGGLE_VARIABLE, 0 },
{N_("Compute &Totals"), &file_op_compute_totals, TOGGLE_VARIABLE, 0 },
{N_("&Verbose operation"), &verbose, TOGGLE_VARIABLE, 0 },
{N_("Mkdir autoname"), &auto_fill_mkdir_name, TOGGLE_VARIABLE, 0 },
/* panel options */
{N_("&Fast dir reload"), &fast_reload, toggle_fast_reload, 0 },
{N_("mi&X all files"), &mix_all_files, toggle_mix_all_files, 0 },
{N_("&Drop down menus"), &drop_menus, TOGGLE_VARIABLE, 0 },
{N_("ma&Rk moves down"), &mark_moves_down, TOGGLE_VARIABLE, 0 },
{N_("show &Hidden files"), &show_dot_files, toggle_show_hidden, 0 },
{N_("show &Backup files"), &show_backups, toggle_show_backup, 0 },
{N_("Use SI si&ze units"), &kilobyte_si, toggle_kilobyte_si, 0 },
{ 0, 0, 0, 0 }
};
/* Make sure this corresponds to the check_options structure */
#define OTHER_OPTIONS 13
#define PANEL_OPTIONS 7
static WRadio *pause_radio;
static const char *pause_options [3] = {
N_("&Never"),
N_("on dumb &Terminals"),
N_("Alwa&ys") };
#define PAUSE_OPTIONS (sizeof(pause_options) / sizeof(pause_options[0]))
/* Heights of the panes */
#define PY 3
#define OY PY
/* Align bottoms of "pause after run" and "other options" */
#define RY (OTHER_OPTIONS - PAUSE_OPTIONS + OY)
#define DLG_Y (OTHER_OPTIONS + 9)
#define BY (DLG_Y - 3)
/* Horizontal dimensions */
#define X_MARGIN 3
#define X_PANE_GAP 1
#define PX X_MARGIN
#define RX X_MARGIN
#define OX (first_width + X_MARGIN + X_PANE_GAP)
/* Create the "Configure options" dialog */
static void
init_configure (void)
void
configure_box (void)
{
int i;
static int i18n_config_flag = 0;
static int b1, b2, b3;
const char *ok_button = _("&OK");
const char *cancel_button = _("&Cancel");
const char *save_button = _("&Save");
static const char *title1, *title2, *title3;
int dlg_width = 60;
int dlg_height = 17;
if (!i18n_config_flag) {
register int l1;
const char *pause_options[] = {
N_("&Never"),
N_("On dumb &terminals"),
N_("Alwa&ys")
};
/* Similar code is in layout.c (init_layout()) */
int pause_options_num = sizeof (pause_options) / sizeof (pause_options[0]);
title1 = _(" Panel options ");
title2 = _(" Pause after run... ");
title3 = _(" Other options ");
QuickWidget quick_widgets[] = {
/* buttons */
QUICK_BUTTON (38, dlg_width, dlg_height - 3, dlg_height, N_("&Cancel"), B_CANCEL, NULL),
QUICK_BUTTON (26, dlg_width, dlg_height - 3, dlg_height, N_("&Save"), B_EXIT, NULL),
QUICK_BUTTON (14, dlg_width, dlg_height - 3, dlg_height, N_("&OK"), B_ENTER, NULL),
/* other options */
QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 12, dlg_height, N_("&Auto save setup"),
&auto_save_setup),
QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 11, dlg_height, N_("Safe de&lete"),
&safe_delete),
QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 10, dlg_height, N_("Cd follows lin&ks"),
&cd_symlinks),
QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 9, dlg_height, N_("Rotatin&g dash"),
&nice_rotating_dash),
QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 8, dlg_height, N_("Co&mplete: show all"),
&show_all_if_ambiguous),
QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 7, dlg_height, N_("Shell &patterns"),
&easy_patterns),
QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 6, dlg_height, N_("&Drop down menus"),
&drop_menus),
QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 5, dlg_height, N_("Auto m&enus"), &auto_menu),
QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 4, dlg_height, N_("Use internal vie&w"),
&use_internal_view),
QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 3, dlg_height, N_("&Use internal edit"),
&use_internal_edit),
QUICK_GROUPBOX (dlg_width / 2, dlg_width, 2, dlg_height, dlg_width / 2 - 4, 12,
N_("Other options")),
/* pause options */
QUICK_RADIO (5, dlg_width, 10, dlg_height, pause_options_num, pause_options,
&pause_after_run),
QUICK_GROUPBOX (3, dlg_width, 9, dlg_height, dlg_width / 2 - 4, 5, N_("Pause after run")),
/* file operation options */
/* ADD: classic_progressbar */
QUICK_CHECKBOX (5, dlg_width, 5, dlg_height, N_("Mkdi&r autoname"), &auto_fill_mkdir_name),
QUICK_CHECKBOX (5, dlg_width, 4, dlg_height, N_("Compute &totals"),
&file_op_compute_totals),
QUICK_CHECKBOX (5, dlg_width, 3, dlg_height, N_("&Verbose operation"), &verbose),
QUICK_GROUPBOX (3, dlg_width, 2, dlg_height, dlg_width / 2 - 4, 5,
N_("File operation options")),
QUICK_END
};
first_width = str_term_width1 (title1) + 1;
second_width = str_term_width1 (title3) + 1;
const size_t qw_num = sizeof (quick_widgets) / sizeof (quick_widgets[0]) - 1;
for (i = 0; check_options[i].text; i++) {
check_options[i].text = _(check_options[i].text);
l1 = str_term_width1 (check_options[i].text) + 7;
if (i >= OTHER_OPTIONS) {
if (l1 > first_width)
first_width = l1;
} else {
if (l1 > second_width)
second_width = l1;
}
}
QuickDialog Quick_input = {
dlg_width, dlg_height, -1, -1,
N_("Configure options"), "[Configuration]",
quick_widgets, TRUE
};
i = PAUSE_OPTIONS;
while (i--) {
pause_options[i] = _(pause_options[i]);
l1 = str_term_width1 (pause_options[i]) + 7;
if (l1 > first_width)
first_width = l1;
}
int b0_len, b1_len, b2_len;
int b_len, c_len, g_len;
size_t i;
l1 = str_term_width1 (title2) + 1;
if (l1 > first_width)
first_width = l1;
#ifdef ENABLE_NLS
{
for (i = 0; i < qw_num; i++)
if (i < 3)
/* buttons */
quick_widgets[i].u.button.text = _(quick_widgets[i].u.button.text);
else if ((i == 13) || (i == 15) || (i == 19))
/* groupboxes */
quick_widgets[i].u.groupbox.title = _(quick_widgets[i].u.groupbox.title);
else if (i == 14)
{
/* radio button */
size_t j;
for (j = 0; j < pause_options_num; j++)
pause_options[j] = _(pause_options[j]);
}
else
/* checkboxes */
quick_widgets[i].u.checkbox.text = _(quick_widgets[i].u.checkbox.text);
l1 = 11 + str_term_width1 (ok_button)
+ str_term_width1 (save_button)
+ str_term_width1 (cancel_button);
i = (first_width + second_width - l1) / 4;
b1 = 5 + i;
b2 = b1 + str_term_width1 (ok_button) + i + 6;
b3 = b2 + str_term_width1 (save_button) + i + 4;
i18n_config_flag = 1;
Quick_input.title = _(Quick_input.title);
}
#endif /* ENABLE_NLS */
conf_dlg =
create_dlg (0, 0, DLG_Y,
first_width + second_width + 2 * X_MARGIN + X_PANE_GAP,
dialog_colors, NULL, "[Configuration]",
_("Configure options"), DLG_CENTER | DLG_REVERSE);
/* calculate widget and dialog widths */
/* dialog title */
dlg_width = max (dlg_width, str_term_width1 (Quick_input.title) + 4);
/* buttons */
b0_len = str_term_width1 (quick_widgets[0].u.button.text) + 3;
b1_len = str_term_width1 (quick_widgets[1].u.button.text) + 3;
b2_len = str_term_width1 (quick_widgets[2].u.button.text) + 5;
b_len = b0_len + b1_len + b2_len + 2;
add_widget (conf_dlg,
groupbox_new (PY, PX, PANEL_OPTIONS + 2, first_width, title1));
/* checkboxes within groupboxes */
c_len = 0;
for (i = 3; i < 19; i++)
if ((i < 13) || (i > 15))
c_len = max (c_len, str_term_width1 (quick_widgets[i].u.checkbox.text) + 3);
/* radiobuttons */
for (i = 0; i < pause_options_num; i++)
c_len = max (c_len, str_term_width1 (pause_options[i]) + 3);
/* groupboxes */
g_len = max (c_len + 2, str_term_width1 (quick_widgets[19].u.groupbox.title) + 4);
g_len = max (g_len, str_term_width1 (quick_widgets[15].u.groupbox.title) + 4);
g_len = max (g_len, str_term_width1 (quick_widgets[13].u.groupbox.title) + 4);
/* dialog width */
Quick_input.xlen = max (dlg_width, g_len * 2 + 9);
Quick_input.xlen = max (Quick_input.xlen, b_len + 2);
if ((Quick_input.xlen & 1) != 0)
Quick_input.xlen++;
add_widget (conf_dlg,
groupbox_new (RY, RX, PAUSE_OPTIONS + 2, first_width, title2));
/* fix widget parameters */
for (i = 0; i < qw_num; i++)
quick_widgets[i].x_divisions = Quick_input.xlen;
add_widget (conf_dlg,
groupbox_new (OY, OX, OTHER_OPTIONS + 2, second_width, title3));
/* groupboxes */
quick_widgets[13].u.groupbox.width =
quick_widgets[15].u.groupbox.width =
quick_widgets[19].u.groupbox.width = Quick_input.xlen / 2 - 4;
add_widget (conf_dlg,
button_new (BY, b3, B_CANCEL, NORMAL_BUTTON,
cancel_button, 0));
/* right column */
quick_widgets[13].relative_x = Quick_input.xlen / 2;
for (i = 3; i < 13; i++)
quick_widgets[i].relative_x = quick_widgets[13].relative_x + 2;
add_widget (conf_dlg,
button_new (BY, b2, B_EXIT, NORMAL_BUTTON,
save_button, 0));
/* buttons */
quick_widgets[2].relative_x = (Quick_input.xlen - b_len) / 2;
quick_widgets[1].relative_x = quick_widgets[2].relative_x + b2_len + 1;
quick_widgets[0].relative_x = quick_widgets[1].relative_x + b1_len + 1;
add_widget (conf_dlg,
button_new (BY, b1, B_ENTER, DEFPUSH_BUTTON,
ok_button, 0));
#define XTRACT(i) *check_options[i].variable, check_options[i].text
/* Add checkboxes for "other options" */
for (i = 0; i < OTHER_OPTIONS; i++) {
check_options[i].widget =
check_new (OY + (OTHER_OPTIONS - i), OX + 2, XTRACT (i));
add_widget (conf_dlg, check_options[i].widget);
}
pause_radio =
radio_new (RY + 1, RX + 2, 3, pause_options);
pause_radio->sel = pause_after_run;
add_widget (conf_dlg, pause_radio);
/* Add checkboxes for "panel options" */
for (i = 0; i < PANEL_OPTIONS; i++) {
check_options[i + OTHER_OPTIONS].widget =
check_new (PY + (PANEL_OPTIONS - i), PX + 2,
XTRACT (i + OTHER_OPTIONS));
add_widget (conf_dlg, check_options[i + OTHER_OPTIONS].widget);
/* Save button */
if (quick_dialog (&Quick_input) == B_EXIT)
{
save_config ();
mc_config_save_file (mc_main_config, NULL);
}
}
void configure_box (void)
void
panel_options_box (void)
{
int result, i;
init_configure ();
run_dlg (conf_dlg);
int dlg_width = 36;
int dlg_height = 19;
result = conf_dlg->ret_value;
if (result == B_ENTER || result == B_EXIT){
for (i = 0; check_options [i].text; i++)
if (check_options [i].widget->state & C_CHANGE){
if (check_options [i].toggle_function)
(*check_options [i].toggle_function)();
else
*check_options [i].variable =
!(*check_options [i].variable);
}
pause_after_run = pause_radio->sel;
QuickWidget quick_widgets[] = {
/* buttons */
QUICK_BUTTON (23, dlg_width, dlg_height - 3, dlg_height, N_("&Cancel"), B_CANCEL, NULL),
QUICK_BUTTON (13, dlg_width, dlg_height - 3, dlg_height, N_("&Save"), B_EXIT, NULL),
QUICK_BUTTON (3, dlg_width, dlg_height - 3, dlg_height, N_("&OK"), B_ENTER, NULL),
/* file highlighting */
QUICK_CHECKBOX (5, dlg_width, 14, dlg_height, N_("&Permissions"),
&panels_options.permission_mode),
QUICK_CHECKBOX (5, dlg_width, 13, dlg_height, N_("File &types"),
&panels_options.filetype_mode),
QUICK_GROUPBOX (3, dlg_width, 12, dlg_height, dlg_width - 6, 4, N_("File highlight")),
/* main panel options */
/* ADD: panels_options.scroll_pages */
QUICK_CHECKBOX (5, dlg_width, 10, dlg_height, N_("A&uto save setup"),
&panels_options.auto_save_setup),
QUICK_CHECKBOX (5, dlg_width, 9, dlg_height, N_("Use SI si&ze units"),
&panels_options.kilobyte_si),
QUICK_CHECKBOX (5, dlg_width, 8, dlg_height, N_("L&ynx-like motion"),
&panels_options.navigate_with_arrows),
QUICK_CHECKBOX (5, dlg_width, 7, dlg_height, N_("Ma&rk moves down"),
&panels_options.mark_moves_down),
QUICK_CHECKBOX (5, dlg_width, 6, dlg_height, N_("&Fast dir reload"),
&panels_options.fast_reload),
QUICK_CHECKBOX (5, dlg_width, 5, dlg_height, N_("Show &hidden files"),
&panels_options.show_dot_files),
QUICK_CHECKBOX (5, dlg_width, 4, dlg_height, N_("Show &backup files"),
&panels_options.show_backups),
QUICK_CHECKBOX (5, dlg_width, 3, dlg_height, N_("Mi&x all files"),
&panels_options.mix_all_files),
QUICK_GROUPBOX (3, dlg_width, 2, dlg_height, dlg_width - 6, 10, N_("Main panel options")),
QUICK_END
};
const size_t qw_num = sizeof (quick_widgets) / sizeof (quick_widgets[0]) - 1;
QuickDialog Quick_input = {
dlg_width, dlg_height, -1, -1,
N_("Panel options"), "[Panel options]",
quick_widgets, TRUE
};
int qd_result;
int b0_len, b1_len, b2_len;
int b_len, c_len, g_len;
size_t i;
#ifdef ENABLE_NLS
{
for (i = 0; i < qw_num; i++)
if (i < 3)
/* buttons */
quick_widgets[i].u.button.text = _(quick_widgets[i].u.button.text);
else if ((i == 5) || (i == 14))
/* groupboxes */
quick_widgets[i].u.groupbox.title = _(quick_widgets[i].u.groupbox.title);
else
/* checkboxes */
quick_widgets[i].u.checkbox.text = _(quick_widgets[i].u.checkbox.text);
Quick_input.title = _(Quick_input.title);
}
#endif /* ENABLE_NLS */
/* calculate widget and dialog widths */
/* dialog title */
dlg_width = max (dlg_width, str_term_width1 (Quick_input.title) + 4);
/* buttons */
b0_len = str_term_width1 (quick_widgets[0].u.button.text) + 3;
b1_len = str_term_width1 (quick_widgets[1].u.button.text) + 3;
b2_len = str_term_width1 (quick_widgets[2].u.button.text) + 5;
b_len = b0_len + b1_len + b2_len + 2;
/* checkboxes within groupboxes */
c_len = 0;
for (i = 3; i < 14; i++)
if (i != 5)
c_len = max (c_len, str_term_width1 (quick_widgets[i].u.checkbox.text) + 3);
/* groupboxes */
g_len = max (c_len + 2, str_term_width1 (quick_widgets[14].u.groupbox.title) + 4);
g_len = max (g_len, str_term_width1 (quick_widgets[5].u.groupbox.title) + 4);
g_len = max (g_len, b_len);
/* dialog width */
Quick_input.xlen = max (dlg_width, g_len + 6);
/* fix widget parameters */
for (i = 0; i < qw_num; i++)
quick_widgets[i].x_divisions = Quick_input.xlen;
/* groupboxes */
quick_widgets[5].u.groupbox.width = quick_widgets[14].u.groupbox.width = Quick_input.xlen - 6;
/* buttons */
quick_widgets[2].relative_x = (Quick_input.xlen - b_len) / 2;
quick_widgets[1].relative_x = quick_widgets[2].relative_x + b2_len + 1;
quick_widgets[0].relative_x = quick_widgets[1].relative_x + b1_len + 1;
qd_result = quick_dialog (&Quick_input);
if ((qd_result == B_ENTER) || (qd_result == B_EXIT))
{
if (!panels_options.fast_reload_msg_shown && panels_options.fast_reload)
{
message (D_NORMAL, _(" Information "),
_(" Using the fast reload option may not reflect the exact \n"
" directory contents. In this case you'll need to do a \n"
" manual reload of the directory. See the man page for \n"
" the details. "));
panels_options.fast_reload_msg_shown = TRUE;
}
update_panels (UP_RELOAD, UP_KEEPSEL);
}
/* If they pressed the save button */
if (result == B_EXIT){
save_configure ();
mc_config_save_file (mc_main_config, NULL);
if (qd_result == B_EXIT)
{
/* save panel options */
panels_save_options ();
mc_config_save_file (mc_main_config, NULL);
}
destroy_dlg (conf_dlg);
}

View File

@ -7,5 +7,6 @@
#define MC_OPTION_H
void configure_box (void);
void panel_options_box (void);
#endif

View File

@ -104,11 +104,7 @@ WPanel *panel_new_with_dir (const char *panel_name, const char *dr);
void panel_clean_dir (WPanel *panel);
extern int torben_fj_mode;
extern int permission_mode;
extern int filetype_mode;
extern int show_mini_info;
extern int panel_scroll_pages;
extern int fast_reload;
void panel_reload (WPanel *panel);
void panel_set_sort_order (WPanel *panel, const panel_field_t *sort_order);

View File

@ -109,21 +109,9 @@ int quick_search_case_sensitive = QSEARCH_PANEL_CASE;
/* If true, show the mini-info on the panel */
int show_mini_info = 1;
/* If true, then use stat() on the cwd to determine directory changes */
int fast_reload = 0;
/* If true, use some usability hacks by Torben */
int torben_fj_mode = 0;
/* If true, up/down keys scroll the pane listing by pages */
int panel_scroll_pages = 1;
/* If 1, we use permission hilighting */
int permission_mode = 0;
/* If 1 - then add per file type hilighting */
int filetype_mode = 1;
/* The hook list for the select file function */
Hook *select_file_hook = 0;
@ -266,7 +254,7 @@ string_file_size (file_entry * fe, int len)
else
#endif
{
size_trunc_len (buffer, (unsigned int) len, fe->st.st_size, 0);
size_trunc_len (buffer, (unsigned int) len, fe->st.st_size, 0, panels_options.kilobyte_si);
}
return buffer;
}
@ -676,7 +664,7 @@ file_compute_color (int attr, file_entry * fe)
return (NORMAL_COLOR);
case NORMAL:
default:
if (!filetype_mode)
if (!panels_options.filetype_mode)
return (NORMAL_COLOR);
}
@ -727,7 +715,7 @@ format_file (char *dest, int limit, WPanel * panel, int file_index, int width, i
break;
perm = 0;
if (permission_mode)
if (panels_options.permission_mode)
{
if (!strcmp (format->id, "perm"))
perm = 1;
@ -906,7 +894,7 @@ display_total_marked_size (WPanel * panel, int y, int x, gboolean size_only)
*/
g_snprintf (b_bytes, sizeof (b_bytes),
ngettext ("%s byte", "%s bytes", (unsigned long) panel->total),
size_trunc_sep (panel->total));
size_trunc_sep (panel->total, panels_options.kilobyte_si));
if (!size_only)
g_snprintf (buffer, sizeof (buffer),
ngettext ("%s in %d file", "%s in %d files", panel->marked),
@ -973,8 +961,8 @@ show_free_space (WPanel * panel)
if (myfs_stats.avail > 0 || myfs_stats.total > 0)
{
char buffer1[6], buffer2[6], tmp[BUF_SMALL];
size_trunc_len (buffer1, sizeof (buffer1) - 1, myfs_stats.avail, 1);
size_trunc_len (buffer2, sizeof (buffer2) - 1, myfs_stats.total, 1);
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 ?
(int) (100 * (double) myfs_stats.avail / myfs_stats.total) : 0);
@ -1004,10 +992,9 @@ show_dir (WPanel * panel)
widget_move (&panel->widget, 0, 1);
tty_print_string (panel_history_prev_item_sign);
tmp = (show_dot_files) ? panel_hiddenfiles_sign_show : panel_hiddenfiles_sign_hide;
tmp =
g_strdup_printf ("%s[%s]%s", tmp, panel_history_show_list_sign,
panel_history_next_item_sign);
tmp = panels_options.show_dot_files ? panel_hiddenfiles_sign_show : panel_hiddenfiles_sign_hide;
tmp = g_strdup_printf ("%s[%s]%s", tmp, panel_history_show_list_sign,
panel_history_next_item_sign);
widget_move (&panel->widget, 0, panel->widget.cols - 6);
tty_print_string (tmp);
@ -1033,7 +1020,8 @@ show_dir (WPanel * panel)
char buffer[BUF_SMALL];
g_snprintf (buffer, sizeof (buffer), " %s ",
size_trunc_sep (panel->dir.list[panel->selected].st.st_size));
size_trunc_sep (panel->dir.list[panel->selected].st.st_size,
panels_options.kilobyte_si));
tty_setcolor (NORMAL_COLOR);
widget_move (&panel->widget, panel->widget.lines - 1, 4);
tty_print_string (buffer);
@ -1435,7 +1423,7 @@ panel_reload (WPanel * panel)
{
struct stat current_stat;
if (fast_reload && !stat (panel->cwd, &current_stat)
if (panels_options.fast_reload && !stat (panel->cwd, &current_stat)
&& current_stat.st_ctime == panel->dir_stat.st_ctime
&& current_stat.st_mtime == panel->dir_stat.st_mtime)
return;
@ -1957,21 +1945,19 @@ mini_status_format (WPanel * panel)
static cb_ret_t
maybe_cd (int move_up_dir)
{
if (navigate_with_arrows)
if (panels_options.navigate_with_arrows && (cmdline->buffer[0] == '\0'))
{
if (!cmdline->buffer[0])
if (move_up_dir)
{
if (move_up_dir)
{
do_cd ("..", cd_exact);
return MSG_HANDLED;
}
if (S_ISDIR (selection (current_panel)->st.st_mode)
|| link_isdir (selection (current_panel)))
{
do_cd (selection (current_panel)->fname, cd_exact);
return MSG_HANDLED;
}
do_cd ("..", cd_exact);
return MSG_HANDLED;
}
if (S_ISDIR (selection (current_panel)->st.st_mode)
|| link_isdir (selection (current_panel)))
{
do_cd (selection (current_panel)->fname, cd_exact);
return MSG_HANDLED;
}
}
return MSG_NOT_HANDLED;
@ -2057,7 +2043,7 @@ move_down (WPanel * panel)
unselect_item (panel);
panel->selected++;
if (panel->selected - panel->top_file == ITEMS (panel) && panel_scroll_pages)
if (panels_options.scroll_pages && panel->selected - panel->top_file == ITEMS (panel))
{
/* Scroll window half screen */
panel->top_file += ITEMS (panel) / 2;
@ -2076,7 +2062,7 @@ move_up (WPanel * panel)
unselect_item (panel);
panel->selected--;
if (panel->selected < panel->top_file && panel_scroll_pages)
if (panels_options.scroll_pages && panel->selected < panel->top_file)
{
/* Scroll window half screen */
panel->top_file -= ITEMS (panel) / 2;
@ -2357,7 +2343,7 @@ static void
do_mark_file (WPanel * panel, mark_act_t do_move)
{
do_file_mark (panel, panel->selected, selection (panel)->f.marked ? 0 : 1);
if ((mark_moves_down && do_move == MARK_DOWN) || do_move == MARK_FORCE_DOWN)
if ((panels_options.mark_moves_down && do_move == MARK_DOWN) || do_move == MARK_FORCE_DOWN)
move_down (panel);
else if (do_move == MARK_FORCE_UP)
move_up (panel);
@ -3342,7 +3328,7 @@ do_panel_event (Gpm_Event * event, WPanel * panel, gboolean * redir)
if (event->y <= 0)
{
mark_if_marking (panel, event);
if (mouse_move_pages)
if (panels_options.mouse_move_pages)
prev_page (panel);
else
move_up (panel);
@ -3352,7 +3338,7 @@ do_panel_event (Gpm_Event * event, WPanel * panel, gboolean * redir)
if (!((panel->top_file + event->y <= panel->count) && event->y <= lines))
{
mark_if_marking (panel, event);
if (mouse_move_pages)
if (panels_options.mouse_move_pages)
next_page (panel);
else
move_down (panel);

View File

@ -91,6 +91,22 @@ int setup_copymove_persistent_attr = 1;
/* default panel values */
int saving_setup;
panels_options_t panels_options = {
.mix_all_files = FALSE,
.show_backups = TRUE,
.show_dot_files = TRUE,
.fast_reload = FALSE,
.fast_reload_msg_shown = FALSE,
.mark_moves_down = TRUE,
.navigate_with_arrows = FALSE,
.kilobyte_si = FALSE,
.scroll_pages = TRUE,
.mouse_move_pages = TRUE,
.auto_save_setup = FALSE,
.filetype_mode = TRUE,
.permission_mode = FALSE
};
/*** file scope macro definitions **************************************/
/* In order to use everywhere the same setup for the locale we use defines */
@ -104,7 +120,8 @@ int saving_setup;
static char *panels_profile_name = NULL; /* .mc/panels.ini */
/* *INDENT-OFF* */
static const struct {
static const struct
{
const char *key;
int list_type;
} list_types [] = {
@ -112,10 +129,11 @@ static const struct {
{ "brief", list_brief },
{ "long", list_long },
{ "user", list_user },
{ 0, 0 }
{ NULL, 0 }
};
static const struct {
static const struct
{
const char *opt_name;
panel_view_mode_t opt_type;
} panel_types [] = {
@ -126,7 +144,8 @@ static const struct {
{ NULL, view_listing }
};
static const struct {
static const struct
{
const char *opt_name;
int *opt_addr;
} layout [] = {
@ -139,21 +158,16 @@ static const struct {
{ "command_prompt", &command_prompt },
{ "menubar_visible", &menubar_visible },
{ "show_mini_info", &show_mini_info },
{ "permission_mode", &permission_mode },
{ "filetype_mode", &filetype_mode },
{ "free_space", &free_space },
{ 0, 0 }
{ NULL, NULL }
};
static const struct {
static const struct
{
const char *opt_name;
int *opt_addr;
int *opt_addr;
} int_options [] = {
{ "show_backups", &show_backups },
{ "kilobyte_si", &kilobyte_si },
{ "show_dot_files", &show_dot_files },
{ "verbose", &verbose },
{ "mark_moves_down", &mark_moves_down },
{ "pause_after_run", &pause_after_run },
{ "shell_patterns", &easy_patterns },
{ "auto_save_setup", &auto_save_setup },
@ -161,9 +175,6 @@ static const struct {
{ "use_internal_view", &use_internal_view },
{ "use_internal_edit", &use_internal_edit },
{ "clear_before_exec", &clear_before_exec },
{ "mix_all_files", &mix_all_files },
{ "fast_reload", &fast_reload },
{ "fast_reload_msg_shown", &fast_reload_w },
{ "confirm_delete", &confirm_delete },
{ "confirm_overwrite", &confirm_overwrite },
{ "confirm_execute", &confirm_execute },
@ -179,11 +190,9 @@ static const struct {
#endif /* !HAVE_CHARSET */
{ "use_8th_bit_as_meta", &use_8th_bit_as_meta },
{ "confirm_view_dir", &confirm_view_dir },
{ "mouse_move_pages", &mouse_move_pages },
{ "mouse_move_pages_viewer", &mcview_mouse_move_pages },
{ "mouse_close_dialog", &mouse_close_dialog},
{ "fast_refresh", &fast_refresh },
{ "navigate_with_arrows", &navigate_with_arrows },
{ "drop_menus", &drop_menus },
{ "wrap_mode", &mcview_global_wrap_mode},
{ "old_esc_mode", &old_esc_mode },
@ -195,10 +204,10 @@ static const struct {
{ "alternate_plus_minus", &alternate_plus_minus },
{ "only_leading_plus_minus", &only_leading_plus_minus },
{ "show_output_starts_shell", &output_starts_shell },
{ "panel_scroll_pages", &panel_scroll_pages },
{ "xtree_mode", &xtree_mode },
{ "num_history_items_recorded", &num_history_items_recorded },
{ "file_op_compute_totals", &file_op_compute_totals },
{ "classic_progressbar", &classic_progressbar},
#ifdef ENABLE_VFS
{ "vfs_timeout", &vfs_timeout },
#ifdef USE_NETCODE
@ -235,7 +244,6 @@ static const struct {
{ "editor_check_new_line", &option_check_nl_at_eof },
{ "editor_show_right_margin", &show_right_margin },
#endif /* USE_INTERNAL_EDIT */
{ "nice_rotating_dash", &nice_rotating_dash },
{ "horizontal_split", &horizontal_split },
{ "mcview_remember_file_position", &mcview_remember_file_position },
@ -244,7 +252,7 @@ static const struct {
{ "copymove_persistent_attr", &setup_copymove_persistent_attr },
{ "select_flags", &select_flags },
{ "quick_search_case_sensitive", &quick_search_case_sensitive },
{ 0, 0 }
{ NULL, NULL }
};
static const struct
@ -267,15 +275,16 @@ static const struct
Get name of config file.
\param subdir
if not NULL, then config also search into specified subdir
if not NULL, then config also search into specified subdir.
\param config_file_name
If specified filename is relative, then will search in standart patches.
\return
Newly allocated path to config name or NULL if file not found
Newly allocated path to config name or NULL if file not found.
If config_file_name is a relative path, then search config in stantart pathes */
If config_file_name is a relative path, then search config in stantart pathes.
*/
static char *
load_setup_get_full_config_name (const char *subdir, const char *config_file_name)
{
@ -340,9 +349,9 @@ static const char *
setup__is_cfg_group_must_panel_config (const char *grp)
{
return (!strcasecmp ("Dirs", grp) ||
!strcasecmp ("Temporal:New Right Panel", grp) ||
!strcasecmp ("Temporal:New Left Panel", grp) ||
!strcasecmp ("New Left Panel", grp) || !strcasecmp ("New Right Panel", grp))
!strcasecmp ("Temporal:New Right Panel", grp) ||
!strcasecmp ("Temporal:New Left Panel", grp) ||
!strcasecmp ("New Left Panel", grp) || !strcasecmp ("New Right Panel", grp))
? grp : NULL;
}
@ -428,7 +437,7 @@ load_layout (void)
for (i = 0; layout[i].opt_name != NULL; i++)
*layout[i].opt_addr = mc_config_get_int (mc_main_config, "Layout",
layout[i].opt_name, *layout[i].opt_addr);
layout[i].opt_name, *layout[i].opt_addr);
}
static void
@ -635,6 +644,7 @@ panel_save_type (const char *section, panel_view_mode_t type)
break;
}
}
/*** public functions **************************************************/
char *
@ -714,6 +724,7 @@ load_setup (void)
str_options[i].opt_defval);
load_layout ();
panels_load_options ();
load_panelize ();
startup_left_mode = setup__load_panel_state ("New Left Panel");
@ -796,6 +807,7 @@ save_setup (void)
save_config ();
save_layout ();
panels_save_options ();
save_hotlist ();
save_panelize ();
save_panel_types ();
@ -1140,8 +1152,7 @@ save_panel_types (void)
if (mc_run_mode != MC_RUN_FULL)
return;
if (!mc_config_get_int (mc_main_config, CONFIG_APP_SECTION,
"auto_save_setup_panels", auto_save_setup))
if (!panels_options.auto_save_setup)
return;
type = get_display_type (0);
@ -1167,3 +1178,121 @@ save_panel_types (void)
mc_config_save_file (mc_panels_config, NULL);
}
/**
Load panels options from section.
*/
void
panels_load_options (void)
{
const char *section = "Panels";
/* Backward compatibility: load old parameters */
panels_options.mix_all_files =
mc_config_get_int (mc_main_config, CONFIG_APP_SECTION, "mix_all_files",
panels_options.mix_all_files);
panels_options.show_backups =
mc_config_get_int (mc_main_config, CONFIG_APP_SECTION, "show_backups",
panels_options.show_backups);
panels_options.show_dot_files =
mc_config_get_int (mc_main_config, CONFIG_APP_SECTION, "show_dot_files",
panels_options.show_dot_files);
panels_options.fast_reload =
mc_config_get_int (mc_main_config, CONFIG_APP_SECTION, "fast_reload",
panels_options.fast_reload);
panels_options.fast_reload_msg_shown =
mc_config_get_int (mc_main_config, CONFIG_APP_SECTION, "fast_reload",
panels_options.fast_reload_msg_shown);
panels_options.mark_moves_down =
mc_config_get_int (mc_main_config, CONFIG_APP_SECTION, "mark_moves_down",
panels_options.mark_moves_down);
panels_options.navigate_with_arrows =
mc_config_get_int (mc_main_config, CONFIG_APP_SECTION, "navigate_with_arrows",
panels_options.navigate_with_arrows);
panels_options.kilobyte_si =
mc_config_get_int (mc_main_config, CONFIG_APP_SECTION, "kilobyte_si",
panels_options.kilobyte_si);
panels_options.scroll_pages =
mc_config_get_int (mc_main_config, CONFIG_APP_SECTION, "panel_scroll_pages",
panels_options.scroll_pages);
panels_options.mouse_move_pages =
mc_config_get_int (mc_main_config, CONFIG_APP_SECTION, "mouse_move_pages",
panels_options.mouse_move_pages);
panels_options.auto_save_setup =
mc_config_get_int (mc_main_config, CONFIG_APP_SECTION, "auto_save_setup_panels",
panels_options.auto_save_setup);
panels_options.filetype_mode =
mc_config_get_int (mc_main_config, CONFIG_APP_SECTION, "filetype_mode",
panels_options.filetype_mode);
panels_options.permission_mode =
mc_config_get_int (mc_main_config, CONFIG_APP_SECTION, "permission_mode",
panels_options.permission_mode);
/* overwrite by new parameters */
if (mc_config_has_group (mc_main_config, section))
{
panels_options.mix_all_files =
mc_config_get_bool (mc_main_config, section, "mix_all_files",
panels_options.mix_all_files);
panels_options.show_backups =
mc_config_get_bool (mc_main_config, section, "show_backups",
panels_options.show_backups);
panels_options.show_dot_files =
mc_config_get_bool (mc_main_config, section, "show_dot_files",
panels_options.show_dot_files);
panels_options.fast_reload =
mc_config_get_bool (mc_main_config, section, "fast_reload", panels_options.fast_reload);
panels_options.fast_reload_msg_shown =
mc_config_get_bool (mc_main_config, section, "fast_reload_msg_shown",
panels_options.fast_reload_msg_shown);
panels_options.mark_moves_down =
mc_config_get_bool (mc_main_config, section, "mark_moves_down",
panels_options.mark_moves_down);
panels_options.navigate_with_arrows =
mc_config_get_bool (mc_main_config, section, "navigate_with_arrows",
panels_options.navigate_with_arrows);
panels_options.kilobyte_si =
mc_config_get_bool (mc_main_config, section, "kilobyte_si", panels_options.kilobyte_si);
panels_options.scroll_pages =
mc_config_get_bool (mc_main_config, section, "scroll_pages",
panels_options.scroll_pages);
panels_options.mouse_move_pages =
mc_config_get_bool (mc_main_config, section, "mouse_move_pages",
panels_options.mouse_move_pages);
panels_options.auto_save_setup =
mc_config_get_bool (mc_main_config, section, "auto_save_setup",
panels_options.auto_save_setup);
panels_options.filetype_mode =
mc_config_get_bool (mc_main_config, section, "filetype_mode",
panels_options.filetype_mode);
panels_options.permission_mode =
mc_config_get_bool (mc_main_config, section, "permission_mode",
panels_options.permission_mode);
}
}
/**
Save panels options in [Panels] section.
*/
void
panels_save_options (void)
{
const char *section = "Panels";
mc_config_set_bool (mc_main_config, section, "mix_all_files", panels_options.mix_all_files);
mc_config_set_bool (mc_main_config, section, "show_backups", panels_options.show_backups);
mc_config_set_bool (mc_main_config, section, "show_dot_files", panels_options.show_dot_files);
mc_config_set_bool (mc_main_config, section, "fast_reload", panels_options.fast_reload);
mc_config_set_bool (mc_main_config, section, "fast_reload_msg_shown",
panels_options.fast_reload_msg_shown);
mc_config_set_bool (mc_main_config, section, "mark_moves_down", panels_options.mark_moves_down);
mc_config_set_bool (mc_main_config, section, "navigate_with_arrows",
panels_options.navigate_with_arrows);
mc_config_set_bool (mc_main_config, section, "kilobyte_si", panels_options.kilobyte_si);
mc_config_set_bool (mc_main_config, section, "scroll_pages", panels_options.scroll_pages);
mc_config_set_bool (mc_main_config, section, "mouse_move_pages",
panels_options.mouse_move_pages);
mc_config_set_bool (mc_main_config, section, "auto_save_setup", panels_options.auto_save_setup);
mc_config_set_bool (mc_main_config, section, "filetype_mode", panels_options.filetype_mode);
mc_config_set_bool (mc_main_config, section, "permission_mode", panels_options.permission_mode);
}

View File

@ -24,6 +24,7 @@ extern int reverse_files_only;
extern int select_flags;
extern int setup_copymove_persistent_attr;
extern int num_history_items_recorded;
extern int classic_progressbar;
char *setup_init (void);
void load_setup (void);
@ -43,6 +44,26 @@ void load_keymap_defs (void);
void free_keymap_defs (void);
/* panel setup */
typedef struct
{
gboolean mix_all_files; /* If FALSE then directories are shown separately from files */
gboolean show_backups; /* If TRUE, show files ending in ~ */
gboolean show_dot_files; /* If TRUE, show files starting with a dot */
gboolean fast_reload; /* If TRUE then use stat() on the cwd to determine directory changes */
gboolean fast_reload_msg_shown; /* Have we shown the fast-reload warning in the past? */
gboolean mark_moves_down; /* If TRUE, marking a files moves the cursor down */
gboolean navigate_with_arrows; /* If TRUE: l&r arrows are used to chdir if the input line is empty */
gboolean kilobyte_si; /* If TRUE, SI units (1000 based) will be used for larger units
* (kilobyte, megabyte, ...). If FALSE, binary units (1024 based) will be used */
gboolean scroll_pages; /* If TRUE, up/down keys scroll the pane listing by pages */
gboolean mouse_move_pages; /* Move page/item? When clicking on the top or bottom of a panel */
gboolean auto_save_setup;
gboolean filetype_mode; /* If TRUE - then add per file type hilighting */
gboolean permission_mode; /* If TRUE, we use permission hilighting */
} panels_options_t;
extern panels_options_t panels_options;
extern panel_view_mode_t startup_left_mode;
extern panel_view_mode_t startup_right_mode;
@ -50,4 +71,7 @@ void panel_load_setup (struct WPanel *panel, const char *section);
void panel_save_setup (struct WPanel *panel, const char *section);
void save_panel_types (void);
void panels_load_options (void);
void panels_save_options (void);
#endif /* MC_SETUP_H */

View File

@ -43,10 +43,11 @@
#include "lib/tty/key.h"
#include "lib/strutil.h"
#include "src/main.h"
#include "src/dialog.h" /* Dlg_head */
#include "src/charsets.h"
#include "src/widget.h" /* WButtonBar */
#include "src/charsets.h"
#include "src/setup.h" /* panels_options */
#include "src/main.h" /* source_codepage */
#include "internal.h"
#include "mcviewer.h"
@ -152,7 +153,7 @@ mcview_display_status (mcview_t * view)
}
else
{
size_trunc_len (buffer, 5, mcview_get_filesize (view), 0);
size_trunc_len (buffer, 5, mcview_get_filesize (view), 0, panels_options.kilobyte_si);
tty_printf ("%9lli/%s%s %s", view->dpy_end,
buffer, mcview_may_still_grow (view) ? "+" : " ",
#ifdef HAVE_CHARSET