Changeset 3eeb6ed
- Timestamp:
- Jul 9, 2011, 4:11:44 PM (14 years ago)
- Branches:
- master, release-1.10, release-1.8, release-1.9
- Children:
- efeec7f
- Parents:
- 786a410
- git-author:
- Jason Gross <jgross@mit.edu> (06/24/11 00:06:56)
- git-committer:
- Jason Gross <jgross@mit.edu> (07/09/11 16:11:44)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
ra16d7e5 r3eeb6ed 721 721 } 722 722 723 /* returns the current message id, if it exists. Otherwise returns 724 * -1 if we are past the end of the message list, and 0 otherwise. */ 725 int owl_function_get_curmsg_id(const owl_view *v) 726 { 727 int curmsg = owl_global_get_curmsg(&g); 728 const owl_message *m = owl_view_get_element(v, curmsg); 729 if (m) 730 return owl_message_get_id(m); 731 if (curmsg > 0) /* past the end of the message list (probably) */ 732 return -1; 733 return 0; 734 } 735 736 /* redisplays the view to the nearest message to the id given. 737 * if msgid < 0, redisplay to past the end of the message list */ 738 void owl_function_redisplay_to_nearest(int msgid, owl_view *v) 739 { 740 int curmsg; 741 /* update all views (we only have one right now) */ 742 owl_view_recalculate(v); 743 744 /* find where the new position should be */ 745 if (msgid < 0) { 746 /* If already at the end, blank the screen and move curmsg 747 * past the end of the messages. */ 748 curmsg = owl_view_get_size(v); 749 owl_global_set_topmsg(&g, curmsg); 750 owl_global_set_curmsg(&g, curmsg); 751 } else { 752 curmsg = owl_view_get_nearest_to_msgid(v, msgid); 753 if (curmsg > owl_view_get_size(v) - 1) 754 curmsg = owl_view_get_size(v) - 1; 755 if (curmsg < 0) 756 curmsg = 0; 757 owl_global_set_curmsg(&g, curmsg); 758 owl_function_calculate_topmsg(OWL_DIRECTION_NONE); 759 } 760 /* if there are no messages set the direction to down in case we 761 * delete everything upwards */ 762 owl_global_set_direction_downwards(&g); 763 764 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 765 } 766 723 767 void owl_function_expunge(void) 724 768 { 725 int curmsg; 726 const owl_message *m; 727 owl_messagelist *ml; 728 owl_view *v; 729 int lastmsgid=0; 730 731 curmsg=owl_global_get_curmsg(&g); 732 v=owl_global_get_current_view(&g); 733 ml=owl_global_get_msglist(&g); 734 735 m=owl_view_get_element(v, curmsg); 736 if (m) lastmsgid = owl_message_get_id(m); 769 owl_messagelist *ml = owl_global_get_msglist(&g); 770 owl_view *v = owl_global_get_current_view(&g); 771 int lastmsgid = owl_function_get_curmsg_id(v); 737 772 738 773 /* expunge the message list */ 739 774 owl_messagelist_expunge(ml); 740 775 741 /* update all views (we only have one right now) */ 742 owl_view_recalculate(v); 743 744 /* find where the new position should be 745 (as close as possible to where we last where) */ 746 curmsg = owl_view_get_nearest_to_msgid(v, lastmsgid); 747 if (curmsg>owl_view_get_size(v)-1) curmsg = owl_view_get_size(v)-1; 748 if (curmsg<0) curmsg = 0; 749 owl_global_set_curmsg(&g, curmsg); 750 owl_function_calculate_topmsg(OWL_DIRECTION_NONE); 751 /* if there are no messages set the direction to down in case we 752 delete everything upwards */ 753 owl_global_set_direction_downwards(&g); 776 owl_function_redisplay_to_nearest(lastmsgid, v); 754 777 755 778 owl_function_makemsg("Messages expunged"); 756 owl_mainwin_redisplay(owl_global_get_mainwin(&g));757 779 } 758 780
Note: See TracChangeset
for help on using the changeset viewer.