Changeset 486688f for functions.c


Ignore:
Timestamp:
Sep 28, 2002, 1:14:45 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:
88736cb
Parents:
55a4578
Message:
Will attempt to keep the current message as close as possible
	     to the previous current message after an expunge.
"set <variable>" and "unset <variable>" now work for boolean variables.
	   (although I'm not totally happy with how I implemented it.)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r601a9e0 r486688f  
    397397  owl_messagelist *ml;
    398398  owl_view *v;
    399   int i, j;
     399  int lastmsgid=0;
    400400
    401401  curmsg=owl_global_get_curmsg(&g);
     
    403403  ml=owl_global_get_msglist(&g);
    404404
    405   /* just check to make sure we're in bounds... */
    406   if (curmsg>owl_view_get_size(v)-1) curmsg=owl_view_get_size(v)-1;
    407   if (curmsg<0) curmsg=0;
    408 
    409   /* first try to move to an undeleted message in the view */
    410405  m=owl_view_get_element(v, curmsg);
    411   if (owl_message_is_delete(m)) {
    412     /* try to find the next undeleted message */
    413     j=owl_view_get_size(v);
    414     for (i=curmsg+1; i<j; i++) {
    415       if (!owl_message_is_delete(owl_view_get_element(v, i))) {
    416         owl_global_set_curmsg(&g, i);
    417         break;
    418       }
    419     }
    420 
    421     /* if we weren't successful try to find one backwards */
    422     curmsg=owl_global_get_curmsg(&g);
    423     if (owl_message_is_delete(owl_view_get_element(v, curmsg))) {
    424       for (i=curmsg; i>0; i--) {
    425         if (!owl_message_is_delete(owl_view_get_element(v, i))) {
    426           owl_global_set_curmsg(&g, i);
    427           break;
    428         }
    429       }
    430     }
    431   }
     406  if (m) lastmsgid = owl_message_get_id(m);
    432407
    433408  /* expunge the message list */
     
    437412  owl_view_recalculate(v);
    438413
    439   if (curmsg>owl_view_get_size(v)-1) {
    440     owl_global_set_curmsg(&g, owl_view_get_size(v)-1);
    441     if (owl_global_get_curmsg(&g)<0) {
    442       owl_global_set_curmsg(&g, 0);
    443     }
    444     owl_function_calculate_topmsg(OWL_DIRECTION_NONE);
    445   }
    446 
     414  /* find where the new position should be
     415     (as close as possible to where we last where) */
     416  curmsg = owl_view_get_nearest_to_msgid(v, lastmsgid);
     417  if (curmsg>owl_view_get_size(v)-1) curmsg = owl_view_get_size(v)-1;
     418  if (curmsg<0) curmsg = 0;
     419  owl_global_set_curmsg(&g, curmsg);
     420  owl_function_calculate_topmsg(OWL_DIRECTION_NONE);
    447421  /* if there are no messages set the direction to down in case we
    448422     delete everything upwards */
Note: See TracChangeset for help on using the changeset viewer.