Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Remove/comment on some heinousness: Earmuffs, refs vs. atoms, dynamic

  • Loading branch information...
commit 7ab15b080bc508ab7bbab2cd09f18ef66b393b99 1 parent f408778
Tim McCormack authored

Showing 1 changed file with 12 additions and 14 deletions. Show diff stats Hide diff stats

  1. +12 14 src/timmcHW3/core.clj
26 src/timmcHW3/core.clj
@@ -24,25 +24,25 @@
24 24 MouseAdapter MouseEvent MouseMotionAdapter MouseWheelListener])
25 25 (:gen-class))
26 26
27   -(def ^{:doc "Collection of GUI components." :dynamic true}
  27 +;; A lot of these should be atoms, and the earmuffs are also kind of
  28 +;; inappropriate.
  29 +(def ^{:doc "Collection of GUI components."}
28 30 *gui* (ref nil))
29   -(def ^{:doc "The viewpoint's state." :dynamic true}
  31 +(def ^{:doc "The viewpoint's state."}
30 32 *view* (ref nil))
31   -(def ^{:doc "Tool and activity state." :dynamic true}
  33 +(def ^{:doc "Tool and activity state."}
32 34 *state* (ref nil))
33   -(def ^{:doc "User data that needs undo/redo." :dynamic true}
  35 +(def ^{:doc "User data that needs undo/redo."}
34 36 *udata* (ref nil))
35   -(def ^{:doc "Undo/redo buffers." :dynamic true}
  37 +(def ^{:doc "Undo/redo buffers."}
36 38 *history* (ref nil))
37   -(def ^{:doc "State dirtiness cascade." :dynamic true}
38   - *cascade* (ref nil))
  39 +(def ^{:doc "State dirtiness cascade."}
  40 + cascade (atom nil))
39 41
40 42 (defn dirty!
41 43 "Mark one or more pieces of state as dirty."
42 44 [& kws]
43   - (dosync
44   - (alter *cascade* (partial reduce dirt/dirty) kws)
45   - nil))
  45 + (apply swap! cascade dirt/dirty kws))
46 46
47 47 (defn clean!
48 48 "Clean up state and re-display where necessary."
@@ -50,9 +50,7 @@
50 50 (apply dirty! kws)
51 51 (clean!))
52 52 ([]
53   - (dosync
54   - (alter *cascade* dirt/clean :all)
55   - nil)))
  53 + (swap! cascade dirt/clean :all)))
56 54
57 55 ;;;; Mode accessors
58 56
@@ -577,7 +575,7 @@
577 575 :view-minspect default-view-minspect
578 576 :view-rot default-view-rot}))
579 577 (ref-set *udata* (udata/create))
580   - (ref-set *cascade* (make-cascade))
  578 + (reset! cascade (make-cascade))
581 579 (ref-set *history* (hist/create @*udata*)))
582 580 (clean!)
583 581 (enliven! *gui*)

0 comments on commit 7ab15b0

Please sign in to comment.
Something went wrong with that request. Please try again.