aboutsummaryrefslogtreecommitdiff
path: root/module/terminal/util.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-04-23 22:51:47 +0200
committerHugo Hörnquist <hugo@hornquist.se>2019-04-23 22:51:47 +0200
commitc9b516afd587050f3424149cfe226f0945378a34 (patch)
tree24d8c6e8a4cb0c8b4d012d4edeae6a13c516d36f /module/terminal/util.scm
parentChange how branch length is calculated. (diff)
downloadcalp-c9b516afd587050f3424149cfe226f0945378a34.tar.gz
calp-c9b516afd587050f3424149cfe226f0945378a34.tar.xz
Get terminal size of terminal output.
Diffstat (limited to '')
-rw-r--r--module/terminal/util.scm9
1 files changed, 9 insertions, 0 deletions
diff --git a/module/terminal/util.scm b/module/terminal/util.scm
index a7435ad8..f4d60fda 100644
--- a/module/terminal/util.scm
+++ b/module/terminal/util.scm
@@ -1,6 +1,8 @@
(define-module (terminal util)
#:use-module (srfi srfi-19)
#:use-module (srfi srfi-60)
+ #:use-module (util)
+ #:use-module (ice-9 popen)
#:export (line ctrl color-escape))
(define* (line #:optional (width 64))
@@ -35,3 +37,10 @@
(string->number gs 16)
(string->number bs 16))))))
+
+(define-public (get-terminal-size)
+ (let* (((rpipe . wpipe) (pipe)))
+ (system (format #f "stty size > /proc/~s/fd/~s"
+ (getpid) (port->fdes wpipe)))
+ (values (read rpipe)
+ (read rpipe))))