Changeset 59cf91c
- Timestamp:
- Aug 17, 2002, 1:21:17 PM (22 years ago)
- 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
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r1fd0b25 r59cf91c 8 8 renamed owl_fmtext_ztext_stylestrip to owl_function_ztext_styletsrip 9 9 and put it in functions.c 10 10 Attempts to stay near the current message when switching views. 11 When switching from an empty view to one we've previously 12 been in, the new current message position will attempt 13 to be close to the current position from the last 14 time we visited that view. 15 11 16 1.2.1 12 17 New framework for command handling. -
filter.c
r1aee7d9 r59cf91c 21 21 f->polarity=0; 22 22 f->color=OWL_COLOR_DEFAULT; 23 f->cachedmsgid=-1; 23 24 owl_list_create(&(f->fes)); 24 25 … … 95 96 int owl_filter_get_color(owl_filter *f) { 96 97 return(f->color); 98 } 99 100 void owl_filter_set_cachedmsgid(owl_filter *f, int cachedmsgid) { 101 f->cachedmsgid=cachedmsgid; 102 } 103 104 int owl_filter_get_cachedmsgid(owl_filter *f) { 105 return(f->cachedmsgid); 97 106 } 98 107 -
functions.c
r37c27cf r59cf91c 1667 1667 owl_view *v; 1668 1668 owl_filter *f; 1669 int curid=-1, newpos; 1670 owl_message *curm; 1669 1671 1670 1672 v=owl_global_get_current_view(&g); 1673 curm=owl_view_get_element(v, owl_global_get_curmsg(&g)); 1674 if (curm) { 1675 curid = owl_message_get_id(curm); 1676 owl_view_save_curmsgid(v, curid); 1677 } 1678 1671 1679 f=owl_global_get_filter(&g, filtname); 1672 1680 if (!f) { … … 1678 1686 owl_view_create(v, f); 1679 1687 1680 owl_global_set_curmsg(&g, 0); 1688 /* Figure out where to set the current message to. 1689 * - If the previous view had messages in it, go to the closest message 1690 * to the last message in that view. 1691 * - If the previous view was empty, attempts to restore the position 1692 * from the last time we were in that view. */ 1693 if (curm) { 1694 newpos = owl_view_get_nearest_to_msgid(v, curid); 1695 } else { 1696 newpos = owl_view_get_nearest_to_saved(v); 1697 } 1698 1699 owl_global_set_curmsg(&g, newpos); 1700 1681 1701 owl_global_set_curmsg_vert_offset(&g, 0); 1682 1702 owl_global_set_direction_downwards(&g); -
owl.h
r1fd0b25 r59cf91c 289 289 owl_list fes; /* filterelements */ 290 290 int color; 291 int cachedmsgid; /* cached msgid: should move into view eventually */ 291 292 } owl_filter; 292 293 -
view.c
r1aee7d9 r59cf91c 56 56 } 57 57 58 /* Returns the position in the view with a message closest 59 * to the passed msgid. */ 60 int 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 74 int 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. */ 82 void owl_view_save_curmsgid(owl_view *v, int curid) { 83 owl_filter_set_cachedmsgid(v->filter, curid); 84 } 85 58 86 char *owl_view_get_filtname(owl_view *v) { 59 87 return(owl_filter_get_name(v->filter));
Note: See TracChangeset
for help on using the changeset viewer.