iced_code_editor/canvas_editor/
bool_options.rs1macro_rules! bool_options {
28 ($(
29 $get:ident, $set:ident $(, $with:ident)?,
30 $get_summary:literal,
31 $get_returns:literal,
32 default: $default_note:literal, $default_negation:literal
33 $(builder: $with_summary:literal,
34 $with_argument:literal)?;
35 )*) => {
36 impl CodeEditor {
37 $(
38 #[doc = $get_summary]
39 #[doc = ""]
40 #[doc = "# Returns"]
41 #[doc = ""]
42 #[doc = $get_returns]
43 #[doc = ""]
44 #[doc = "# Example"]
45 #[doc = ""]
46 #[doc = "```"]
47 #[doc = "use iced_code_editor::CodeEditor;"]
48 #[doc = ""]
49 #[doc = "let mut editor = CodeEditor::new(\"fn main() {}\", \"rs\");"]
50 #[doc = concat!("// ", $default_note)]
51 #[doc = concat!(
52 "assert!(",
53 $default_negation,
54 "editor.",
55 stringify!($get),
56 "());"
57 )]
58 #[doc = ""]
59 #[doc = concat!("editor.", stringify!($set), "(true);")]
60 #[doc = concat!("assert!(editor.", stringify!($get), "());")]
61 #[doc = ""]
62 #[doc = concat!("editor.", stringify!($set), "(false);")]
63 #[doc = concat!("assert!(!editor.", stringify!($get), "());")]
64 #[doc = "```"]
65 #[must_use]
66 pub fn $get(&self) -> bool {
67 self.$get
68 }
69
70 $(
71 #[doc = $with_summary]
72 #[doc = ""]
73 #[doc = "# Arguments"]
74 #[doc = ""]
75 #[doc = concat!("* `enabled` - ", $with_argument)]
76 #[doc = ""]
77 #[doc = "# Returns"]
78 #[doc = ""]
79 #[doc = "Self for method chaining"]
80 #[doc = ""]
81 #[doc = "# Example"]
82 #[doc = ""]
83 #[doc = "```"]
84 #[doc = "use iced_code_editor::CodeEditor;"]
85 #[doc = ""]
86 #[doc = concat!(
87 "let editor = CodeEditor::new(\"fn main() {}\", \"rs\")"
88 )]
89 #[doc = concat!(" .", stringify!($with), "(false);")]
90 #[doc = concat!("assert!(!editor.", stringify!($get), "());")]
91 #[doc = "```"]
92 #[must_use]
93 pub fn $with(mut self, enabled: bool) -> Self {
94 self.$set(enabled);
98 self
99 }
100 )?
101 )*
102 }
103 };
104}
105
106use super::CodeEditor;
107
108bool_options! {
109 auto_close_brackets, set_auto_close_brackets,
110 "Returns whether auto-closing of brackets and quotes is enabled.",
111 "`true` if auto-closing is enabled, `false` otherwise",
112 default: "Enabled by default.", "";
113 auto_indent_enabled, set_auto_indent_enabled,
114 "Returns whether auto-indentation is enabled.",
115 "`true` if auto-indentation is enabled, `false` otherwise",
116 default: "Enabled by default.", "";
117 bracket_match_highlight_enabled, set_bracket_match_highlight_enabled,
118 "Returns whether the matching-bracket/quote-pair highlight overlay is enabled.",
119 "`true` if the highlight is enabled, `false` otherwise",
120 default: "Enabled by default.", "";
121 bracket_pair_colorization_enabled, set_bracket_pair_colorization_enabled,
122 "Returns whether bracket-pair colorization (rainbow brackets) is enabled.",
123 "`true` if bracket-pair colorization is enabled, `false` otherwise",
124 default: "Enabled by default.", "";
125 command_palette_enabled, set_command_palette_enabled, with_command_palette_enabled,
126 "Returns whether the command palette can be opened.",
127 "`true` if the palette can be opened, `false` otherwise",
128 default: "Available by default.", ""
129 builder: "Sets command-palette availability using the builder pattern.",
130 "Whether the palette can be opened";
131 default_command_palette_enabled, set_default_command_palette_enabled,
132 "Returns whether the built-in commands are listed in the palette.",
133 "`true` if the built-in commands are listed, `false` otherwise",
134 default: "Listed by default.", "";
135 default_context_menu_enabled, set_default_context_menu_enabled, with_default_context_menu_enabled,
136 "Returns whether the built-in context-menu actions are enabled.",
137 "`true` if the built-in actions are shown, `false` otherwise",
138 default: "Shown by default.", ""
139 builder: "Sets built-in context-menu visibility using the builder pattern.",
140 "Whether to show the built-in actions";
141 folding_enabled, set_folding_enabled, with_folding_enabled,
142 "Returns whether code folding is enabled.",
143 "`true` if code folding is enabled, `false` otherwise",
144 default: "Enabled by default.", ""
145 builder: "Enables or disables code folding using the builder pattern.",
146 "Whether to enable code folding";
147 line_numbers_enabled, set_line_numbers_enabled, with_line_numbers_enabled,
148 "Returns whether line numbers are displayed.",
149 "`true` if line numbers are displayed, `false` otherwise",
150 default: "Displayed by default.", ""
151 builder: "Sets the line numbers display with builder pattern.",
152 "Whether to display line numbers";
153 reveal_in_file_manager_enabled, set_reveal_in_file_manager_enabled,
154 "Returns whether the reveal-in-file-manager action is shown.",
155 "`true` if the reveal action is shown, `false` otherwise",
156 default: "Off by default: the editor doesn't know its own file path.", "!";
157 search_replace_enabled, set_search_replace_enabled,
158 "Returns whether search/replace functionality is enabled.",
159 "`true` if search/replace is enabled, `false` otherwise",
160 default: "Enabled by default.", "";
161 show_color_previews, set_show_color_previews, with_show_color_previews,
162 "Returns whether inline color previews are drawn.",
163 "`true` if color-preview swatches are rendered, `false` otherwise",
164 default: "Enabled by default.", ""
165 builder: "Sets the inline color-preview display with builder pattern.",
166 "Whether to draw color-preview swatches";
167 show_indent_guides, set_show_indent_guides, with_show_indent_guides,
168 "Returns whether indentation guides are drawn.",
169 "`true` if indentation guides are rendered, `false` otherwise",
170 default: "Enabled by default.", ""
171 builder: "Sets the indentation-guide display with builder pattern.",
172 "Whether to draw indentation guides";
173 show_whitespace, set_show_whitespace,
174 "Returns whether visible whitespace rendering is enabled.",
175 "`true` if whitespace characters are rendered, `false` otherwise",
176 default: "Enabled by default.", "";
177 sticky_scroll_enabled, set_sticky_scroll_enabled, with_sticky_scroll_enabled,
178 "Returns whether sticky scroll is enabled.",
179 "`true` if enclosing block headers are pinned, `false` otherwise",
180 default: "Enabled by default.", ""
181 builder: "Sets sticky scroll with builder pattern.",
182 "Whether to pin enclosing block headers above the viewport";
183 vim_enabled, set_vim_enabled, with_vim_enabled,
184 "Returns whether Vim behavior is enabled for this editor instance.",
185 "`true` if Vim behavior is enabled, `false` otherwise",
186 default: "Off by default.", "!"
187 builder: "Sets whether Vim behavior is enabled using the builder pattern.",
188 "Whether to enable Vim behavior";
189 wrap_enabled, set_wrap_enabled, with_wrap_enabled,
190 "Returns whether line wrapping is enabled.",
191 "`true` if line wrapping is enabled, `false` otherwise",
192 default: "Enabled by default.", ""
193 builder: "Sets the line wrapping with builder pattern.",
194 "Whether to enable line wrapping";
195}