From c9b516afd587050f3424149cfe226f0945378a34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 23 Apr 2019 22:51:47 +0200 Subject: Get terminal size of terminal output. --- module/terminal/util.scm | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'module/terminal/util.scm') 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)))) -- cgit v1.2.3