1 ! Copyright (C) 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel colors colors.constants accessors combinators math ;
11 { foreground initial: COLOR: black }
12 { background initial: COLOR: white } ;
17 : font-with-foreground ( font color -- font' )
18 [ clone ] dip >>foreground ; inline
20 : font-with-background ( font color -- font' )
21 [ clone ] dip >>background ; inline
23 : font-with-size ( font size -- font' )
24 [ clone ] dip >>size ; inline
26 : reverse-video-font ( font -- font )
28 [ foreground>> ] [ background>> ] bi
29 [ >>background ] [ >>foreground ] bi* ;
31 : derive-font ( base font -- font' )
34 [ [ name>> ] either? >>name ]
35 [ [ size>> ] either? >>size ]
36 [ [ bold?>> ] either? >>bold? ]
37 [ [ italic?>> ] either? >>italic? ]
38 [ [ foreground>> ] either? >>foreground ]
39 [ [ background>> ] either? >>background ]
43 : serif-font ( -- font )
48 : sans-serif-font ( -- font )
53 : monospace-font ( -- font )
58 : strip-font-colors ( font -- font' )
59 clone f >>background f >>foreground ;
61 TUPLE: metrics width ascent descent height leading cap-height x-height ;
63 : compute-height ( metrics -- metrics )
64 dup [ ascent>> ] [ descent>> ] bi + >>height ; inline
66 TUPLE: selection string start end color ;
68 C: <selection> selection