1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors sequences kernel math io calendar grouping
4 calendar.format calendar.model arrays models models.filter
5 namespaces ui.gadgets ui.gadgets.labels ui.gadgets.theme ui ;
8 : lcd-digit ( row digit -- str )
9 dup CHAR: : = [ drop 10 ] [ CHAR: 0 - ] if swap {
11 " | | | _| _| |_| |_ |_ | |_| |_| * "
12 " |_| | |_ _| | _| |_| | |_| | * "
14 } nth 4 <groups> nth ;
16 : lcd-row ( num row -- string )
17 [ swap lcd-digit ] curry { } map-as concat ;
19 : lcd ( digit-str -- string )
20 4 [ lcd-row ] with map "\n" join ;
22 : hh:mm:ss ( timestamp -- string )
23 [ hour>> ] [ minute>> ] [ second>> >fixnum ] tri
24 3array [ pad-00 ] map ":" join ;
26 : <time-display> ( timestamp -- gadget )
27 [ hh:mm:ss lcd ] <filter> <label-control>
28 "99:99:99" lcd over set-label-string
29 monospace-font >>font ;
32 [ time get <time-display> "Time" open-window ] with-ui ;