Compare commits

..

No commits in common. "f01422eaf549f9eb8b3e581f9740ae00b6893d34" and "a78f4536b2dd1012a30e2292ee0a11cf5c337b87" have entirely different histories.

12 changed files with 119 additions and 198 deletions

2
.gitignore vendored
View File

@ -1,7 +1,7 @@
.cache
.vscode
compile_commands.json
*core*
core*
build
test-data
log

View File

@ -2,7 +2,6 @@
CPPC = g++
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
DEBUG_ASANITIZE = -fsanitize=address -ggdb -fno-omit-frame-pointer -std=c++23 -lncursesw -lcurl -lmenuw -lpanel -Wall -Wextra -Wno-write-strings
SRC_PATH := src
@ -20,9 +19,6 @@ all: make-build-dir $(BIN_PATH)/bakatui
debug: CPPC_FLAGS = $(DEBUG_FLAGS)
debug: make-build-dir $(BIN_PATH)/bakatui
asan: CPPC_FLAGS = $(DEBUG_ASANITIZE)
asan: make-build-dir $(BIN_PATH)/bakatui
make-build-dir:
mkdir -p $(OBJ_PATH)
@ -43,4 +39,4 @@ install:
clean:
rm -fr build
.PHONY: all clean install debug asan
.PHONY: all clean install debug

View File

