xterm_js_rs/sugar/
builder.rs

1// Builder patterns for all options
2use crate::*;
3use js_sys::Function;
4
5// Generate builder pattern:
6// '<,'>s/\(.*\)set_\(.*\)(.*,\(.*\));/\1with_\2(\&self,\3) -> \&Self \{ self.set_\2(val); self \}/
7
8impl TerminalOptions {
9    pub fn with_transparency(&self, val: bool) -> &Self {
10        self.set_allow_transparency(val);
11        self
12    }
13
14    pub fn with_bell_sound(&self, val: &str) -> &Self {
15        self.set_bell_sound(val);
16        self
17    }
18
19    pub fn with_bell_style(&self, val: BellStyle) -> &Self {
20        self.set_bell_style(val);
21        self
22    }
23
24    pub fn with_convert_eol(&self, val: bool) -> &Self {
25        self.set_convert_eol(val);
26        self
27    }
28
29    pub fn with_cols(&self, val: u32) -> &Self {
30        self.set_cols(val);
31        self
32    }
33
34    pub fn with_cursor_blink(&self, val: bool) -> &Self {
35        self.set_cursor_blink(val);
36        self
37    }
38
39    pub fn with_cursor_style(&self, val: CursorStyle) -> &Self {
40        self.set_cursor_style(val);
41        self
42    }
43
44    pub fn with_cursor_width(&self, val: u32) -> &Self {
45        self.set_cursor_width(val);
46        self
47    }
48
49    pub fn with_disable_stdin(&self, val: bool) -> &Self {
50        self.set_disable_stdin(val);
51        self
52    }
53
54    pub fn with_draw_bold_text_in_bright_colors(&self, val: bool) -> &Self {
55        self.set_draw_bold_text_in_bright_colors(val);
56        self
57    }
58
59    pub fn with_fast_scroll_modifier(&self, val: FastScrollModifier) -> &Self {
60        self.set_fast_scroll_modifier(val);
61        self
62    }
63
64    pub fn with_fast_scroll_sensitivity(&self, val: u32) -> &Self {
65        self.set_fast_scroll_sensitivity(val);
66        self
67    }
68
69    pub fn with_font_size(&self, val: u32) -> &Self {
70        self.set_font_size(val);
71        self
72    }
73
74    pub fn with_font_family(&self, val: &str) -> &Self {
75        self.set_font_family(val);
76        self
77    }
78
79    pub fn with_font_weight(&self, val: FontWeight) -> &Self {
80        self.set_font_weight(val);
81        self
82    }
83
84    pub fn with_font_weight_bold(&self, val: FontWeight) -> &Self {
85        self.set_font_weight_bold(val);
86        self
87    }
88
89    pub fn with_letter_spacing(&self, val: u32) -> &Self {
90        self.set_letter_spacing(val);
91        self
92    }
93
94    pub fn with_line_height(&self, val: u32) -> &Self {
95        self.set_line_height(val);
96        self
97    }
98
99    pub fn with_link_tooltip_hover_duration(&self, val: u32) -> &Self {
100        self.set_link_tooltip_hover_duration(val);
101        self
102    }
103
104    pub fn with_log_level(&self, val: LogLevel) -> &Self {
105        self.set_log_level(val);
106        self
107    }
108
109    pub fn with_mac_option_is_meta(&self, val: bool) -> &Self {
110        self.set_mac_option_is_meta(val);
111        self
112    }
113
114    pub fn with_mac_option_click_forces_selection(&self, val: bool) -> &Self {
115        self.set_mac_option_click_forces_selection(val);
116        self
117    }
118
119    pub fn with_minimum_contrast_ratio(&self, val: u32) -> &Self {
120        self.set_minimum_contrast_ratio(val);
121        self
122    }
123
124    pub fn with_renderer_type(&self, val: RendererType) -> &Self {
125        self.set_renderer_type(val);
126        self
127    }
128
129    pub fn with_right_click_selects_word(&self, val: bool) -> &Self {
130        self.set_right_click_selects_word(val);
131        self
132    }
133
134    pub fn with_rows(&self, val: u32) -> &Self {
135        self.set_rows(val);
136        self
137    }
138
139    pub fn with_screen_reader_mode(&self, val: bool) -> &Self {
140        self.set_screen_reader_mode(val);
141        self
142    }
143
144    pub fn with_scrollback(&self, val: u32) -> &Self {
145        self.set_scrollback(val);
146        self
147    }
148
149    pub fn with_scroll_sensitivity(&self, val: u32) -> &Self {
150        self.set_scroll_sensitivity(val);
151        self
152    }
153
154    pub fn with_tab_stop_width(&self, val: u32) -> &Self {
155        self.set_tab_stop_width(val);
156        self
157    }
158
159    pub fn with_theme(&self, val: &Theme) -> &Self {
160        self.set_theme(val);
161        self
162    }
163
164    pub fn with_windows_mode(&self, val: bool) -> &Self {
165        self.set_windows_mode(val);
166        self
167    }
168
169    pub fn with_word_separator(&self, val: &str) -> &Self {
170        self.set_word_separator(val);
171        self
172    }
173
174    pub fn with_window_options(&self, val: &WindowOptions) -> &Self {
175        self.set_window_options(val);
176        self
177    }
178}
179
180impl Theme {
181    pub fn with_foreground(&self, val: &str) -> &Self {
182        self.set_foreground(val);
183        self
184    }
185
186    pub fn with_background(&self, val: &str) -> &Self {
187        self.set_background(val);
188        self
189    }
190
191    pub fn with_cursor(&self, val: &str) -> &Self {
192        self.set_cursor(val);
193        self
194    }
195
196    pub fn with_cursor_accent(&self, val: &str) -> &Self {
197        self.set_cursor_accent(val);
198        self
199    }
200
201    pub fn with_selection(&self, val: &str) -> &Self {
202        self.set_selection(val);
203        self
204    }
205
206    pub fn with_black(&self, val: &str) -> &Self {
207        self.set_black(val);
208        self
209    }
210
211    pub fn with_red(&self, val: &str) -> &Self {
212        self.set_red(val);
213        self
214    }
215
216    pub fn with_green(&self, val: &str) -> &Self {
217        self.set_green(val);
218        self
219    }
220
221    pub fn with_yellow(&self, val: &str) -> &Self {
222        self.set_yellow(val);
223        self
224    }
225
226    pub fn with_blue(&self, val: &str) -> &Self {
227        self.set_blue(val);
228        self
229    }
230
231    pub fn with_magenta(&self, val: &str) -> &Self {
232        self.set_magenta(val);
233        self
234    }
235
236    pub fn with_cyan(&self, val: &str) -> &Self {
237        self.set_cyan(val);
238        self
239    }
240
241    pub fn with_white(&self, val: &str) -> &Self {
242        self.set_white(val);
243        self
244    }
245
246    pub fn with_bright_black(&self, val: &str) -> &Self {
247        self.set_bright_black(val);
248        self
249    }
250
251    pub fn with_bright_red(&self, val: &str) -> &Self {
252        self.set_bright_red(val);
253        self
254    }
255
256    pub fn with_bright_green(&self, val: &str) -> &Self {
257        self.set_bright_green(val);
258        self
259    }
260
261    pub fn with_bright_yellow(&self, val: &str) -> &Self {
262        self.set_bright_yellow(val);
263        self
264    }
265
266    pub fn with_bright_blue(&self, val: &str) -> &Self {
267        self.set_bright_blue(val);
268        self
269    }
270
271    pub fn with_bright_magenta(&self, val: &str) -> &Self {
272        self.set_bright_magenta(val);
273        self
274    }
275
276    pub fn with_bright_cyan(&self, val: &str) -> &Self {
277        self.set_bright_cyan(val);
278        self
279    }
280
281    pub fn with_bright_white(&self, val: &str) -> &Self {
282        self.set_bright_white(val);
283        self
284    }
285}
286
287impl LinkMatcherOptions {
288    pub fn with_match_index(&self, val: u32) -> &Self {
289        self.set_match_index(val);
290        self
291    }
292
293    pub fn with_validation_callback(&self, val: &Function) -> &Self {
294        self.set_validation_callback(val);
295        self
296    }
297
298    pub fn with_tooltip_callback(&self, val: &Function) -> &Self {
299        self.set_tooltip_callback(val);
300        self
301    }
302
303    pub fn with_leave_callback(&self, val: &Function) -> &Self {
304        self.set_leave_callback(val);
305        self
306    }
307
308    pub fn with_priority(&self, val: u32) -> &Self {
309        self.set_priority(val);
310        self
311    }
312
313    pub fn with_will_link_activate(&self, val: &Function) -> &Self {
314        self.set_will_link_activate(val);
315        self
316    }
317}
318
319impl WindowOptions {
320    pub fn with_restore_win(&self, val: bool) -> &Self {
321        self.set_restore_win(val);
322        self
323    }
324
325    pub fn with_minimize_win(&self, val: bool) -> &Self {
326        self.set_minimize_win(val);
327        self
328    }
329
330    pub fn with_win_position(&self, val: bool) -> &Self {
331        self.set_win_position(val);
332        self
333    }
334
335    pub fn with_win_size_pixels(&self, val: bool) -> &Self {
336        self.set_win_size_pixels(val);
337        self
338    }
339
340    pub fn with_raise_win(&self, val: bool) -> &Self {
341        self.set_raise_win(val);
342        self
343    }
344
345    pub fn with_lower_win(&self, val: bool) -> &Self {
346        self.set_lower_win(val);
347        self
348    }
349
350    pub fn with_refresh_win(&self, val: bool) -> &Self {
351        self.set_refresh_win(val);
352        self
353    }
354
355    pub fn with_win_size_chars(&self, val: bool) -> &Self {
356        self.set_win_size_chars(val);
357        self
358    }
359
360    pub fn with_maximize_win(&self, val: bool) -> &Self {
361        self.set_maximize_win(val);
362        self
363    }
364
365    pub fn with_fullscreen_win(&self, val: bool) -> &Self {
366        self.set_fullscreen_win(val);
367        self
368    }
369
370    pub fn with_push_title(&self, val: bool) -> &Self {
371        self.set_push_title(val);
372        self
373    }
374
375    pub fn with_pop_title(&self, val: bool) -> &Self {
376        self.set_pop_title(val);
377        self
378    }
379
380    pub fn with_win_lines(&self, val: bool) -> &Self {
381        self.set_win_lines(val);
382        self
383    }
384}