]> gitweb.factorcode.org Git - factor.git/commitdiff
calendar.model: delete in favor of inline timers in lcd vocab.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 25 Oct 2017 18:53:37 +0000 (11:53 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 25 Oct 2017 18:53:37 +0000 (11:53 -0700)
basis/calendar/model/model.factor [deleted file]
basis/calendar/model/summary.txt [deleted file]
extra/lcd/lcd.factor

diff --git a/basis/calendar/model/model.factor b/basis/calendar/model/model.factor
deleted file mode 100644 (file)
index 4948c94..0000000
+++ /dev/null
@@ -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
diff --git a/basis/calendar/model/summary.txt b/basis/calendar/model/summary.txt
deleted file mode 100644 (file)
index 4cc85fd..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Timestamp model updated every second
index 63699ae93d9dcb77f22620c20dad8c3202274699..2dd7c5f3344cfffed9d3f670c39123fab6e78079 100644 (file)
@@ -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 ;