@ -6,7 +6,6 @@
#include <algorithm>
#include <codecvt>
#include <csignal>
#include <cstring>
#include <curses.h>
#include <dirent.h>
#include <filesystem>
@ -208,11 +207,6 @@ char *wchar_to_char(const wchar_t *src) {
size_t len = wcslen(src) + 1; // +1 for null terminator
char *dest = new char[len * MB_CUR_MAX];
current_allocated->push_back(allocation{
GENERIC_ARRAY,
dest,
len * MB_CUR_MAX,
});
std::wcstombs(dest, src, len * MB_CUR_MAX);
return dest;

View File

@ -26,28 +26,22 @@ using nlohmann::json;
std::vector<allocation> komens_allocated;
void insert_content(WINDOW *content_win, WINDOW *attachment_win,
const json &resp_from_api);
void komens_print_usage_message() {
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(COLOR_BLUE));
refresh();
}
json &resp_from_api);
void komens_page(koment_type type) {
current_allocated = &komens_allocated;
const json resp_from_api = [&]() -> json {
json resp_from_api;
{
/*std::ifstream f("test-data/komens.json");
resp_from_api = json::parse(f);
f.close();*/
const char *types[] = {"/api/3/komens/messages/received",
"/api/3/komens/messages/sent",
"/api/3/komens/messages/noticeboard"};
const std::string endpoint = types[type];
return bakaapi::get_data_from_endpoint(endpoint, POST);
}();
resp_from_api = bakaapi::get_data_from_endpoint(endpoint, POST);
}
/* Initialize curses */
setlocale(LC_ALL, "");
@ -63,16 +57,14 @@ void komens_page(koment_type type) {
}
complete_menu komens_choise_menu;
komens_allocated.push_back({COMPLETE_MENU_TYPE, &komens_choise_menu, 1});
size_t num_of_komens = resp_from_api["Messages"].size();
komens_choise_menu.items = new ITEM *[num_of_komens + 1];
komens_choise_menu.items_size = num_of_komens + 1;
komens_allocated.push_back(
{ITEM_ARRAY, komens_choise_menu.items, num_of_komens});
char **title_bufs = new char *[num_of_komens];
komens_allocated.push_back({CHAR_PTR_ARRAY, title_bufs, num_of_komens});
char **name_bufs = new char *[num_of_komens];
komens_allocated.push_back({CHAR_PTR_ARRAY, name_bufs, num_of_komens});
size_t max_item_lenght;
{
size_t max_title_lenght = 0;
@ -80,9 +72,11 @@ void komens_page(koment_type type) {
size_t tmp_lenght;
char tmp_buf[1500];
for (size_t i = 0; i < num_of_komens; i++) {
strlcpy(tmp_buf,
resp_from_api["Messages"][i]["Title"].get<std::string>().c_str(),
sizeof(tmp_buf));
wcstombs(tmp_buf,
string_to_wstring(
resp_from_api["Messages"][i]["Title"].get<std::string>())
.c_str(),
sizeof(tmp_buf));
tmp_lenght =
resp_from_api["Messages"][i]["Title"].get<std::string>().length();
@ -93,12 +87,12 @@ void komens_page(koment_type type) {
title_bufs[i] = new char[strlen(tmp_buf) + 1];
strlcpy(title_bufs[i], tmp_buf, strlen(tmp_buf) + 1);
strlcpy(tmp_buf,
resp_from_api["Messages"][i]["Sender"]["Name"]
.get<std::string>()
.c_str(),
sizeof(tmp_buf));
wcstombs(
tmp_buf,
string_to_wstring(
resp_from_api["Messages"][i]["Sender"]["Name"].get<std::string>())
.c_str(),
sizeof(tmp_buf));
tmp_lenght = resp_from_api["Messages"][i]["Sender"]["Name"]
.get<std::string>()
@ -118,6 +112,7 @@ void komens_page(koment_type type) {
komens_choise_menu.items[num_of_komens] = nullptr;
komens_choise_menu.menu = new_menu(komens_choise_menu.items);
komens_allocated.push_back({MENU_TYPE, komens_choise_menu.menu, 1});
komens_choise_menu.win =
newwin(MAIN_WIN_HIGHT, max_item_lenght + 1, DEFAULT_OFSET, DEFAULT_OFSET);
@ -148,13 +143,17 @@ void komens_page(koment_type type) {
komens_allocated.push_back({WINDOW_TYPE, content_win, 1});
WINDOW *attachment_win = newwin(1, 1, LINES, COLS);
komens_allocated.push_back({WINDOW_TYPE, attachment_win, 1});
insert_content(content_win, attachment_win,
resp_from_api["Messages"][item_index(
current_item(komens_choise_menu.menu))]);
komens_print_usage_message();
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(COLOR_BLUE));
refresh();
int c;
while ((c = getch()) != KEY_F(1)) {
@ -205,7 +204,6 @@ void komens_page(koment_type type) {
komens_choise_menu.menu))]["Attachments"][index]["Id"]
.get<std::string>(),
path);
komens_print_usage_message();
}
}
break;
@ -216,13 +214,11 @@ void komens_page(koment_type type) {
current_item(komens_choise_menu.menu))]);
wrefresh(komens_choise_menu.win);
}
unpost_menu(komens_choise_menu.menu);
endwin();
delete_all(&komens_allocated);
}
void insert_content(WINDOW *content_win, WINDOW *attachment_win,
const json &message) {
json &message) {
wclear(content_win);
mvwprintw(content_win, 0, 0, "%s",
html_to_string(message.at("Text")).c_str());

View File

@ -1,7 +1,6 @@
#include "komens_menu.h"
#include "helper_funcs.h"
#include "komens.h"
#include "memory.h"
#include "net.h"
#include "types.h"
#include <cstdlib>
@ -9,19 +8,15 @@
#include <curses.h>
#include <menu.h>
std::vector<allocation> komens_menu_allocated;
void komens_menu() {
current_allocated = &komens_menu_allocated;
wchar_t *choices[] = {
L"received", L"sent", L"noticeboard", L"Exit", nullptr,
};
complete_menu komens_menu;
komens_menu_allocated.push_back({COMPLETE_MENU_TYPE, &komens_menu, 1});
int c;
int n_choices;
int n_choices, i;
/* Initialize curses */
setlocale(LC_ALL, "");
@ -35,11 +30,8 @@ void komens_menu() {
/* Create items */
n_choices = ARRAY_SIZE(choices);
komens_menu.items = new ITEM *[ARRAY_SIZE(choices)];
komens_menu.items_size = ARRAY_SIZE(choices);
for (int i = 0; i < n_choices; ++i)
komens_menu.items = (ITEM **)calloc(n_choices, sizeof(ITEM *));
for (i = 0; i < n_choices; ++i)
komens_menu.items[i] =
new_item(wchar_to_char(choices[i]), wchar_to_char(choices[i]));
@ -97,7 +89,6 @@ void komens_menu() {
}
komens_page(
static_cast<koment_type>(item_index(current_item(komens_menu.menu))));
current_allocated = &komens_menu_allocated;
pos_menu_cursor(komens_menu.menu);
refresh();
wrefresh(komens_menu.win);
@ -109,6 +100,8 @@ close_menu:
/* Unpost and free all the memory taken up */
unpost_menu(komens_menu.menu);
delete_all(&komens_menu_allocated);
free_menu(komens_menu.menu);
for (i = 0; i < n_choices; ++i)
free_item(komens_menu.items[i]);
endwin();
}

View File

@ -1,21 +1,16 @@
#include "helper_funcs.h"
#include "komens_menu.h"
#include "marks.h"
#include "memory.h"
#include "net.h"
#include "timetable.h"
#include "types.h"
#include <cstddef>
#include <cstdlib>
#include <cstring>
#include <curses.h>
#include <menu.h>
std::vector<allocation> main_menu_allocated;
void main_menu() {
current_allocated = &main_menu_allocated;
const wchar_t *choices[] = {
wchar_t *choices[] = {
L"login", L"Marks", L"timetable", L"Komens",
L"Homework", L"Absence", L"Exit", nullptr,
};
@ -23,7 +18,9 @@ void main_menu() {
nullptr, nullptr, nullptr, nullptr};
complete_menu main_menu;
main_menu_allocated.push_back({COMPLETE_MENU_TYPE, &main_menu, 1});
int c;
int n_choices, i;
/* Initialize curses */
setlocale(LC_ALL, "");
@ -36,15 +33,14 @@ void main_menu() {
init_pair(2, COLOR_CYAN, COLOR_BLACK);
/* Create items */
main_menu.items = new ITEM *[ARRAY_SIZE(choices)];
main_menu.items_size = ARRAY_SIZE(choices);
for (size_t i = 0; i < ARRAY_SIZE(choices); ++i) {
n_choices = ARRAY_SIZE(choices);
main_menu.items = (ITEM **)calloc(n_choices, sizeof(ITEM *));
for (i = 0; i < n_choices; ++i)
main_menu.items[i] =
new_item(wchar_to_char(choices[i]), wchar_to_char(choices[i]));
}
/* Crate menu */
main_menu.menu = new_menu(main_menu.items);
main_menu.menu = new_menu((ITEM **)main_menu.items);
/* Create the window to be associated with the menu */
main_menu.win = newwin(12, 40, 4, 4);
@ -77,7 +73,6 @@ void main_menu() {
attroff(COLOR_PAIR(2));
refresh();
int c;
while ((c = getch()) != KEY_F(1)) {
switch (c) {
case KEY_DOWN:
@ -93,11 +88,10 @@ void main_menu() {
break;
case 10: // ENTER
clear();
if (item_index(current_item(main_menu.menu)) == ARRAY_SIZE(choices) - 1) {
if (item_index(current_item(main_menu.menu)) == n_choices - 1) {
goto close_menu;
}
choicesFuncs[item_index(current_item(main_menu.menu))]();
current_allocated = &main_menu_allocated;
pos_menu_cursor(main_menu.menu);
refresh();
wrefresh(main_menu.win);
@ -109,6 +103,8 @@ close_menu:
/* Unpost and free all the memory taken up */
unpost_menu(main_menu.menu);
delete_all(&main_menu_allocated);
free_menu(main_menu.menu);
for (i = 0; i < n_choices; ++i)
free_item(main_menu.items[i]);
endwin();
}

View File

@ -31,25 +31,22 @@ using nlohmann::json;
std::vector<allocation> marks_allocated;
void init_wins(WINDOW **wins, const int n, const json &marks_json);
void win_show(WINDOW *win, const wchar_t *label, const int label_color,
int width, int height, const json &marks_json,
const int SubjectIndex);
void init_wins(WINDOW **wins, int n, json marks_json);
void win_show(WINDOW *win, wchar_t *label, int label_color, int width,
int height, json marks_json, int SubjectIndex);
void marks_page() {
current_allocated = &marks_allocated;
// thanks to lambda i can make this const
const json resp_from_api = [&]() -> json {
const std::string endpoint = "api/3/marks";
return bakaapi::get_data_from_endpoint(endpoint, GET);
}();
const size_t size_my_wins = resp_from_api["Subjects"].size();
json resp_from_api;
{
std::string endpoint = "api/3/marks";
resp_from_api = bakaapi::get_data_from_endpoint(endpoint, GET);
}
size_t size_my_wins = resp_from_api["Subjects"].size();
WINDOW **my_wins = new (std::nothrow) WINDOW *[size_my_wins];
marks_allocated.push_back({WINDOW_ARRAY, my_wins, size_my_wins});
const size_t size_my_panels = size_my_wins;
size_t size_my_panels = resp_from_api["Subjects"].size();
PANEL **my_panels = new (std::nothrow) PANEL *[size_my_panels];
marks_allocated.push_back({PANEL_ARRAY, my_panels, size_my_panels});
@ -135,7 +132,7 @@ void marks_page() {
}
/* Put all the windows */
void init_wins(WINDOW **wins, const int n, const json &marks_json) {
void init_wins(WINDOW **wins, int n, json marks_json) {
int x, y, i;
wchar_t label[1500];
@ -148,12 +145,12 @@ void init_wins(WINDOW **wins, const int n, const json &marks_json) {
for (i = 0; i < n; ++i) {
// Calculate label and max_text_length to determine window width
const std::string sub_name = marks_json["Subjects"][i]["Subject"]["Name"];
const std::string sub_avg_s = marks_json["Subjects"][i]["AverageText"];
std::string sub_name = marks_json["Subjects"][i]["Subject"]["Name"];
std::string sub_avg_s = marks_json["Subjects"][i]["AverageText"];
// Convert to wchar_t
const std::wstring wsub_name = string_to_wstring(sub_name);
const std::wstring wsub_avg_s = string_to_wstring(sub_avg_s);
std::wstring wsub_name = string_to_wstring(sub_name);
std::wstring wsub_avg_s = string_to_wstring(sub_avg_s);
// Using swprintf for wide character formatting
swprintf(label, sizeof(label) / sizeof(label[0]), L"%ls - avg: %ls",
@ -163,18 +160,17 @@ void init_wins(WINDOW **wins, const int n, const json &marks_json) {
for (unsigned int j = 0; j < static_cast<unsigned int>(
marks_json["Subjects"][i]["Marks"].size());
j++) {
const std::string caption =
std::string caption =
rm_tr_le_whitespace(marks_json["Subjects"][i]["Marks"][j]["Caption"]);
const std::string theme =
std::string theme =
rm_tr_le_whitespace(marks_json["Subjects"][i]["Marks"][j]["Theme"]);
const std::wstring wcaption = string_to_wstring(caption);
const std::wstring wtheme = string_to_wstring(theme);
std::wstring wcaption = string_to_wstring(caption);
std::wstring wtheme = string_to_wstring(theme);
// Some code that does something and fixes some edge cases
const std::string testCaption =
caption + std::format(" {{{}}} [{}]", "X", 0);
const std::wstring wTestCaption = string_to_wstring(testCaption);
std::string testCaption = caption + std::format(" {{{}}} [{}]", "X", 0);
std::wstring wTestCaption = string_to_wstring(testCaption);
max_text_length =
std::max({max_text_length, wTestCaption.length(), wtheme.length()});
}
@ -207,9 +203,8 @@ void init_wins(WINDOW **wins, const int n, const json &marks_json) {
}
/* Show the window with a border and a label */
void win_show(WINDOW *win, const wchar_t *label, const int label_color,
int width, int height, const json &marks_json,
const int SubjectIndex) {
void win_show(WINDOW *win, wchar_t *label, int label_color, int width,
int height, json marks_json, int SubjectIndex) {
// is the compiler smoking weed or something, why is it thinking starty is not
// used ??

View File

@ -1,34 +1,9 @@
#include "memory.h"
#include "color.h"
#include "types.h"
#include <curses.h>
#include <iostream>
#include <menu.h>
#include <ncurses.h>
#include <panel.h>
template <typename T> struct NcursesDeleter {
static void delete_element(T obj);
};
template <> void NcursesDeleter<WINDOW *>::delete_element(WINDOW *win) {
delwin(win);
}
template <> void NcursesDeleter<PANEL *>::delete_element(PANEL *pan) {
del_panel(pan);
}
template <> void NcursesDeleter<ITEM *>::delete_element(ITEM *item) {
free_item(item);
}
template <typename T> void delete_ncurses_arrays(void *ptr, std::size_t size) {
T *array = static_cast<T *>(ptr);
for (std::size_t j = 0; j < size; ++j) {
NcursesDeleter<T>::delete_element(array[j]);
}
delete[] array;
}
void delete_all(std::vector<allocation> *allocated) {
if (allocated == nullptr) {
return;
@ -36,26 +11,27 @@ void delete_all(std::vector<allocation> *allocated) {
for (long long i = allocated->size() - 1; i >= 0; i--) {
switch (allocated->at(i).type) {
case WINDOW_ARRAY: {
delete_ncurses_arrays<WINDOW *>(allocated->at(i).ptr,
allocated->at(i).size);
WINDOW **windows = static_cast<WINDOW **>(allocated->at(i).ptr);
for (std::size_t j = 0; j < allocated->at(i).size; j++) {
delwin(windows[j]);
}
delete[] windows;
break;
}
case PANEL_ARRAY: {
delete_ncurses_arrays<PANEL *>(allocated->at(i).ptr,
allocated->at(i).size);
PANEL **panels = static_cast<PANEL **>(allocated->at(i).ptr);
for (std::size_t j = 0; j < allocated->at(i).size; j++) {
del_panel(panels[j]);
}
delete[] panels;
break;
}
case ITEM_ARRAY: {
delete_ncurses_arrays<ITEM *>(allocated->at(i).ptr,
allocated->at(i).size);
break;
}
case CHAR_PTR_ARRAY: {
char **array = static_cast<char **>(allocated->at(i).ptr);
for (std::size_t j = 0; j < allocated->at(i).size; ++j) {
delete[] array[j];
ITEM **items = static_cast<ITEM **>(allocated->at(i).ptr);
for (std::size_t j = 0; j < allocated->at(i).size; j++) {
free_item(items[j]);
}
delete[] array;
delete[] items;
break;
}
case GENERIC_ARRAY:
@ -70,15 +46,6 @@ void delete_all(std::vector<allocation> *allocated) {
case MENU_TYPE:
free_menu(static_cast<MENU *>(allocated->at(i).ptr));
break;
case COMPLETE_MENU_TYPE: {
free_menu(static_cast<complete_menu *>(allocated->at(i).ptr)->menu);
delwin(static_cast<complete_menu *>(allocated->at(i).ptr)->win);
delete_ncurses_arrays<ITEM *>(
static_cast<complete_menu *>(allocated->at(i).ptr)->items,
static_cast<complete_menu *>(allocated->at(i).ptr)->items_size);
break;
}
case GENERIC_TYPE:
delete static_cast<char *>(allocated->at(i).ptr);
break;

View File

@ -9,12 +9,10 @@ enum AllocationType {
WINDOW_ARRAY,
PANEL_ARRAY,
ITEM_ARRAY,
CHAR_PTR_ARRAY,
GENERIC_ARRAY,
WINDOW_TYPE,
PANEL_TYPE,
MENU_TYPE,
COMPLETE_MENU_TYPE,
GENERIC_TYPE
};

View File

@ -9,7 +9,6 @@
#include <cstdlib>
#include <cstring>
#include <curl/curl.h>
#include <curl/header.h>
#include <curses.h>
#include <dirent.h>
#include <fcntl.h>
@ -112,29 +111,24 @@ std::tuple<std::string, int> send_curl_request(
safe_exit(EINVAL);
}
CURLcode curl_return_code = curl_easy_perform(curl);
curl_slist_free_all(headers);
if (curl_return_code != CURLE_OK) {
std::cerr << RED "[ERROR] " << RESET << "curl_easy_perform() failed: "
<< curl_easy_strerror(curl_return_code) << "\n";
safe_exit(21);
}
if (fileStream) {
fileStream->close();
}
int http_code = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);
return {response, http_code};
} else {
std::cerr << RED "[ERROR] " << RESET "curl not initialised\n";
safe_exit(20);
// prevent compiler warning
return {"", -1};
}
CURLcode curl_return_code = curl_easy_perform(curl);
if (curl_return_code != CURLE_OK) {
std::cerr << RED "[ERROR] " << RESET << "curl_easy_perform() failed: "
<< curl_easy_strerror(curl_return_code) << "\n";
safe_exit(21);
}
if (fileStream) {
fileStream->close();
}
int http_code = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);
return {response, http_code};
}
namespace bakaapi {

View File

@ -32,18 +32,16 @@ const wchar_t *day_abriviations[] = {nullptr, L"Mo", L"Tu", L"We",
L"Th", L"Fr", L"Sa", L"Su"};
void draw_days(WINDOW **&day_windows, uint16_t cell_height, uint8_t num_of_days,
const json &resp_from_api);
json &resp_from_api);
void draw_lessons(WINDOW **&lesson_windows, uint8_t num_of_columns,
uint16_t cell_width,
const std::vector<uint8_t> &HourIdLookupTable,
const json &resp_from_api);
uint16_t cell_width, std::vector<uint8_t> &HourIdLookupTable,
json &resp_from_api);
void draw_cells(uint8_t num_of_columns, uint8_t num_of_days,
uint16_t cell_width, uint16_t cell_height,
std::vector<std::vector<WINDOW *>> &cells,
const std::vector<uint8_t> &HourIdLookupTable,
const json &resp_from_api);
std::vector<uint8_t> &HourIdLookupTable, json &resp_from_api);
uint8_t hour_id_to_index(const std::vector<uint8_t> &HourIdLookupTable,
uint8_t id) {
@ -55,8 +53,8 @@ uint8_t hour_id_to_index(const std::vector<uint8_t> &HourIdLookupTable,
return 0;
}
const json *partial_json_by_id(const json &resp_from_api,
const std::string &what, const std::string &id) {
json *partial_json_by_id(json &resp_from_api, const std::string &what,
const std::string &id) {
for (uint8_t i = 0; i < resp_from_api[what].size(); i++) {
if (resp_from_api[what][i]["Id"].get<std::string>() == id) {
return &resp_from_api[what][i];
@ -65,7 +63,7 @@ const json *partial_json_by_id(const json &resp_from_api,
return nullptr;
}
std::wstring get_data_for_atom(const json &resp_from_api, const json *atom,
std::wstring get_data_for_atom(json &resp_from_api, json *atom,
const std::string &from_where,
const std::string &id_key,
const std::string &what) {
@ -76,10 +74,9 @@ std::wstring get_data_for_atom(const json &resp_from_api, const json *atom,
.get<std::string>());
}
const json *
find_atom_by_indexes(const json &resp_from_api, uint8_t day_index,
uint8_t hour_index,
const std::vector<uint8_t> &HourIdLookupTable) {
json *find_atom_by_indexes(json &resp_from_api, uint8_t day_index,
uint8_t hour_index,
const std::vector<uint8_t> &HourIdLookupTable) {
for (uint8_t k = 0; k < resp_from_api["Days"][day_index]["Atoms"].size();
k++) {
if (resp_from_api["Days"][day_index]["Atoms"][k]["HourId"].get<uint8_t>() ==
@ -94,7 +91,6 @@ void timetable_page() {
current_allocated = &timetable_allocated;
auto dateSelected = std::chrono::system_clock::now();
reload_for_new_week:
clear();
std::time_t date_time_t = std::chrono::system_clock::to_time_t(dateSelected);
std::tm local_time = *std::localtime(&date_time_t);
@ -104,7 +100,7 @@ reload_for_new_week:
std::string date_string = "date=" + date_stringstream.str();
std::string endpoint = "api/3/timetable/actual";
const json resp_from_api =
json resp_from_api =
bakaapi::get_data_from_endpoint(endpoint, GET, date_string);
// this may be unnecessary but i dont have enaugh data to test it
@ -388,8 +384,8 @@ reload_for_new_week:
goto reload_for_new_week;
break;
case 10: // ENTER
const json *atom = find_atom_by_indexes(
resp_from_api, selected_cell.y, selected_cell.x, HourIdLookupTable);
json *atom = find_atom_by_indexes(resp_from_api, selected_cell.y,
selected_cell.x, HourIdLookupTable);
if (atom == nullptr) {
std::cerr << RED "[ERROR]" << RESET " Selector at invalid position\n";
safe_exit(129);
@ -539,7 +535,7 @@ reload_for_new_week:
}
void draw_days(WINDOW **&day_windows, uint16_t cell_height, uint8_t num_of_days,
const json &resp_from_api) {
json &resp_from_api) {
for (uint8_t i = 0; i < num_of_days; i++) {
// this wont draw left boarder window making it so it looks partially
// offscreen
@ -553,9 +549,8 @@ void draw_days(WINDOW **&day_windows, uint16_t cell_height, uint8_t num_of_days,
}
void draw_lessons(WINDOW **&lesson_windows, uint8_t num_of_columns,
uint16_t cell_width,
const std::vector<uint8_t> &HourIdLookupTable,
const json &resp_from_api) {
uint16_t cell_width, std::vector<uint8_t> &HourIdLookupTable,
json &resp_from_api) {
for (uint8_t i = 0; i < num_of_columns; i++) {
wborder(lesson_windows[i], 0, 0, ' ', 0, ACS_VLINE, ACS_VLINE, 0, 0);
std::wstring caption;
@ -599,13 +594,11 @@ void draw_lessons(WINDOW **&lesson_windows, uint8_t num_of_columns,
void draw_cells(uint8_t num_of_columns, uint8_t num_of_days,
uint16_t cell_width, uint16_t cell_height,
std::vector<std::vector<WINDOW *>> &cells,
const std::vector<uint8_t> &HourIdLookupTable,
const json &resp_from_api) {
std::vector<uint8_t> &HourIdLookupTable, json &resp_from_api) {
for (uint8_t i = 0; i < num_of_days; i++) {
for (uint8_t j = 0; j < num_of_columns; j++) {
const json *atom =
find_atom_by_indexes(resp_from_api, i, j, HourIdLookupTable);
json *atom = find_atom_by_indexes(resp_from_api, i, j, HourIdLookupTable);
if (atom == nullptr) {
continue;
}

View File

@ -148,7 +148,6 @@ struct SelectorType {
struct complete_menu {
WINDOW *win;
ITEM **items;
size_t items_size;
MENU *menu;
};