Changeset 59cf91c for view.c


Ignore:
Timestamp:
Aug 17, 2002, 1:21:17 PM (22 years ago)
Author:
Erik Nygren <nygren@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
67103d4
Parents:
37c27cf
Message:
	Attempts to stay near the current message when switching views.
	     When switching from an empty view to one we've previously
	     been in, the new current message position will attempt
	     to be close to the current position from the last
	     time we visited that view.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • view.c

    r1aee7d9 r59cf91c  
    5656}
    5757
     58/* Returns the position in the view with a message closest
     59 * to the passed msgid. */
     60int owl_view_get_nearest_to_msgid(owl_view *v, int targetid) {
     61  int i, bestdist=-1, bestpos=0, curid, curdist;
     62
     63  for (i=0; i<owl_view_get_size(v); i++) {
     64    curid = owl_message_get_id(owl_view_get_element(v, i));
     65    curdist = abs(targetid-curid);
     66    if (bestdist<0 || curdist<bestdist) {
     67      bestdist = curdist;
     68      bestpos = i;
     69    }
     70  }
     71  return bestpos;
     72}
     73
     74int owl_view_get_nearest_to_saved(owl_view *v) {
     75  int cachedid = owl_filter_get_cachedmsgid(v->filter);
     76  if (cachedid<0) return(0);
     77  return owl_view_get_nearest_to_msgid(v, cachedid);
     78}
     79
     80/* saves the current message position in the filter so it can
     81 * be restored later if we switch back to this filter. */
     82void owl_view_save_curmsgid(owl_view *v, int curid) {
     83  owl_filter_set_cachedmsgid(v->filter, curid);
     84}
     85
    5886char *owl_view_get_filtname(owl_view *v) {
    5987  return(owl_filter_get_name(v->filter));
Note: See TracChangeset for help on using the changeset viewer.