Align Left, Right, and Center works

This commit is contained in:
Hojjat 2023-02-22 18:31:49 -07:00
parent 9a4d067f9d
commit 00ff5b72f3
5 changed files with 106 additions and 31 deletions

View file

@ -10,7 +10,9 @@ use unicode_segmentation::UnicodeSegmentation;
#[cfg(feature = "swash")]
use crate::Color;
use crate::{Attrs, AttrsList, BufferLine, FontSystem, LayoutGlyph, LayoutLine, ShapeLine, Wrap};
use crate::{
Align, Attrs, AttrsList, BufferLine, FontSystem, LayoutGlyph, LayoutLine, ShapeLine, Wrap,
};
/// Current cursor location
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Ord, PartialOrd)]
@ -301,6 +303,7 @@ pub struct Buffer<'a> {
/// True if a redraw is requires. Set to false after processing
redraw: bool,
wrap: Wrap,
align: Align,
}
impl<'a> Buffer<'a> {
@ -317,6 +320,7 @@ impl<'a> Buffer<'a> {
scroll: 0,
redraw: false,
wrap: Wrap::Word,
align: Align::Center,
};
buffer.set_text("", Attrs::new());
buffer
@ -334,6 +338,7 @@ impl<'a> Buffer<'a> {
self.metrics.font_size,
self.width,
self.wrap,
self.align,
);
}
}
@ -364,6 +369,7 @@ impl<'a> Buffer<'a> {
self.metrics.font_size,
self.width,
self.wrap,
self.align,
);
total_layout += layout.len() as i32;
}
@ -397,6 +403,7 @@ impl<'a> Buffer<'a> {
self.metrics.font_size,
self.width,
self.wrap,
self.align,
);
if line_i == cursor.line {
let layout_cursor = self.layout_cursor(&cursor);
@ -482,6 +489,7 @@ impl<'a> Buffer<'a> {
self.metrics.font_size,
self.width,
self.wrap,
self.align,
))
}