io.styles: only allow character styles to inherit.

flac
John Benediktsson 2020-02-15 08:42:06 -08:00 committed by Steve Ayerhart
parent e16fb922c8
commit a688aff7af
No known key found for this signature in database
GPG Key ID: 5BFD39C5359E967D
1 changed files with 19 additions and 6 deletions

View File

@ -1,10 +1,9 @@
! Copyright (C) 2005, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs colors colors.constants delegate
delegate.protocols destructors fry hashtables io
io.streams.plain io.streams.string kernel make math.order
namespaces present sequences splitting strings strings.tables
summary ;
USING: accessors assocs colors delegate delegate.protocols
destructors hashtables io io.streams.plain io.streams.string
kernel make namespaces present sequences sets splitting strings
strings.tables summary ;
IN: io.styles
GENERIC: stream-format ( str style stream -- )
@ -62,8 +61,10 @@ C: <ignore-close-stream> ignore-close-stream
TUPLE: style-stream < filter-writer style ;
INSTANCE: style-stream output-stream
DEFER: inherit-style
: do-nested-style ( style style-stream -- style stream )
[ style>> swap assoc-union ] [ stream>> ] bi ; inline
[ style>> inherit-style ] [ stream>> ] bi ; inline
C: <style-stream> style-stream
@ -144,6 +145,18 @@ CONSTANT: standard-table-style
{ table-border T{ rgba f 0.8 0.8 0.8 1.0 } }
}
<PRIVATE
: inherit? ( format -- ? )
HS{
foreground background font-name font-size font-style
} in? ;
PRIVATE>
: inherit-style ( child parent -- child' )
[ drop inherit? ] assoc-filter swap assoc-union! ;
! Input history
TUPLE: input string ;