From 829e63f0e929245abcd34cfbbe35c2150f30ee54 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sun, 29 Jul 2012 23:41:36 +0200 Subject: [PATCH] editor(1) now bails if the terminal resolution isn't 80x25. This isn't perfect, but support for other resolutions is near! --- utils/editor.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/utils/editor.cpp b/utils/editor.cpp index 9857640e..d5b7176e 100644 --- a/utils/editor.cpp +++ b/utils/editor.cpp @@ -29,6 +29,7 @@ #include #include #include +#include const int MODE_QUIT = 1; const int MODE_TEXT = 2; @@ -442,6 +443,15 @@ void run() int main(int argc, char* argv[]) { if ( !isatty(1) ) { error(1, errno, "stdout must be a tty"); return 1; } + struct winsize ws; + if ( tcgetwinsize(1, &ws) != 0 ) + error(1, errno, "tcgetwinsize"); + if ( ws.ws_col != 80 || ws.ws_row != 25 ) + { + fprintf(stderr, "Sorry, this application only works with 80x25 " + "terminal resolutions, please fix it. :)\n"); + exit(1); + } if ( argc < 2 ) {