aboutsummaryrefslogtreecommitdiffstats
path: root/src/display.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/display.c')
-rw-r--r--src/display.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/display.c b/src/display.c
new file mode 100644
index 0000000..e7dd031
--- /dev/null
+++ b/src/display.c
@@ -0,0 +1,58 @@
+#include "display.h"
+
+#include <curses.h>
+
+#include "err.h"
+#include "log.h"
+#include "version.h"
+#include "wm.h"
+
+void
+color_pair_init(void)
+{
+ init_pair(COLOR_PAIR_FM_HL, COLOR_BLACK, COLOR_WHITE);
+ init_pair(COLOR_PAIR_FM_DIR, COLOR_CYAN, COLOR_BLACK);
+ init_pair(COLOR_PAIR_FM_STATUS_BAR, COLOR_BLUE, COLOR_BLACK);
+}
+
+terminal *
+ncurses_init(void)
+{
+ initscr();
+ raw();
+ curs_set(0);
+ noecho();
+ if (!has_colors()) {
+ log_write(LOG_WARN, "Terminal does not support colors");
+ }
+
+ start_color();
+ color_pair_init();
+ terminal *t = wm_init();
+ keypad(ROOT_WIN, TRUE);
+ return t;
+}
+
+void
+wprintw_colorful(WINDOW *w, int attr, const char *format, ...)
+{
+ va_list ap;
+ va_start(ap, format);
+ wattron(w, COLOR_PAIR(attr));
+ vw_printw(w, format, ap);
+ wattroff(w, COLOR_PAIR(attr));
+ va_end(ap);
+}
+
+void
+handle_resize(void)
+{
+ endwin();
+ refresh();
+}
+
+void
+redraw(void)
+{
+ erase();
+}