Changeset aa2f33b3 for functions.c
- Timestamp:
- Jul 16, 2002, 9:55:47 PM (23 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:
- f2e36b5
- Parents:
- e50cd56
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
re50cd56 raa2f33b3 712 712 713 713 void 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; 716 715 owl_view *v; 717 716 718 mw=owl_global_get_mainwin(&g);719 717 v=owl_global_get_current_view(&g); 718 curmsg=owl_global_get_curmsg(&g); 720 719 topmsg=owl_global_get_topmsg(&g); 721 curmsg=owl_global_get_curmsg(&g);722 v=owl_global_get_current_view(&g);723 720 recwinlines=owl_global_get_recwin_lines(&g); 724 721 … … 726 723 return; 727 724 } 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 */ 762 int owl_function_calculate_topmsg_top(int direction, owl_view *v, int curmsg, int topmsg, int recwinlines) { 763 return curmsg; 764 } 765 766 int 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 776 int 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 789 int 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 829 int owl_function_calculate_topmsg_normal(int direction, owl_view *v, int curmsg, int topmsg, int recwinlines) { 830 int savey, j, i, foo, y; 728 831 729 832 /* Find number of lines from top to bottom of curmsg (store in savey) */ … … 761 864 } 762 865 if (j<0) j=0; 763 owl_global_set_topmsg(&g, j); 764 return; 866 return j; 765 867 } 766 868 } … … 778 880 j--; 779 881 } 780 owl_global_set_topmsg(&g, j+1); 781 return; 782 } 783 } 882 return j+1; 883 } 884 } 885 886 return topmsg; 784 887 } 785 888 … … 1219 1322 "Variables: (use 'show variable <name>' for details)\n"); 1220 1323 owl_variable_dict_get_names(owl_global_get_vardict(&g), &varnames); 1221 owl_variable_get_summaryheader(&fm);1222 1324 numvarnames = owl_list_get_size(&varnames); 1223 1325 for (i=0; i<numvarnames; i++) { 1224 1326 varname = owl_list_get_element(&varnames, i); 1225 1327 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); 1227 1329 } 1228 1330 }
Note: See TracChangeset
for help on using the changeset viewer.