Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

remove old icons when new icons come

  • Loading branch information...
commit 5052afb3942980bb22623858e0e5f42f90b21160 1 parent c35abb3
Samuel Edwin Ward authored

Showing 1 changed file with 23 additions and 9 deletions. Show diff stats Hide diff stats

  1. +23 9 mum.lisp
32 mum.lisp
@@ -99,13 +99,26 @@
99 99 (parenscript:ps
100 100 (defvar *clock* (ps:lisp (clock user)))
101 101
  102 + (defvar *icons* (list))
  103 +
  104 + (defun coordinate-id (coordinates)
  105 + (+ "#char-"
  106 + (ps:@ coordinates 0)
  107 + "-"
  108 + (ps:@ coordinates 1)))
  109 +
102 110 (defun draw-icon (icon)
103 111 (when (= 0 (ps:@ icon coordinates 2))
104   - (ps:chain ($ (+ "#char-"
105   - (ps:@ icon coordinates 0)
106   - "-"
107   - (ps:@ icon coordinates 1)))
108   - (html (ps:@ icon html)))))
  112 + (let ((id (coordinate-id (ps:@ icon coordinates))))
  113 + (setf (ps:@ icon old-html)
  114 + (ps:chain ($ id)
  115 + (html)))
  116 + (ps:chain ($ id)
  117 + (html (ps:@ icon html))))))
  118 +
  119 + (defun undraw-icon (icon)
  120 + (ps:chain ($ (coordinate-id (ps:@ icon coordinates)))
  121 + (html (ps:@ icon old-html))))
109 122
110 123 (defun update-handler (update old-action old-arguments old-clock)
111 124 "The action, arguments, and clock are those that were taken
@@ -137,10 +150,11 @@ which initiated this update."
137 150 (html
138 151 stragglers-string))))
139 152 (:icons
140   - ;; TODO just add them for now; later we'll have to deal with clearing the old ones
141   - (mapcar #'draw-icon
142   - (ps:@ update :arguments))
143   - )))
  153 + (let ((icons (ps:@ update :arguments)))
  154 + (mapcar #'undraw-icon *icons*)
  155 + (setf *icons* icons)
  156 + (mapcar #'draw-icon icons)))
  157 + ))
144 158
145 159 (defun new-turn-handler (data old-action old-arguments old-clock)
146 160 (ps:chain $

0 comments on commit 5052afb

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