Commits

Steve Losh  committed 28faced

Initial commit.

  • Participants
  • Tags entry-01

Comments (0)

Files changed (5)

+/target
+/lib
+/classes
+/checkouts
+pom.xml
+*.jar
+*.class
+.lein-deps-sum
+.lein-failures
+.lein-plugins
+syntax:glob
+target/
+lib/
+classes/
+checkouts/
+pom.xml
+*.jar
+*.class
+.lein-deps-sum
+.lein-failures
+.lein-plugins

File README.markdown

+# The Caves of Clojure
+
+The code for my [Caves of Clojure][caves] series of blog posts.
+
+[caves]: http://stevelosh.com/blog/
+
+## Usage
+
+Clone the repo.
+
+Run `lein deps` to pull down deps.
+
+Follow along with the entries by using tags:
+
+    hg update entry-06
+    git checkout entry-06o
+
+That will put you at the code as it stood right at the *end* of entry number
+six, so you can see how it all works together.
+
+You can run the program by running `lein trampoline run` twice.  No, I don't
+know why you need to do it twice -- you just do.
+
+You can also just load it up in your Swank/Eclipse/whatever setup.
+
+## License
+
+Copyright 2012 Steve Losh
+
+Distributed under the MIT/X11 License.
+(defproject caves "0.1.0-SNAPSHOT"
+  :description "The Caves of Clojure"
+  :url "http://stevelosh.com/blog/2012/07/caves-of-clojure-01/"
+  :license {:name "MIT/X11"}
+  :dependencies [[org.clojure/clojure "1.4.0"]
+                 [clojure-lanterna "0.9.0"]]
+  :main caves.core)

File src/caves/core.clj

+(ns caves.core
+  (:require [lanterna.screen :as s]))
+
+
+(defn main [screen-type]
+  (let [screen (s/get-screen screen-type)]
+    (s/in-screen screen
+                 (s/put-string screen 0 0 "Welcome to the Caves of Clojure!")
+                 (s/put-string screen 0 1 "Press any key to exit...")
+                 (s/redraw screen)
+                 (s/get-key-blocking screen))))
+
+
+(defn -main [& args]
+  (let [args (set args)
+        screen-type (cond
+                      (args ":swing") :swing
+                      (args ":text")  :text
+                      :else           :auto)]
+    (main screen-type)))
+
+(comment
+  (main :swing))