1 ! Copyright (C) 2012 John Benediktsson
2 ! See http://factorcode.org/license.txt for BSD license
4 USING: accessors arrays environment kernel math math.parser
5 sequences system vocabs ;
9 HOOK: (terminal-size) os ( -- columns lines )
11 "terminal." os name>> append require
13 : terminal-size ( -- dim )
15 [ os-env [ string>number ] [ 0 ] if* ] bi@
16 2dup [ 0 <= ] either? [
18 [ over 0 <= [ nip ] [ drop ] if ] bi-curry@ bi*
21 : terminal-width ( -- width ) terminal-size first ;
23 : terimal-height ( -- height ) terminal-size second ;