mirror of
https://gitlab.com/comunic/comunicterm
synced 2024-12-25 13:08:54 +00:00
Display the list of conversations
This commit is contained in:
parent
115607b1fe
commit
12898fb609
@ -48,7 +48,7 @@ static void ChooseConv(ConversationsList &list, const UsersList &users, Conversa
|
||||
|
||||
/* Create items */
|
||||
vector<string> itemsStr;
|
||||
int numItems = 0;
|
||||
size_t numItems = 0;
|
||||
n_choices = static_cast<int>(list.size()) + 2;
|
||||
my_items = static_cast<ITEM **>(calloc(static_cast<size_t>(n_choices), sizeof(ITEM *)));
|
||||
|
||||
@ -57,8 +57,16 @@ static void ChooseConv(ConversationsList &list, const UsersList &users, Conversa
|
||||
|
||||
// Conversations
|
||||
for(size_t i = 0; i < list.size(); ++i) {
|
||||
itemsStr.push_back(list[i].name(users));
|
||||
my_items[i+1] = new_item("yo", "d");
|
||||
std::string name = list[i].name(users);
|
||||
ui_utils::remove_special_chars(name);
|
||||
itemsStr.push_back(name);
|
||||
itemsStr.push_back(to_string(list[i].members().size()) + " members");
|
||||
}
|
||||
|
||||
for(size_t i = 0; i < list.size(); ++i) {
|
||||
my_items[i+1] = new_item(itemsStr.at(numItems).c_str(),
|
||||
itemsStr.at(numItems+1).c_str());
|
||||
numItems+=2;
|
||||
}
|
||||
|
||||
my_items[n_choices-1] = new_item(nullptr, nullptr);
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include <ui_utils.h>
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -70,3 +72,10 @@ void print_in_middle(WINDOW *win, int starty, int startx, int width, char *strin
|
||||
wattroff(win, color);
|
||||
refresh();
|
||||
}
|
||||
|
||||
void ui_utils::remove_special_chars(string &input)
|
||||
{
|
||||
input.erase(std::remove_if(input.begin(), input.end(),
|
||||
[](char c) { return !std::isspace(c) && !std::isalpha(c); } ),
|
||||
input.end());
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
namespace ui_utils {
|
||||
void alert(WINDOW *win, const std::string &msg);
|
||||
void print_base_screen(WINDOW *w);
|
||||
void remove_special_chars(std::string &input);
|
||||
}
|
||||
|
||||
void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string, chtype color);
|
||||
|
Loading…
Reference in New Issue
Block a user