]> gitweb.factorcode.org Git - factor.git/blob - extra/terminal/linux/linux.factor
classes.struct: moving to new/boa instead of <struct>/<struct-boa>
[factor.git] / extra / terminal / linux / linux.factor
1 ! Copyright (C) 2012 John Benediktsson
2 ! See http://factorcode.org/license.txt for BSD license
3
4 USING: accessors arrays classes.struct io.streams.c kernel
5 math system terminal unix unix.ffi ;
6 QUALIFIED-WITH: alien.c-types c
7
8 IN: terminal.linux
9
10 <PRIVATE
11
12 CONSTANT: TIOCGWINSZ 0x5413
13
14 STRUCT: winsize
15 { ws_row c:short }
16 { ws_col c:short }
17 { ws_xpixel c:short }
18 { ws_ypixel c:short } ;
19
20 PRIVATE>
21
22 M: unix (terminal-size)
23     stdout-handle fileno TIOCGWINSZ winsize new
24     [ ioctl ] keep swap 0 < [
25         drop 0 0
26     ] [
27         [ ws_col>> ] [ ws_row>> ] bi
28     ] if ;