Use new pager functions.
Showing
25 changed files
with
150 additions
and
218 deletions
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2001, 2002, 2003, 2005 Free Software Foundation, Inc. |
3 | 3 | ||
4 | GNU Mailutils is free software; you can redistribute it and/or modify | 4 | GNU Mailutils is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
... | @@ -29,50 +29,15 @@ mail_delete_msg (msgset_t *mspec, message_t msg, void *data) | ... | @@ -29,50 +29,15 @@ mail_delete_msg (msgset_t *mspec, message_t msg, void *data) |
29 | 29 | ||
30 | message_get_attribute (msg, &attr); | 30 | message_get_attribute (msg, &attr); |
31 | attribute_set_deleted (attr); | 31 | attribute_set_deleted (attr); |
32 | 32 | cond_page_invalidate (mspec->msg_part[0]); | |
33 | if (cursor == mspec->msg_part[0]) | ||
34 | { | ||
35 | /* deleting current message. let the caller know */ | ||
36 | *(int *)data = 1; | ||
37 | } | ||
38 | return 0; | 33 | return 0; |
39 | } | 34 | } |
40 | 35 | ||
41 | int | 36 | int |
42 | mail_delete (int argc, char **argv) | 37 | mail_delete (int argc, char **argv) |
43 | { | 38 | { |
44 | int reset_cursor = 0; | ||
45 | int rc = util_foreach_msg (argc, argv, MSG_NODELETED|MSG_SILENT, | 39 | int rc = util_foreach_msg (argc, argv, MSG_NODELETED|MSG_SILENT, |
46 | mail_delete_msg, &reset_cursor); | 40 | mail_delete_msg, NULL); |
47 | |||
48 | /* Readjust the cursor not to point to the deleted messages. */ | ||
49 | if (reset_cursor) | ||
50 | { | ||
51 | unsigned int here; | ||
52 | for (here = cursor; here <= total; here++) | ||
53 | { | ||
54 | message_t msg = NULL; | ||
55 | attribute_t attr = NULL; | ||
56 | |||
57 | mailbox_get_message (mbox, here, &msg); | ||
58 | message_get_attribute (msg, &attr); | ||
59 | if (!attribute_is_deleted (attr)) | ||
60 | break; | ||
61 | } | ||
62 | |||
63 | if (here > total) | ||
64 | for (here = cursor; here > 0; here--) | ||
65 | { | ||
66 | message_t msg = NULL; | ||
67 | attribute_t attr = NULL; | ||
68 | |||
69 | mailbox_get_message (mbox, here, &msg); | ||
70 | message_get_attribute (msg, &attr); | ||
71 | if (!attribute_is_deleted (attr)) | ||
72 | break; | ||
73 | } | ||
74 | cursor = here; | ||
75 | } | ||
76 | 41 | ||
77 | if (util_getenv (NULL, "autoprint", Mail_env_boolean, 0) == 0) | 42 | if (util_getenv (NULL, "autoprint", Mail_env_boolean, 0) == 0) |
78 | util_do_command("print"); | 43 | util_do_command("print"); | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2000, 2001, 2005 Free Software Foundation, Inc. |
3 | 3 | ||
4 | GNU Mailutils is free software; you can redistribute it and/or modify | 4 | GNU Mailutils is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
... | @@ -30,7 +30,7 @@ edit0 (msgset_t *mspec, message_t msg, void *data) | ... | @@ -30,7 +30,7 @@ edit0 (msgset_t *mspec, message_t msg, void *data) |
30 | util_do_command ("shell %s %s", getenv ("EDITOR"), file); | 30 | util_do_command ("shell %s %s", getenv ("EDITOR"), file); |
31 | remove (file); | 31 | remove (file); |
32 | free (file); | 32 | free (file); |
33 | cursor = mspec->msg_part[0]; | 33 | set_cursor (mspec->msg_part[0]); |
34 | return 0; | 34 | return 0; |
35 | } | 35 | } |
36 | 36 | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2001, 2002, 2003, 2005 Free Software Foundation, Inc. |
3 | 3 | ||
4 | GNU Mailutils is free software; you can redistribute it and/or modify | 4 | GNU Mailutils is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
... | @@ -26,11 +26,16 @@ int | ... | @@ -26,11 +26,16 @@ int |
26 | mail_eq (int argc, char **argv) | 26 | mail_eq (int argc, char **argv) |
27 | { | 27 | { |
28 | msgset_t *list = NULL; | 28 | msgset_t *list = NULL; |
29 | 29 | size_t n; | |
30 | |||
30 | switch (argc) | 31 | switch (argc) |
31 | { | 32 | { |
32 | case 1: | 33 | case 1: |
33 | fprintf (ofile, "%d\n", cursor); | 34 | n = get_cursor (); |
35 | if (n == 0) | ||
36 | util_error (_("No applicable message")); | ||
37 | else | ||
38 | fprintf (ofile, "%u\n", n); | ||
34 | break; | 39 | break; |
35 | 40 | ||
36 | case 2: | 41 | case 2: |
... | @@ -38,8 +43,8 @@ mail_eq (int argc, char **argv) | ... | @@ -38,8 +43,8 @@ mail_eq (int argc, char **argv) |
38 | { | 43 | { |
39 | if (list->msg_part[0] <= total) | 44 | if (list->msg_part[0] <= total) |
40 | { | 45 | { |
41 | cursor = list->msg_part[0]; | 46 | set_cursor (list->msg_part[0]); |
42 | fprintf (ofile, "%d\n", cursor); | 47 | fprintf (ofile, "%u\n", list->msg_part[0]); |
43 | } | 48 | } |
44 | else | 49 | else |
45 | util_error_range (list->msg_part[0]); | 50 | util_error_range (list->msg_part[0]); | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2001, 2002, 2005 Free Software Foundation, Inc. |
3 | 3 | ||
4 | GNU Mailutils is free software; you can redistribute it and/or modify | 4 | GNU Mailutils is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
... | @@ -113,7 +113,7 @@ mail_file (int argc, char **argv) | ... | @@ -113,7 +113,7 @@ mail_file (int argc, char **argv) |
113 | 113 | ||
114 | mbox = newbox; | 114 | mbox = newbox; |
115 | mailbox_messages_count (mbox, &total); | 115 | mailbox_messages_count (mbox, &total); |
116 | cursor = 1; | 116 | set_cursor (1); |
117 | if (util_getenv (NULL, "header", Mail_env_boolean, 0) == 0) | 117 | if (util_getenv (NULL, "header", Mail_env_boolean, 0) == 0) |
118 | { | 118 | { |
119 | util_do_command ("summary"); | 119 | util_do_command ("summary"); | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2001, 2002, 2003, 2005 Free Software Foundation, Inc. |
3 | 3 | ||
4 | GNU Mailutils is free software; you can redistribute it and/or modify | 4 | GNU Mailutils is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
... | @@ -32,12 +32,20 @@ mail_followup (int argc, char **argv) | ... | @@ -32,12 +32,20 @@ mail_followup (int argc, char **argv) |
32 | msgset_t *msglist, *mp; | 32 | msgset_t *msglist, *mp; |
33 | compose_env_t env; | 33 | compose_env_t env; |
34 | int status; | 34 | int status; |
35 | size_t n; | ||
35 | 36 | ||
36 | compose_init (&env); | 37 | compose_init (&env); |
37 | if (msgset_parse (argc, argv, MSG_NODELETED, &msglist)) | 38 | if (msgset_parse (argc, argv, MSG_NODELETED, &msglist)) |
38 | return 1; | 39 | return 1; |
39 | 40 | ||
40 | if (util_get_message (mbox, cursor, &msg)) | 41 | n = get_cursor (); |
42 | if (n == 0) | ||
43 | { | ||
44 | util_error (_("No applicable message")); | ||
45 | return 1; | ||
46 | } | ||
47 | |||
48 | if (util_get_message (mbox, n, &msg)) | ||
41 | { | 49 | { |
42 | msgset_free (msglist); | 50 | msgset_free (msglist); |
43 | return 1; | 51 | return 1; |
... | @@ -58,7 +66,7 @@ mail_followup (int argc, char **argv) | ... | @@ -58,7 +66,7 @@ mail_followup (int argc, char **argv) |
58 | } | 66 | } |
59 | 67 | ||
60 | /* Generate "to" list */ | 68 | /* Generate "to" list */ |
61 | compose_header_set (&env, MU_HEADER_TO, util_get_sender (cursor, 0), | 69 | compose_header_set (&env, MU_HEADER_TO, util_get_sender (get_cursor (), 0), |
62 | COMPOSE_SINGLE_LINE); | 70 | COMPOSE_SINGLE_LINE); |
63 | 71 | ||
64 | /* Add authors of the subsequent messages to the to list | 72 | /* Add authors of the subsequent messages to the to list | ... | ... |
... | @@ -144,7 +144,7 @@ mail_from0 (msgset_t *mspec, message_t msg, void *data) | ... | @@ -144,7 +144,7 @@ mail_from0 (msgset_t *mspec, message_t msg, void *data) |
144 | fromp = from ? from : ""; | 144 | fromp = from ? from : ""; |
145 | subjp = subj ? subj : fromp; | 145 | subjp = subj ? subj : fromp; |
146 | fprintf (ofile, "%c%c%4d %-18.18s %-16.16s %s %.*s\n", | 146 | fprintf (ofile, "%c%c%4d %-18.18s %-16.16s %s %.*s\n", |
147 | mspec->msg_part[0] == cursor ? '>' : ' ', cflag, | 147 | is_current_message (mspec->msg_part[0]) ? '>' : ' ', cflag, |
148 | mspec->msg_part[0], | 148 | mspec->msg_part[0], |
149 | fromp, date, st, (subjl < 0) ? 0 : subjl, subjp); | 149 | fromp, date, st, (subjl < 0) ? 0 : subjl, subjp); |
150 | 150 | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2000, 2001, 2002, 2003, |
3 | 2005 Free Software Foundation, Inc. | ||
3 | 4 | ||
4 | GNU Mailutils is free software; you can redistribute it and/or modify | 5 | GNU Mailutils is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
... | @@ -30,39 +31,9 @@ | ... | @@ -30,39 +31,9 @@ |
30 | int | 31 | int |
31 | mail_headers (int argc, char **argv) | 32 | mail_headers (int argc, char **argv) |
32 | { | 33 | { |
33 | int low = 1, high = total; | 34 | if (argc > 1) |
34 | msgset_t *list = NULL, *mp; | 35 | return mail_from (argc, argv); |
35 | int lines = util_screen_lines (); | 36 | |
36 | int num; | 37 | page_do (mail_from0, NULL); |
37 | |||
38 | if (msgset_parse (argc, argv, MSG_NODELETED|MSG_SILENT, &list)) | ||
39 | return 1; | ||
40 | |||
41 | num = 0; | ||
42 | for (mp = list; mp; mp = mp->next) | ||
43 | num++; | ||
44 | |||
45 | if (num == 0) | ||
46 | return 0; | ||
47 | lines = (lines / num) - 2; | ||
48 | if (lines < 0) | ||
49 | lines = util_screen_lines (); | ||
50 | |||
51 | if ((unsigned int)lines < total) | ||
52 | { | ||
53 | low = list->msg_part[0] - (lines / 2); | ||
54 | if (low < 1) | ||
55 | low = 1; | ||
56 | high = low + util_screen_lines (); | ||
57 | if ((unsigned int)high > total) | ||
58 | { | ||
59 | high = total; | ||
60 | low = high - lines; | ||
61 | } | ||
62 | } | ||
63 | |||
64 | util_range_msg (low, high, MSG_NODELETED|MSG_SILENT, mail_from0, NULL); | ||
65 | |||
66 | msgset_free (list); | ||
67 | return 0; | 38 | return 0; |
68 | } | 39 | } | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2001 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2001, 2005 Free Software Foundation, Inc. |
3 | 3 | ||
4 | GNU Mailutils is free software; you can redistribute it and/or modify | 4 | GNU Mailutils is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
... | @@ -31,7 +31,7 @@ hold0 (msgset_t *mspec, message_t msg, void *data) | ... | @@ -31,7 +31,7 @@ hold0 (msgset_t *mspec, message_t msg, void *data) |
31 | message_get_attribute (msg, &attr); | 31 | message_get_attribute (msg, &attr); |
32 | attribute_unset_userflag (attr, MAIL_ATTRIBUTE_MBOXED); | 32 | attribute_unset_userflag (attr, MAIL_ATTRIBUTE_MBOXED); |
33 | 33 | ||
34 | cursor = mspec->msg_part[0]; | 34 | set_cursor (mspec->msg_part[0]); |
35 | 35 | ||
36 | return 0; | 36 | return 0; |
37 | } | 37 | } | ... | ... |
... | @@ -20,13 +20,13 @@ | ... | @@ -20,13 +20,13 @@ |
20 | #include "mail.h" | 20 | #include "mail.h" |
21 | 21 | ||
22 | /* Global variables and constants*/ | 22 | /* Global variables and constants*/ |
23 | mailbox_t mbox; | 23 | mailbox_t mbox; /* Mailbox being operated upon */ |
24 | unsigned int cursor; | 24 | size_t total; /* Total number of messages in the mailbox */ |
25 | size_t total; | 25 | FILE *ofile; /* Output file */ |
26 | FILE *ofile; | 26 | int interactive; /* Is the session interactive */ |
27 | int interactive; | ||
28 | 27 | ||
29 | static list_t command_list; | 28 | static list_t command_list; /* List of commands to be executed after parsing |
29 | command line */ | ||
30 | 30 | ||
31 | const char *program_version = "mail (" PACKAGE_STRING ")"; | 31 | const char *program_version = "mail (" PACKAGE_STRING ")"; |
32 | static char doc[] = N_("GNU mail -- the standard /bin/mail interface"); | 32 | static char doc[] = N_("GNU mail -- the standard /bin/mail interface"); |
... | @@ -286,7 +286,7 @@ main (int argc, char **argv) | ... | @@ -286,7 +286,7 @@ main (int argc, char **argv) |
286 | int i, rc; | 286 | int i, rc; |
287 | 287 | ||
288 | ofile = stdout; | 288 | ofile = stdout; |
289 | cursor = 1; | 289 | set_cursor (1); |
290 | 290 | ||
291 | /* Native Language Support */ | 291 | /* Native Language Support */ |
292 | mu_init_nls (); | 292 | mu_init_nls (); |
... | @@ -495,9 +495,11 @@ main (int argc, char **argv) | ... | @@ -495,9 +495,11 @@ main (int argc, char **argv) |
495 | 495 | ||
496 | 496 | ||
497 | void | 497 | void |
498 | mail_mainloop (char *(*input) __P((void *, int)), void *closure, int do_history) | 498 | mail_mainloop (char *(*input) __P((void *, int)), |
499 | void *closure, int do_history) | ||
499 | { | 500 | { |
500 | char *command, *cmd; | 501 | char *command, *cmd; |
502 | |||
501 | while ((command = (*input)(closure, 0)) != NULL) | 503 | while ((command = (*input)(closure, 0)) != NULL) |
502 | { | 504 | { |
503 | int len = strlen (command); | 505 | int len = strlen (command); |
... | @@ -558,3 +560,4 @@ mail_warranty (int argc ARG_UNUSED, char **argv ARG_UNUSED) | ... | @@ -558,3 +560,4 @@ mail_warranty (int argc ARG_UNUSED, char **argv ARG_UNUSED) |
558 | 560 | ||
559 | return 0; | 561 | return 0; |
560 | } | 562 | } |
563 | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2000, 2001, 2002, 2005 Free Software Foundation, Inc. |
3 | 3 | ||
4 | GNU Mailutils is free software; you can redistribute it and/or modify | 4 | GNU Mailutils is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
... | @@ -39,6 +39,7 @@ sig_handler (int signo) | ... | @@ -39,6 +39,7 @@ sig_handler (int signo) |
39 | case SIGWINCH: | 39 | case SIGWINCH: |
40 | util_do_command ("set screen=%d", util_getlines()); | 40 | util_do_command ("set screen=%d", util_getlines()); |
41 | util_do_command ("set columns=%d", util_getcols()); | 41 | util_do_command ("set columns=%d", util_getcols()); |
42 | page_invalidate (1); | ||
42 | break; | 43 | break; |
43 | #endif | 44 | #endif |
44 | } | 45 | } | ... | ... |
... | @@ -31,7 +31,7 @@ mbox0 (msgset_t *mspec, message_t msg, void *data) | ... | @@ -31,7 +31,7 @@ mbox0 (msgset_t *mspec, message_t msg, void *data) |
31 | attribute_set_userflag (attr, MAIL_ATTRIBUTE_MBOXED); | 31 | attribute_set_userflag (attr, MAIL_ATTRIBUTE_MBOXED); |
32 | util_mark_read (msg); | 32 | util_mark_read (msg); |
33 | 33 | ||
34 | cursor = mspec->msg_part[0]; | 34 | set_cursor (mspec->msg_part[0]); |
35 | 35 | ||
36 | return 0; | 36 | return 0; |
37 | } | 37 | } | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005 |
3 | Free Software Foundation, Inc. | ||
3 | 4 | ||
4 | GNU Mailutils is free software; you can redistribute it and/or modify | 5 | GNU Mailutils is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
... | @@ -73,11 +74,11 @@ static msgset_t *result; | ... | @@ -73,11 +74,11 @@ static msgset_t *result; |
73 | 74 | ||
74 | input : /* empty */ | 75 | input : /* empty */ |
75 | { | 76 | { |
76 | result = msgset_make_1 (cursor); | 77 | result = msgset_make_1 (get_cursor ()); |
77 | } | 78 | } |
78 | | '.' | 79 | | '.' |
79 | { | 80 | { |
80 | result = msgset_make_1 (cursor); | 81 | result = msgset_make_1 (get_cursor ()); |
81 | } | 82 | } |
82 | | msgset | 83 | | msgset |
83 | { | 84 | { |
... | @@ -390,7 +391,7 @@ msgset_count (msgset_t *set) | ... | @@ -390,7 +391,7 @@ msgset_count (msgset_t *set) |
390 | 391 | ||
391 | /* Create a message set consisting of a single msg_num and no subparts */ | 392 | /* Create a message set consisting of a single msg_num and no subparts */ |
392 | msgset_t * | 393 | msgset_t * |
393 | msgset_make_1 (int number) | 394 | msgset_make_1 (size_t number) |
394 | { | 395 | { |
395 | msgset_t *mp; | 396 | msgset_t *mp; |
396 | 397 | ... | ... |
... | @@ -34,8 +34,8 @@ mail_next (int argc, char **argv) | ... | @@ -34,8 +34,8 @@ mail_next (int argc, char **argv) |
34 | int rc; | 34 | int rc; |
35 | attribute_t attr = NULL; | 35 | attribute_t attr = NULL; |
36 | 36 | ||
37 | rc = util_get_message (mbox, cursor, &msg); | 37 | n = get_cursor (); |
38 | if (rc) | 38 | if (n == 0 || util_get_message (mbox, n, &msg)) |
39 | { | 39 | { |
40 | util_error (_("No applicable message")); | 40 | util_error (_("No applicable message")); |
41 | return 1; | 41 | return 1; |
... | @@ -49,7 +49,7 @@ mail_next (int argc, char **argv) | ... | @@ -49,7 +49,7 @@ mail_next (int argc, char **argv) |
49 | } | 49 | } |
50 | 50 | ||
51 | rc = 1; | 51 | rc = 1; |
52 | for (n = cursor + 1; n <= total; n++) | 52 | while (++n <= total) |
53 | { | 53 | { |
54 | if (util_isdeleted (n)) | 54 | if (util_isdeleted (n)) |
55 | continue; | 55 | continue; |
... | @@ -81,7 +81,7 @@ mail_next (int argc, char **argv) | ... | @@ -81,7 +81,7 @@ mail_next (int argc, char **argv) |
81 | return 1; | 81 | return 1; |
82 | } | 82 | } |
83 | } | 83 | } |
84 | cursor = n; | 84 | set_cursor (n); |
85 | util_do_command ("print"); | 85 | util_do_command ("print"); |
86 | return 0; | 86 | return 0; |
87 | } | 87 | } | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2001, 2002, 2003, 2005 Free Software Foundation, Inc. |
3 | 3 | ||
4 | GNU Mailutils is free software; you can redistribute it and/or modify | 4 | GNU Mailutils is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
... | @@ -32,14 +32,17 @@ mail_previous (int argc, char **argv) | ... | @@ -32,14 +32,17 @@ mail_previous (int argc, char **argv) |
32 | if (argc < 2) | 32 | if (argc < 2) |
33 | { | 33 | { |
34 | int rc = 1; | 34 | int rc = 1; |
35 | for (n = cursor - 1; n > 0; n--) | 35 | |
36 | { | 36 | n = get_cursor (); |
37 | if (util_isdeleted (n)) | 37 | if (n) |
38 | continue; | 38 | while (--n > 0) |
39 | rc = util_get_message (mbox, n, &msg); | 39 | { |
40 | if (rc == 0) | 40 | if (util_isdeleted (n)) |
41 | break; | 41 | continue; |
42 | } | 42 | rc = util_get_message (mbox, n, &msg); |
43 | if (rc == 0) | ||
44 | break; | ||
45 | } | ||
43 | 46 | ||
44 | if (rc) | 47 | if (rc) |
45 | { | 48 | { |
... | @@ -64,7 +67,7 @@ mail_previous (int argc, char **argv) | ... | @@ -64,7 +67,7 @@ mail_previous (int argc, char **argv) |
64 | return 1; | 67 | return 1; |
65 | } | 68 | } |
66 | } | 69 | } |
67 | cursor = n; | 70 | set_cursor (n); |
68 | util_do_command ("print"); | 71 | util_do_command ("print"); |
69 | return 0; | 72 | return 0; |
70 | } | 73 | } | ... | ... |
... | @@ -35,7 +35,6 @@ mail_print_msg (msgset_t *mspec, message_t mesg, void *data) | ... | @@ -35,7 +35,6 @@ mail_print_msg (msgset_t *mspec, message_t mesg, void *data) |
35 | off_t off = 0; | 35 | off_t off = 0; |
36 | size_t n = 0, lines = 0; | 36 | size_t n = 0, lines = 0; |
37 | FILE *out = ofile; | 37 | FILE *out = ofile; |
38 | attribute_t attr; | ||
39 | int pagelines = util_get_crt (); | 38 | int pagelines = util_get_crt (); |
40 | 39 | ||
41 | message_lines (mesg, &lines); | 40 | message_lines (mesg, &lines); |
... | @@ -106,7 +105,7 @@ mail_print_msg (msgset_t *mspec, message_t mesg, void *data) | ... | @@ -106,7 +105,7 @@ mail_print_msg (msgset_t *mspec, message_t mesg, void *data) |
106 | 105 | ||
107 | util_mark_read (mesg); | 106 | util_mark_read (mesg); |
108 | 107 | ||
109 | cursor = mspec->msg_part[0]; | 108 | set_cursor (mspec->msg_part[0]); |
110 | 109 | ||
111 | return 0; | 110 | return 0; |
112 | } | 111 | } | ... | ... |
... | @@ -54,7 +54,7 @@ reply0 (msgset_t *mspec, message_t msg, void *data) | ... | @@ -54,7 +54,7 @@ reply0 (msgset_t *mspec, message_t msg, void *data) |
54 | int status; | 54 | int status; |
55 | char *str; | 55 | char *str; |
56 | 56 | ||
57 | cursor = mspec->msg_part[0]; | 57 | set_cursor (mspec->msg_part[0]); |
58 | 58 | ||
59 | compose_init (&env); | 59 | compose_init (&env); |
60 | 60 | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2001 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2001, 2005 Free Software Foundation, Inc. |
3 | 3 | ||
4 | GNU Mailutils is free software; you can redistribute it and/or modify | 4 | GNU Mailutils is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
... | @@ -31,7 +31,7 @@ size0 (msgset_t *mspec, message_t msg, void *data) | ... | @@ -31,7 +31,7 @@ size0 (msgset_t *mspec, message_t msg, void *data) |
31 | message_lines (msg, &lines); | 31 | message_lines (msg, &lines); |
32 | 32 | ||
33 | fprintf (ofile, "%c%2d %3d/%-5d\n", | 33 | fprintf (ofile, "%c%2d %3d/%-5d\n", |
34 | mspec->msg_part[0] == cursor ? '>' : ' ', | 34 | is_current_message (mspec->msg_part[0]) ? '>' : ' ', |
35 | mspec->msg_part[0], lines, size); | 35 | mspec->msg_part[0], lines, size); |
36 | return 0; | 36 | return 0; |
37 | } | 37 | } | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2001, 2002, 2005 Free Software Foundation, Inc. |
3 | 3 | ||
4 | GNU Mailutils is free software; you can redistribute it and/or modify | 4 | GNU Mailutils is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
... | @@ -20,7 +20,7 @@ | ... | @@ -20,7 +20,7 @@ |
20 | 20 | ||
21 | /* Simple summary dysplaying a blurb on the name of the | 21 | /* Simple summary dysplaying a blurb on the name of the |
22 | mailbox and how many new:deleted:read messages. | 22 | mailbox and how many new:deleted:read messages. |
23 | The side effect is that is set the cursor/cursor | 23 | The side effect is that it sets the cursor |
24 | to the newest or read message number. */ | 24 | to the newest or read message number. */ |
25 | int | 25 | int |
26 | mail_summary (int argc ARG_UNUSED, char **argv ARG_UNUSED) | 26 | mail_summary (int argc ARG_UNUSED, char **argv ARG_UNUSED) |
... | @@ -73,7 +73,7 @@ mail_summary (int argc ARG_UNUSED, char **argv ARG_UNUSED) | ... | @@ -73,7 +73,7 @@ mail_summary (int argc ARG_UNUSED, char **argv ARG_UNUSED) |
73 | printf("\n"); | 73 | printf("\n"); |
74 | 74 | ||
75 | /* Set the cursor. */ | 75 | /* Set the cursor. */ |
76 | cursor = (first_new == 0) ? ((first_unread == 0) ? | 76 | set_cursor ((first_new == 0) ? ((first_unread == 0) ? |
77 | 1 : first_unread) : first_new ; | 77 | 1 : first_unread) : first_new) ; |
78 | return 0; | 78 | return 0; |
79 | } | 79 | } | ... | ... |
... | @@ -43,7 +43,7 @@ top0 (msgset_t *mspec, message_t msg, void *data) | ... | @@ -43,7 +43,7 @@ top0 (msgset_t *mspec, message_t msg, void *data) |
43 | break; | 43 | break; |
44 | fprintf (ofile, "%s", buf); | 44 | fprintf (ofile, "%s", buf); |
45 | } | 45 | } |
46 | cursor = mspec->msg_part[0]; | 46 | set_cursor (mspec->msg_part[0]); |
47 | 47 | ||
48 | util_mark_read (msg); | 48 | util_mark_read (msg); |
49 | 49 | ... | ... |
... | @@ -36,7 +36,8 @@ touch0 (msgset_t *mspec, message_t msg, void *data) | ... | @@ -36,7 +36,8 @@ touch0 (msgset_t *mspec, message_t msg, void *data) |
36 | util_mark_read (msg); | 36 | util_mark_read (msg); |
37 | } | 37 | } |
38 | 38 | ||
39 | cursor = mspec->msg_part[0]; | 39 | set_cursor (mspec->msg_part[0]); |
40 | return 0; | ||
40 | } | 41 | } |
41 | 42 | ||
42 | int | 43 | int | ... | ... |
... | @@ -30,9 +30,8 @@ undelete0 (msgset_t *mspec, message_t msg, void *data) | ... | @@ -30,9 +30,8 @@ undelete0 (msgset_t *mspec, message_t msg, void *data) |
30 | message_get_attribute (msg, &attr); | 30 | message_get_attribute (msg, &attr); |
31 | attribute_unset_deleted (attr); | 31 | attribute_unset_deleted (attr); |
32 | util_mark_read (msg); | 32 | util_mark_read (msg); |
33 | cond_page_invalidate (mspec->msg_part[0]); | ||
33 | 34 | ||
34 | if (cursor == 0) | ||
35 | cursor = mspec->msg_part[0]; | ||
36 | return 0; | 35 | return 0; |
37 | } | 36 | } |
38 | 37 | ... | ... |
... | @@ -193,17 +193,31 @@ util_foreach_msg (int argc, char **argv, int flags, | ... | @@ -193,17 +193,31 @@ util_foreach_msg (int argc, char **argv, int flags, |
193 | return status; | 193 | return status; |
194 | } | 194 | } |
195 | 195 | ||
196 | int | 196 | size_t |
197 | util_range_msg (size_t low, size_t high, int flags, | 197 | util_range_msg (size_t low, size_t high, int flags, |
198 | msg_handler_t func, void *data) | 198 | msg_handler_t func, void *data) |
199 | { | 199 | { |
200 | msgset_t msgspec = { 0 }; | 200 | msgset_t msgspec = { 0 }; |
201 | int count = 0; | 201 | size_t count, expect_count; |
202 | 202 | ||
203 | msgspec.next = NULL; | 203 | msgspec.next = NULL; |
204 | msgspec.npart = 0; | 204 | msgspec.npart = 0; |
205 | msgspec.msg_part = &low; | 205 | msgspec.msg_part = &low; |
206 | for (; low <= high; low++) | 206 | if (!func) |
207 | flags |= MSG_SILENT; | ||
208 | |||
209 | if (low > total) | ||
210 | return 0; | ||
211 | if (!(flags & MSG_COUNT)) | ||
212 | { | ||
213 | if (high < low) | ||
214 | return 0; | ||
215 | expect_count = high - low + 1; | ||
216 | } | ||
217 | else | ||
218 | expect_count = high; | ||
219 | |||
220 | for (count = 0; count < expect_count && low <= total; low++) | ||
207 | { | 221 | { |
208 | message_t mesg; | 222 | message_t mesg; |
209 | 223 | ||
... | @@ -218,7 +232,8 @@ util_range_msg (size_t low, size_t high, int flags, | ... | @@ -218,7 +232,8 @@ util_range_msg (size_t low, size_t high, int flags, |
218 | if (util_get_message (mbox, low, &mesg) == 0) | 232 | if (util_get_message (mbox, low, &mesg) == 0) |
219 | { | 233 | { |
220 | count ++; | 234 | count ++; |
221 | func (&msgspec, mesg, data) ; | 235 | if (func) |
236 | func (&msgspec, mesg, data) ; | ||
222 | /* Bail out if we receive an interrupt. */ | 237 | /* Bail out if we receive an interrupt. */ |
223 | if (ml_got_interrupt () != 0) | 238 | if (ml_got_interrupt () != 0) |
224 | break; | 239 | break; |
... | @@ -545,27 +560,6 @@ util_setenv (const char *variable, void *value, mail_env_data_t type, | ... | @@ -545,27 +560,6 @@ util_setenv (const char *variable, void *value, mail_env_data_t type, |
545 | 560 | ||
546 | case Mail_env_string: | 561 | case Mail_env_string: |
547 | ep->value.string = strdup (value); | 562 | ep->value.string = strdup (value); |
548 | if (strcmp (variable, "replyregex") == 0) | ||
549 | { | ||
550 | int rc; | ||
551 | char *err; | ||
552 | |||
553 | if (rc = munre_set_regex (value, 0, &err)) | ||
554 | { | ||
555 | fprintf (stderr, "%s", mu_strerror (rc)); | ||
556 | if (err) | ||
557 | { | ||
558 | fprintf (stderr, "%s", err); | ||
559 | free (err); | ||
560 | } | ||
561 | fprintf (stderr, "\n"); | ||
562 | } | ||
563 | } | ||
564 | else if (strcmp (variable, "decode-fallback") == 0) | ||
565 | { | ||
566 | if (mu_set_default_fallback (value)) | ||
567 | mu_error (_("Incorrect value for decode-fallback")); | ||
568 | } | ||
569 | break; | 563 | break; |
570 | 564 | ||
571 | case Mail_env_boolean: | 565 | case Mail_env_boolean: |
... | @@ -576,6 +570,31 @@ util_setenv (const char *variable, void *value, mail_env_data_t type, | ... | @@ -576,6 +570,31 @@ util_setenv (const char *variable, void *value, mail_env_data_t type, |
576 | } | 570 | } |
577 | } | 571 | } |
578 | 572 | ||
573 | /* Special handling for some variables */ | ||
574 | if (strcmp (variable, "replyregex") == 0) | ||
575 | { | ||
576 | int rc; | ||
577 | char *err; | ||
578 | |||
579 | if (rc = munre_set_regex (value, 0, &err)) | ||
580 | { | ||
581 | fprintf (stderr, "%s", mu_strerror (rc)); | ||
582 | if (err) | ||
583 | { | ||
584 | fprintf (stderr, "%s", err); | ||
585 | free (err); | ||
586 | } | ||
587 | fprintf (stderr, "\n"); | ||
588 | } | ||
589 | } | ||
590 | else if (strcmp (variable, "decode-fallback") == 0) | ||
591 | { | ||
592 | if (mu_set_default_fallback (value)) | ||
593 | mu_error (_("Incorrect value for decode-fallback")); | ||
594 | } | ||
595 | else if (strcmp (variable, "screen") == 0) | ||
596 | page_invalidate (1); | ||
597 | |||
579 | return 0; | 598 | return 0; |
580 | } | 599 | } |
581 | 600 | ... | ... |
... | @@ -36,7 +36,7 @@ visual0 (msgset_t *mspec, message_t msg, void *data) | ... | @@ -36,7 +36,7 @@ visual0 (msgset_t *mspec, message_t msg, void *data) |
36 | /* Mark as read */ | 36 | /* Mark as read */ |
37 | util_mark_read (msg); | 37 | util_mark_read (msg); |
38 | 38 | ||
39 | cursor = mspec->msg_part[0]; | 39 | set_cursor (mspec->msg_part[0]); |
40 | 40 | ||
41 | return 0; | 41 | return 0; |
42 | } | 42 | } | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2001, 2002, 2003, 2005 Free Software Foundation, Inc. |
3 | 3 | ||
4 | GNU Mailutils is free software; you can redistribute it and/or modify | 4 | GNU Mailutils is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
... | @@ -42,8 +42,14 @@ mail_write (int argc, char **argv) | ... | @@ -42,8 +42,14 @@ mail_write (int argc, char **argv) |
42 | filename = util_outfolder_name (argv[--argc]); | 42 | filename = util_outfolder_name (argv[--argc]); |
43 | else | 43 | else |
44 | { | 44 | { |
45 | size_t n = get_cursor (); | ||
45 | char *p = NULL; | 46 | char *p = NULL; |
46 | asprintf (&p, "%d", cursor); | 47 | if (n == 0) |
48 | { | ||
49 | util_error (_("No applicable message")); | ||
50 | return 1; | ||
51 | } | ||
52 | asprintf (&p, "%u", n); | ||
47 | filename = util_outfolder_name (p); | 53 | filename = util_outfolder_name (p); |
48 | free (p); | 54 | free (p); |
49 | } | 55 | } | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2001, 2002, 2005 Free Software Foundation, Inc. |
3 | 3 | ||
4 | GNU Mailutils is free software; you can redistribute it and/or modify | 4 | GNU Mailutils is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
... | @@ -107,46 +107,27 @@ z_parse_args(int argc, char **argv, | ... | @@ -107,46 +107,27 @@ z_parse_args(int argc, char **argv, |
107 | int | 107 | int |
108 | mail_z (int argc, char **argv) | 108 | mail_z (int argc, char **argv) |
109 | { | 109 | { |
110 | unsigned int i, nlines; | ||
111 | unsigned int pagelines = util_screen_lines(); | ||
112 | unsigned int count; | 110 | unsigned int count; |
113 | int dir; | 111 | int dir; |
114 | int crs, end; | 112 | unsigned int pagelines = util_screen_lines (); |
115 | 113 | ||
116 | if (z_parse_args(argc, argv, &count, &dir)) | 114 | if (z_parse_args(argc, argv, &count, &dir)) |
117 | return 1; | 115 | return 1; |
118 | 116 | ||
119 | nlines = pagelines; | ||
120 | |||
121 | count *= pagelines; | 117 | count *= pagelines; |
122 | crs = cursor; | 118 | |
123 | switch (dir) | 119 | switch (dir) |
124 | { | 120 | { |
125 | case D_BWD: | 121 | case D_BWD: |
126 | if (crs < nlines) | 122 | if (page_move (-count) == 0) |
127 | { | 123 | { |
128 | fprintf (stdout, _("On first screenful of messages\n")); | 124 | fprintf (stdout, _("On first screenful of messages\n")); |
129 | return 0; | 125 | return 0; |
130 | } | 126 | } |
131 | if (crs < count) | ||
132 | crs = 1; | ||
133 | else | ||
134 | crs -= count; | ||
135 | break; | 127 | break; |
136 | 128 | ||
137 | case D_FWD: | 129 | case D_FWD: |
138 | if (crs + pagelines > total) | 130 | if (page_move (count) == 0) |
139 | { | ||
140 | fprintf (stdout, _("On last screenful of messages\n")); | ||
141 | return 0; | ||
142 | } | ||
143 | |||
144 | crs += count; | ||
145 | |||
146 | if (crs + nlines > total) | ||
147 | nlines = total - crs + 1; | ||
148 | |||
149 | if (nlines <= 0) | ||
150 | { | 131 | { |
151 | fprintf (stdout, _("On last screenful of messages\n")); | 132 | fprintf (stdout, _("On last screenful of messages\n")); |
152 | return 0; | 133 | return 0; |
... | @@ -160,43 +141,13 @@ mail_z (int argc, char **argv) | ... | @@ -160,43 +141,13 @@ mail_z (int argc, char **argv) |
160 | of the last message. This behaviour is used on startup | 141 | of the last message. This behaviour is used on startup |
161 | when displaying the summary and the headers, new messages | 142 | when displaying the summary and the headers, new messages |
162 | are last but we want to display a screenful with the | 143 | are last but we want to display a screenful with the |
163 | real crs set by summary() to the new message. */ | 144 | real crs set by summary() to the new message. |
164 | 145 | FIXME: Basically it's the same as headers now. Do we need | |
165 | /* Find the start of the last screen page. */ | 146 | it still? */ |
166 | int lastpage = total - pagelines + 1; | ||
167 | if (lastpage <= 0) | ||
168 | lastpage = 1; | ||
169 | |||
170 | if (crs > (unsigned int)lastpage) | ||
171 | { | ||
172 | crs = lastpage; | ||
173 | |||
174 | if (crs + nlines > total) | ||
175 | nlines = total - crs; | ||
176 | |||
177 | util_range_msg (crs, crs + nlines, | ||
178 | MSG_NODELETED|MSG_SILENT, mail_from0, NULL); | ||
179 | return 1; | ||
180 | } | ||
181 | else if (crs + nlines > total) | ||
182 | nlines = total - crs + 1; | ||
183 | } | ||
184 | break; | ||
185 | } | ||
186 | |||
187 | cursor = crs; | ||
188 | end = cursor + nlines - 1; | ||
189 | i = 0; | ||
190 | do | ||
191 | { | ||
192 | int cnt = util_range_msg (crs, end, | ||
193 | MSG_NODELETED|MSG_SILENT, mail_from0, NULL); | ||
194 | if (cnt == 0) | ||
195 | break; | 147 | break; |
196 | i += cnt; | 148 | } |
197 | crs += nlines; | ||
198 | } | 149 | } |
199 | while (i < nlines && crs <= total); | ||
200 | 150 | ||
201 | return 1; | 151 | page_do (mail_from0, NULL); |
152 | return 0; | ||
202 | } | 153 | } | ... | ... |
-
Please register or sign in to post a comment