Permalink
Browse files

Attempt to fix clojure 1.2 support

  • Loading branch information...
1 parent c6ad84d commit cda2d4c615ebdd1e7ba5c92798f6ea542beac0c7 @stathissideris committed Mar 10, 2012
Showing with 24 additions and 139 deletions.
  1. +1 −1 README.md
  2. +11 −7 project.clj
  3. +0 −128 src/clarity/core.clj
  4. +7 −0 src/clarity/document.clj
  5. +5 −0 src/clarity/renderer.clj
  6. +0 −3 test/clarity/test/core.clj
View
@@ -5,7 +5,7 @@ Clojure GUI library, based on Swing. See the project wiki for details on how to
If you are using leiningen, add the following dependency to your
`project.clj`:
-`[clarity "0.5.5"]`
+`[clarity "0.5.6"]`
Example of the form facilities:
View
@@ -1,12 +1,13 @@
-(defproject clarity "0.5.5"
+(defproject clarity "0.5.6"
:description "Clojure GUI library, based on Swing."
+ :url "http://stathissideris.github.com/clarity/"
:autodoc {:name "Clarity"
:page-title "Clarity API docs"
:web-src-dir "https://github.com/stathissideris/clarity/blob/"
:web-home "http://stathissideris.github.com/clarity/"
:output-path "autodoc"
:trim-prefix "clarity."
- :copyright "Copyright 2011 by Stathis Sideris"
+ :copyright "Copyright 2011-2012 by Stathis Sideris"
:load-except-list [#"test/" #"project\.clj"
#"autodoc/" #"src/examples/"]}
:dependencies [[org.clojure/clojure "1.3.0"]
@@ -15,9 +16,12 @@
:dev-dependencies [[lein-clojars "0.6.0"]
[lein-multi "1.1.0-SNAPSHOT"]
[org.clojars.weavejester/autodoc "0.9.0"]]
- :multi-deps {"1.2" [[org.clojure/clojure "1.2.0"]
- [org.clojure/clojure-contrib "1.2.0"]
- [artem "0.5"]
- [org.markdownj/markdownj "0.3.0-1.0.2b4"]]}
- :main clarity.core
+ :multi-deps {"1.2.0" [[org.clojure/clojure "1.2.0"]
+ [org.clojure/clojure-contrib "1.2.0"]
+ [artem "0.5"]
+ [org.markdownj/markdownj "0.3.0-1.0.2b4"]]
+ "1.2.1" [[org.clojure/clojure "1.2.1"]
+ [org.clojure/clojure-contrib "1.2.0"]
+ [artem "0.5"]
+ [org.markdownj/markdownj "0.3.0-1.0.2b4"]]}
:jvm-opts ["-Xdebug" "-Xrunjdwp:transport=dt_socket,server=y,suspend=n"])
View
@@ -1,128 +0,0 @@
-(ns clarity.core
- (:require [clarity.chain :as chain]
- [clarity.document :as doc]
- [clarity.renderer :as render]
- [clarity.list :as l])
- (:import (javax.swing JFrame JButton JTextField JList JScrollPane)
- (java.awt.event ActionListener)))
-
-(defmacro frame [& args] `(new JFrame ~@args))
-(defmacro button [& args] `(new JButton ~@args))
-(defmacro text [& args] `(new JTextField ~@args))
-(defmacro jlist [& args] `(new JList ~@args))
-
-#_(defn test-document []
- (let [text-component (text)]
- (sw/do-swing (.setText text-component "pre-"))
- (.setDocument text-component
- (doc/build-document text-component
- (doc/max-len 10)
- (doc/min-len 4)
- doc/all-upper))
- (doto (frame)
- (.add text-component)
- (.pack)
- (.setVisible true))))
-
-(defn test-document []
- (let [text-component (text)]
- (.setText text-component "0x")
- (.setDocument text-component
- (doc/build-document text-component
- doc/all-upper
- ))
- (doto (frame)
- (.add text-component)
- (.pack)
- (.setVisible true))))
-
-
-(defn test-document []
- (let [text-component (text)]
- (.setDocument text-component
- (doc/build-document text-component
- doc/all-upper
- (doc/matches #"[A-F0-9]*")))
- (.setText text-component "0X")
- (doto (frame)
- (.add text-component)
- (.pack)
- (.setVisible true))))
-
-(defn test-list-render []
- (let [list-comp (jlist (l/immutable-list-model
- ["ena" "dyo" "tria" "tessara" "pede"]))]
- (.setCellRenderer list-comp
- (render/make-list-renderer
- render/stripy
- render/stripy-selection))
- (doto (frame)
- (.add (new JScrollPane list-comp))
- (.pack)
- (.setVisible true))))
-
-(def ldata (ref ["ena" "dyo" "tria" "tessara" "pede"]))
-(defn test-list-render2 []
- (let [list-comp (jlist (l/mutable-list-model ldata))]
- (.setCellRenderer list-comp
- (render/make-list-renderer
- render/stripy
- render/stripy-selection))
- (doto (frame)
- (.add (new JScrollPane list-comp))
- (.pack)
- (.setVisible true))))
-
-(defn -main []
- (test-list-render2))
-
-(defmacro on-action [component & body]
- `(. ~component ~'addActionListener
- (proxy [java.awt.event.ActionListener] []
- (~'actionPerformed [~'event] ~@body))))
-
-(defmacro on-mouse-over [component & body]
- `(. ~component ~'addMouseListener
- (proxy [java.awt.event.MouseAdapter] []
- (mouseEntered [~'event] ~@body))))
-
-(defmacro on-mouse-out [component & body]
- `(. ~component ~'addMouseListener
- (proxy [java.awt.event.MouseAdapter] []
- (mouseExited [~'event] ~@body))))
-
-(def mouse-listener-map
- {:on-mouse-over :mouseEntered
- :on-mouse-out :mouseExited
- :on-click :mouseClicked
- :on-mouse-press :mousePressed
- :on-mouse-release :mouseReleased})
-
-(def f {:on-click '(prn "wdw")
- :on-mouse-out '(prn "out")})
-
-(defn- make-proxy-fn [pair]
- (list
- (symbol (name ((first pair) mouse-listener-map)))
- ['event]
- (second pair)))
-
-(defmacro make-listeners [fnmap]
- `(proxy [java.awt.event.MouseListener] []
- ~@(map make-proxy-fn fnmap)))
-
-;;(defn make-mouse-listener [fnmap]
-;; (proxy [MouseListener] []
-;; (mouseClicked [e] (when-let [f (:clicked fnmap)] (f e)))
-;; (mousePressed [e] (when-let [f (:pressed fnmap)] (f e))) ...))
-;;
-
-(defmacro def-watched [name & value]
- `(do
- (def ~name ~@value)
- (add-watch (var ~name)
- :re-bind
- (fn [~'key ~'r old# new#]
- (println old# " -> " new#)))))
-
-;;(def-watched x (* 12 2))
View
@@ -49,3 +49,10 @@
(proxy-super remove offset length)))))
(replace [offset length text attrs]
(proxy-super replace offset length text attrs)))))
+
+;;example (possibly outdated)
+#_(doc/build-document text-component
+ (doc/max-len 10)
+ (doc/min-len 4)
+ (doc/matches #"[A-F0-9]*")
+ doc/all-upper)
View
@@ -61,3 +61,8 @@
renderer-fn (apply comp (reverse renderers))]
(first (renderer-fn component list-component
value index selected? focused?))))))
+
+;;example (possibly outdated)
+#_(render/make-list-renderer
+ render/stripy
+ render/stripy-selection)
@@ -1,3 +0,0 @@
-(ns clarity.test.core
- (:use [clarity.core] :reload)
- (:use [clojure.test]))

0 comments on commit cda2d4c

Please sign in to comment.