BufferLine: remove wrap from struct, as wrap is passed to layout
This commit is contained in:
parent
816ea4fae7
commit
b877f873df
2 changed files with 2 additions and 25 deletions
|
|
@ -9,7 +9,6 @@ pub struct BufferLine {
|
||||||
//TODO: make this not pub(crate)
|
//TODO: make this not pub(crate)
|
||||||
text: String,
|
text: String,
|
||||||
attrs_list: AttrsList,
|
attrs_list: AttrsList,
|
||||||
wrap: Wrap,
|
|
||||||
align: Option<Align>,
|
align: Option<Align>,
|
||||||
shape_opt: Option<ShapeLine>,
|
shape_opt: Option<ShapeLine>,
|
||||||
layout_opt: Option<Vec<LayoutLine>>,
|
layout_opt: Option<Vec<LayoutLine>>,
|
||||||
|
|
@ -24,7 +23,6 @@ impl BufferLine {
|
||||||
Self {
|
Self {
|
||||||
text: text.into(),
|
text: text.into(),
|
||||||
attrs_list,
|
attrs_list,
|
||||||
wrap: Wrap::Word,
|
|
||||||
align: None,
|
align: None,
|
||||||
shape_opt: None,
|
shape_opt: None,
|
||||||
layout_opt: None,
|
layout_opt: None,
|
||||||
|
|
@ -78,25 +76,6 @@ impl BufferLine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get wrapping setting (wrap by characters/words or no wrapping)
|
|
||||||
pub fn wrap(&self) -> Wrap {
|
|
||||||
self.wrap
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Set wrapping setting (wrap by characters/words or no wrapping)
|
|
||||||
///
|
|
||||||
/// Will reset shape and layout if it differs from current wrapping setting.
|
|
||||||
/// Returns true if the line was reset
|
|
||||||
pub fn set_wrap(&mut self, wrap: Wrap) -> bool {
|
|
||||||
if wrap != self.wrap {
|
|
||||||
self.wrap = wrap;
|
|
||||||
self.reset_layout();
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the Text alignment
|
/// Get the Text alignment
|
||||||
pub fn align(&self) -> Option<Align> {
|
pub fn align(&self) -> Option<Align> {
|
||||||
self.align
|
self.align
|
||||||
|
|
@ -146,7 +125,7 @@ impl BufferLine {
|
||||||
self.reset();
|
self.reset();
|
||||||
|
|
||||||
let mut new = Self::new(text, attrs_list, self.shaping);
|
let mut new = Self::new(text, attrs_list, self.shaping);
|
||||||
new.wrap = self.wrap;
|
new.align = self.align;
|
||||||
new
|
new
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -223,7 +202,6 @@ impl BufferLine {
|
||||||
wrap: Wrap,
|
wrap: Wrap,
|
||||||
) -> &[LayoutLine] {
|
) -> &[LayoutLine] {
|
||||||
if self.layout_opt.is_none() {
|
if self.layout_opt.is_none() {
|
||||||
self.wrap = wrap;
|
|
||||||
let align = self.align;
|
let align = self.align;
|
||||||
let shape = self.shape_in_buffer(scratch, font_system);
|
let shape = self.shape_in_buffer(scratch, font_system);
|
||||||
let mut layout = Vec::with_capacity(1);
|
let mut layout = Vec::with_capacity(1);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use syntect::parsing::{ParseState, ScopeStack, SyntaxReference, SyntaxSet};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Action, AttrsList, BorrowedWithFontSystem, Buffer, Change, Color, Cursor, Edit, Editor,
|
Action, AttrsList, BorrowedWithFontSystem, Buffer, Change, Color, Cursor, Edit, Editor,
|
||||||
FontSystem, Selection, Shaping, Style, Weight, Wrap,
|
FontSystem, Selection, Shaping, Style, Weight,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use syntect::highlighting::Theme as SyntaxTheme;
|
pub use syntect::highlighting::Theme as SyntaxTheme;
|
||||||
|
|
@ -283,7 +283,6 @@ impl<'a> Edit for SyntaxEditor<'a> {
|
||||||
|
|
||||||
// Update line attributes. This operation only resets if the line changes
|
// Update line attributes. This operation only resets if the line changes
|
||||||
line.set_attrs_list(attrs_list);
|
line.set_attrs_list(attrs_list);
|
||||||
line.set_wrap(Wrap::Word);
|
|
||||||
|
|
||||||
// Perform shaping and layout of this line in order to count if we have reached scroll
|
// Perform shaping and layout of this line in order to count if we have reached scroll
|
||||||
match buffer.line_layout(font_system, line_i) {
|
match buffer.line_layout(font_system, line_i) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue