1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 21:30:03 -04:00

Decrease indentation with shift-tab

This commit is contained in:
Emil Ernerfeldt
2021-05-02 20:09:11 +02:00
parent bf8ce774cc
commit 66122e4c9a
4 changed files with 80 additions and 6 deletions

View File

@@ -51,6 +51,18 @@ impl std::ops::Sub<usize> for CCursor {
}
}
impl std::ops::AddAssign<usize> for CCursor {
fn add_assign(&mut self, rhs: usize) {
self.index = self.index.saturating_add(rhs);
}
}
impl std::ops::SubAssign<usize> for CCursor {
fn sub_assign(&mut self, rhs: usize) {
self.index = self.index.saturating_sub(rhs);
}
}
/// Row Cursor
#[derive(Clone, Copy, Debug, Default, PartialEq)]
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]

View File

@@ -127,7 +127,7 @@ impl FontImpl {
if c == '\t' {
if let Some(space) = self.glyph_info(' ') {
glyph_info.advance_width = crate::text::TAB_SIZE * space.advance_width;
glyph_info.advance_width = crate::text::TAB_SIZE as f32 * space.advance_width;
}
}

View File

@@ -5,8 +5,8 @@ mod font;
mod fonts;
mod galley;
/// Default size for a `\t` character.
pub const TAB_SIZE: f32 = 4.0;
/// One `\t` character is this many spaces wide.
pub const TAB_SIZE: usize = 4;
pub use {
fonts::{FontDefinitions, FontFamily, Fonts, TextStyle},