Rebol 程式設計/stylize
外觀
STYLIZE specs /master /styles styls
返回一個樣式表塊。
STYLIZE 是一個函式值。
- specs -- 一個包含新樣式:舊樣式方面的塊 (型別:塊)
- /master -- 新增到或更改主樣式表
- /styles
- styls -- 基於現有樣式表 (型別:塊)
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
]