Skip to content

Commit 8070a99

Browse files
committed
Improved font functions
1 parent 0bde231 commit 8070a99

File tree

1 file changed

+22
-31
lines changed

1 file changed

+22
-31
lines changed

src/clooj/core.clj

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -87,37 +87,6 @@
8787
URL. slurp read-string (nth 2))
8888
(catch Exception _ nil)))))
8989

90-
;; font
91-
92-
(defonce current-font (atom nil))
93-
94-
(defn font [name size]
95-
(Font. name Font/PLAIN size))
96-
97-
(defn set-font
98-
([app font-name size]
99-
(let [f (font font-name size)]
100-
(utils/awt-event
101-
(utils/write-value-to-prefs utils/clooj-prefs "app-font"
102-
[font-name size])
103-
(dorun (map #(.setFont (app %) f)
104-
[:doc-text-area :repl-in-text-area
105-
:repl-out-text-area :arglist-label
106-
:search-text-area :help-text-area
107-
:completion-list]))
108-
(reset! current-font [font-name size]))))
109-
([app font-name]
110-
(let [size (second @current-font)]
111-
(set-font app font-name size))))
112-
113-
(defn resize-font [app fun]
114-
(let [[name size] @current-font]
115-
(set-font app name (fun size))))
116-
117-
(defn grow-font [app] (resize-font app inc))
118-
119-
(defn shrink-font [app] (resize-font app dec))
120-
12190
;; settings
12291

12392
(def default-settings
@@ -147,6 +116,16 @@
147116

148117
(defn set-line-wrapping [text-area mode]
149118
(.setLineWrap text-area mode))
119+
120+
(defn set-font
121+
[app font-name size]
122+
(let [f (Font. font-name Font/PLAIN size)]
123+
(utils/awt-event
124+
(dorun (map #(.setFont (app %) f)
125+
[:doc-text-area :repl-in-text-area
126+
:repl-out-text-area :arglist-label
127+
:search-text-area :help-text-area
128+
:completion-list])))))
150129

151130
(set-line-wrapping
152131
(:doc-text-area app)
@@ -164,6 +143,18 @@
164143
(reset! (:settings app) settings)
165144
(save-settings settings))
166145

146+
;; font
147+
148+
(defn resize-font [app fun]
149+
(apply-settings app (update-in @(:settings app)
150+
[:font-size]
151+
fun)))
152+
153+
(defn grow-font [app] (resize-font app inc))
154+
155+
(defn shrink-font [app] (resize-font app dec))
156+
157+
167158
;; caret finding
168159

169160
(def highlight-agent (agent nil))

0 commit comments

Comments
 (0)