Skip to content
This repository has been archived by the owner on Feb 3, 2020. It is now read-only.

Commit

Permalink
Updated the way that messges are handled.
Browse files Browse the repository at this point in the history
  Read messages are now marked as such, which causes a bug, as
 expected.  Issue #3 is real and will be a pain to fix.
  • Loading branch information
skx committed May 13, 2013
1 parent 45d79aa commit 2c154cc
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
4 changes: 3 additions & 1 deletion global.cc
Expand Up @@ -257,6 +257,7 @@ std::vector<CMessage *> CGlobal::get_messages()
*/
CGlobal *global = CGlobal::Instance();
std::vector<std::string> folders = global->get_selected_folders();
std::string * filter = global->get_index_limit();

/**
* The sum of all messages we're going to display.
Expand All @@ -280,7 +281,8 @@ std::vector<CMessage *> CGlobal::get_messages()
*/
std::vector<CMessage *>::iterator mit;
for (mit = contents.begin(); mit != contents.end(); ++mit) {
messages.push_back(*mit);
if ( (*mit)->matches_filter( filter ) )
messages.push_back(*mit) ;
}
}

Expand Down
15 changes: 15 additions & 0 deletions message.cc
Expand Up @@ -93,6 +93,21 @@ std::string CMessage::flags()
return flags;
}

/**
* Does this message match the given filter.
*/
bool CMessage::matches_filter( std::string *filter )
{
if ( strcmp( filter->c_str(), "all" ) == 0 )
return true;

if ( ( strcmp( filter->c_str(), "new" ) == 0 ) &&
is_new() )
return true;

return false;
}


/**
* Is this message new?
Expand Down
5 changes: 5 additions & 0 deletions message.h
Expand Up @@ -67,6 +67,11 @@ class CMessage
*/
std::string flags();

/**
* Does this message match the given filter?
*/
bool matches_filter( std::string *filter );

/**
* Is this message new?
*/
Expand Down
8 changes: 5 additions & 3 deletions screen.cc
Expand Up @@ -196,8 +196,8 @@ void CScreen::drawIndex()
* Bound the selection.
*/
if (selected >= count) {
global->set_selected_message(0);
selected = 0;
selected = count-1;
global->set_selected_message(selected);
}

/**
Expand Down Expand Up @@ -295,7 +295,7 @@ void CScreen::drawMessage()

CMessage *cur = NULL;
if ((selected) < count)
cur = messages[ selected];
cur = messages[selected];
else
{
clear();
Expand Down Expand Up @@ -360,6 +360,8 @@ void CScreen::drawMessage()
printw( "%s", body[i].c_str() );
}

if ( cur->is_new() )
cur->mark_read();
}

/**
Expand Down

0 comments on commit 2c154cc

Please sign in to comment.