calendar.model: delete in favor of inline timers in lcd vocab.
parent
5f43d8ccea
commit
1a38a6f63a
|
@ -1,21 +0,0 @@
|
|||
! Copyright (C) 2008, 2010 Slava Pestov
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: calendar namespaces models threads kernel init ;
|
||||
IN: calendar.model
|
||||
|
||||
SYMBOL: time
|
||||
|
||||
: (time-thread) ( -- )
|
||||
now time get set-model
|
||||
1 seconds sleep (time-thread) ;
|
||||
|
||||
: time-thread ( -- )
|
||||
[
|
||||
init-namespaces
|
||||
(time-thread)
|
||||
] "Time model update" spawn drop ;
|
||||
|
||||
[
|
||||
f <model> time set-global
|
||||
time-thread
|
||||
] "calendar.model" add-startup-hook
|
|
@ -1 +0,0 @@
|
|||
Timestamp model updated every second
|
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors calendar.format calendar.model fonts fry
|
||||
grouping kernel math models.arrow namespaces sequences ui
|
||||
USING: accessors calendar calendar.format fonts fry grouping
|
||||
kernel math sequences timers threads ui ui.gadgets
|
||||
ui.gadgets.labels ;
|
||||
IN: lcd
|
||||
|
||||
|
@ -19,10 +19,19 @@ IN: lcd
|
|||
: lcd ( digit-str -- string )
|
||||
4 <iota> [ lcd-row ] with map "\n" join ;
|
||||
|
||||
: <time-display> ( model -- gadget )
|
||||
[ timestamp>hms lcd ] <arrow> <label-control>
|
||||
"99:99:99" lcd >>string
|
||||
monospace-font >>font ;
|
||||
TUPLE: time-display < label timer ;
|
||||
|
||||
: <time-display> ( -- gadget )
|
||||
"99:99:99" lcd time-display new-label
|
||||
monospace-font >>font
|
||||
dup '[ now timestamp>hms lcd _ string<< ]
|
||||
f 1 seconds <timer> >>timer ;
|
||||
|
||||
M: time-display graft*
|
||||
[ timer>> start-timer yield ] [ call-next-method ] bi ;
|
||||
|
||||
M: time-display ungraft*
|
||||
[ timer>> stop-timer ] [ call-next-method ] bi ;
|
||||
|
||||
MAIN-WINDOW: time-window { { title "Time" } }
|
||||
time get <time-display> >>gadgets ;
|
||||
<time-display> >>gadgets ;
|
||||
|
|
Loading…
Reference in New Issue