|
6 | 6 | (:import (javax.swing AbstractListModel BorderFactory JDialog
|
7 | 7 | JFrame JLabel JList JMenuBar JOptionPane
|
8 | 8 | JPanel JScrollPane JSplitPane JTextArea
|
9 |
| - JTextField JTree SpringLayout JTextPane |
| 9 | + JTextField JTree KeyStroke SpringLayout JTextPane |
10 | 10 | UIManager)
|
11 | 11 | (javax.swing.event TreeSelectionListener
|
12 | 12 | TreeExpansionListener)
|
13 | 13 | (javax.swing.text DocumentFilter)
|
14 | 14 | (javax.swing.tree DefaultMutableTreeNode DefaultTreeModel
|
15 | 15 | TreePath TreeSelectionModel)
|
16 | 16 | (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) |
19 | 20 | (java.net URL)
|
20 | 21 | (java.io File FileReader FileWriter))
|
21 | 22 | (:use [clojure.contrib.duck-streams :only (writer)]
|
|
42 | 43 | choose-file choose-directory
|
43 | 44 | comment-out uncomment-out
|
44 | 45 | indent unindent awt-event persist-window-shape
|
45 |
| - confirmed? create-button is-win)] |
| 46 | + confirmed? create-button is-win |
| 47 | + get-keystroke)] |
46 | 48 | [clooj.indent :only (setup-autoindent)])
|
47 | 49 | (:require [clojure.contrib.string :as string]
|
48 | 50 | [clojure.main :only (repl repl-prompt)])
|
|
299 | 301 | (attach-action-keys text-comp
|
300 | 302 | ["special R" #(.requestFocusInWindow (:repl-in-text-area doc))]
|
301 | 303 | ["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))])) |
303 | 307 |
|
304 | 308 | (defn create-doc []
|
305 | 309 | (let [doc-text-area (make-text-area false)
|
|
544 | 548 | ["Find next" "cmd G" #(highlight-step doc false)]
|
545 | 549 | ["Find prev" "cmd shift G" #(highlight-step doc true)])
|
546 | 550 | (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)))) |
550 | 567 |
|
551 | 568 | ;; startup
|
552 | 569 |
|
|
557 | 574 | (let [doc (create-doc)]
|
558 | 575 | (reset! current-doc doc)
|
559 | 576 | (make-menus doc)
|
| 577 | + (add-visibility-shortcut doc) |
560 | 578 | (let [ta-in (doc :repl-in-text-area)
|
561 | 579 | ta-out (doc :repl-out-text-area)]
|
562 | 580 | (add-repl-input-handler doc))
|
|
0 commit comments