new patch: panel_scroll_pages option

Shiar shiar at shiar.org
Mon Apr 8 19:48:50 UTC 2002


y'ello everybody.

i just switched to mc from years of nc and wincmd. looks quite nice, and
i hope there's still some developers alive.

something i found annoying in mc is the 'jumpy' panel scrolling, instead
of simply one file at a time. that's why i added it, making it an option
selectable in Options > Configuration > Panel Options.

the diff's attached, and i hope it's good enough to get included in mc =)

l8r

-- 
Shiar            m00h  ( _ )
shiar at shiar.org     \  ~O o~__
shiar at irc.shiar.net    (._.) |\
http://www.shiar.org     |_|_|
-------------- next part --------------
diff -rct src.org/main.c src.shiar/main.c
*** src.org/main.c	Mon Mar 25 08:46:19 2002
--- src.shiar/main.c	Mon Apr  8 21:02:34 2002
***************
*** 129,134 ****
--- 129,137 ----
  /* they do a complete refresh, refreshing all the parts of the program */
  int fast_refresh = 0;
  
+ /* If true, up/down keys scroll the pane listing by pages */
+ int panel_scroll_pages = 1;
+ 
  /* If true, marking a files moves the cursor down */
  int   mark_moves_down = 1;
  
diff -rct src.org/main.h src.shiar/main.h
*** src.org/main.h	Thu Jan 17 08:17:54 2002
--- src.shiar/main.h	Mon Apr  8 21:02:59 2002
***************
*** 34,39 ****
--- 34,40 ----
  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;
diff -rct src.org/option.c src.shiar/option.c
*** src.org/option.c	Mon Sep  3 07:07:41 2001
--- src.shiar/option.c	Mon Apr  8 21:12:49 2002
***************
*** 80,90 ****
     {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_("&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_("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" },
--- 80,91 ----
     {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_("&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,102 ****
  
  static char *pause_options [3] = {
      N_("&Never"),
!     N_("on dumb &Terminals"),
!     N_("alwa&Ys") };
  
  static int configure_callback (struct Dlg_head *h, int Id, int Msg)
  {
--- 96,103 ----
  
  static char *pause_options [3] = {
      N_("&Never"),
!     N_("on dumb terminals"),
!     N_("always") };
  
  static int configure_callback (struct Dlg_head *h, int Id, int Msg)
  {
***************
*** 105,111 ****
          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, RY, RX, 5, first_width);
          draw_box (h, OY, OX, 15, second_width);
  
--- 106,112 ----
          attrset (COLOR_NORMAL);
          dlg_erase (h);
          draw_box (h, 1, 2, h->lines - 2, h->cols - 4);
!         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,154 ****
                  title3 = _(" Other options ");
  
                  first_width = strlen (title1) + 1;
!                 for (i = 13; i < 19; i++)
                  {
                          check_options[i].text = _(check_options[i].text);
                          l1 = strlen (check_options[i].text) + 7;
--- 149,155 ----
                  title3 = _(" Other options ");
  
                  first_width = strlen (title1) + 1;
!                 for (i = 13; i < 20; i++)
                  {
                          check_options[i].text = _(check_options[i].text);
                          l1 = strlen (check_options[i].text) + 7;
***************
*** 221,228 ****
      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,
                                                    XTRACT(i+13));
          add_widget (conf_dlg, check_options [i+13].widget);
      }
--- 222,229 ----
      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 < 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);
      }
diff -rct src.org/panel.h src.shiar/panel.h
*** src.org/panel.h	Wed Jan 23 00:16:21 2002
--- src.shiar/panel.h	Mon Apr  8 21:01:29 2002
***************
*** 136,142 ****
  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]))
  
--- 136,141 ----
diff -rct src.org/screen.c src.shiar/screen.c
*** src.org/screen.c	Wed Feb  6 06:14:17 2002
--- src.shiar/screen.c	Mon Apr  8 20:59:50 2002
***************
*** 61,69 ****
  /* 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;
  
--- 61,66 ----
***************
*** 1541,1554 ****
      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))
!                 panel->top_file = panel->count - ITEMS (panel);
          paint_dir (panel);
-         select_item (panel);
      }
      select_item (panel);
  }
--- 1538,1547 ----
      unselect_item (panel);
      panel->selected++;
  
!     if (panel->selected - panel->top_file == ITEMS (panel)){
!         if (panel_scroll_pages) panel->top_file += ITEMS (panel)/2;
!         else panel->top_file++;
          paint_dir (panel);
      }
      select_item (panel);
  }
***************
*** 1561,1570 ****
  
      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;
          paint_dir (panel);
      }
      select_item (panel);
--- 1554,1562 ----
  
      unselect_item (panel);
      panel->selected--;
!     if (panel->selected < panel->top_file){
!         if (panel_scroll_pages) panel->top_file -= ITEMS (panel)/2;
!         else panel->top_file--;
          paint_dir (panel);
      }
      select_item (panel);
***************
*** 1574,1591 ****
  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;
!     }
      select_item (panel);
  }
  
--- 1566,1573 ----
  move_rel (WPanel *panel, int rel)
  {
      unselect_item (panel);
!     if (rel < 0) panel->selected = panel->selected + rel;
!     else panel->selected = panel->selected + rel;
      select_item (panel);
  }
  
***************
*** 1595,1604 ****
  static void
  move_up (WPanel *panel)
  {
!     if (panel->list_type == list_icons){
          move_rel (panel, -ICONS_PER_ROW (panel));
!     } else
!         do_move_up (panel);
  }
  
  static void
--- 1577,1585 ----
  static void
  move_up (WPanel *panel)
  {
!     if (panel->list_type == list_icons)
          move_rel (panel, -ICONS_PER_ROW (panel));
!     else do_move_up (panel);
  }
  
  static void


More information about the mc-devel mailing list