Compare commits
3 Commits
e51088eb26
...
6b3d47ceed
Author | SHA1 | Date | |
---|---|---|---|
6b3d47ceed | |||
89c67035ca | |||
0486d9fb22 |
@ -12,7 +12,7 @@ inline constexpr auto hash_djb2a(const std::string_view sv) {
|
|||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline constexpr auto operator"" _sh(const char *str, size_t len) {
|
inline constexpr auto operator""_sh(const char *str, size_t len) {
|
||||||
return hash_djb2a(std::string_view{str, len});
|
return hash_djb2a(std::string_view{str, len});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,8 +99,9 @@ void main_menu() {
|
|||||||
choicesFuncs[item_index(current_item(main_menu.menu))]();
|
choicesFuncs[item_index(current_item(main_menu.menu))]();
|
||||||
current_allocated = &main_menu_allocated;
|
current_allocated = &main_menu_allocated;
|
||||||
pos_menu_cursor(main_menu.menu);
|
pos_menu_cursor(main_menu.menu);
|
||||||
refresh();
|
|
||||||
wrefresh(main_menu.win);
|
wrefresh(main_menu.win);
|
||||||
|
refresh();
|
||||||
|
redrawwin(main_menu.win);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
wrefresh(main_menu.win);
|
wrefresh(main_menu.win);
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include <bits/chrono.h>
|
#include <bits/chrono.h>
|
||||||
|
#include <climits>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
@ -26,6 +27,16 @@ using nlohmann::json;
|
|||||||
|
|
||||||
#define DEFAULT_OFFSET 3
|
#define DEFAULT_OFFSET 3
|
||||||
|
|
||||||
|
#define REMOVED_COLOR_PAIR COLOR_GREEN
|
||||||
|
#define ROOMCHANGED_COLOR_PAIR COLOR_MAGENTA
|
||||||
|
#define SUBSTITUTION_COLOR_PAIR COLOR_YELLOW
|
||||||
|
#define ADDED_COLOR_PAIR COLOR_BLUE
|
||||||
|
|
||||||
|
#define HELP_TEXT \
|
||||||
|
"Arrows/hjkl to select | ENTER to show info | p/n to select weeks |F1 to " \
|
||||||
|
"exit"
|
||||||
|
#define HELP_TEXT_LENGTH sizeof(HELP_TEXT) - 1
|
||||||
|
|
||||||
std::vector<allocation> timetable_allocated;
|
std::vector<allocation> timetable_allocated;
|
||||||
|
|
||||||
const wchar_t *day_abriviations[] = {nullptr, L"Mo", L"Tu", L"We",
|
const wchar_t *day_abriviations[] = {nullptr, L"Mo", L"Tu", L"We",
|
||||||
@ -279,9 +290,32 @@ reload_for_new_week:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
attron(COLOR_PAIR(COLOR_BLUE));
|
attron(COLOR_PAIR(COLOR_BLUE));
|
||||||
mvprintw(LINES - 2, 0,
|
mvprintw(LINES - 2, 0, HELP_TEXT);
|
||||||
"Arrows/hjkl to select | ENTER to show info | p/n to select weeks "
|
attroff(COLOR_PAIR(COLOR_BLUE));
|
||||||
"|F1 to exit");
|
|
||||||
|
{
|
||||||
|
constexpr char *change_types[] = {"Canceled/Removed", "RoomChanged",
|
||||||
|
"Substitution", "Added"};
|
||||||
|
|
||||||
|
constexpr uint8_t change_types_colors[] = {
|
||||||
|
REMOVED_COLOR_PAIR, ROOMCHANGED_COLOR_PAIR, SUBSTITUTION_COLOR_PAIR,
|
||||||
|
ADDED_COLOR_PAIR};
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < ARRAY_SIZE(change_types); i++) {
|
||||||
|
init_pair(UCHAR_MAX - i, COLOR_BLACK, change_types_colors[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t text_offset = 1;
|
||||||
|
for (uint8_t i = 0; i < ARRAY_SIZE(change_types); i++) {
|
||||||
|
attron(COLOR_PAIR(UCHAR_MAX - i));
|
||||||
|
mvprintw(LINES - 2, HELP_TEXT_LENGTH + text_offset, "%s",
|
||||||
|
change_types[i]);
|
||||||
|
attroff(COLOR_PAIR(UCHAR_MAX - i));
|
||||||
|
text_offset += strlen(change_types[i]) + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
attron(COLOR_PAIR(COLOR_BLUE));
|
||||||
{
|
{
|
||||||
std::tm end_week = local_time;
|
std::tm end_week = local_time;
|
||||||
std::tm start_week = local_time;
|
std::tm start_week = local_time;
|
||||||
@ -296,12 +330,13 @@ reload_for_new_week:
|
|||||||
.get<uint8_t>();
|
.get<uint8_t>();
|
||||||
|
|
||||||
// Calculate days back to start day (handles week wraparound)
|
// Calculate days back to start day (handles week wraparound)
|
||||||
int days_back = (current_wday >= start_day)
|
uint8_t days_back = (current_wday >= start_day)
|
||||||
? (current_wday - start_day)
|
? (current_wday - start_day)
|
||||||
: (current_wday + 7 - start_day);
|
: (current_wday + 7 - start_day);
|
||||||
|
|
||||||
// Calculate days forward to end day (handles week wraparound)
|
// Calculate days forward to end day (handles week wraparound)
|
||||||
int days_forward = (current_wday <= end_day) ? (end_day - current_wday)
|
uint8_t days_forward = (current_wday <= end_day)
|
||||||
|
? (end_day - current_wday)
|
||||||
: (end_day + 7 - current_wday);
|
: (end_day + 7 - current_wday);
|
||||||
|
|
||||||
// Adjust dates
|
// Adjust dates
|
||||||
@ -619,20 +654,24 @@ void draw_cells(uint8_t num_of_columns, uint8_t num_of_days,
|
|||||||
hash_djb2a(atom->at("Change")["ChangeType"].get<std::string>())) {
|
hash_djb2a(atom->at("Change")["ChangeType"].get<std::string>())) {
|
||||||
case "Canceled"_sh:
|
case "Canceled"_sh:
|
||||||
case "Removed"_sh:
|
case "Removed"_sh:
|
||||||
wattron(cells[i][j], COLOR_PAIR(COLOR_GREEN));
|
wattron(cells[i][j], COLOR_PAIR(REMOVED_COLOR_PAIR));
|
||||||
box(cells[i][j], 0, 0);
|
box(cells[i][j], 0, 0);
|
||||||
wattroff(cells[i][j], COLOR_PAIR(COLOR_GREEN));
|
wattroff(cells[i][j], COLOR_PAIR(REMOVED_COLOR_PAIR));
|
||||||
break;
|
break;
|
||||||
case "RoomChanged"_sh:
|
case "RoomChanged"_sh:
|
||||||
case "Substitution"_sh:
|
wattron(cells[i][j], COLOR_PAIR(ROOMCHANGED_COLOR_PAIR));
|
||||||
wattron(cells[i][j], COLOR_PAIR(COLOR_YELLOW));
|
|
||||||
box(cells[i][j], 0, 0);
|
box(cells[i][j], 0, 0);
|
||||||
wattroff(cells[i][j], COLOR_PAIR(COLOR_YELLOW));
|
wattroff(cells[i][j], COLOR_PAIR(ROOMCHANGED_COLOR_PAIR));
|
||||||
|
break;
|
||||||
|
case "Substitution"_sh:
|
||||||
|
wattron(cells[i][j], COLOR_PAIR(SUBSTITUTION_COLOR_PAIR));
|
||||||
|
box(cells[i][j], 0, 0);
|
||||||
|
wattroff(cells[i][j], COLOR_PAIR(SUBSTITUTION_COLOR_PAIR));
|
||||||
break;
|
break;
|
||||||
case "Added"_sh:
|
case "Added"_sh:
|
||||||
wattron(cells[i][j], COLOR_PAIR(COLOR_BLUE));
|
wattron(cells[i][j], COLOR_PAIR(ADDED_COLOR_PAIR));
|
||||||
box(cells[i][j], 0, 0);
|
box(cells[i][j], 0, 0);
|
||||||
wattroff(cells[i][j], COLOR_PAIR(COLOR_BLUE));
|
wattroff(cells[i][j], COLOR_PAIR(ADDED_COLOR_PAIR));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// TODO add error handling
|
// TODO add error handling
|
||||||
|
Loading…
x
Reference in New Issue
Block a user