mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 21:00:03 -04:00
When we load a string in `TextEdit` we keep the tabs as they are.
Now depending on `tab_as_spaces` and `tab_size` properties of the
`TextEdit` we have the following situations:
- When `tab_as_spaces` is false, then when we press `TAB` a `TAB`
char in added to the string.
- When `tab_as_spaces` is true, then when we press `TAB` a chunck
of `tab_size` spaces is added to the string.
To config `tab_as_spaces` and `tab_size` to the values we want we
can use the folliwing helper functions:
- `TextEdit::tab_as_spaces()`
- `TextEdit::tab_size()`
Example usage:
```rust
ui.add(egui::TextEdit::multiline(&mut self.multiline_text_input)
.tab_as_spaces(self.tab_as_spaces)
.tab_size(self.tab_size));
```
Demo:
A better demo of this new functionality was implemented in the
misc widgets demo
What's left to do:
- Render actual `TAB` as a rect the size of `tab_size` spaces.
- Without default parameters values it seems a pain to implement.
I need to think if it is possible to avoid API breaking changes
for the font system. From my checks so far I need to pass at
least `tab_size` to the fonts system to know how big the glyph
for `TAB` will be.
egui demo library
this crate contains example code for egui.
it is in a separate crate for two reasons:
- to ensure it only uses the public
eguiapi. - to remove the amount of code in
eguiproper.