** (These functions had once been macros in h/mh.h)
*/
+#include <sysexits.h>
#include <h/mh.h>
static void
assert_msg_range(struct msgs *mp, int msgnum)
{
if (msgnum < mp->lowoff || msgnum > mp->hghoff) {
- adios(NULL, "Bug: message out of bounds");
+ adios(EX_SOFTWARE, NULL, "Bug: message out of bounds");
}
}
set_selected(struct msgs *mp, int msgnum)
{
assert_msg_range(mp, msgnum);
+
+ if (is_selected(mp, msgnum)) {
+ return;
+ }
+
mp->msgstats[msgnum - mp->lowoff] |= SELECTED;
+ if (mp->lowsel == 0 || msgnum < mp->lowsel) {
+ mp->lowsel = msgnum;
+ }
+ if (msgnum > mp->hghsel) {
+ mp->hghsel = msgnum;
+ }
+ mp->numsel++;
}
void
unset_selected(struct msgs *mp, int msgnum)
{
assert_msg_range(mp, msgnum);
- mp->msgstats[msgnum - mp->lowoff] &= ~SELECTED;
-}
-void
-unset_unseen(struct msgs *mp, int msgnum)
-{
- assert_msg_range(mp, msgnum);
- mp->msgstats[msgnum - mp->lowoff] &= ~SELECT_UNSEEN;
+ if (!is_selected(mp, msgnum)) {
+ return;
+ }
+
+ mp->msgstats[msgnum - mp->lowoff] &= ~SELECTED;
+ if (mp->numsel > 0) {
+ mp->numsel--;
+ }
}