Simplify default-tabs

Simplify default-tabs

--- src/cljs/asciinema_player/vt.cljs
+++ src/cljs/asciinema_player/vt.cljs
@@ -21,7 +21,7 @@
     (vec (repeat height line))))

 (defn default-tabs [width]
-  (filter #(zero? (mod % 8)) (range 8 width)))
+  (range 8 width 8))

 (defn make-vt [width height]
   {:width width


refactor

refactor

--- src/cljs/triboard/logic/move.cljs
+++ src/cljs/triboard/logic/move.cljs
@@ -31,16 +31,20 @@
   [cell]
   (or (= cell :empty) (= cell :wall)))

+(defn- aboard-cell-at
+  [board x y]
+  (if (and (< -1 x cst/board-width) (< -1 y cst/board-height))
+    (aget board x y)
+    :wall))
+
 (defn- available-cells-by-dir
-  "Indicates the convertible cells when clicking at [x y]"  ;; TODO - Refactor & Test
-  [board init-coord [dx dy]]
-  (loop [x (+ (first init-coord) dx)
-         y (+ (second init-coord) dy)
+  "Indicates the convertible cells when clicking at [x y]"
+  [board [x-init y-init :as init-coord] [dx dy]]
+  (loop [x (+ x-init dx)
+         y (+ y-init dy)
          looser nil
          taken []]
-    (let [cell (if (and (<= 0 x (dec cst/board-width)) (<= 0 y (dec cst/board-height)))
-                 (aget board x y)
-                 :wall)]
+    (let [cell (aboard-cell-at board x y)]
       (cond
         (is-not-convertible? cell) nil                      ;; No move: reached end and only 1 type of cell
         (and looser (not= looser cell)) {:winner cell       ;; Who wins the cells


Get current time

Get current time

--- src/whitman/utils.clj
+++ src/whitman/utils.clj
@@ -1,8 +1,12 @@
 (ns whitman.utils
   (:gen-class)
-  (:require [clojure.java.io :as io]))
+  (:require [clojure.java.io :as io])
+  (:import [java.util Date]))

 (def version
   (if (.exists (io/as-file "project.clj"))
     (-> "project.clj" slurp read-string (nth 2))
     (-> (eval 'karmanaut.utils) .getPackage .getImplementationVersion)))
+
+(defn utcnow []
+  (Date.))


Update tests

Update tests

--- test/asciinema_player/view_test.cljs
+++ test/asciinema_player/view_test.cljs
@@ -22,17 +22,17 @@
   (is (= (v/bg-color 15 true) 15)))

 (deftest part-class-name-test
-  (is (= (v/part-class-name {}) ""))
-  (is (= (v/part-class-name {:fg 1}) "fg-1"))
-  (is (= (v/part-class-name {:bg 2}) "bg-2"))
-  (is (= (v/part-class-name {:fg 1 :bold true}) "fg-9 bright"))
-  (is (= (v/part-class-name {:fg 9 :bold true}) "fg-9 bright"))
-  (is (= (v/part-class-name {:fg 1 :bg 2 :underline true}) "fg-1 bg-2 underline"))
-  (is (= (v/part-class-name {:inverse true}) "fg-bg bg-fg"))
-  (is (= (v/part-class-name {:fg 1 :inverse true}) "fg-bg bg-1"))
-  (is (= (v/part-class-name {:bg 2 :inverse true}) "fg-2 bg-fg"))
-  (is (= (v/part-class-name {:fg 1 :bg 2 :inverse true}) "fg-2 bg-1"))
-  (is (= (v/part-class-name {:fg 1 :bg 2 :bold true :blink true :inverse true}) "fg-10 bg-9 bright")))
+  (is (= (v/part-class-name {} false) ""))
+  (is (= (v/part-class-name {:fg 1} false) "fg-1"))
+  (is (= (v/part-class-name {:bg 2} false) "bg-2"))
+  (is (= (v/part-class-name {:fg 1 :bold true} false) "fg-9 bright"))
+  (is (= (v/part-class-name {:fg 9 :bold true} false) "fg-9 bright"))
+  (is (= (v/part-class-name {:fg 1 :bg 2 :underline true} false) "fg-1 bg-2 underline"))
+  (is (= (v/part-class-name {:inverse true} false) "fg-bg bg-fg"))
+  (is (= (v/part-class-name {:fg 1 :inverse true} false) "fg-bg bg-1"))
+  (is (= (v/part-class-name {:bg 2 :inverse true} false) "fg-2 bg-fg"))
+  (is (= (v/part-class-name {:fg 1 :bg 2 :inverse true} false) "fg-2 bg-1"))
+  (is (= (v/part-class-name {:fg 1 :bg 2 :bold true :blink true :inverse true} false) "fg-10 bg-9 bright")))

 (deftest elapsed-time-test
   (is (= (v/elapsed-time 0.88) "00:00"))
@@ -45,11 +45,10 @@
   (is (= (v/remaining-time 133.95 134) "-00:00")))

 (deftest insert-cursor-test
-  (is (= (v/insert-cursor [["foo" {:foo true}] ["bar" {:bar true}]] 0) [["f" {:foo true :cursor true}] ["oo" {:foo true}] ["bar" {:bar true}]]))
-  (is (= (v/insert-cursor [["foo" {:foo true}] ["bar" {:bar true}]] 1) [["f" {:foo true}] ["o" {:foo true :cursor true}] ["o" {:foo true}] ["bar" {:bar true}]]))
-  (is (= (v/insert-cursor [["foo" {:foo true}] ["bar" {:bar true}]] 2) [["fo" {:foo true}] ["o" {:foo true :cursor true}] ["bar" {:bar true}]]))
-  (is (= (v/insert-cursor [["foo" {:foo true}] ["bar" {:bar true}]] 5) [["foo" {:foo true}] ["ba" {:bar true}] ["r" {:bar true :cursor true}]]))
-  (is (= (v/insert-cursor [["f" {:foo true}] ["bar" {:bar true}]] 0) [["f" {:foo true :cursor true}] ["bar" {:bar true}]]))
-  (is (= (v/insert-cursor [["foo" {:foo true}] ["b" {:bar true}]] 3) [["foo" {:foo true}] ["b" {:bar true :cursor true}]]))
-  (is (= (v/insert-cursor [["foo" {:foo true}] ["b" {:bar true}] ["qux" {:qux true}]] 3) [["foo" {:foo true}] ["b" {:bar true :cursor true}] ["qux" {:qux true}]]))
-  )
+  (is (= (v/insert-cursor [["foo" {:foo true}] ["bar" {:bar true}]] 0) [["f" {:foo true :cursor true :inverse true}] ["oo" {:foo true}] ["bar" {:bar true}]]))
+  (is (= (v/insert-cursor [["foo" {:foo true}] ["bar" {:bar true}]] 1) [["f" {:foo true}] ["o" {:foo true :cursor true :inverse true}] ["o" {:foo true}] ["bar" {:bar true}]]))
+  (is (= (v/insert-cursor [["foo" {:foo true}] ["bar" {:bar true}]] 2) [["fo" {:foo true}] ["o" {:foo true :cursor true :inverse true}] ["bar" {:bar true}]]))
+  (is (= (v/insert-cursor [["foo" {:foo true}] ["bar" {:bar true}]] 5) [["foo" {:foo true}] ["ba" {:bar true}] ["r" {:bar true :cursor true :inverse true}]]))
+  (is (= (v/insert-cursor [["f" {:foo true}] ["bar" {:bar true}]] 0) [["f" {:foo true :cursor true :inverse true}] ["bar" {:bar true}]]))
+  (is (= (v/insert-cursor [["foo" {:foo true}] ["b" {:bar true}]] 3) [["foo" {:foo true}] ["b" {:bar true :cursor true :inverse true}]]))
+  (is (= (v/insert-cursor [["foo" {:foo true}] ["b" {:bar true}] ["qux" {:qux true}]] 3) [["foo" {:foo true}] ["b" {:bar true :cursor true :inverse true}] ["qux" {:qux true}]])))


Rename function to reflect what it actually does

--- src/wireframes/renderer/bitmap.clj
+++ src/wireframes/renderer/bitmap.clj
@@ -16,7 +16,7 @@
     (.moveTo ax ay)
     (.lineTo bx by)))

-(defn- draw-shape [^Graphics2D g2d focal-length transform shape]
+(defn- draw-wireframe [^Graphics2D g2d focal-length transform shape]
   (let [path (GeneralPath.)
         points (mapv
                  (comp
@@ -55,7 +55,7 @@
       (.setStroke (BasicStroke. (/ 1.0 (quot w 2))))
       (.setRenderingHint RenderingHints/KEY_ANTIALIASING RenderingHints/VALUE_ANTIALIAS_ON)
       (.setRenderingHint RenderingHints/KEY_RENDERING RenderingHints/VALUE_RENDER_QUALITY))
-    (draw-shape g2d focal-length transform shape)
+    (draw-wireframe g2d focal-length transform shape)
     (.dispose g2d)
     img))