! Copyright (C) 2011 John Benediktsson ! See http://factorcode.org/license.txt for BSD license USING: accessors assocs colors.hex io io.encodings.utf8 io.files io.styles kernel locals math math.parser namespaces sequences xmode.catalog xmode.marker ; IN: xmode.highlight : highlight-tokens ( tokens -- ) [ [ str>> ] [ id>> ] bi [ name>> STYLES at ] [ f ] if* BASE assoc-union format ] each nl ; : highlight-lines ( lines mode -- ) [ f ] 2dip load-mode [ tokenize-line highlight-tokens ] curry each drop ; :: highlight. ( path -- ) path utf8 file-lines [ path over first find-mode highlight-lines ] unless-empty ;