1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 13:50:04 -04:00

Tab identation for multiline text edit (#246)

Lock focus on multiline text edit, and insert tabs on tab char

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
This commit is contained in:
Cristian Dinu
2021-05-02 19:56:28 +03:00
committed by GitHub
parent 101eed0d67
commit 35c7b09285
6 changed files with 150 additions and 7 deletions

View File

@@ -120,7 +120,7 @@ impl FontImpl {
if c == '\t' {
if let Some(space) = self.glyph_info(' ') {
glyph_info.advance_width = 4.0 * space.advance_width;
glyph_info.advance_width = crate::text::MAX_TAB_SIZE * space.advance_width;
}
}
@@ -285,6 +285,7 @@ impl Font {
for c in text.chars() {
if !self.fonts.is_empty() {
let (font_index, glyph_info) = self.glyph_info(c);
let font_impl = &self.fonts[font_index];
if let Some(last_glyph_id) = last_glyph_id {

View File

@@ -5,6 +5,9 @@ mod font;
mod fonts;
mod galley;
/// Default size for a `\t` character.
pub const MAX_TAB_SIZE: f32 = 4.0;
pub use {
fonts::{FontDefinitions, FontFamily, Fonts, TextStyle},
galley::{Galley, Row},