panel scrolling



I just post this here because it's a personal itch of mine.

I have many programs that are essentially list managers.

mc is one. xmms another. xmms I've abandoned for my own music player,
but mc I keep using. It's so *effective* at getting shit done.

That said, I have peeve that's been going on since 1983:

One thing I despise is a list manager that, when you hit the down arrow,
the cursor goes to the bottom of the window and *then* starts scrolling.

This drives me batty. I hate it. I cannot see what I'm going for. It's
like driving forward with a tarp over your windshield. mc does that silly
jump scroll thing which is better, but still sucks.

I have patch, I call panel_scroll_center, where the cursor *tends* to
stay in the center of the panel. If you scroll down, when the cursor hits
the middle of the panel, the panel starts scrolling. Only when the list
runs out does the cursor scroll to the bottom. Vice versa for up-scroll.

It's not a fancy patch, it's just a math issue in panels.c. This is the
first thing I always patch new versions with. Always.

Try it, you'll like it. It also demonstrates how easy it is to add new
option to mc these days.

[code]
--- src/setup.h~        2013-11-29 10:27:07.000000000 -0800
+++ src/setup.h 2013-12-02 09:42:32.720215654 -0800
@@ -48,6 +48,7 @@ typedef struct
gboolean navigate_with_arrows; /* If TRUE: l&r arrows are used to chdir if the input line is empty */ gboolean scroll_pages; /* If TRUE, panel is scrolled by half the display when the cursor reaches the end or the beginning of the panel */ + gboolean scroll_center; /* If TRUE, scroll when the cursor hits the middle of the panel */
     gboolean mouse_move_pages;  /* Scroll page/item using mouse wheel */
gboolean filetype_mode; /* If TRUE then add per file type hilighting */ gboolean permission_mode; /* If TRUE, we use permission hilighting */
--- src/setup.c~        2013-11-29 10:27:07.000000000 -0800
+++ src/setup.c 2013-12-02 09:44:08.287525675 -0800
@@ -142,6 +142,7 @@ panels_options_t panels_options = {
     .auto_save_setup = FALSE,
     .navigate_with_arrows = FALSE,
     .scroll_pages = TRUE,
+    .scroll_center = TRUE,
     .mouse_move_pages = TRUE,
     .filetype_mode = TRUE,
     .permission_mode = FALSE,
@@ -399,6 +400,7 @@ static const struct
     { "auto_save_setup_panels", &panels_options.auto_save_setup },
     { "navigate_with_arrows", &panels_options.navigate_with_arrows },
     { "panel_scroll_pages", &panels_options.scroll_pages },
+    { "panel_scroll_center", &panels_options.scroll_center },
     { "mouse_move_pages",  &panels_options.mouse_move_pages },
     { "filetype_mode", &panels_options.filetype_mode },
     { "permission_mode", &panels_options.permission_mode },
--- src/filemanager/boxes.c~    2013-11-29 10:27:07.000000000 -0800
+++ src/filemanager/boxes.c     2013-12-02 09:45:22.143627364 -0800
@@ -554,6 +554,7 @@ panel_options_box (void)
QUICK_CHECKBOX (N_("L&ynx-like motion"), &panels_options.navigate_with_arrows,
                                     NULL),
QUICK_CHECKBOX (N_("Pa&ge scrolling"), &panels_options.scroll_pages, NULL), + QUICK_CHECKBOX (N_("&Center scrolling"), &panels_options.scroll_center, NULL), QUICK_CHECKBOX (N_("&Mouse page scrolling"), &panels_options.mouse_move_pages,
                                     NULL),
                 QUICK_STOP_GROUPBOX,
--- src/filemanager/panel.c~    2013-11-29 10:27:07.000000000 -0800
+++ src/filemanager/panel.c     2013-12-02 09:47:46.553407483 -0800
@@ -2018,6 +2018,12 @@ move_down (WPanel * panel)
         if (panel->top_file > panel->dir.len - ITEMS (panel))
             panel->top_file = panel->dir.len - ITEMS (panel);
         paint_dir (panel);
+    } else if ( panels_options.scroll_center &&
+           (panel->selected - panel->top_file) > (ITEMS (panel)/2) ) {
+       /* Scroll window when cursor is halfway down */
+       panel->top_file++;
+       if (panel->top_file > panel->dir.len - ITEMS (panel))
+           panel->top_file = panel->dir.len - ITEMS (panel);
     }
     select_item (panel);
 }
@@ -2039,6 +2045,11 @@ move_up (WPanel * panel)
         if (panel->top_file < 0)
             panel->top_file = 0;
         paint_dir (panel);
+    } else if ( panels_options.scroll_center &&
+           panel->selected < (panel->top_file + ITEMS (panel)/2)) {
+       /* Scroll window when cursor is halfway up */
+        panel->top_file--;
+        if (panel->top_file < 0) panel->top_file = 0;
     }
     select_item (panel);
 }
[/code]

Merry Christmas.

--
Peace and Cheer


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