commit - a6d7eb8dbe881d3132e03307cec02e1acce931d1
commit + 25791caa10d65e80e2ccc2823bb37f611531a081
blob - 885bafc24ce73234f4b4f7b934e7faa5d29d4730
blob + dbd0f0897a169d7fc4b34a0698363c4a947ddb85
--- tog/tog.c
+++ tog/tog.c
#include <sys/queue.h>
#include <sys/stat.h>
+#include <sys/ioctl.h>
#include <errno.h>
#define _XOPEN_SOURCE_EXTENDED
static const struct got_error *input_tree_view(struct tog_view **,
struct tog_view **, struct tog_view **, struct tog_view *, int);
static const struct got_error *close_tree_view(struct tog_view *);
+
+static volatile sig_atomic_t tog_sigwinch_received;
+
+static void
+tog_sigwinch(int signo)
+{
+ tog_sigwinch_received = 1;
+}
static const struct got_error *
view_close(struct tog_view *view)
return got_error_from_errno();
if (replace_panel(view->panel, view->window) == ERR)
return got_error_from_errno();
+ wclear(view->window);
view->nlines = nlines;
view->ncols = ncols;
view_is_splitscreen(struct tog_view *view)
{
return !view_is_parent_view(view) && view->begin_x > 0;
+}
+
+static void
+tog_resizeterm()
+{
+ int cols, lines;
+ struct winsize size;
+
+ if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &size) < 0) {
+ cols = 80; /* Default */
+ lines = 24;
+ } else {
+ cols = size.ws_col;
+ lines = size.ws_row;
+ }
+ resize_term(lines, cols);
}
static const struct got_error *
if (errcode)
return got_error_set_errno(errcode);
nodelay(stdscr, TRUE);
+
+ if (tog_sigwinch_received) {
+ tog_resizeterm();
+ tog_sigwinch_received = 0;
+ TAILQ_FOREACH(v, views, entry) {
+ err = view_resize(v);
+ if (err)
+ return err;
+ err = v->input(new, dead, focus, v, KEY_RESIZE);
+ if (err)
+ return err;
+ }
+ }
+
switch (ch) {
case ERR:
break;
}
break;
case KEY_RESIZE:
- TAILQ_FOREACH(v, views, entry) {
- err = view_resize(v);
- if (err)
- return err;
- err = v->input(new, dead, focus, v, ch);
- if (err)
- return err;
- }
break;
default:
err = view->input(new, dead, focus, view, ch);
got_repo_close(repo);
return error;
}
+
static void
init_curses(void)
{
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
curs_set(0);
+ signal(SIGWINCH, tog_sigwinch);
}
__dead static void