aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2012-07-12 11:15:46 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2012-07-12 11:15:46 -0400
commit8f10efb6aa82ac98976f116044a7d23520b68600 (patch)
tree8c926727b2ded71cf46c633b36ac8b148e912a31
parentb90733576418546d846ec6f887c055ecd78f2ce7 (diff)
downloadtextadept-8f10efb6aa82ac98976f116044a7d23520b68600.tar.gz
textadept-8f10efb6aa82ac98976f116044a7d23520b68600.zip
Handle terminal resizes in ncurses; src/textadept.c
-rw-r--r--src/textadept.c19
1 files changed, 19 insertions, 0 deletions
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 <signal.h>
+#include <sys/ioctl.h>
#include <termios.h>
#include <ncurses.h>
#include <cdk/cdk.h>
@@ -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;