nandi/jolt-nativepublic Fork 0
main
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.

counter.clj · 34 lines · 1.4 KBClojure Blame HistoryRaw
Write dvui's shape in jolt, on SDL3, with no shared object 109c7e4 Veronika Winters 9d ago1(ns glimmer-jvui.counter
2 "The same component glimmer-vidya, glimmer-tui and glimmer-gfx render, with
3 jvui underneath instead of egui, a terminal or a rasterizer."
4 (:require [glimmer.ratom :as ra]
5 [glimmer.core :as ui]
6 [glimmer-jvui.core])) ; installs this backend
7
8(defn counter []
9 (let [n (ra/atom 0)
10 loud? (ra/atom false)
11 who (ra/atom "")]
12 (fn []
13 [:card {}
14 [:title {:label "Counter"}]
15 [:label {:label (str "Count: " (ra/deref n)
16 (when (ra/deref loud?) "!"))}]
17 [:hbox {:spacing 8}
18 [:button {:label "- 1" :on-click #(ra/swap! n dec)}]
19 [:button {:label "+ 1" :kind :primary :on-click #(ra/swap! n inc)}]
20 [:button {:label "reset" :on-click #(ra/reset! n 0)}]]
21 [:separator {}]
22 [:checkbox {:label "Exclaim" :checked (ra/deref loud?)
23 :on-change #(ra/reset! loud? %)}]
24 [:entry {:value (ra/deref who) :placeholder "your name"
25 :on-change #(ra/reset! who %)}]
26 [:label {:dim true
27 :label (if (= "" (ra/deref who))
28 "nobody yet"
29 (str "hello, " (ra/deref who)))}]])))
30
31(defn -main [& args]
32 (ui/run counter (cond-> {:title "glimmer-jvui" :max-width 420}
33 (some #{"--shot"} args)
34 (assoc :frames 3 :shot "/tmp/glimmer-jvui.bmp"))))