Commit ad6dab31 authored by mbionchi's avatar mbionchi

undo unneeded refactor b/c it messes with window resizing

parent 3be4e41f
......@@ -46,20 +46,12 @@ int main(int argc, char **argv) {
opt = getopt_long_only(argc, argv, "", options, NULL);
}
WINDOW *main_window = initscr();
cbreak();
halfdelay(1);
noecho();
curs_set(0);
nonl();
keypad(main_window, 1);
if (!site_path) {
fprintf(stderr, "Usage: %s --site <path-to-dir> [--splash <path-to-file>]\n", binary_name);
exit(1);
}
if (splash_path) {
splash(main_window, splash_path);
splash(splash_path);
}
site(main_window, site_path);
endwin();
site(site_path);
}
......@@ -63,7 +63,7 @@ void winch_handler(int signo) {
* - error handling everywhere please
* - refactor the event loop, it's horrifying atm
*/
void site(WINDOW *window, char *path) {
void site(char *path) {
signal(SIGWINCH, winch_handler);
struct window index_window;
......@@ -88,6 +88,14 @@ void site(WINDOW *window, char *path) {
gen_err_opening(&content_window.content);
}
WINDOW *main_window = initscr();
cbreak();
halfdelay(1);
noecho();
curs_set(0);
nonl();
keypad(main_window, 1);
int index_left_margin = 2;
int index_cols = get_index_width(sections, n_sections);
int index_scroll_threshold = 5;
......@@ -393,4 +401,5 @@ void site(WINDOW *window, char *path) {
delwin(index_window.window);
delwin(separator_window.window);
delwin(content_window.window);
endwin();
}
......@@ -20,6 +20,6 @@
#include <ncurses.h>
void site(WINDOW *window, char *site_path);
void site(char *site_path);
#endif
......@@ -29,11 +29,16 @@
#include <string.h>
#include <signal.h>
void splash(WINDOW *window, char *path) {
signal(SIGWINCH, SIG_IGN);
void splash(char *path) {
struct window splash_window;
splash_window.window = initscr();
cbreak();
halfdelay(1);
noecho();
curs_set(0);
nonl();
FILE *fp = fopen(path, "r");
if (fp != NULL) {
splash_window.content.type = STATIC;
......@@ -45,8 +50,6 @@ void splash(WINDOW *window, char *path) {
gen_err_opening(&splash_window.content);
}
splash_window.window = window;
splash_window.cols = COLS;
splash_window.rows = LINES;
splash_window.scroll = 0;
......@@ -60,7 +63,7 @@ void splash(WINDOW *window, char *path) {
render_ncontent(&splash_window);
wrefresh(window);
wrefresh(splash_window.window);
int ch = getch();
while (ch == ERR) {
......@@ -72,6 +75,7 @@ void splash(WINDOW *window, char *path) {
free_content(&splash_window);
free_anim_refs(&splash_window);
clear();
wrefresh(window);
wrefresh(splash_window.window);
endwin();
return;
}
......@@ -20,6 +20,6 @@
#include <ncurses.h>
void splash(WINDOW *window, char *path);
void splash(char *path);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment