panel_scroll_pages patch
Shiar
shiar at shiar.org
Wed Apr 10 14:18:22 UTC 2002
a few more thingies altered:
- fixed page up/down (it didn't update the mini status).
- an option to disable the panel header (Name Size MTime) in
Options|Layout|panel heaDer.
- the command line history icon [^] seems to have slight cosmetic
errors. in ncurses i've improved it a little, but it'll need more work.
--
Shiar m00h ( _ )
shiar at shiar.org \ ~O o~__
shiar at irc.shiar.net (._.) |\
http://www.shiar.org |_|_|
-------------- next part --------------
Index: src/layout.c
===================================================================
RCS file: /cvs/gnome/mc/src/layout.c,v
retrieving revision 1.35
diff -u -r1.35 layout.c
--- src/layout.c 6 Feb 2002 05:23:50 -0000 1.35
+++ src/layout.c 10 Apr 2002 14:03:29 -0000
@@ -93,6 +93,9 @@
int output_lines = 0;
/* Set if the command prompt is to be displayed */
+int panel_header = 1;
+
+/* Set if the command prompt is to be displayed */
int command_prompt = 1;
/* Set if the nice and usefull keybar is visible */
@@ -128,6 +131,7 @@
static int _equal_split;
static int _first_panel_size;
static int _menubar_visible;
+static int _panel_header;
static int _output_lines;
static int _command_prompt;
static int _keybar_visible;
@@ -169,6 +173,7 @@
{ N_("&Keybar visible"), &keybar_visible, 0, "k" },
{ N_("command &Prompt"), &command_prompt, 0, "p" },
{ N_("show &Mini status"), &show_mini_info, 0, "m" },
+ { N_("panel hea&Der"), &panel_header, 0, "hd" },
{ N_("menu&Bar visible"), &menubar_visible, 0, "me" },
{ N_("&Equal split"), &equal_split, 0, "eq" },
{ N_("pe&Rmissions"), &permission_mode, 0, "pr" },
@@ -233,8 +238,8 @@
if (_equal_split){
/* Turn equal split off */
_equal_split = 0;
- check_options [6].widget->state = check_options [6].widget->state & ~C_BOOL;
- dlg_select_widget (layout_dlg, check_options [6].widget);
+ check_options [7].widget->state = check_options [7].widget->state & ~C_BOOL;
+ dlg_select_widget (layout_dlg, check_options [7].widget);
dlg_select_widget (layout_dlg, bleft_widget);
}
_first_panel_size++;
@@ -246,8 +251,8 @@
if (_equal_split){
/* Turn equal split off */
_equal_split = 0;
- check_options [6].widget->state = check_options [6].widget->state & ~C_BOOL;
- dlg_select_widget (layout_dlg, check_options [6].widget);
+ check_options [7].widget->state = check_options [7].widget->state & ~C_BOOL;
+ dlg_select_widget (layout_dlg, check_options [7].widget);
dlg_select_widget (layout_dlg, bright_widget);
}
_first_panel_size--;
@@ -300,19 +305,20 @@
if (old_output_lines != _output_lines){
old_output_lines = _output_lines;
attrset (COLOR_NORMAL);
- dlg_move (h, 9, 16 + first_width);
+ dlg_move (h, 10, 16 + first_width);
addstr (output_lines_label);
- dlg_move (h, 9, 10 + first_width);
+ dlg_move (h, 10, 10 + first_width);
printw ("%02d", _output_lines);
}
}
break;
case DLG_POST_KEY:
- _filetype_mode = check_options [8].widget->state & C_BOOL;
- _permission_mode = check_options [7].widget->state & C_BOOL;
- _equal_split = check_options [6].widget->state & C_BOOL;
- _menubar_visible = check_options [5].widget->state & C_BOOL;
+ _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;
+ _panel_header = check_options [5].widget->state & C_BOOL;
_command_prompt = check_options [4].widget->state & C_BOOL;
_keybar_visible = check_options [2].widget->state & C_BOOL;
_message_visible = check_options [1].widget->state & C_BOOL;
@@ -346,7 +352,7 @@
if (old_output_lines != _output_lines){
old_output_lines = _output_lines;
attrset (COLOR_NORMAL);
- dlg_move (h, 9, 10 + first_width);
+ dlg_move (h, 10, 10 + first_width);
printw ("%02d", _output_lines);
}
}
@@ -387,7 +393,7 @@
first_width = l1;
}
- for (i = 0; i <= 8; i++)
+ for (i = 0; i <= 9; i++)
{
check_options[i].text = _(check_options[i].text);
l1 = strlen (check_options[i].text) + 7;
@@ -405,7 +411,7 @@
second_width = strlen (title3) + 1;
- for (i = 0; i < 6; i++)
+ for (i = 0; i < 7; i++)
{
check_options[i].text = _(check_options[i].text);
l1 = strlen (check_options[i].text) + 7;
@@ -454,28 +460,29 @@
button_new (BY, b1, B_ENTER, DEFPUSH_BUTTON, ok_button, 0, 0, "o"));
if (console_flag){
add_widget (layout_dlg,
- button_new (9, 12 + first_width, B_MINUS, NARROW_BUTTON, "&-",
+ button_new (10, 12 + first_width, B_MINUS, NARROW_BUTTON, "&-",
bminus_cback, 0, NULL));
add_widget (layout_dlg,
- button_new (9, 7 + first_width, B_PLUS, NARROW_BUTTON, "&+",
+ button_new (10, 7 + first_width, B_PLUS, NARROW_BUTTON, "&+",
bplus_cback, 0, NULL));
}
#define XTRACT(i) *check_options[i].variable, check_options[i].text, check_options[i].tkname
- for (i = 0; i < 6; i++){
- check_options [i].widget = check_new (8 - i, 7 + first_width, XTRACT(i));
+ for (i = 0; i < 7; i++){
+ check_options [i].widget = check_new (9 - i, 7 + first_width, XTRACT(i));
add_widget (layout_dlg, check_options [i].widget);
}
- check_options [8].widget = check_new (10, 6, XTRACT(8));
+ 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);
- check_options [7].widget = check_new (9, 6, XTRACT(7));
- add_widget (layout_dlg, check_options [7].widget);
_filetype_mode = filetype_mode;
_permission_mode = permission_mode;
_equal_split = equal_split;
_menubar_visible = menubar_visible;
+ _panel_header = panel_header;
_command_prompt = command_prompt;
_keybar_visible = keybar_visible;
_message_visible = message_visible;
@@ -484,14 +491,14 @@
add_widget (layout_dlg, bright_widget);
bleft_widget = button_new (6, 9, B_2LEFT, NARROW_BUTTON, "&<", b2left_cback, 0, "<");
add_widget (layout_dlg, bleft_widget);
- check_options [6].widget = check_new (5, 6, XTRACT(6));
+ 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 [6].widget);
+ add_widget (layout_dlg, check_options [7].widget);
radio_widget = radio_new (3, 6, 2, s_split_direction, 1, "r");
add_widget (layout_dlg, radio_widget);
radio_widget->sel = horizontal_split;
@@ -666,7 +673,12 @@
widget_set_size (&cmdline->input.widget,
LINES-1-keybar_visible, promptl,
1, COLS-promptl-(keybar_visible ? 0 : 1));
- winput_set_origin (&cmdline->input, promptl, COLS-promptl-(keybar_visible ? 0 : 1));
+ #ifdef HAVE_SLANG
+ winput_set_origin (&cmdline->input, promptl,
+ COLS-promptl-(keybar_visible ? 0 : 1));
+ #else
+ winput_set_origin (&cmdline->input, promptl, COLS-promptl);
+ #endif
widget_set_size (&the_prompt->widget,
LINES-1-keybar_visible, 0,
1, promptl);
Index: src/layout.h
===================================================================
RCS file: /cvs/gnome/mc/src/layout.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 layout.h
--- src/layout.h 27 Feb 1998 04:54:43 -0000 1.1.1.1
+++ src/layout.h 10 Apr 2002 14:03:29 -0000
@@ -29,6 +29,7 @@
extern int equal_split;
extern int first_panel_size;
extern int output_lines;
+extern int panel_header;
extern int command_prompt;
extern int keybar_visible;
extern int layout_do_change;
Index: src/main.c
===================================================================
RCS file: /cvs/gnome/mc/src/main.c,v
retrieving revision 1.185
diff -u -r1.185 main.c
--- src/main.c 25 Mar 2002 07:46:19 -0000 1.185
+++ src/main.c 10 Apr 2002 14:03:34 -0000
@@ -129,6 +129,9 @@
/* they do a complete refresh, refreshing all the parts of the program */
int fast_refresh = 0;
+/* If true, scolls panels no more than one file at a time */
+int panel_scroll_pages = 0;
+
/* If true, marking a files moves the cursor down */
int mark_moves_down = 1;
@@ -1727,6 +1730,7 @@
if (baudrate () < 9600 || slow_terminal){
verbose = 0;
+ panel_scroll_pages = 1;
}
init_mouse ();
Index: src/main.h
===================================================================
RCS file: /cvs/gnome/mc/src/main.h,v
retrieving revision 1.29
diff -u -r1.29 main.h
--- src/main.h 17 Jan 2002 07:17:54 -0000 1.29
+++ src/main.h 10 Apr 2002 14:03:35 -0000
@@ -34,6 +34,7 @@
void subshell_chdir (char *command);
/* See main.c for details on these variables */
+extern int panel_scroll_pages;
extern int mark_moves_down;
extern int auto_menu;
extern int pause_after_run;
Index: src/option.c
===================================================================
RCS file: /cvs/gnome/mc/src/option.c,v
retrieving revision 1.15
diff -u -r1.15 option.c
--- src/option.c 3 Sep 2001 05:07:41 -0000 1.15
+++ src/option.c 10 Apr 2002 14:03:35 -0000
@@ -80,11 +80,12 @@
{N_("auto m&Enus"), &auto_menu, TOGGLE_VARIABLE, 0, "auto-menus" },
{N_("&Auto save setup"), &auto_save_setup, TOGGLE_VARIABLE, 0, "auto-save" },
{N_("shell &Patterns"), &easy_patterns, TOGGLE_VARIABLE, 0, "shell-patt" },
- {N_("Compute &Totals"), &file_op_compute_totals, TOGGLE_VARIABLE, 0, "compute-totals" },
+ {N_("Compute &Totals"), &file_op_compute_totals,TOGGLE_VARIABLE, 0, "compute-totals" },
{N_("&Verbose operation"), &verbose, TOGGLE_VARIABLE, 0, "verbose" },
{N_("&Fast dir reload"), &fast_reload, toggle_fast_reload, 0, "fast-reload" },
{N_("mi&X all files"), &mix_all_files, toggle_mix_all_files, 0, "mix-files" },
{N_("&Drop down menus"), &drop_menus, TOGGLE_VARIABLE, 0, "drop-menus" },
+ {N_("scroll paged"), &panel_scroll_pages,TOGGLE_VARIABLE, 0, "panel-scroll-pages" },
{N_("ma&Rk moves down"), &mark_moves_down, TOGGLE_VARIABLE, 0, "mark-moves" },
{N_("show &Hidden files"), &show_dot_files, toggle_show_hidden, 0, "show-hidden" },
{N_("show &Backup files"), &show_backups, toggle_show_backup, 0, "show-backup" },
@@ -95,8 +96,8 @@
static char *pause_options [3] = {
N_("&Never"),
- N_("on dumb &Terminals"),
- N_("alwa&Ys") };
+ N_("on dumb terminals"),
+ N_("always") };
static int configure_callback (struct Dlg_head *h, int Id, int Msg)
{
@@ -105,7 +106,7 @@
attrset (COLOR_NORMAL);
dlg_erase (h);
draw_box (h, 1, 2, h->lines - 2, h->cols - 4);
- draw_box (h, PY, PX, 8, first_width);
+ draw_box (h, PY, PX, 9, first_width);
draw_box (h, RY, RX, 5, first_width);
draw_box (h, OY, OX, 15, second_width);
@@ -148,7 +149,7 @@
title3 = _(" Other options ");
first_width = strlen (title1) + 1;
- for (i = 13; i < 19; i++)
+ for (i = 13; i < 20; i++)
{
check_options[i].text = _(check_options[i].text);
l1 = strlen (check_options[i].text) + 7;
@@ -221,8 +222,8 @@
pause_radio = radio_new (RY+1, RX+2, 3, pause_options, 1, "pause-radio");
pause_radio->sel = pause_after_run;
add_widget (conf_dlg, pause_radio);
- for (i = 0; i < 6; i++){
- check_options [i+13].widget = check_new (PY + (6-i), PX+2,
+ for (i = 0; i < 7; i++){
+ check_options [i+13].widget = check_new (PY + (7-i), PX+2,
XTRACT(i+13));
add_widget (conf_dlg, check_options [i+13].widget);
}
Index: src/panel.h
===================================================================
RCS file: /cvs/gnome/mc/src/panel.h,v
retrieving revision 1.54
diff -u -r1.54 panel.h
--- src/panel.h 22 Jan 2002 23:16:21 -0000 1.54
+++ src/panel.h 10 Apr 2002 14:03:36 -0000
@@ -136,7 +136,6 @@
extern int permission_mode;
extern int filetype_mode;
extern int show_mini_info;
-extern int panel_scroll_pages;
#define selection(p) (&(p->dir.list [p->selected]))
Index: src/screen.c
===================================================================
RCS file: /cvs/gnome/mc/src/screen.c,v
retrieving revision 1.109
diff -u -r1.109 screen.c
--- src/screen.c 6 Feb 2002 05:14:17 -0000 1.109
+++ src/screen.c 10 Apr 2002 14:03:40 -0000
@@ -61,9 +61,6 @@
/* 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;
@@ -86,7 +83,7 @@
#define x_reset_sort_labels(x)
/* This macro extracts the number of available lines in a panel */
-#define llines(p) (p->widget.lines-3 - (show_mini_info ? 2 : 0))
+#define llines(p) (p->widget.lines - 2 - panel_header - (show_mini_info ? 2 : 0))
#ifdef PORT_NOT_FOCUS_SELECT_ITEM
# define focus_select_item(x)
@@ -594,11 +591,11 @@
if (mv){
if (!isstatus && panel->split){
widget_move (&panel->widget,
- (file_index - panel->top_file) %
- llines (panel) + 2,
- (offset + 1));
+ (file_index - panel->top_file) % llines (panel) + panel_header + 1,
+ (offset + 1));
} else
- widget_move (&panel->widget, file_index - panel->top_file + 2, 1);
+ widget_move (&panel->widget,
+ file_index - panel->top_file + panel_header + 1, 1);
}
format_file (buffer, sizeof(buffer), panel, file_index, width, attr, isstatus);
@@ -619,7 +616,7 @@
if (!show_mini_info)
return;
- widget_move (&panel->widget, llines (panel)+3, 1);
+ widget_move (&panel->widget, panel->widget.lines - 2, 1);
if (panel->searching){
attrset (INPUT_COLOR);
@@ -636,7 +633,7 @@
attrset (MARKED_COLOR);
printw ("%*s", cols, " ");
- widget_move (&panel->widget, llines (panel)+3, 1);
+ widget_move (&panel->widget, panel->widget.lines - 2, 1);
/* FIXME: use ngettext() here when gettext-0.10.35 becomes history */
g_snprintf (buffer, sizeof (buffer), (panel->marked == 1) ?
_("%s bytes in %d file") : _("%s bytes in %d files"),
@@ -703,7 +700,7 @@
return;
standend ();
- widget_move (&panel->widget, llines (panel)+2, 1);
+ widget_move (&panel->widget, panel->widget.lines - 3, 1);
#ifdef HAVE_SLANG
attrset (NORMAL_COLOR);
hline (ACS_HLINE, panel->widget.cols-2);
@@ -1040,48 +1037,50 @@
widget_erase (&panel->widget);
show_dir (panel);
- widget_move (&panel->widget, 1, 1);
+ if (panel_header){
+ widget_move (&panel->widget, 1, 1);
- for (side = 0; side <= panel->split; side++){
- format_e *format;
+ for (side = 0; side <= panel->split; side++){
+ format_e *format;
- if (side){
- attrset (NORMAL_COLOR);
- one_vline ();
- width = panel->widget.cols - panel->widget.cols/2 - 1;
- } else if (panel->split)
- width = panel->widget.cols/2 - 3;
- else
- width = panel->widget.cols - 2;
+ if (side){
+ attrset (NORMAL_COLOR);
+ one_vline ();
+ width = panel->widget.cols - panel->widget.cols/2 - 1;
+ } else if (panel->split)
+ width = panel->widget.cols/2 - 3;
+ else
+ width = panel->widget.cols - 2;
+
+ for (format = panel->format; format; format = format->next){
+ if (format->string_fn){
+ txt = format->title;
- for (format = panel->format; format; format = format->next){
- if (format->string_fn){
- txt = format->title;
-
- header_len = strlen (txt);
- if (header_len > format->field_len){
- strcpy (buffer, txt);
- txt = buffer;
- txt [format->field_len] = 0;
header_len = strlen (txt);
+ if (header_len > format->field_len){
+ strcpy (buffer, txt);
+ txt = buffer;
+ txt [format->field_len] = 0;
+ header_len = strlen (txt);
+ }
+
+ attrset (MARKED_COLOR);
+ spaces = (format->field_len - header_len) / 2;
+ extra = (format->field_len - header_len) % 2;
+ printw ("%*s%-s%*s", spaces, "",
+ txt, spaces+extra, "");
+ width -= 2 * spaces + extra + header_len;
+ } else {
+ attrset (NORMAL_COLOR);
+ one_vline ();
+ width --;
+ continue;
}
-
- attrset (MARKED_COLOR);
- spaces = (format->field_len - header_len) / 2;
- extra = (format->field_len - header_len) % 2;
- printw ("%*s%-s%*s", spaces, "",
- txt, spaces+extra, "");
- width -= 2 * spaces + extra + header_len;
- } else {
- attrset (NORMAL_COLOR);
- one_vline ();
- width --;
- continue;
}
- }
- if (width > 0)
- printw ("%*s", width, "");
+ if (width > 0)
+ printw ("%*s", width, "");
+ }
}
}
@@ -1475,10 +1474,10 @@
if (panel->selected < 0)
panel->selected = 0;
- if (panel->selected > panel->count-1)
+ if (panel->selected >= panel->count)
panel->selected = panel->count - 1;
- if (panel->top_file > panel->count-1){
+ if (panel->top_file >= panel->count){
repaint = 1;
panel->top_file = panel->count-1;
}
@@ -1541,14 +1540,16 @@
unselect_item (panel);
panel->selected++;
- if (panel->selected - panel->top_file == ITEMS (panel) &&
- panel_scroll_pages){
- /* Scroll window half screen */
- panel->top_file += ITEMS (panel)/2;
- if (panel->top_file > panel->count - ITEMS (panel))
+ if (panel->selected - panel->top_file == ITEMS (panel)){
+ if (panel_scroll_pages){
+ /* Scroll window half screen */
+ panel->top_file += ITEMS (panel)/2;
+ /* w/o the following select_item will correct and redraw */
+ if (panel->top_file > panel->count - ITEMS (panel))
panel->top_file = panel->count - ITEMS (panel);
+ } else panel->top_file++;
+ /* scroll dir (faster than allowing select_item to do so) */
paint_dir (panel);
- select_item (panel);
}
select_item (panel);
}
@@ -1561,10 +1562,13 @@
unselect_item (panel);
panel->selected--;
- if (panel->selected < panel->top_file && panel_scroll_pages){
- /* Scroll window half screen */
- panel->top_file -= ITEMS (panel)/2;
- if (panel->top_file < 0) panel->top_file = 0;
+ if (panel->selected < panel->top_file){
+ if (panel_scroll_pages){
+ /* Scroll window half screen */
+ panel->top_file -= ITEMS (panel)/2;
+ if (panel->top_file < 0) panel->top_file = 0;
+ } else panel->top_file--;
+ /* scroll dir (faster than allowing select_item to do so) */
paint_dir (panel);
}
select_item (panel);
@@ -1574,18 +1578,7 @@
move_rel (WPanel *panel, int rel)
{
unselect_item (panel);
-
- if (rel < 0){
- if (panel->selected + rel < 0)
- panel->selected = 0;
- else
- panel->selected = panel->selected + rel;
- } else {
- if (panel->selected + rel >= panel->count)
- panel->selected = panel->count - 1;
- else
- panel->selected = panel->selected + rel;
- }
+ panel->selected = panel->selected + rel;
select_item (panel);
}
@@ -1686,22 +1679,24 @@
return;
unselect_item (panel);
items = ITEMS (panel);
- if (panel->top_file < items)
- items = panel->top_file;
+ if (!panel_scroll_pages) items--;
if (!items)
panel->selected = 0;
else
panel->selected -= items;
- panel->top_file -= items;
+ /* This keeps the selection in it's relative position */
+ if (panel->selected < 0) panel->selected = 0;
- /* This keeps the selection in a reasonable place */
- if (panel->selected < 0)
- panel->selected = 0;
- if (panel->top_file < 0)
- panel->top_file = 0;
- x_adjust_top_file (panel);
- select_item (panel);
+ if (panel_scroll_pages){
+ panel->top_file -= items;
+ if (panel->top_file < 0) panel->top_file = 0;
+ } else {
+ panel->top_file = panel->selected;
+ }
+
+// x_adjust_top_file (panel); //what's this??
paint_dir (panel);
+ select_item (panel);
}
static void
@@ -1723,24 +1718,27 @@
return;
unselect_item (panel);
items = ITEMS (panel);
- if (panel->top_file > panel->count - 2 * items)
- items = panel->count - items - panel->top_file;
- if (panel->top_file + items < 0)
- items = - panel->top_file;
+ if (!panel_scroll_pages) items--;
if (!items)
- panel->selected = panel->count - 1;
+ panel->selected = panel->count - 1;
else
- panel->selected += items;
- panel->top_file += items;
-
+ panel->selected += items;
/* This keeps the selection in it's relative position */
if (panel->selected >= panel->count)
panel->selected = panel->count - 1;
- if (panel->top_file >= panel->count)
- panel->top_file = panel->count - 1;
- x_adjust_top_file (panel);
- select_item (panel);
+
+ if (panel_scroll_pages){
+ panel->top_file += items;
+ if (panel->top_file > panel->count - 1)
+ panel->top_file = panel->count - 1; //items;
+ } else {
+ panel->top_file = panel->selected - items;
+ if (panel->top_file < 0) panel->top_file = 0;
+ }
+
+// x_adjust_top_file (panel); //what's this??
paint_dir (panel);
+ select_item (panel);
}
static void next_page_key (WPanel *panel)
Index: src/setup.c
===================================================================
RCS file: /cvs/gnome/mc/src/setup.c,v
retrieving revision 1.58
diff -u -r1.58 setup.c
--- src/setup.c 4 Feb 2002 18:09:42 -0000 1.58
+++ src/setup.c 10 Apr 2002 14:03:42 -0000
@@ -135,6 +135,7 @@
{ "xterm_hintbar", &xterm_hintbar },
{ "output_lines", &output_lines },
{ "command_prompt", &command_prompt },
+ { "panel_header", &panel_header },
{ "menubar_visible", &menubar_visible },
{ "show_mini_info", &show_mini_info },
{ "permission_mode", &permission_mode },
More information about the mc-devel
mailing list