/src/slix/repl/ui.clj

http://github.com/ksuzuki/Sevenri · Clojure · 55 lines · 37 code · 6 blank · 12 comment · 0 complexity · 168ef629e64f1b16759a7fcd84780e38 MD5 · raw file

  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. (ns slix.repl.ui
  12. (:use [sevenri log slix ui]
  13. [slix.repl defs])
  14. (:import (java.awt BorderLayout Color)
  15. (javax.swing.text AbstractDocument$LeafElement
  16. StyleConstants$ColorConstants)
  17. (bsh.util JConsole)))
  18. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  19. (defn- -set-colors
  20. [jconsole]
  21. (doto jconsole
  22. (.setBackground *console-background-color*)
  23. (.setPromptColor *console-prompt-color*))
  24. (doto (.getTextPane jconsole)
  25. (.setForeground *text-foreground-color*)
  26. (.setBackground *text-background-color*)
  27. (.setCaretColor *text-caret-color*)))
  28. (defn create-content-pane
  29. [cp]
  30. (let [jc (JConsole.)
  31. tp (.getComponent (.getViewport jc) 0)]
  32. (assert jc)
  33. (-set-colors jc)
  34. ;; Close with META+W.
  35. (add-default-key-listener tp)
  36. (doto cp
  37. (.setLayout (BorderLayout.))
  38. (.add jc))))
  39. (defn create-frame
  40. [frame]
  41. (doto frame
  42. (.pack)
  43. (.setSize 640 480)))
  44. (defn create-repl-frame
  45. []
  46. (let [fr (slix-frame)
  47. cp (.getContentPane fr)]
  48. (create-content-pane cp)
  49. (create-frame fr)))