From 1a38a6f63a341f20bb8a9237bfa91e32ebfd40dc Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Wed, 25 Oct 2017 11:53:37 -0700 Subject: [PATCH] calendar.model: delete in favor of inline timers in lcd vocab. --- basis/calendar/model/model.factor | 21 --------------------- basis/calendar/model/summary.txt | 1 - extra/lcd/lcd.factor | 23 ++++++++++++++++------- 3 files changed, 16 insertions(+), 29 deletions(-) delete mode 100644 basis/calendar/model/model.factor delete mode 100644 basis/calendar/model/summary.txt diff --git a/basis/calendar/model/model.factor b/basis/calendar/model/model.factor deleted file mode 100644 index 4948c94581..0000000000 --- a/basis/calendar/model/model.factor +++ /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 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 index 4cc85fd2b9..0000000000 --- a/basis/calendar/model/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Timestamp model updated every second diff --git a/extra/lcd/lcd.factor b/extra/lcd/lcd.factor index 63699ae93d..2dd7c5f334 100644 --- a/extra/lcd/lcd.factor +++ b/extra/lcd/lcd.factor @@ -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 [ lcd-row ] with map "\n" join ; -: ( model -- gadget ) - [ timestamp>hms lcd ] - "99:99:99" lcd >>string - monospace-font >>font ; +TUPLE: time-display < label timer ; + +: ( -- gadget ) + "99:99:99" lcd time-display new-label + monospace-font >>font + dup '[ now timestamp>hms lcd _ string<< ] + f 1 seconds >>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 >>gadgets ; + >>gadgets ;