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. ! Copyright (C) 2005, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs colors colors.constants delegate USING: accessors assocs colors delegate delegate.protocols
delegate.protocols destructors fry hashtables io destructors hashtables io io.streams.plain io.streams.string
io.streams.plain io.streams.string kernel make math.order kernel make namespaces present sequences sets splitting strings
namespaces present sequences splitting strings strings.tables strings.tables summary ;
summary ;
IN: io.styles IN: io.styles
GENERIC: stream-format ( str style stream -- ) GENERIC: stream-format ( str style stream -- )
@ -62,8 +61,10 @@ C: <ignore-close-stream> ignore-close-stream
TUPLE: style-stream < filter-writer style ; TUPLE: style-stream < filter-writer style ;
INSTANCE: style-stream output-stream INSTANCE: style-stream output-stream
DEFER: inherit-style
: do-nested-style ( style style-stream -- style stream ) : 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 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 } } { 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 ! Input history
TUPLE: input string ; TUPLE: input string ;