commit f2a9de18ab36ce30de4c644663fc46edf93c0bda
parent a280c92022d32e5004277e0cbe3c7384fafed1fd
Author: Jake Bauer <jbauer@paritybit.ca>
Date: Mon, 5 Dec 2022 20:30:20 -0500
Fifth day
Diffstat:
10 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1,4 @@
+/text-editor/target
+*.jar
+*.class
+/text-editor/.lein-*
diff --git a/README.md b/README.md
@@ -1,7 +1,8 @@
# Clojurecember
-In which I attempt to learn at least a little bit of Clojure, even if it's just
-about one standard library data structure, each day of December.
+In which I attempt to learn at least a little bit of Clojure with the end goal
+of writing a text editor, even if it's just about one standard library data
+structure, each day of December.
## DEC01
@@ -19,3 +20,10 @@ Finished up with Functions in Clojure and moved on to [Sequential](https://www.c
## DEC04
Moved onto learning Clojure [Flow Control](https://www.clojure.org/guides/learn/flow) and [Namespaces](https://www.clojure.org/guides/learn/namespaces) which finishes off learning the basics of Clojure.
+
+## DEC05
+
+Installed [leiningen](https://codeberg.org/leiningen/leiningen) which is
+apparently Clojure's version of `pip`, `npm`, etc. Created a new project which
+uses [Seesaw](https://github.com/clj-commons/seesaw/) and made a basic program
+that spawns a window that lets you type text in.
diff --git a/flow-control.clj b/clojure-guides/flow-control.clj
diff --git a/functions.clj b/clojure-guides/functions.clj
diff --git a/hashed-collections.clj b/clojure-guides/hashed-collections.clj
diff --git a/namespaces.clj b/clojure-guides/namespaces.clj
diff --git a/sequential-collections.clj b/clojure-guides/sequential-collections.clj
diff --git a/syntax.clj b/clojure-guides/syntax.clj
diff --git a/text-editor/project.clj b/text-editor/project.clj
@@ -0,0 +1,8 @@
+(defproject text-editor "0.1.0-SNAPSHOT"
+ :description "A little text editor."
+ :dependencies [[org.clojure/clojure "1.11.1"]
+ [seesaw "1.5.0"]]
+ :main ^:skip-aot text-editor.core
+ :target-path "target/%s"
+ :profiles {:uberjar {:aot :all
+ :jvm-opts ["-Dclojure.compiler.direct-linking=true"]}})
diff --git a/text-editor/src/text_editor/core.clj b/text-editor/src/text_editor/core.clj
@@ -0,0 +1,14 @@
+(ns text-editor.core
+ (:use seesaw.core))
+
+; Make the window look like a native app
+(native!)
+
+(defn -main [& args]
+ (invoke-later ; Executes the body sometime later on the Swing UI thread
+ (-> (frame :title "Text Editor", ; Frame makes a new window
+ :content (editor-pane) ; editor-pane is a JEditorPane
+ :minimum-size [640 :by 480]
+ :on-close :exit)
+ pack! ; Resize window to fit contents
+ show!))) ; Show the window