diff th_util.c @ 143:c878cdcfea9d

Implement terminal width.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 07 Dec 2014 20:49:10 +0200
parents aa2d608fb3f3
children fdea1c3acc53
line wrap: on
line diff
--- a/th_util.c	Sat Nov 22 23:37:44 2014 +0200
+++ b/th_util.c	Sun Dec 07 20:49:10 2014 +0200
@@ -56,6 +56,24 @@
 }
 
 
+int th_term_width()
+{
+    char *var = getenv("COLUMNS");
+    int res = (var != NULL) ? atoi(var) : 80;
+    if (res < 5) res = 80;
+    return res;
+}
+
+
+int th_term_height()
+{
+    char *var = getenv("LINESS");
+    int res = (var != NULL) ? atoi(var) : 25;
+    if (res < 1) res = 1;
+    return res;
+}
+
+
 /* Print formatted error, warning and information messages
  * TODO: Implement th_vfprintf() and friends?
  */