tterm: override screen size with LINES and COLUMNS - neatvi - [fork] simple vi-… | |
git clone git://src.adamsgaard.dk/neatvi | |
Log | |
Files | |
Refs | |
README | |
--- | |
commit 8f774acd2f6aa77052899ed737b8d34658601156 | |
parent 1f17a310ce1b7e9b2ce95245e2ba8e4f39843478 | |
Author: Ali Gholami Rudi <[email protected]> | |
Date: Mon, 4 May 2015 12:23:59 +0430 | |
tterm: override screen size with LINES and COLUMNS | |
Diffstat: | |
M term.c | 12 +++++++++--- | |
1 file changed, 9 insertions(+), 3 deletions(-) | |
--- | |
diff --git a/term.c b/term.c | |
t@@ -8,7 +8,7 @@ | |
#include "vi.h" | |
static struct sbuf *term_sbuf; | |
-static int rows = 25, cols = 80; | |
+static int rows, cols; | |
static struct termios termios; | |
void term_init(void) | |
t@@ -20,10 +20,16 @@ void term_init(void) | |
newtermios.c_lflag &= ~ICANON; | |
newtermios.c_lflag &= ~ECHO; | |
tcsetattr(0, TCSAFLUSH, &newtermios); | |
+ if (getenv("LINES")) | |
+ rows = atoi(getenv("LINES")); | |
+ if (getenv("COLUMNS")) | |
+ cols = atoi(getenv("COLUMNS")); | |
if (!ioctl(0, TIOCGWINSZ, &win)) { | |
- cols = win.ws_col; | |
- rows = win.ws_row; | |
+ cols = cols ? cols : win.ws_col; | |
+ rows = rows ? rows : win.ws_row; | |
} | |
+ cols = cols ? cols : 80; | |
+ rows = rows ? rows : 25; | |
} | |
void term_done(void) |