summaryrefslogtreecommitdiff
path: root/clojure/wordmonger/timer.clj
diff options
context:
space:
mode:
authorJason Katz-Brown <jason@airbnb.com>2013-08-25 02:17:13 -0700
committerJason Katz-Brown <jason@airbnb.com>2013-08-25 02:17:13 -0700
commit9306cb60c32082c5403931de0823a9fd5daa196c (patch)
treeca1b6eb695fdf3f0c2294e92416b272164bae642 /clojure/wordmonger/timer.clj
parent8fb2c681cecc01b46b0f4ba02d5cc177c4747b1c (diff)
Initial git commit.
Diffstat (limited to 'clojure/wordmonger/timer.clj')
-rw-r--r--clojure/wordmonger/timer.clj18
1 files changed, 18 insertions, 0 deletions
diff --git a/clojure/wordmonger/timer.clj b/clojure/wordmonger/timer.clj
new file mode 100644
index 0000000..f739e7e
--- /dev/null
+++ b/clojure/wordmonger/timer.clj
@@ -0,0 +1,18 @@
+(doto *timer-label*
+ (.setFont (new Font *display* "bitstream vera sans mono" 12 SWT/NORMAL))
+ (.setText " ")
+ (.setLayoutData (new GridData GridData/HORIZONTAL_ALIGN_CENTER)))
+
+(defn initialize-timer [timer-max]
+ (def *timer-value* (ref timer-max)))
+
+(defn decrement-timer []
+ (let [value @*timer-value*
+ new-value (dec value)]
+ (unless (.isDisposed *shell*)
+ (.asyncExec *display* (proxy [Runnable] []
+ (run [] (.setText *timer-label*
+ (str new-value)))))
+ (comment
+ (async (.setText *timer-label* (str new-value))))
+ (def *timer-value* (ref new-value)))))