Changeset aa2f33b3 for functions.c


Ignore:
Timestamp:
Jul 16, 2002, 9:55:47 PM (19 years ago)
Author:
Erik Nygren <nygren@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
f2e36b5
Parents:
e50cd56
Message:
	Variables now have a summary and a long description.
	        Only the summary is shown with help.
		The long description is shown with "show variable foo".
        Fix the scrolling bug where we would sometimes fail to scroll
             the screen down, leaving the current message off
             the bottom of the screen.
        Added a 'scrollmode' variable which determines how the screen
	     will scroll as the cursor moves.  The default behaves
	     identically to previous versions of owl.
             The following modes are supported:
	     normal      - This is the owl default.  Scrolling happens
	                   when it needs to, and an attempt is made to
	                   keep the current message roughly near
	                   the middle of the screen.  (default)
	     top         - The current message will always be the
	                   the top message displayed.
	     neartop     - The current message will be one down
	                   from the top message displayed,
	                   where possible.
	     center      - An attempt is made to keep the current
	                   message near the center of the screen.
	     paged       - The top message displayed only changes
	                   when user moves the cursor to the top
	                   or bottom of the screen.  When it moves,
	                   the screen will be paged up or down and
	                   the cursor will be near the top or
	                   the bottom.
	     pagedcenter - The top message displayed only changes
	                   when user moves the cursor to the top
	                   or bottom of the screen.  When it moves,
	                   the screen will be paged up or down and
	                   the cursor will be near the center.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    re50cd56 raa2f33b3  
    712712
    713713void owl_function_calculate_topmsg(int direction) {
    714   int recwinlines, y, savey, i, j, topmsg, curmsg, foo;
    715   owl_mainwin *mw;
     714  int recwinlines, topmsg, curmsg;
    716715  owl_view *v;
    717716
    718   mw=owl_global_get_mainwin(&g);
    719 
     717  v=owl_global_get_current_view(&g);
     718  curmsg=owl_global_get_curmsg(&g);
    720719  topmsg=owl_global_get_topmsg(&g);
    721   curmsg=owl_global_get_curmsg(&g);
    722   v=owl_global_get_current_view(&g);
    723720  recwinlines=owl_global_get_recwin_lines(&g);
    724721
     
    726723    return;
    727724  }
     725
     726  switch (owl_global_get_scrollmode(&g)) {
     727  case OWL_SCROLLMODE_TOP:
     728    topmsg = owl_function_calculate_topmsg_top(direction, v, curmsg,
     729                                               topmsg, recwinlines);
     730    break;
     731  case OWL_SCROLLMODE_NEARTOP:
     732    topmsg = owl_function_calculate_topmsg_neartop(direction, v, curmsg,
     733                                                   topmsg, recwinlines);
     734    break;
     735  case OWL_SCROLLMODE_CENTER:
     736    topmsg = owl_function_calculate_topmsg_center(direction, v, curmsg,
     737                                                  topmsg, recwinlines);
     738    break;
     739  case OWL_SCROLLMODE_PAGED:
     740    topmsg = owl_function_calculate_topmsg_paged(direction, v, curmsg,
     741                                                 topmsg, recwinlines, 0);
     742    break;
     743  case OWL_SCROLLMODE_PAGEDCENTER:
     744    topmsg = owl_function_calculate_topmsg_paged(direction, v, curmsg,
     745                                                 topmsg, recwinlines, 1);
     746    break;
     747  case OWL_SCROLLMODE_NORMAL:
     748  default:
     749    topmsg = owl_function_calculate_topmsg_normal(direction, v, curmsg,
     750                                                  topmsg, recwinlines);
     751  }
     752  owl_global_set_topmsg(&g, topmsg);
     753}
     754
     755/* Returns what the new topmsg should be. 
     756 * Passed the last direction of movement,
     757 * the current view,
     758 * the current message number in the view,
     759 * the top message currently being displayed,
     760 * and the number of lines in the recwin.
     761 */
     762int owl_function_calculate_topmsg_top(int direction, owl_view *v, int curmsg, int topmsg, int recwinlines) {
     763  return curmsg;
     764}
     765
     766int owl_function_calculate_topmsg_neartop(int direction, owl_view *v, int curmsg, int topmsg, int recwinlines) {
     767  if (curmsg>0
     768      && (owl_message_get_numlines(owl_view_get_element(v, curmsg-1))
     769          <  recwinlines/2)) {
     770    return curmsg-1;
     771  } else {
     772    return curmsg;
     773  }
     774}
     775 
     776int owl_function_calculate_topmsg_center(int direction, owl_view *v, int curmsg, int topmsg, int recwinlines) {
     777  int i, last, lines;
     778
     779  last = curmsg;
     780  lines = 0;
     781  for (i=curmsg-1; i>=0; i--) {
     782    lines += owl_message_get_numlines(owl_view_get_element(v, i));
     783    if (lines > recwinlines/2) break;
     784    last = i;
     785  }
     786  return last;
     787}
     788 
     789int owl_function_calculate_topmsg_paged(int direction, owl_view *v, int curmsg, int topmsg, int recwinlines, int center_on_page) {
     790  int i, last, lines, savey;
     791 
     792  /* If we're off the top of the screen, scroll up such that the
     793   * curmsg is near the botton of the screen. */
     794  if (curmsg < topmsg) {
     795    last = curmsg;
     796    lines = 0;
     797    for (i=curmsg; i>=0; i--) {
     798      lines += owl_message_get_numlines(owl_view_get_element(v, i));
     799      if (lines > recwinlines) break;
     800    last = i;
     801    }
     802    if (center_on_page) {
     803      return owl_function_calculate_topmsg_center(direction, v, curmsg, 0, recwinlines);
     804    } else {
     805      return last;
     806    }
     807  }
     808
     809  /* Find number of lines from top to bottom of curmsg (store in savey) */
     810  savey=0;
     811  for (i=topmsg; i<=curmsg; i++) {
     812    savey+=owl_message_get_numlines(owl_view_get_element(v, i));
     813  }
     814
     815  /* if we're off the bottom of the screen, scroll down */
     816  if (savey > recwinlines) {
     817    if (center_on_page) {
     818      return owl_function_calculate_topmsg_center(direction, v, curmsg, 0, recwinlines);
     819    } else {
     820      return curmsg;
     821    }
     822  }
     823
     824  /* else just stay as we are... */
     825  return topmsg;
     826}
     827
     828
     829int owl_function_calculate_topmsg_normal(int direction, owl_view *v, int curmsg, int topmsg, int recwinlines) {
     830  int savey, j, i, foo, y;
    728831 
    729832  /* Find number of lines from top to bottom of curmsg (store in savey) */
     
    761864      }
    762865      if (j<0) j=0;
    763       owl_global_set_topmsg(&g, j);
    764       return;
     866      return j;
    765867    }
    766868  }
     
    778880        j--;
    779881      }
    780       owl_global_set_topmsg(&g, j+1);
    781       return;
    782     }
    783   }
     882      return j+1;
     883    }
     884  }
     885
     886  return topmsg;
    784887}
    785888
     
    12191322      "Variables: (use 'show variable <name>' for details)\n");
    12201323  owl_variable_dict_get_names(owl_global_get_vardict(&g), &varnames);
    1221   owl_variable_get_summaryheader(&fm);
    12221324  numvarnames = owl_list_get_size(&varnames);
    12231325  for (i=0; i<numvarnames; i++) {
    12241326    varname = owl_list_get_element(&varnames, i);
    12251327    if (varname && varname[0]!='_') {
    1226       owl_variable_get_summary(owl_global_get_vardict(&g), varname, &fm);
     1328      owl_variable_describe(owl_global_get_vardict(&g), varname, &fm);
    12271329    }
    12281330  }
Note: See TracChangeset for help on using the changeset viewer.