| Bind the terminal backend from the side that renders into it 3cfee15 nandi 17d ago | 1 | (ns glimmer-tui.counter |
| 2 | "The smallest thing that shows the backend works: a number and two buttons. |
| 3 | |
| 4 | The same component renders under glimmer-vidya in a window. Nothing here |
| 5 | names a terminal." |
| 6 | (:require [glimmer.ratom :as r :refer [atom]] |
| 7 | [glimmer.core :as ui] |
| 8 | [glimmer-tui.core])) |
| 9 | |
| 10 | (defonce n (atom 0)) |
| 11 | |
| 12 | (defn counter [] |
| 13 | [:vbox {:spacing 1 :margin 2} |
| 14 | [:title {:label "counter"}] |
| 15 | [:label {:label (str "n = " @n)}] |
| 16 | [:hbox {:spacing 2} |
| 17 | [:button {:label "-" :on-click #(swap! n dec)}] |
| 18 | [:button {:label "+" :kind :primary :on-click #(swap! n inc)}]] |
| 19 | [:dim-label {:label "tab moves, enter presses, ctrl-q quits"}]]) |
| 20 | |
| 21 | (defn -main [& _] (ui/run counter)) |