Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add :font option

  • Loading branch information...
commit 7bdd365a3c323a1dd62210ff64c9a443638e7622 1 parent 986f173
Ivan Kozik authored April 25, 2012
10  src/clj/org/dipert/swingrepl/main.clj
@@ -3,6 +3,7 @@
3 3
   (:require clojure.main clojure.repl)
4 4
   (:import (javax.swing JFrame)
5 5
            (java.awt.event WindowEvent)
  6
+           (java.awt Font)
6 7
            (bsh.util JConsole))
7 8
   (:gen-class))
8 9
 
@@ -20,6 +21,7 @@
20 21
      default-opts
21 22
      {:width 972
22 23
       :height 400
  24
+      :font (Font. "Monospaced" Font/PLAIN 14)
23 25
       :title (str "Clojure " clj-version " REPL")
24 26
       :prompt #(print "user=> ")
25 27
       :init set-safe-printing!
@@ -48,7 +50,7 @@
48 50
   ([] (make-repl-jframe {}))
49 51
   ([optmap]
50 52
     (let [options (merge default-opts optmap)
51  
-          {:keys [title width height on-close prompt init eval]} options
  53
+          {:keys [title width height font on-close prompt init eval]} options
52 54
           jframe (doto (JFrame. title)
53 55
         (.setSize width height)
54 56
         (.setDefaultCloseOperation on-close)
@@ -63,8 +65,10 @@
63 65
         (.requestFocus console)
64 66
         (let [thread  (make-repl-thread console :prompt prompt :init init :eval eval)
65 67
               stopper (clojure.repl/thread-stopper thread)]
66  
-          (.setInterruptFunction console (fn [reason] (stopper reason)))
67  
-          (.setEOFFunction console (window-closing-dispatcher jframe))
  68
+          (doto console
  69
+            (.setFont font)
  70
+            (.setInterruptFunction (fn [reason] (stopper reason)))
  71
+            (.setEOFFunction (window-closing-dispatcher jframe)))
68 72
           (.start thread)
69 73
           (.setVisible jframe true))))))
70 74
 
3  src/jvm/bsh/util/JConsole.java
@@ -126,9 +126,7 @@ public void paste() {
126 126
 			}
127 127
 		};
128 128
 
129  
-		Font font = new Font("Monospaced", Font.PLAIN, 14);
130 129
 		text.setText("");
131  
-		text.setFont(font);
132 130
 		text.setMargin(new Insets(7, 5, 7, 5));
133 131
 		text.addKeyListener(this);
134 132
 		setViewportView(text);
@@ -715,6 +713,7 @@ public void setFont(Font font) {
715 713
 
716 714
 		if (text != null) {
717 715
 			text.setFont(font);
  716
+			text.repaint();
718 717
 		}
719 718
 	}
720 719
 

0 notes on commit 7bdd365

Please sign in to comment.
Something went wrong with that request. Please try again.