mirror of
https://gitlab.com/comunic/comunicterm
synced 2024-11-16 10:31:06 +00:00
Implement conversations screen
This commit is contained in:
parent
12898fb609
commit
5dc77f7aa0
@ -16,7 +16,7 @@
|
||||
using namespace std;
|
||||
|
||||
// Show the screen to choose a conversation
|
||||
static void ChooseConv(ConversationsList &list, const UsersList &users, Conversation **choice) {
|
||||
static int ChooseConv(ConversationsList &list, const UsersList &users) {
|
||||
|
||||
ITEM **my_items;
|
||||
int c;
|
||||
@ -100,30 +100,29 @@ static void ChooseConv(ConversationsList &list, const UsersList &users, Conversa
|
||||
attroff(COLOR_PAIR(2));
|
||||
refresh();
|
||||
|
||||
int action = -1;
|
||||
while(action == -1)
|
||||
bool stop = false;
|
||||
int numChoice = 0;
|
||||
while(!stop)
|
||||
{
|
||||
c = wgetch(my_menu_win);
|
||||
switch(c)
|
||||
{ case KEY_DOWN:
|
||||
menu_driver(my_menu, REQ_DOWN_ITEM);
|
||||
if(numChoice < list.size())
|
||||
numChoice++;
|
||||
break;
|
||||
case KEY_UP:
|
||||
menu_driver(my_menu, REQ_UP_ITEM);
|
||||
break;
|
||||
case KEY_NPAGE:
|
||||
menu_driver(my_menu, REQ_SCR_DPAGE);
|
||||
break;
|
||||
case KEY_PPAGE:
|
||||
menu_driver(my_menu, REQ_SCR_UPAGE);
|
||||
if(numChoice > 0)
|
||||
numChoice--;
|
||||
break;
|
||||
case 10:
|
||||
auto item = current_item(my_menu);
|
||||
action = item->index;
|
||||
stop = true;
|
||||
}
|
||||
wrefresh(my_menu_win);
|
||||
}
|
||||
|
||||
|
||||
/* Unpost and free all the memory taken up */
|
||||
unpost_menu(my_menu);
|
||||
free_menu(my_menu);
|
||||
@ -131,6 +130,12 @@ static void ChooseConv(ConversationsList &list, const UsersList &users, Conversa
|
||||
free_item(my_items[i]);
|
||||
endwin();
|
||||
|
||||
return numChoice - 1;
|
||||
}
|
||||
|
||||
|
||||
static void showConversation(Conversation &c, UsersList &users) {
|
||||
// TODO : implement screen
|
||||
}
|
||||
|
||||
|
||||
@ -146,12 +151,14 @@ void showConversationsScreen()
|
||||
auto users = UserHelper::getMultiple(list.usersList());
|
||||
|
||||
// Get the conversation to show
|
||||
Conversation *c = nullptr;
|
||||
ChooseConv(list, users, &c);
|
||||
int idConv = ChooseConv(list, users);
|
||||
|
||||
if(c == nullptr) {
|
||||
if(idConv < 0) {
|
||||
stop = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// Open the conversation
|
||||
showConversation(list[static_cast<size_t>(idConv)], users);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user