xmode.highlight: enable highlighting of words.

db4
John Benediktsson 2013-03-28 16:43:22 -07:00
parent b38f42f73c
commit 47fbfdf1f0
2 changed files with 15 additions and 10 deletions

View File

@ -1,8 +1,8 @@
! Copyright (C) 2011 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
USING: help.markup help.syntax sequences strings xmode.catalog
xmode.highlight xmode.tokens ;
USING: help.markup help.syntax sequences strings words
xmode.catalog xmode.highlight xmode.tokens ;
IN: xmode.highlight
@ -20,8 +20,7 @@ HELP: highlight-lines
} ;
HELP: highlight.
{ $values { "path" string } }
{ $values { "obj" string } }
{ $description
"Highlight and print code from the specified file (represented by "
{ $snippet "path" } "). The mode is determined using the file extension."
"Highlight and print code from the specified " { $link word } " or path (with a mode determined using the file extension)."
} ;

View File

@ -1,9 +1,9 @@
! 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 ;
USING: accessors assocs colors.hex io io.encodings.utf8
io.files io.streams.string io.styles kernel locals see
sequences splitting strings words xmode.catalog xmode.marker ;
IN: xmode.highlight
@ -46,7 +46,7 @@ PRIVATE>
: highlight-tokens ( tokens -- )
[
[ str>> ] [ id>> ] bi
[ name>> STYLES at ] [ f ] if* BASE assoc-union
[ name>> STYLES at BASE assoc-union ] [ BASE ] if*
format
] each nl ;
@ -55,7 +55,13 @@ PRIVATE>
tokenize-line highlight-tokens
] curry each drop ;
:: highlight. ( path -- )
GENERIC: highlight. ( obj -- )
M:: string highlight. ( path -- )
path utf8 file-lines [
path over first find-mode highlight-lines
] unless-empty ;
M: word highlight.
[ see ] with-string-writer string-lines
"factor" highlight-lines ;