Ticket #3130: patch-panel-scroll-center.diff

File patch-panel-scroll-center.diff, 4.0 KB (added by Miven, 11 years ago)

panel-scroll-center diff

  • doc/man/mc.1.in

    old new If set (the default), panel will scroll  
    20772077cursor reaches the end or the beginning of the panel, otherwise it 
    20782078will just scroll a file at a time. 
    20792079.PP 
     2080.I Center scrolling. 
     2081If set, panel will scroll when the cursor reaches the middle of the 
     2082panel, only hitting the top or bottom of the panel when actually on 
     2083the first or last file. This behavior applies when scrolling one file 
     2084at a time, and does not apply to the page up/down keys. 
     2085.PP 
    20802086.I Mouse page scrolling. 
    20812087Controls whenever scrolling with the mouse wheel is done by pages or 
    20822088line by line on the panels. 
  • src/setup.h

    old new typedef struct 
    4848    gboolean navigate_with_arrows;      /* If TRUE: l&r arrows are used to chdir if the input line is empty */ 
    4949    gboolean scroll_pages;      /* If TRUE, panel is scrolled by half the display when the cursor reaches 
    5050                                   the end or the beginning of the panel */ 
     51    gboolean scroll_center;     /* If TRUE, scroll when the cursor hits the middle of the panel */ 
    5152    gboolean mouse_move_pages;  /* Scroll page/item using mouse wheel */ 
    5253    gboolean filetype_mode;     /* If TRUE then add per file type hilighting */ 
    5354    gboolean permission_mode;   /* If TRUE, we use permission hilighting */ 
  • src/setup.c

    old new panels_options_t panels_options = { 
    142142    .auto_save_setup = FALSE, 
    143143    .navigate_with_arrows = FALSE, 
    144144    .scroll_pages = TRUE, 
     145    .scroll_center = FALSE, 
    145146    .mouse_move_pages = TRUE, 
    146147    .filetype_mode = TRUE, 
    147148    .permission_mode = FALSE, 
    static const struct 
    400401    { "auto_save_setup_panels", &panels_options.auto_save_setup }, 
    401402    { "navigate_with_arrows", &panels_options.navigate_with_arrows }, 
    402403    { "panel_scroll_pages", &panels_options.scroll_pages }, 
     404    { "panel_scroll_center", &panels_options.scroll_center }, 
    403405    { "mouse_move_pages",  &panels_options.mouse_move_pages }, 
    404406    { "filetype_mode", &panels_options.filetype_mode }, 
    405407    { "permission_mode", &panels_options.permission_mode }, 
  • src/filemanager/boxes.c

    old new panel_options_box (void) 
    554554                    QUICK_CHECKBOX (N_("L&ynx-like motion"), &panels_options.navigate_with_arrows, 
    555555                                    NULL), 
    556556                    QUICK_CHECKBOX (N_("Pa&ge scrolling"), &panels_options.scroll_pages, NULL), 
     557                    QUICK_CHECKBOX (N_("Center &scrolling"), &panels_options.scroll_center, NULL), 
    557558                    QUICK_CHECKBOX (N_("&Mouse page scrolling"), &panels_options.mouse_move_pages, 
    558559                                    NULL), 
    559560                QUICK_STOP_GROUPBOX, 
  • src/filemanager/panel.c

    old new move_down (WPanel * panel) 
    20192019            panel->top_file = panel->dir.len - ITEMS (panel); 
    20202020        paint_dir (panel); 
    20212021    } 
     2022    else if (panels_options.scroll_center && 
     2023             (panel->selected - panel->top_file) > (ITEMS (panel) / 2)) 
     2024    { 
     2025        /* Scroll window when cursor is halfway down */ 
     2026        panel->top_file++; 
     2027        if (panel->top_file > panel->dir.len - ITEMS (panel)) 
     2028            panel->top_file = panel->dir.len - ITEMS (panel); 
     2029    } 
    20222030    select_item (panel); 
    20232031} 
    20242032 
    move_up (WPanel * panel) 
    20402048            panel->top_file = 0; 
    20412049        paint_dir (panel); 
    20422050    } 
     2051    else if (panels_options.scroll_center && 
     2052             panel->selected < (panel->top_file + ITEMS (panel) / 2)) 
     2053    { 
     2054        /* Scroll window when cursor is halfway up */ 
     2055        panel->top_file--; 
     2056        if (panel->top_file < 0) 
     2057            panel->top_file = 0; 
     2058    } 
    20432059    select_item (panel); 
    20442060} 
    20452061