attempt at puting komes on multiple lines
Some checks are pending
/ sync-to-origin (push) Waiting to run

This commit is contained in:
PoliEcho 2025-04-06 16:08:54 +02:00
parent 0a3bbffb52
commit 50ef8d9fda

View File

@ -2,6 +2,7 @@
#include "helper_funcs.h" #include "helper_funcs.h"
#include "memory.h" #include "memory.h"
#include <cstddef> #include <cstddef>
#include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <curses.h> #include <curses.h>
@ -41,28 +42,27 @@ void komens_page() {
ITEM **komens_items = new ITEM *[num_of_komens + 1]; ITEM **komens_items = new ITEM *[num_of_komens + 1];
komens_allocated.push_back({ITEM_ARRAY, komens_items, num_of_komens}); komens_allocated.push_back({ITEM_ARRAY, komens_items, num_of_komens});
char **title_bufs = new char *[num_of_komens]; char **komens_bufs = new char *[num_of_komens];
char **name_bufs = new char *[num_of_komens]; char title_buf[1500];
char tmp_buf[1500]; char name_buf[1500];
for (size_t i = 0; i < num_of_komens; i++) { for (size_t i = 0; i < num_of_komens; i++) {
wcstombs(tmp_buf, wcstombs(title_buf,
string_to_wstring( string_to_wstring(
resp_from_api["Messages"][i]["Title"].get<std::string>()) resp_from_api["Messages"][i]["Title"].get<std::string>())
.c_str(), .c_str(),
sizeof(tmp_buf)); sizeof(title_buf));
title_bufs[i] = new char[strlen(tmp_buf) + 1];
strlcpy(title_bufs[i], tmp_buf, strlen(tmp_buf));
wcstombs( wcstombs(
tmp_buf, name_buf,
string_to_wstring( string_to_wstring(
resp_from_api["Messages"][i]["Sender"]["Name"].get<std::string>()) resp_from_api["Messages"][i]["Sender"]["Name"].get<std::string>())
.c_str(), .c_str(),
sizeof(tmp_buf)); sizeof(name_buf));
name_bufs[i] = new char[strlen(tmp_buf) + 1]; komens_bufs[i] = new char[strlen(title_buf) + strlen(name_buf) + 2];
strlcpy(name_bufs[i], tmp_buf, strlen(tmp_buf)); snprintf(komens_bufs[i], strlen(title_buf) + strlen(name_buf) + 1, "%s\n%s",
title_buf, name_buf);
komens_items[i] = new_item(title_bufs[i], name_bufs[i]); komens_items[i] = new_item(komens_bufs[i], "");
} }
komens_items[num_of_komens] = nullptr; komens_items[num_of_komens] = nullptr;