/[mailutils]/mailutils/mail/z.c
ViewVC logotype

Diff of /mailutils/mail/z.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.14 by polak, Mon Dec 23 22:01:35 2002 UTC revision 1.15 by gray, Sun Dec 29 13:37:43 2002 UTC
# Line 31  Line 31 
31   */   */
32    
33  static int  static int
34  z_parse_args(int argc, char **argv, unsigned int *return_count, int *return_dir)  z_parse_args(int argc, char **argv,
35                 unsigned int *return_count, int *return_dir)
36  {  {
37    int count = 1;    int count = 1;
38    int mul = 1;    int mul = 1;
# Line 109  mail_z (int argc, char **argv) Line 110  mail_z (int argc, char **argv)
110    unsigned int pagelines = util_screen_lines();    unsigned int pagelines = util_screen_lines();
111    unsigned int count;    unsigned int count;
112    int dir;    int dir;
113      int crs;
114      
115    if (z_parse_args(argc, argv, &count, &dir))    if (z_parse_args(argc, argv, &count, &dir))
116      return 1;      return 1;
117    
118    nlines = pagelines;    nlines = pagelines;
119    
120    count *= pagelines;    count *= pagelines;
121      crs = cursor;
122    switch (dir)    switch (dir)
123      {      {
124      case D_BWD:      case D_BWD:
125        if (cursor < nlines)        if (crs < nlines)
126          {          {
127            fprintf (stdout, _("On first screenful of messages\n"));            fprintf (stdout, _("On first screenful of messages\n"));
128            return 0;            return 0;
129          }          }
130        if (cursor < count)        if (crs < count)
131          cursor = 1;          crs = 1;
132        else        else
133          cursor -= count;          crs -= count;
134        break;        break;
135    
136      case D_FWD:      case D_FWD:
137        if (cursor + pagelines > total)        if (crs + pagelines > total)
138          {          {
139            fprintf (stdout, _("On last screenful of messages\n"));            fprintf (stdout, _("On last screenful of messages\n"));
140            return 0;            return 0;
141          }          }
142    
143        cursor += count;        crs += count;
144    
145        if (cursor + nlines > total)        if (crs + nlines > total)
146          nlines = total - cursor + 1;          nlines = total - crs + 1;
147    
148        if (nlines <= 0)        if (nlines <= 0)
149          {          {
# Line 156  mail_z (int argc, char **argv) Line 159  mail_z (int argc, char **argv)
159             of the last message.  This behaviour is used on startup             of the last message.  This behaviour is used on startup
160             when displaying the summary and the headers, new messages             when displaying the summary and the headers, new messages
161             are last but we want to display a screenful with the             are last but we want to display a screenful with the
162             real cursor set by summary() to the new message.  */             real crs set by summary() to the new message.  */
163    
164          /* Find the start of the last screen page.  */          /* Find the start of the last screen page.  */
165          int lastpage =  total - pagelines + 1;          int lastpage =  total - pagelines + 1;
166          if (lastpage <= 0)          if (lastpage <= 0)
167            lastpage = 1;            lastpage = 1;
168    
169          if (cursor > (unsigned int)lastpage)          if (crs > (unsigned int)lastpage)
170            {            {
171              realcursor = cursor;              crs = lastpage;
172              cursor = lastpage;  
173                if (crs + nlines > total)
174                  nlines = total - crs;
175    
176              if (cursor + nlines > total)              util_range_msg (crs, crs + nlines,
177                nlines = total - cursor + 1;                              MSG_NODELETED|MSG_SILENT, mail_from0, NULL);
           
             for (i = 0; i < nlines; i++)  
               {  
                 mail_from0 (cursor, 0);  
                 cursor++;  
               }  
             cursor = realcursor;  
178              return 1;              return 1;
179            }            }
180            else if (crs + nlines > total)
181              nlines = total - crs + 1;
182        }        }
183        break;        break;
184      }      }
185    
186    realcursor = cursor;    cursor = crs;
187    
188    for (i = 0; i < nlines && cursor <= total; )    i = 0;
189      do
190      {      {
191        if (mail_from0 (cursor, 0) == 0)        int cnt = util_range_msg (crs, crs + nlines - 1,
192          i++;                                  MSG_NODELETED|MSG_SILENT, mail_from0, NULL);
193        cursor++;        if (cnt == 0)
194            break;
195          i += cnt;
196          crs += nlines;
197      }      }
198      while (i < nlines && crs <= total);
   cursor = realcursor;  
199    
200    return 1;    return 1;
201  }  }

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26