Skip to content

Commit 4b9fb40

Browse files
show and hide clooj app (for gui development)
1 parent 356169b commit 4b9fb40

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defproject clooj "0.1.14"
1+
(defproject clooj "0.1.15"
22
:description "clooj, a small IDE for clojure"
33
:main clooj.core
44
:dependencies [[clojure "1.2.1"]

src/clooj/core.clj

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@
66
(:import (javax.swing AbstractListModel BorderFactory JDialog
77
JFrame JLabel JList JMenuBar JOptionPane
88
JPanel JScrollPane JSplitPane JTextArea
9-
JTextField JTree SpringLayout JTextPane
9+
JTextField JTree KeyStroke SpringLayout JTextPane
1010
UIManager)
1111
(javax.swing.event TreeSelectionListener
1212
TreeExpansionListener)
1313
(javax.swing.text DocumentFilter)
1414
(javax.swing.tree DefaultMutableTreeNode DefaultTreeModel
1515
TreePath TreeSelectionModel)
1616
(java.awt Insets Point Rectangle Window)
17-
(java.awt.event FocusAdapter WindowAdapter KeyAdapter)
18-
(java.awt Color Font GridLayout)
17+
(java.awt.event AWTEventListener FocusAdapter
18+
WindowAdapter KeyAdapter)
19+
(java.awt AWTEvent Color Font GridLayout Toolkit)
1920
(java.net URL)
2021
(java.io File FileReader FileWriter))
2122
(:use [clojure.contrib.duck-streams :only (writer)]
@@ -42,7 +43,8 @@
4243
choose-file choose-directory
4344
comment-out uncomment-out
4445
indent unindent awt-event persist-window-shape
45-
confirmed? create-button is-win)]
46+
confirmed? create-button is-win
47+
get-keystroke)]
4648
[clooj.indent :only (setup-autoindent)])
4749
(:require [clojure.contrib.string :as string]
4850
[clojure.main :only (repl repl-prompt)])
@@ -299,7 +301,9 @@
299301
(attach-action-keys text-comp
300302
["special R" #(.requestFocusInWindow (:repl-in-text-area doc))]
301303
["special E" #(.requestFocusInWindow (:doc-text-area doc))]
302-
["special P" #(.requestFocusInWindow (:docs-tree doc))]))
304+
["special P" #(.requestFocusInWindow (:docs-tree doc))]
305+
["special F" #(.toFront (:frame doc))]
306+
["special B" #(.toBack (:frame doc))]))
303307

304308
(defn create-doc []
305309
(let [doc-text-area (make-text-area false)
@@ -544,9 +548,22 @@
544548
["Find next" "cmd G" #(highlight-step doc false)]
545549
["Find prev" "cmd shift G" #(highlight-step doc true)])
546550
(add-menu menu-bar "Window"
547-
["Move to REPL" "special R" #(.requestFocusInWindow (:repl-in-text-area doc))]
548-
["Move to Editor" "special E" #(.requestFocusInWindow (:doc-text-area doc))]
549-
["Move to Project Tree" "special P" #(.requestFocusInWindow (:docs-tree doc))])))
551+
["Go to REPL input" "special R" #(.requestFocusInWindow (:repl-in-text-area doc))]
552+
["Go to Editor" "special E" #(.requestFocusInWindow (:doc-text-area doc))]
553+
["Go to Project Tree" "special P" #(.requestFocusInWindow (:docs-tree doc))]
554+
["Send clooj window to back" "special B" #(.toBack (:frame doc))]
555+
["Bring clooj window to front" "special F" #(.toFront (:frame doc))])))
556+
557+
(defn add-visibility-shortcut [doc]
558+
(let [shortcut (get-keystroke "special F")]
559+
(.. Toolkit getDefaultToolkit
560+
(addAWTEventListener
561+
(proxy [AWTEventListener] []
562+
(eventDispatched [e]
563+
(when (= (KeyStroke/getKeyStrokeForEvent e)
564+
shortcut)
565+
(.toFront (:frame doc)))))
566+
AWTEvent/KEY_EVENT_MASK))))
550567

551568
;; startup
552569

@@ -557,6 +574,7 @@
557574
(let [doc (create-doc)]
558575
(reset! current-doc doc)
559576
(make-menus doc)
577+
(add-visibility-shortcut doc)
560578
(let [ta-in (doc :repl-in-text-area)
561579
ta-out (doc :repl-out-text-area)]
562580
(add-repl-input-handler doc))

0 commit comments

Comments
 (0)