set SEQMOD if clear_msg_flags change the flags
[mmh] / sbr / seq_msgstats.c
index eb483b7..bfd7fb2 100644 (file)
@@ -27,6 +27,8 @@ void
 clear_msg_flags(struct msgs *mp, int msgnum)
 {
        assert_msg_range(mp, msgnum);
+       if (mp->msgstats[msgnum - mp->lowoff])
+               mp->msgflags |= SEQMOD;
        mp->msgstats[msgnum - mp->lowoff] = 0;
 }
 
@@ -98,7 +100,19 @@ void
 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
@@ -119,14 +133,15 @@ 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--;
+       }
 }