nandi/jolt-nativepublic Fork 0
65272e3e9431369b8ac5bf985825fb43c8a7048a
Commits
Clone
git clone https://git.rickub.com/nandi/jolt-native.git
git clone ssh://git@rickub.com/nandi/jolt-native.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Write dvui's shape in jolt, on SDL3, with no shared object 109c7e4 · on 65272e3e9431369b8ac5bf985825fb43c8a7048a · Veronika Winters · 9d ago
counter.clj · 34 lines · 1.4 KBClojure Blame HistoryRaw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(ns glimmer-jvui.counter
  "The same component glimmer-vidya, glimmer-tui and glimmer-gfx render, with
   jvui underneath instead of egui, a terminal or a rasterizer."
  (:require [glimmer.ratom :as ra]
            [glimmer.core :as ui]
            [glimmer-jvui.core]))          ; installs this backend

(defn counter []
  (let [n (ra/atom 0)
        loud? (ra/atom false)
        who (ra/atom "")]
    (fn []
      [:card {}
       [:title {:label "Counter"}]
       [:label {:label (str "Count: " (ra/deref n)
                            (when (ra/deref loud?) "!"))}]
       [:hbox {:spacing 8}
        [:button {:label "- 1" :on-click #(ra/swap! n dec)}]
        [:button {:label "+ 1" :kind :primary :on-click #(ra/swap! n inc)}]
        [:button {:label "reset" :on-click #(ra/reset! n 0)}]]
       [:separator {}]
       [:checkbox {:label "Exclaim" :checked (ra/deref loud?)
                   :on-change #(ra/reset! loud? %)}]
       [:entry {:value (ra/deref who) :placeholder "your name"
                :on-change #(ra/reset! who %)}]
       [:label {:dim true
                :label (if (= "" (ra/deref who))
                         "nobody yet"
                         (str "hello, " (ra/deref who)))}]])))

(defn -main [& args]
  (ui/run counter (cond-> {:title "glimmer-jvui" :max-width 420}
                    (some #{"--shot"} args)
                    (assoc :frames 3 :shot "/tmp/glimmer-jvui.bmp"))))