/src/slix/repl/ui.clj
Clojure | 55 lines | 37 code | 6 blank | 12 comment | 0 complexity | 168ef629e64f1b16759a7fcd84780e38 MD5 | raw file
Possible License(s): EPL-1.0, LGPL-3.0
1;; %! Copyright (C) 2011 Kei Suzuki All rights reserved. !% 2;; 3;; This file is part of Sevenri, a Clojure environment ("This Software"). 4;; 5;; The use and distribution terms for this software are covered by the Eclipse 6;; Public License version 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 7;; which can be found in the COPYING at the root of this distribution. 8;; By using this software in any fashion, you are agreeing to be bound by the 9;; terms of this license. 10;; You must not remove this notice, or any other, from this software. 11 12(ns slix.repl.ui 13 (:use [sevenri log slix ui] 14 [slix.repl defs]) 15 (:import (java.awt BorderLayout Color) 16 (javax.swing.text AbstractDocument$LeafElement 17 StyleConstants$ColorConstants) 18 (bsh.util JConsole))) 19 20;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 21 22(defn- -set-colors 23 [jconsole] 24 (doto jconsole 25 (.setBackground *console-background-color*) 26 (.setPromptColor *console-prompt-color*)) 27 (doto (.getTextPane jconsole) 28 (.setForeground *text-foreground-color*) 29 (.setBackground *text-background-color*) 30 (.setCaretColor *text-caret-color*))) 31 32(defn create-content-pane 33 [cp] 34 (let [jc (JConsole.) 35 tp (.getComponent (.getViewport jc) 0)] 36 (assert jc) 37 (-set-colors jc) 38 ;; Close with META+W. 39 (add-default-key-listener tp) 40 (doto cp 41 (.setLayout (BorderLayout.)) 42 (.add jc)))) 43 44(defn create-frame 45 [frame] 46 (doto frame 47 (.pack) 48 (.setSize 640 480))) 49 50(defn create-repl-frame 51 [] 52 (let [fr (slix-frame) 53 cp (.getContentPane fr)] 54 (create-content-pane cp) 55 (create-frame fr)))