/
font_settings.clj
357 lines (256 loc) · 16.2 KB
/
font_settings.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
(ns chromex.ext.font-settings
"Use the chrome.fontSettings API to manage Chrome's font settings.
* available since Chrome 30
* https://developer.chrome.com/extensions/fontSettings"
(:refer-clojure :only [defmacro defn apply declare meta let partial])
(:require [chromex.wrapgen :refer [gen-wrap-helper]]
[chromex.callgen :refer [gen-call-helper gen-tap-all-events-call]]))
(declare api-table)
(declare gen-call)
; -- functions --------------------------------------------------------------------------------------------------------------
(defmacro clear-font
"Clears the font set by this extension, if any.
|details| - https://developer.chrome.com/extensions/fontSettings#property-clearFont-details.
This function returns a core.async channel of type `promise-chan` which eventually receives a result value.
Signature of the result value put on the channel is [].
In case of an error the channel closes without receiving any value and relevant error object can be obtained via
chromex.error/get-last-error.
https://developer.chrome.com/extensions/fontSettings#method-clearFont."
([details] (gen-call :function ::clear-font &form details)))
(defmacro get-font
"Gets the font for a given script and generic font family.
|details| - https://developer.chrome.com/extensions/fontSettings#property-getFont-details.
This function returns a core.async channel of type `promise-chan` which eventually receives a result value.
Signature of the result value put on the channel is [details] where:
|details| - https://developer.chrome.com/extensions/fontSettings#property-callback-details.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via
chromex.error/get-last-error.
https://developer.chrome.com/extensions/fontSettings#method-getFont."
([details] (gen-call :function ::get-font &form details)))
(defmacro set-font
"Sets the font for a given script and generic font family.
|details| - https://developer.chrome.com/extensions/fontSettings#property-setFont-details.
This function returns a core.async channel of type `promise-chan` which eventually receives a result value.
Signature of the result value put on the channel is [].
In case of an error the channel closes without receiving any value and relevant error object can be obtained via
chromex.error/get-last-error.
https://developer.chrome.com/extensions/fontSettings#method-setFont."
([details] (gen-call :function ::set-font &form details)))
(defmacro get-font-list
"Gets a list of fonts on the system.
This function returns a core.async channel of type `promise-chan` which eventually receives a result value.
Signature of the result value put on the channel is [results] where:
|results| - https://developer.chrome.com/extensions/fontSettings#property-callback-results.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via
chromex.error/get-last-error.
https://developer.chrome.com/extensions/fontSettings#method-getFontList."
([] (gen-call :function ::get-font-list &form)))
(defmacro clear-default-font-size
"Clears the default font size set by this extension, if any.
|details| - This parameter is currently unused.
This function returns a core.async channel of type `promise-chan` which eventually receives a result value.
Signature of the result value put on the channel is [].
In case of an error the channel closes without receiving any value and relevant error object can be obtained via
chromex.error/get-last-error.
https://developer.chrome.com/extensions/fontSettings#method-clearDefaultFontSize."
([details] (gen-call :function ::clear-default-font-size &form details))
([] `(clear-default-font-size :omit)))
(defmacro get-default-font-size
"Gets the default font size.
|details| - This parameter is currently unused.
This function returns a core.async channel of type `promise-chan` which eventually receives a result value.
Signature of the result value put on the channel is [details] where:
|details| - https://developer.chrome.com/extensions/fontSettings#property-callback-details.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via
chromex.error/get-last-error.
https://developer.chrome.com/extensions/fontSettings#method-getDefaultFontSize."
([details] (gen-call :function ::get-default-font-size &form details))
([] `(get-default-font-size :omit)))
(defmacro set-default-font-size
"Sets the default font size.
|details| - https://developer.chrome.com/extensions/fontSettings#property-setDefaultFontSize-details.
This function returns a core.async channel of type `promise-chan` which eventually receives a result value.
Signature of the result value put on the channel is [].
In case of an error the channel closes without receiving any value and relevant error object can be obtained via
chromex.error/get-last-error.
https://developer.chrome.com/extensions/fontSettings#method-setDefaultFontSize."
([details] (gen-call :function ::set-default-font-size &form details)))
(defmacro clear-default-fixed-font-size
"Clears the default fixed font size set by this extension, if any.
|details| - This parameter is currently unused.
This function returns a core.async channel of type `promise-chan` which eventually receives a result value.
Signature of the result value put on the channel is [].
In case of an error the channel closes without receiving any value and relevant error object can be obtained via
chromex.error/get-last-error.
https://developer.chrome.com/extensions/fontSettings#method-clearDefaultFixedFontSize."
([details] (gen-call :function ::clear-default-fixed-font-size &form details))
([] `(clear-default-fixed-font-size :omit)))
(defmacro get-default-fixed-font-size
"Gets the default size for fixed width fonts.
|details| - This parameter is currently unused.
This function returns a core.async channel of type `promise-chan` which eventually receives a result value.
Signature of the result value put on the channel is [details] where:
|details| - https://developer.chrome.com/extensions/fontSettings#property-callback-details.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via
chromex.error/get-last-error.
https://developer.chrome.com/extensions/fontSettings#method-getDefaultFixedFontSize."
([details] (gen-call :function ::get-default-fixed-font-size &form details))
([] `(get-default-fixed-font-size :omit)))
(defmacro set-default-fixed-font-size
"Sets the default size for fixed width fonts.
|details| - https://developer.chrome.com/extensions/fontSettings#property-setDefaultFixedFontSize-details.
This function returns a core.async channel of type `promise-chan` which eventually receives a result value.
Signature of the result value put on the channel is [].
In case of an error the channel closes without receiving any value and relevant error object can be obtained via
chromex.error/get-last-error.
https://developer.chrome.com/extensions/fontSettings#method-setDefaultFixedFontSize."
([details] (gen-call :function ::set-default-fixed-font-size &form details)))
(defmacro clear-minimum-font-size
"Clears the minimum font size set by this extension, if any.
|details| - This parameter is currently unused.
This function returns a core.async channel of type `promise-chan` which eventually receives a result value.
Signature of the result value put on the channel is [].
In case of an error the channel closes without receiving any value and relevant error object can be obtained via
chromex.error/get-last-error.
https://developer.chrome.com/extensions/fontSettings#method-clearMinimumFontSize."
([details] (gen-call :function ::clear-minimum-font-size &form details))
([] `(clear-minimum-font-size :omit)))
(defmacro get-minimum-font-size
"Gets the minimum font size.
|details| - This parameter is currently unused.
This function returns a core.async channel of type `promise-chan` which eventually receives a result value.
Signature of the result value put on the channel is [details] where:
|details| - https://developer.chrome.com/extensions/fontSettings#property-callback-details.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via
chromex.error/get-last-error.
https://developer.chrome.com/extensions/fontSettings#method-getMinimumFontSize."
([details] (gen-call :function ::get-minimum-font-size &form details))
([] `(get-minimum-font-size :omit)))
(defmacro set-minimum-font-size
"Sets the minimum font size.
|details| - https://developer.chrome.com/extensions/fontSettings#property-setMinimumFontSize-details.
This function returns a core.async channel of type `promise-chan` which eventually receives a result value.
Signature of the result value put on the channel is [].
In case of an error the channel closes without receiving any value and relevant error object can be obtained via
chromex.error/get-last-error.
https://developer.chrome.com/extensions/fontSettings#method-setMinimumFontSize."
([details] (gen-call :function ::set-minimum-font-size &form details)))
; -- events -----------------------------------------------------------------------------------------------------------------
;
; docs: https://github.com/binaryage/chromex/#tapping-events
(defmacro tap-on-font-changed-events
"Fired when a font setting changes.
Events will be put on the |channel| with signature [::on-font-changed [details]] where:
|details| - https://developer.chrome.com/extensions/fontSettings#property-onFontChanged-details.
Note: |args| will be passed as additional parameters into Chrome event's .addListener call.
https://developer.chrome.com/extensions/fontSettings#event-onFontChanged."
([channel & args] (apply gen-call :event ::on-font-changed &form channel args)))
(defmacro tap-on-default-font-size-changed-events
"Fired when the default font size setting changes.
Events will be put on the |channel| with signature [::on-default-font-size-changed [details]] where:
|details| - https://developer.chrome.com/extensions/fontSettings#property-onDefaultFontSizeChanged-details.
Note: |args| will be passed as additional parameters into Chrome event's .addListener call.
https://developer.chrome.com/extensions/fontSettings#event-onDefaultFontSizeChanged."
([channel & args] (apply gen-call :event ::on-default-font-size-changed &form channel args)))
(defmacro tap-on-default-fixed-font-size-changed-events
"Fired when the default fixed font size setting changes.
Events will be put on the |channel| with signature [::on-default-fixed-font-size-changed [details]] where:
|details| - https://developer.chrome.com/extensions/fontSettings#property-onDefaultFixedFontSizeChanged-details.
Note: |args| will be passed as additional parameters into Chrome event's .addListener call.
https://developer.chrome.com/extensions/fontSettings#event-onDefaultFixedFontSizeChanged."
([channel & args] (apply gen-call :event ::on-default-fixed-font-size-changed &form channel args)))
(defmacro tap-on-minimum-font-size-changed-events
"Fired when the minimum font size setting changes.
Events will be put on the |channel| with signature [::on-minimum-font-size-changed [details]] where:
|details| - https://developer.chrome.com/extensions/fontSettings#property-onMinimumFontSizeChanged-details.
Note: |args| will be passed as additional parameters into Chrome event's .addListener call.
https://developer.chrome.com/extensions/fontSettings#event-onMinimumFontSizeChanged."
([channel & args] (apply gen-call :event ::on-minimum-font-size-changed &form channel args)))
; -- convenience ------------------------------------------------------------------------------------------------------------
(defmacro tap-all-events
"Taps all valid non-deprecated events in chromex.ext.font-settings namespace."
[chan]
(gen-tap-all-events-call api-table (meta &form) chan))
; ---------------------------------------------------------------------------------------------------------------------------
; -- API TABLE --------------------------------------------------------------------------------------------------------------
; ---------------------------------------------------------------------------------------------------------------------------
(def api-table
{:namespace "chrome.fontSettings",
:since "30",
:functions
[{:id ::clear-font,
:name "clearFont",
:callback? true,
:params [{:name "details", :type "object"} {:name "callback", :optional? true, :type :callback}]}
{:id ::get-font,
:name "getFont",
:callback? true,
:params
[{:name "details", :type "object"}
{:name "callback", :optional? true, :type :callback, :callback {:params [{:name "details", :type "object"}]}}]}
{:id ::set-font,
:name "setFont",
:callback? true,
:params [{:name "details", :type "object"} {:name "callback", :optional? true, :type :callback}]}
{:id ::get-font-list,
:name "getFontList",
:callback? true,
:params
[{:name "callback",
:type :callback,
:callback {:params [{:name "results", :type "[array-of-fontSettings.FontNames]"}]}}]}
{:id ::clear-default-font-size,
:name "clearDefaultFontSize",
:callback? true,
:params [{:name "details", :optional? true, :type "object"} {:name "callback", :optional? true, :type :callback}]}
{:id ::get-default-font-size,
:name "getDefaultFontSize",
:callback? true,
:params
[{:name "details", :optional? true, :type "object"}
{:name "callback", :optional? true, :type :callback, :callback {:params [{:name "details", :type "object"}]}}]}
{:id ::set-default-font-size,
:name "setDefaultFontSize",
:callback? true,
:params [{:name "details", :type "object"} {:name "callback", :optional? true, :type :callback}]}
{:id ::clear-default-fixed-font-size,
:name "clearDefaultFixedFontSize",
:callback? true,
:params [{:name "details", :optional? true, :type "object"} {:name "callback", :optional? true, :type :callback}]}
{:id ::get-default-fixed-font-size,
:name "getDefaultFixedFontSize",
:callback? true,
:params
[{:name "details", :optional? true, :type "object"}
{:name "callback", :optional? true, :type :callback, :callback {:params [{:name "details", :type "object"}]}}]}
{:id ::set-default-fixed-font-size,
:name "setDefaultFixedFontSize",
:callback? true,
:params [{:name "details", :type "object"} {:name "callback", :optional? true, :type :callback}]}
{:id ::clear-minimum-font-size,
:name "clearMinimumFontSize",
:callback? true,
:params [{:name "details", :optional? true, :type "object"} {:name "callback", :optional? true, :type :callback}]}
{:id ::get-minimum-font-size,
:name "getMinimumFontSize",
:callback? true,
:params
[{:name "details", :optional? true, :type "object"}
{:name "callback", :optional? true, :type :callback, :callback {:params [{:name "details", :type "object"}]}}]}
{:id ::set-minimum-font-size,
:name "setMinimumFontSize",
:callback? true,
:params [{:name "details", :type "object"} {:name "callback", :optional? true, :type :callback}]}],
:events
[{:id ::on-font-changed, :name "onFontChanged", :params [{:name "details", :type "object"}]}
{:id ::on-default-font-size-changed, :name "onDefaultFontSizeChanged", :params [{:name "details", :type "object"}]}
{:id ::on-default-fixed-font-size-changed,
:name "onDefaultFixedFontSizeChanged",
:params [{:name "details", :type "object"}]}
{:id ::on-minimum-font-size-changed, :name "onMinimumFontSizeChanged", :params [{:name "details", :type "object"}]}]})
; -- helpers ----------------------------------------------------------------------------------------------------------------
; code generation for native API wrapper
(defmacro gen-wrap [kind item-id config & args]
(apply gen-wrap-helper api-table kind item-id config args))
; code generation for API call-site
(def gen-call (partial gen-call-helper api-table))