From 8f10efb6aa82ac98976f116044a7d23520b68600 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Thu, 12 Jul 2012 11:15:46 -0400 Subject: Handle terminal resizes in ncurses; src/textadept.c --- src/textadept.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/textadept.c b/src/textadept.c index 45f5e970..5e72ac30 100644 --- a/src/textadept.c +++ b/src/textadept.c @@ -25,6 +25,7 @@ #define PLAT_GTK 1 #elif NCURSES #include +#include #include #include #include @@ -2166,6 +2167,20 @@ static void new_window() { #endif } +#if NCURSES +/** + * Signal for a terminal resize. + */ +static void resize(int signal) { + struct winsize win; + ioctl(0, TIOCGWINSZ, &win); + resizeterm(win.ws_row, win.ws_col); + wresize(scintilla_get_window(focused_view), LINES - 2, COLS); + lL_event(lua, "update_ui", -1); + scintilla_refresh(focused_view); +} +#endif + /** * Runs Textadept. * Initializes the Lua state, creates the user interface, and then runs @@ -2255,6 +2270,10 @@ int main(int argc, char **argv) { term.c_oflag &= ~OPOST; term.c_lflag &= ~ISIG; tcsetattr(0, TCSANOW, &term); + // Set terminal resize handler. + struct sigaction act; + memset(&act, 0, sizeof(struct sigaction)); + act.sa_handler = resize, sigaction(SIGWINCH, &act, NULL); TermKeyResult res; TermKeyKey key; -- cgit v1.2.3