Paste: Print across window
Author: | tgunr |
Mode: | factor |
Date: | Sun, 23 Dec 2012 17:43:19 |
Plain Text |
USING: accessors assocs colors.constants fonts io io.styles kernel ui.private
math math.order math.parser namespaces prettyprint.sections sequences ui.text vocabs.parser ;
IN: ui.gadgets.world
: front-window
windows get
[ second focused?>> ] map-find nip
second ;
: window-width
dim>> first ;
IN: kernel
: 1+
1 + ;
IN: splitting
: split-nth
0 swap
[ drop 1 + 2dup = [ drop 0 t ] [ f ] if ] split*-when 2nip
;
IN: prettyprint
: abullet
"•" write ;
: bullets
iota [ drop abullet ] each ;
: column-numbers
iota [ 10 mod number>string write ] each ;
: space
"\s" write ;
: spaces
iota [ drop space ] each ;
<PRIVATE
: (max-length)
0 over [ length max ] each 1+
;
: (printx)
(max-length) dup
front-window window-width
swap "*" <repetition> concat monospace-font swap text-width /i
1 max
;
: (assemble-word)
dup [ length - ] dip
[ " " <repetition> concat ] dip
prepend ;
: (assemble-line)
"" -rot [ (assemble-word) append ] with each ;
PRIVATE>
: printx-split
(printx) rot split-nth ;
: tablex
printx-split nip
H{
{ font-name "monospace" }
{ font-size 9 }
{ table-border COLOR: black }
}
[
0 swap [ [ [ [ over pprint pprint 1 + ] with-cell output-stream get stream-flush ] each ] with-row ] each
drop
] tabular-output
;
: printx
printx-split
H{
{ foreground COLOR: DarkRed }
}
[ [ [ (assemble-line) write nl ] with each
] with with-pprint
] with-style
;
IN: vocabs
: current-vocab-str
current-vocab name>> ;
: vwords
current-vocab-str vocab-words keys
[ printx ] unless-empty ;
IN: sequences
vwords
New Annotation