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;
|
using namespace std;
|
||||||
|
|
||||||
// Show the screen to choose a conversation
|
// 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;
|
ITEM **my_items;
|
||||||
int c;
|
int c;
|
||||||
@ -100,30 +100,29 @@ static void ChooseConv(ConversationsList &list, const UsersList &users, Conversa
|
|||||||
attroff(COLOR_PAIR(2));
|
attroff(COLOR_PAIR(2));
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
int action = -1;
|
bool stop = false;
|
||||||
while(action == -1)
|
int numChoice = 0;
|
||||||
|
while(!stop)
|
||||||
{
|
{
|
||||||
c = wgetch(my_menu_win);
|
c = wgetch(my_menu_win);
|
||||||
switch(c)
|
switch(c)
|
||||||
{ case KEY_DOWN:
|
{ case KEY_DOWN:
|
||||||
menu_driver(my_menu, REQ_DOWN_ITEM);
|
menu_driver(my_menu, REQ_DOWN_ITEM);
|
||||||
|
if(numChoice < list.size())
|
||||||
|
numChoice++;
|
||||||
break;
|
break;
|
||||||
case KEY_UP:
|
case KEY_UP:
|
||||||
menu_driver(my_menu, REQ_UP_ITEM);
|
menu_driver(my_menu, REQ_UP_ITEM);
|
||||||
break;
|
if(numChoice > 0)
|
||||||
case KEY_NPAGE:
|
numChoice--;
|
||||||
menu_driver(my_menu, REQ_SCR_DPAGE);
|
|
||||||
break;
|
|
||||||
case KEY_PPAGE:
|
|
||||||
menu_driver(my_menu, REQ_SCR_UPAGE);
|
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
auto item = current_item(my_menu);
|
stop = true;
|
||||||
action = item->index;
|
|
||||||
}
|
}
|
||||||
wrefresh(my_menu_win);
|
wrefresh(my_menu_win);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Unpost and free all the memory taken up */
|
/* Unpost and free all the memory taken up */
|
||||||
unpost_menu(my_menu);
|
unpost_menu(my_menu);
|
||||||
free_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]);
|
free_item(my_items[i]);
|
||||||
endwin();
|
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());
|
auto users = UserHelper::getMultiple(list.usersList());
|
||||||
|
|
||||||
// Get the conversation to show
|
// Get the conversation to show
|
||||||
Conversation *c = nullptr;
|
int idConv = ChooseConv(list, users);
|
||||||
ChooseConv(list, users, &c);
|
|
||||||
|
|
||||||
if(c == nullptr) {
|
if(idConv < 0) {
|
||||||
stop = true;
|
stop = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Open the conversation
|
||||||
|
showConversation(list[static_cast<size_t>(idConv)], users);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user