Rebol Programming/stylize

USAGE:

edit
STYLIZE specs /master /styles styls 

DESCRIPTION:

edit

Return a style sheet block.

STYLIZE is a function value.

ARGUMENTS

edit
  • specs -- A block of: new-style: old-style facets (Type: block)

REFINEMENTS

edit
  • /master -- Add to or change master style sheet
  • /styles
    • styls -- Base on existing style sheet (Type: block)

SOURCE CODE

edit
stylize: func [
    "Return a style sheet block." 
    specs [block!] "A block of: new-style: old-style facets" 
    /master "Add to or change master style sheet" 
    /styles styls [block!] "Base on existing style sheet" 
    /local new old new-face old-face args tmp
][
    styles: either master [vid-styles] [copy either styles [styls] [[]]] 
    while [specs: find specs set-word!] [
        set [new old] specs 
        specs: skip specs 2 
        new: to-word :new 
        if not word? :old [error "Invalid style for:" new] 
        if not any [
            old-face: select styles old 
            old-face: select vid-styles old
        ] [error "No such style:" old] 
        if not tmp: find specs set-word! [tmp: tail specs] 
        args: copy/part specs tmp 
        forall args [
            if any [
                find facet-words first args 
                all [old-face/words find old-face/words first args]
            ] [
                change args to-lit-word first args
            ]
        ] 
        args: reduce head args 
        new-face: make old-face either tmp: select args 'with [expand-specs old-face tmp] [[]] 
        new-face/facets: args 
        new-face/style: old 
        new-face/flags: exclude new-face/flags state-flags 
        grow-facets new-face args 
        either old: find styles new [change next old new-face] [repend styles [new new-face]] 
        if tmp: new-face/words [
            while [tmp: find tmp block!] [
                change tmp func [new args] first tmp
            ]
        ]
    ] 
    styles
]