panel_scroll_pages patch



heyhey, an updated version :)
(i've diffed it with cvs, hope it's okay now.)

panel_scroll_pages is now on by default, but still an option for those
who prefer the old way. starting in --slow mode also activates it.

furthermore, i've altered the way page up/down works a little. with
panel_scroll_pages activated, it works as in wincmd (or as in nc
flipped). eg: going up or down also moves your selection.
without the scroll_pages it just goes to the next/previous page without
moving your selection, like it used to. i did alter it a littlebit so it
always moves a full page (when near the top or bottom it didn't do so to
let your selection remain at the same position.) it's more logical this
way.

also drawing speeds may have improved slightly, because i did more
redrawing with paint_dir instead of using paint_panel in select_item.

let's hope i didn't screw up too much.
one thing i'm not sure about is the call x_adjust_top_file(panel);
in prev_page() and next_page(). what's this supposed to do?

greetz
-- 
Shiar            m00h  ( _ )
shiar shiar org     \  ~O o~__
shiar irc shiar net    (._.) |\
http://www.shiar.org     |_|_|
Index: main.c
===================================================================
RCS file: /cvs/gnome/mc/src/main.c,v
retrieving revision 1.185
diff -c -r1.185 main.c
*** main.c	25 Mar 2002 07:46:19 -0000	1.185
--- main.c	9 Apr 2002 20:22:36 -0000
***************
*** 129,134 ****
--- 129,137 ----
  /* 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,1732 ****
--- 1730,1736 ----
      
      if (baudrate () < 9600 || slow_terminal){
  	verbose = 0;
+ 	panel_scroll_pages = 1;
      }
      init_mouse ();
  
Index: main.h
===================================================================
RCS file: /cvs/gnome/mc/src/main.h,v
retrieving revision 1.29
diff -c -r1.29 main.h
*** main.h	17 Jan 2002 07:17:54 -0000	1.29
--- main.h	9 Apr 2002 20:22:37 -0000
***************
*** 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;
Index: option.c
===================================================================
RCS file: /cvs/gnome/mc/src/option.c,v
retrieving revision 1.15
diff -c -r1.15 option.c
*** option.c	3 Sep 2001 05:07:41 -0000	1.15
--- option.c	9 Apr 2002 20:22:38 -0000
***************
*** 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);
      }
Index: panel.h
===================================================================
RCS file: /cvs/gnome/mc/src/panel.h,v
retrieving revision 1.54
diff -c -r1.54 panel.h
*** panel.h	22 Jan 2002 23:16:21 -0000	1.54
--- panel.h	9 Apr 2002 20:22:39 -0000
***************
*** 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 ----
Index: screen.c
===================================================================
RCS file: /cvs/gnome/mc/src/screen.c,v
retrieving revision 1.109
diff -c -r1.109 screen.c
*** screen.c	6 Feb 2002 05:14:17 -0000	1.109
--- screen.c	9 Apr 2002 20:22:48 -0000
***************
*** 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 ----
***************
*** 1475,1484 ****
      if (panel->selected < 0)
  	panel->selected = 0;
  
!     if (panel->selected > panel->count-1)
  	panel->selected = panel->count - 1;
  
!     if (panel->top_file > panel->count-1){
  	repaint = 1;
  	panel->top_file = panel->count-1;
      }
--- 1472,1481 ----
      if (panel->selected < 0)
  	panel->selected = 0;
  
!     if (panel->selected >= panel->count)
  	panel->selected = panel->count - 1;
  
!     if (panel->top_file >= panel->count){
  	repaint = 1;
  	panel->top_file = panel->count-1;
      }
***************
*** 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,1553 ----
      unselect_item (panel);
      panel->selected++;
  
!     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);
  }
***************
*** 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);
--- 1560,1572 ----
  
      unselect_item (panel);
      panel->selected--;
!     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,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);
  }
  
--- 1576,1582 ----
  move_rel (WPanel *panel, int rel)
  {
      unselect_item (panel);
!     panel->selected = panel->selected + rel;
      select_item (panel);
  }
  
***************
*** 1686,1706 ****
      	return;
      unselect_item (panel);
      items = ITEMS (panel);
!     if (panel->top_file < items)
!     	items = panel->top_file;
      if (!items)
      	panel->selected = 0;
      else
      	panel->selected -= items;
!     panel->top_file -= items;
  
!     /* 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);
      paint_dir (panel);
  }
  
--- 1677,1698 ----
      	return;
      unselect_item (panel);
      items = ITEMS (panel);
!     if (!panel_scroll_pages) items--;
      if (!items)
      	panel->selected = 0;
      else
      	panel->selected -= items;
!     /* This keeps the selection in it's relative position */
!     if (panel->selected < 0) panel->selected = 0;
  
!     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);
  }
  
***************
*** 1723,1745 ****
      	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 (!items)
!     	panel->selected = panel->count - 1;
      else
!     	panel->selected += items;
!     panel->top_file += 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);
      paint_dir (panel);
  }
  
--- 1715,1739 ----
      	return;
      unselect_item (panel);
      items = ITEMS (panel);
!     if (!panel_scroll_pages) items--;
      if (!items)
! 	panel->selected = panel->count - 1;
      else
! 	panel->selected += items;
      /* This keeps the selection in it's relative position */
      if (panel->selected >= panel->count)
  	panel->selected = panel->count - 1;
! 
!     if (panel_scroll_pages){
! 	panel->top_file += items;
! 	if (panel->top_file > panel->count - items)
! 	    panel->top_file = panel->count - 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);
  }
  


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