Compare commits

...

2 Commits

Author SHA1 Message Date
50ef8d9fda attempt at puting komes on multiple lines
Some checks are pending
/ sync-to-origin (push) Waiting to run
2025-04-06 16:08:54 +02:00
0a3bbffb52 komens list works(sort of) 2025-04-06 15:41:11 +02:00
2 changed files with 30 additions and 12 deletions

View File

@ -1,7 +1,7 @@
# Compiler and flags
CPPC = g++
CPPC_FLAGS = -std=c++23 -s -O3 -lncursesw -lcurl -lmenu -lpanel -Wall -Wextra -Wno-write-strings
DEBUG_FLAGS = -ggdb -std=c++23 -lncursesw -lcurl -lmenu -lpanel -Wall -Wextra -Wno-write-strings
CPPC_FLAGS = -std=c++23 -s -O3 -lncursesw -lcurl -lmenuw -lpanel -Wall -Wextra -Wno-write-strings
DEBUG_FLAGS = -ggdb -std=c++23 -lncursesw -lcurl -lmenuw -lpanel -Wall -Wextra -Wno-write-strings
SRC_PATH := src

View File

@ -2,9 +2,11 @@
#include "helper_funcs.h"
#include "memory.h"
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <curses.h>
#include <cwchar>
#include <fstream>
#include <iostream>
#include <menu.h>
@ -40,24 +42,40 @@ void komens_page() {
ITEM **komens_items = new ITEM *[num_of_komens + 1];
komens_allocated.push_back({ITEM_ARRAY, komens_items, num_of_komens});
char **komens_bufs = new char *[num_of_komens];
char title_buf[1500];
char name_buf[1500];
for (size_t i = 0; i < num_of_komens; i++) {
komens_items[i] = new_item(
resp_from_api["Messages"][i]["Title"].get<std::string>().c_str(),
resp_from_api["Messages"][i]["Sender"]["Name"]
.get<std::string>()
.c_str());
wcstombs(title_buf,
string_to_wstring(
resp_from_api["Messages"][i]["Title"].get<std::string>())
.c_str(),
sizeof(title_buf));
wcstombs(
name_buf,
string_to_wstring(
resp_from_api["Messages"][i]["Sender"]["Name"].get<std::string>())
.c_str(),
sizeof(name_buf));
komens_bufs[i] = new char[strlen(title_buf) + strlen(name_buf) + 2];
snprintf(komens_bufs[i], strlen(title_buf) + strlen(name_buf) + 1, "%s\n%s",
title_buf, name_buf);
komens_items[i] = new_item(komens_bufs[i], "");
}
komens_items[num_of_komens] = nullptr;
MENU *komens_choise_menu = new_menu(komens_items);
komens_allocated.push_back({MENU_TYPE, komens_choise_menu, 0});
WINDOW *komens_choise_menu_win = newwin(20, 40, 4, 4);
WINDOW *komens_choise_menu_win = newwin(40, 80, 4, 4);
komens_allocated.push_back({WINDOW_TYPE, komens_choise_menu_win, 0});
set_menu_win(komens_choise_menu, komens_choise_menu_win);
set_menu_sub(komens_choise_menu, derwin(komens_choise_menu_win, 8, 38, 3, 1));
set_menu_format(komens_choise_menu, 7, 1);
set_menu_sub(komens_choise_menu,
derwin(komens_choise_menu_win, 30, 78, 3, 1));
set_menu_format(komens_choise_menu, 29, 1);
set_menu_mark(komens_choise_menu, " * ");
@ -71,11 +89,11 @@ void komens_page() {
post_menu(komens_choise_menu);
wrefresh(komens_choise_menu_win);
attron(COLOR_PAIR(2));
attron(COLOR_PAIR(COLOR_BLUE));
mvprintw(LINES - 2, 0,
"Use PageUp and PageDown to scoll down or up a page of items");
mvprintw(LINES - 1, 0, "Arrow Keys to navigate (F1 to Exit)");
attroff(COLOR_PAIR(2));
attroff(COLOR_PAIR(COLOR_BLUE));
refresh();
int c;