fltk_builder/extensions/builder/
display.rs1use fltk::{
2 enums::{Align, Color, Font},
3 prelude::DisplayExt,
4 text::{Cursor, StyleTableEntry, StyleTableEntryExt, TextBuffer, WrapMode},
5};
6
7pub trait DisplayBuilderExt {
9 fn with_buffer<B: Into<Option<TextBuffer>>>(self, buffer: B) -> Self;
11 fn with_text_font(self, font: Font) -> Self;
13 fn with_text_color(self, color: Color) -> Self;
15 fn with_text_size(self, sz: i32) -> Self;
17 fn with_highlight_data<B: Into<Option<TextBuffer>>>(
19 self,
20 style_buffer: B,
21 entries: Vec<StyleTableEntry>,
22 ) -> Self;
23 fn with_highlight_data_ext<B: Into<Option<TextBuffer>>>(
25 self,
26 style_buffer: B,
27 entries: Vec<StyleTableEntryExt>,
28 ) -> Self;
29 fn with_cursor_style(self, style: Cursor) -> Self;
31 fn with_cursor_color(self, color: Color) -> Self;
33 fn with_scrollbar_size(self, size: i32) -> Self;
35 fn with_scrollbar_align(self, align: Align) -> Self;
37 fn with_linenumber_width(self, w: i32) -> Self;
39 fn with_linenumber_font(self, font: Font) -> Self;
41 fn with_linenumber_size(self, size: i32) -> Self;
43 fn with_linenumber_fgcolor(self, color: Color) -> Self;
45 fn with_linenumber_bgcolor(self, color: Color) -> Self;
47 fn with_linenumber_align(self, align: Align) -> Self;
49 fn with_wrap_mode(self, wrap: WrapMode, wrap_margin: i32) -> Self;
54 fn with_grammar_underline_color(self, color: Color) -> Self;
56 fn with_spelling_underline_color(self, color: Color) -> Self;
58 fn with_secondary_selection_color(self, color: Color) -> Self;
60}
61
62impl<D> DisplayBuilderExt for D
63where
64 D: DisplayExt,
65{
66 fn with_buffer<B: Into<Option<TextBuffer>>>(mut self, buffer: B) -> Self {
67 self.set_buffer(buffer);
68 self
69 }
70
71 fn with_text_font(mut self, font: Font) -> Self {
72 self.set_text_font(font);
73 self
74 }
75
76 fn with_text_color(mut self, color: Color) -> Self {
77 self.set_text_color(color);
78 self
79 }
80
81 fn with_text_size(mut self, sz: i32) -> Self {
82 self.set_text_size(sz);
83 self
84 }
85
86 fn with_highlight_data<B: Into<Option<TextBuffer>>>(
87 mut self,
88 style_buffer: B,
89 entries: Vec<StyleTableEntry>,
90 ) -> Self {
91 self.set_highlight_data(style_buffer, entries);
92 self
93 }
94
95 fn with_highlight_data_ext<B: Into<Option<TextBuffer>>>(
96 mut self,
97 style_buffer: B,
98 entries: Vec<StyleTableEntryExt>,
99 ) -> Self {
100 self.set_highlight_data_ext(style_buffer, entries);
101 self
102 }
103
104 fn with_cursor_style(mut self, style: Cursor) -> Self {
105 self.set_cursor_style(style);
106 self
107 }
108
109 fn with_cursor_color(mut self, color: Color) -> Self {
110 self.set_cursor_color(color);
111 self
112 }
113
114 fn with_scrollbar_size(mut self, size: i32) -> Self {
115 self.set_scrollbar_size(size);
116 self
117 }
118
119 fn with_scrollbar_align(mut self, align: Align) -> Self {
120 self.set_scrollbar_align(align);
121 self
122 }
123
124 fn with_linenumber_width(mut self, w: i32) -> Self {
125 self.set_linenumber_width(w);
126 self
127 }
128
129 fn with_linenumber_font(mut self, font: Font) -> Self {
130 self.set_linenumber_font(font);
131 self
132 }
133
134 fn with_linenumber_size(mut self, size: i32) -> Self {
135 self.set_linenumber_size(size);
136 self
137 }
138
139 fn with_linenumber_fgcolor(mut self, color: Color) -> Self {
140 self.set_linenumber_fgcolor(color);
141 self
142 }
143
144 fn with_linenumber_bgcolor(mut self, color: Color) -> Self {
145 self.set_linenumber_bgcolor(color);
146 self
147 }
148
149 fn with_linenumber_align(mut self, align: Align) -> Self {
150 self.set_linenumber_align(align);
151 self
152 }
153
154 fn with_wrap_mode(mut self, wrap: WrapMode, wrap_margin: i32) -> Self {
155 self.wrap_mode(wrap, wrap_margin);
156 self
157 }
158
159 fn with_grammar_underline_color(mut self, color: Color) -> Self {
160 self.set_grammar_underline_color(color);
161 self
162 }
163
164 fn with_spelling_underline_color(mut self, color: Color) -> Self {
165 self.set_spelling_underline_color(color);
166 self
167 }
168
169 fn with_secondary_selection_color(mut self, color: Color) -> Self {
170 self.set_secondary_selection_color(color);
171 self
172 }
173}