mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 17:08:21 +00:00
upgrade ratatui
This commit is contained in:
parent
195a6f2c90
commit
4f3be697d5
21 changed files with 134 additions and 123 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
|
@ -1445,9 +1445,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ratatui"
|
name = "ratatui"
|
||||||
version = "0.20.1"
|
version = "0.21.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dcc0d032bccba900ee32151ec0265667535c230169f5a011154cdcd984e16829"
|
checksum = "ce841e0486e7c2412c3740168ede33adeba8e154a15107b879d8162d77c7174e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cassowary",
|
"cassowary",
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ log = "0.4"
|
||||||
notify = "5.1"
|
notify = "5.1"
|
||||||
notify-debouncer-mini = "0.2"
|
notify-debouncer-mini = "0.2"
|
||||||
once_cell = "1"
|
once_cell = "1"
|
||||||
ratatui = { version = "0.20", default-features = false, features = ['crossterm', 'serde'] }
|
ratatui = { version = "0.21", default-features = false, features = ['crossterm', 'serde'] }
|
||||||
rayon-core = "1.11"
|
rayon-core = "1.11"
|
||||||
ron = "0.8"
|
ron = "0.8"
|
||||||
scopeguard = "1.1"
|
scopeguard = "1.1"
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ use ratatui::{
|
||||||
layout::{
|
layout::{
|
||||||
Alignment, Constraint, Direction, Layout, Margin, Rect,
|
Alignment, Constraint, Direction, Layout, Margin, Rect,
|
||||||
},
|
},
|
||||||
text::{Span, Spans},
|
text::{Line, Span},
|
||||||
widgets::{Block, Borders, Paragraph, Tabs},
|
widgets::{Block, Borders, Paragraph, Tabs},
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
|
|
@ -1189,7 +1189,7 @@ impl App {
|
||||||
let table_area = r; // use entire area to allow drawing the horizontal separator line
|
let table_area = r; // use entire area to allow drawing the horizontal separator line
|
||||||
let text_area = left_right[1];
|
let text_area = left_right[1];
|
||||||
|
|
||||||
let tabs = tab_labels.into_iter().map(Spans::from).collect();
|
let tabs = tab_labels.into_iter().map(Line::from).collect();
|
||||||
|
|
||||||
f.render_widget(
|
f.render_widget(
|
||||||
Tabs::new(tabs)
|
Tabs::new(tabs)
|
||||||
|
|
@ -1206,7 +1206,7 @@ impl App {
|
||||||
);
|
);
|
||||||
|
|
||||||
f.render_widget(
|
f.render_widget(
|
||||||
Paragraph::new(Spans::from(vec![Span::styled(
|
Paragraph::new(Line::from(vec![Span::styled(
|
||||||
ellipsis_trim_start(
|
ellipsis_trim_start(
|
||||||
&self.repo_path_text,
|
&self.repo_path_text,
|
||||||
text_area.width as usize,
|
text_area.width as usize,
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use crate::{
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::{Alignment, Rect},
|
layout::{Alignment, Rect},
|
||||||
text::{Span, Spans},
|
text::{Line, Span},
|
||||||
widgets::Paragraph,
|
widgets::Paragraph,
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
|
|
@ -151,7 +151,7 @@ impl CommandBar {
|
||||||
.draw_list
|
.draw_list
|
||||||
.split(|c| matches!(c, DrawListEntry::LineBreak))
|
.split(|c| matches!(c, DrawListEntry::LineBreak))
|
||||||
.map(|c_arr| {
|
.map(|c_arr| {
|
||||||
Spans::from(
|
Line::from(
|
||||||
c_arr
|
c_arr
|
||||||
.iter()
|
.iter()
|
||||||
.map(|c| match c {
|
.map(|c| match c {
|
||||||
|
|
@ -174,7 +174,7 @@ impl CommandBar {
|
||||||
.collect::<Vec<Span>>(),
|
.collect::<Vec<Span>>(),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.collect::<Vec<Spans>>();
|
.collect::<Vec<Line>>();
|
||||||
|
|
||||||
f.render_widget(
|
f.render_widget(
|
||||||
Paragraph::new(texts).alignment(Alignment::Left),
|
Paragraph::new(texts).alignment(Alignment::Left),
|
||||||
|
|
@ -190,7 +190,7 @@ impl CommandBar {
|
||||||
);
|
);
|
||||||
|
|
||||||
f.render_widget(
|
f.render_widget(
|
||||||
Paragraph::new(Spans::from(vec![Span::raw(
|
Paragraph::new(Line::from(vec![Span::raw(
|
||||||
Cow::from(if self.expanded {
|
Cow::from(if self.expanded {
|
||||||
"less [.]"
|
"less [.]"
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ use fuzzy_matcher::FuzzyMatcher;
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::{Constraint, Direction, Layout, Margin, Rect},
|
layout::{Constraint, Direction, Layout, Margin, Rect},
|
||||||
text::{Span, Spans},
|
text::{Line, Span},
|
||||||
widgets::{Block, Borders, Clear},
|
widgets::{Block, Borders, Clear},
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
|
|
@ -233,7 +233,7 @@ impl DrawableComponent for BranchFindPopup {
|
||||||
&self.branches[*idx],
|
&self.branches[*idx],
|
||||||
width,
|
width,
|
||||||
);
|
);
|
||||||
Spans::from(
|
Line::from(
|
||||||
full_text
|
full_text
|
||||||
.char_indices()
|
.char_indices()
|
||||||
.map(|(c_idx, c)| {
|
.map(|(c_idx, c)| {
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ use ratatui::{
|
||||||
layout::{
|
layout::{
|
||||||
Alignment, Constraint, Direction, Layout, Margin, Rect,
|
Alignment, Constraint, Direction, Layout, Margin, Rect,
|
||||||
},
|
},
|
||||||
text::{Span, Spans, Text},
|
text::{Line, Span, Text},
|
||||||
widgets::{Block, BorderType, Borders, Clear, Paragraph, Tabs},
|
widgets::{Block, BorderType, Borders, Clear, Paragraph, Tabs},
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
|
|
@ -661,7 +661,7 @@ impl BranchListComponent {
|
||||||
theme.branch(selected, is_head),
|
theme.branch(selected, is_head),
|
||||||
);
|
);
|
||||||
|
|
||||||
txt.push(Spans::from(vec![
|
txt.push(Line::from(vec![
|
||||||
span_prefix,
|
span_prefix,
|
||||||
span_name,
|
span_name,
|
||||||
span_hash,
|
span_hash,
|
||||||
|
|
@ -702,7 +702,7 @@ impl BranchListComponent {
|
||||||
let tabs = [Span::raw("Local"), Span::raw("Remote")]
|
let tabs = [Span::raw("Local"), Span::raw("Remote")]
|
||||||
.iter()
|
.iter()
|
||||||
.cloned()
|
.cloned()
|
||||||
.map(Spans::from)
|
.map(Line::from)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
f.render_widget(
|
f.render_widget(
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ use crossterm::event::Event;
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::{Constraint, Direction, Layout, Rect},
|
layout::{Constraint, Direction, Layout, Rect},
|
||||||
text::{Span, Spans, Text},
|
text::{Line, Span, Text},
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -65,9 +65,9 @@ impl CompareDetailsComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unstable_name_collisions)]
|
#[allow(unstable_name_collisions)]
|
||||||
fn get_commit_text(&self, data: &CommitDetails) -> Vec<Spans> {
|
fn get_commit_text(&self, data: &CommitDetails) -> Vec<Line> {
|
||||||
let mut res = vec![
|
let mut res = vec![
|
||||||
Spans::from(vec![
|
Line::from(vec![
|
||||||
style_detail(&self.theme, &Detail::Author),
|
style_detail(&self.theme, &Detail::Author),
|
||||||
Span::styled(
|
Span::styled(
|
||||||
Cow::from(format!(
|
Cow::from(format!(
|
||||||
|
|
@ -77,7 +77,7 @@ impl CompareDetailsComponent {
|
||||||
self.theme.text(true, false),
|
self.theme.text(true, false),
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
Spans::from(vec![
|
Line::from(vec![
|
||||||
style_detail(&self.theme, &Detail::Date),
|
style_detail(&self.theme, &Detail::Date),
|
||||||
Span::styled(
|
Span::styled(
|
||||||
Cow::from(time_to_string(
|
Cow::from(time_to_string(
|
||||||
|
|
@ -89,7 +89,7 @@ impl CompareDetailsComponent {
|
||||||
]),
|
]),
|
||||||
];
|
];
|
||||||
|
|
||||||
res.push(Spans::from(vec![
|
res.push(Line::from(vec![
|
||||||
style_detail(&self.theme, &Detail::Message),
|
style_detail(&self.theme, &Detail::Message),
|
||||||
Span::styled(
|
Span::styled(
|
||||||
Cow::from(
|
Cow::from(
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ use ratatui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::{Constraint, Direction, Layout, Rect},
|
layout::{Constraint, Direction, Layout, Rect},
|
||||||
style::{Modifier, Style},
|
style::{Modifier, Style},
|
||||||
text::{Span, Spans, Text},
|
text::{Line, Span, Text},
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
use std::clone::Clone;
|
use std::clone::Clone;
|
||||||
|
|
@ -133,7 +133,7 @@ impl DetailsComponent {
|
||||||
&self,
|
&self,
|
||||||
width: usize,
|
width: usize,
|
||||||
height: usize,
|
height: usize,
|
||||||
) -> Vec<Spans> {
|
) -> Vec<Line> {
|
||||||
let (wrapped_title, wrapped_message) =
|
let (wrapped_title, wrapped_message) =
|
||||||
Self::get_wrapped_lines(&self.data, width);
|
Self::get_wrapped_lines(&self.data, width);
|
||||||
|
|
||||||
|
|
@ -144,7 +144,7 @@ impl DetailsComponent {
|
||||||
.skip(self.scroll.get_top())
|
.skip(self.scroll.get_top())
|
||||||
.take(height)
|
.take(height)
|
||||||
.map(|(i, line)| {
|
.map(|(i, line)| {
|
||||||
Spans::from(vec![Span::styled(
|
Line::from(vec![Span::styled(
|
||||||
line.clone(),
|
line.clone(),
|
||||||
self.get_theme_for_line(i < wrapped_title.len()),
|
self.get_theme_for_line(i < wrapped_title.len()),
|
||||||
)])
|
)])
|
||||||
|
|
@ -153,10 +153,10 @@ impl DetailsComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unstable_name_collisions, clippy::too_many_lines)]
|
#[allow(unstable_name_collisions, clippy::too_many_lines)]
|
||||||
fn get_text_info(&self) -> Vec<Spans> {
|
fn get_text_info(&self) -> Vec<Line> {
|
||||||
self.data.as_ref().map_or_else(Vec::new, |data| {
|
self.data.as_ref().map_or_else(Vec::new, |data| {
|
||||||
let mut res = vec![
|
let mut res = vec![
|
||||||
Spans::from(vec![
|
Line::from(vec![
|
||||||
style_detail(&self.theme, &Detail::Author),
|
style_detail(&self.theme, &Detail::Author),
|
||||||
Span::styled(
|
Span::styled(
|
||||||
Cow::from(format!(
|
Cow::from(format!(
|
||||||
|
|
@ -166,7 +166,7 @@ impl DetailsComponent {
|
||||||
self.theme.text(true, false),
|
self.theme.text(true, false),
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
Spans::from(vec![
|
Line::from(vec![
|
||||||
style_detail(&self.theme, &Detail::Date),
|
style_detail(&self.theme, &Detail::Date),
|
||||||
Span::styled(
|
Span::styled(
|
||||||
Cow::from(time_to_string(
|
Cow::from(time_to_string(
|
||||||
|
|
@ -180,7 +180,7 @@ impl DetailsComponent {
|
||||||
|
|
||||||
if let Some(ref committer) = data.committer {
|
if let Some(ref committer) = data.committer {
|
||||||
res.extend(vec![
|
res.extend(vec![
|
||||||
Spans::from(vec![
|
Line::from(vec![
|
||||||
style_detail(&self.theme, &Detail::Commiter),
|
style_detail(&self.theme, &Detail::Commiter),
|
||||||
Span::styled(
|
Span::styled(
|
||||||
Cow::from(format!(
|
Cow::from(format!(
|
||||||
|
|
@ -190,7 +190,7 @@ impl DetailsComponent {
|
||||||
self.theme.text(true, false),
|
self.theme.text(true, false),
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
Spans::from(vec![
|
Line::from(vec![
|
||||||
style_detail(&self.theme, &Detail::Date),
|
style_detail(&self.theme, &Detail::Date),
|
||||||
Span::styled(
|
Span::styled(
|
||||||
Cow::from(time_to_string(
|
Cow::from(time_to_string(
|
||||||
|
|
@ -203,7 +203,7 @@ impl DetailsComponent {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.push(Spans::from(vec![
|
res.push(Line::from(vec![
|
||||||
Span::styled(
|
Span::styled(
|
||||||
Cow::from(strings::commit::details_sha()),
|
Cow::from(strings::commit::details_sha()),
|
||||||
self.theme.text(false, false),
|
self.theme.text(false, false),
|
||||||
|
|
@ -215,12 +215,12 @@ impl DetailsComponent {
|
||||||
]));
|
]));
|
||||||
|
|
||||||
if !self.tags.is_empty() {
|
if !self.tags.is_empty() {
|
||||||
res.push(Spans::from(style_detail(
|
res.push(Line::from(style_detail(
|
||||||
&self.theme,
|
&self.theme,
|
||||||
&Detail::Sha,
|
&Detail::Sha,
|
||||||
)));
|
)));
|
||||||
|
|
||||||
res.push(Spans::from(
|
res.push(Line::from(
|
||||||
itertools::Itertools::intersperse(
|
itertools::Itertools::intersperse(
|
||||||
self.tags.iter().map(|tag| {
|
self.tags.iter().map(|tag| {
|
||||||
Span::styled(
|
Span::styled(
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ use itertools::Itertools;
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::{Alignment, Rect},
|
layout::{Alignment, Rect},
|
||||||
text::{Span, Spans},
|
text::{Line, Span},
|
||||||
widgets::{Block, Borders, Paragraph},
|
widgets::{Block, Borders, Paragraph},
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
|
|
@ -306,7 +306,7 @@ impl CommitList {
|
||||||
width: usize,
|
width: usize,
|
||||||
now: DateTime<Local>,
|
now: DateTime<Local>,
|
||||||
marked: Option<bool>,
|
marked: Option<bool>,
|
||||||
) -> Spans<'a> {
|
) -> Line<'a> {
|
||||||
let mut txt: Vec<Span> = Vec::with_capacity(
|
let mut txt: Vec<Span> = Vec::with_capacity(
|
||||||
ELEMENTS_PER_LINE + if marked.is_some() { 2 } else { 0 },
|
ELEMENTS_PER_LINE + if marked.is_some() { 2 } else { 0 },
|
||||||
);
|
);
|
||||||
|
|
@ -390,13 +390,13 @@ impl CommitList {
|
||||||
theme.text(true, selected),
|
theme.text(true, selected),
|
||||||
));
|
));
|
||||||
|
|
||||||
Spans::from(txt)
|
Line::from(txt)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_text(&self, height: usize, width: usize) -> Vec<Spans> {
|
fn get_text(&self, height: usize, width: usize) -> Vec<Line> {
|
||||||
let selection = self.relative_selection();
|
let selection = self.relative_selection();
|
||||||
|
|
||||||
let mut txt: Vec<Spans> = Vec::with_capacity(height);
|
let mut txt: Vec<Line> = Vec::with_capacity(height);
|
||||||
|
|
||||||
let now = Local::now();
|
let now = Local::now();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ use ratatui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::Rect,
|
layout::Rect,
|
||||||
symbols,
|
symbols,
|
||||||
text::{Span, Spans},
|
text::{Line, Span},
|
||||||
widgets::{Block, Borders, Paragraph},
|
widgets::{Block, Borders, Paragraph},
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
|
|
@ -330,15 +330,15 @@ impl DiffComponent {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_text(&self, width: u16, height: u16) -> Vec<Spans> {
|
fn get_text(&self, width: u16, height: u16) -> Vec<Line> {
|
||||||
let mut res: Vec<Spans> = Vec::new();
|
let mut res: Vec<Line> = Vec::new();
|
||||||
if let Some(diff) = &self.diff {
|
if let Some(diff) = &self.diff {
|
||||||
if diff.hunks.is_empty() {
|
if diff.hunks.is_empty() {
|
||||||
let is_positive = diff.size_delta >= 0;
|
let is_positive = diff.size_delta >= 0;
|
||||||
let delta_byte_size =
|
let delta_byte_size =
|
||||||
ByteSize::b(diff.size_delta.unsigned_abs());
|
ByteSize::b(diff.size_delta.unsigned_abs());
|
||||||
let sign = if is_positive { "+" } else { "-" };
|
let sign = if is_positive { "+" } else { "-" };
|
||||||
res.extend(vec![Spans::from(vec![
|
res.extend(vec![Line::from(vec![
|
||||||
Span::raw(Cow::from("size: ")),
|
Span::raw(Cow::from("size: ")),
|
||||||
Span::styled(
|
Span::styled(
|
||||||
Cow::from(format!(
|
Cow::from(format!(
|
||||||
|
|
@ -435,7 +435,7 @@ impl DiffComponent {
|
||||||
end_of_hunk: bool,
|
end_of_hunk: bool,
|
||||||
theme: &SharedTheme,
|
theme: &SharedTheme,
|
||||||
scrolled_right: usize,
|
scrolled_right: usize,
|
||||||
) -> Spans<'a> {
|
) -> Line<'a> {
|
||||||
let style = theme.diff_hunk_marker(selected_hunk);
|
let style = theme.diff_hunk_marker(selected_hunk);
|
||||||
|
|
||||||
let left_side_of_line = if end_of_hunk {
|
let left_side_of_line = if end_of_hunk {
|
||||||
|
|
@ -465,7 +465,7 @@ impl DiffComponent {
|
||||||
format!("{content}\n")
|
format!("{content}\n")
|
||||||
};
|
};
|
||||||
|
|
||||||
Spans::from(vec![
|
Line::from(vec![
|
||||||
left_side_of_line,
|
left_side_of_line,
|
||||||
Span::styled(
|
Span::styled(
|
||||||
Cow::from(filled),
|
Cow::from(filled),
|
||||||
|
|
@ -666,7 +666,7 @@ impl DrawableComponent for DiffComponent {
|
||||||
);
|
);
|
||||||
|
|
||||||
let txt = if self.pending {
|
let txt = if self.pending {
|
||||||
vec![Spans::from(vec![Span::styled(
|
vec![Line::from(vec![Span::styled(
|
||||||
Cow::from(strings::loading_text(&self.key_config)),
|
Cow::from(strings::loading_text(&self.key_config)),
|
||||||
self.theme.text(false, false),
|
self.theme.text(false, false),
|
||||||
)])]
|
)])]
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ use crossterm::{
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::Rect,
|
layout::Rect,
|
||||||
text::{Span, Spans},
|
text::{Line, Span},
|
||||||
widgets::{Block, BorderType, Borders, Clear, Paragraph},
|
widgets::{Block, BorderType, Borders, Clear, Paragraph},
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
|
|
@ -129,7 +129,7 @@ impl DrawableComponent for ExternalEditorComponent {
|
||||||
_rect: Rect,
|
_rect: Rect,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
if self.visible {
|
if self.visible {
|
||||||
let txt = Spans::from(
|
let txt = Line::from(
|
||||||
strings::msg_opening_editor(&self.key_config)
|
strings::msg_opening_editor(&self.key_config)
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.map(|string| {
|
.map(|string| {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ use fuzzy_matcher::FuzzyMatcher;
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::{Constraint, Direction, Layout, Margin, Rect},
|
layout::{Constraint, Direction, Layout, Margin, Rect},
|
||||||
text::{Span, Spans},
|
text::{Line, Span},
|
||||||
widgets::{Block, Borders, Clear},
|
widgets::{Block, Borders, Clear},
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
|
|
@ -243,7 +243,7 @@ impl DrawableComponent for FileFindPopup {
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
width,
|
width,
|
||||||
);
|
);
|
||||||
Spans::from(
|
Line::from(
|
||||||
full_text
|
full_text
|
||||||
.char_indices()
|
.char_indices()
|
||||||
.map(|(c_idx, c)| {
|
.map(|(c_idx, c)| {
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ use crossterm::event::Event;
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::{Constraint, Direction, Layout, Rect},
|
layout::{Constraint, Direction, Layout, Rect},
|
||||||
text::{Span, Spans, Text},
|
text::{Line, Span, Text},
|
||||||
widgets::{Block, Borders, Cell, Clear, Row, Table, TableState},
|
widgets::{Block, Borders, Cell, Clear, Row, Table, TableState},
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
|
|
@ -314,7 +314,7 @@ impl FileRevlogComponent {
|
||||||
self.items
|
self.items
|
||||||
.iter()
|
.iter()
|
||||||
.map(|entry| {
|
.map(|entry| {
|
||||||
let spans = Spans::from(vec![
|
let spans = Line::from(vec![
|
||||||
Span::styled(
|
Span::styled(
|
||||||
entry.hash_short.to_string(),
|
entry.hash_short.to_string(),
|
||||||
self.theme.commit_hash(false),
|
self.theme.commit_hash(false),
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ use ratatui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
||||||
style::{Modifier, Style},
|
style::{Modifier, Style},
|
||||||
text::{Span, Spans},
|
text::{Line, Span},
|
||||||
widgets::{Block, BorderType, Borders, Clear, Paragraph},
|
widgets::{Block, BorderType, Borders, Clear, Paragraph},
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
|
|
@ -73,7 +73,7 @@ impl DrawableComponent for HelpComponent {
|
||||||
);
|
);
|
||||||
|
|
||||||
f.render_widget(
|
f.render_widget(
|
||||||
Paragraph::new(Spans::from(vec![Span::styled(
|
Paragraph::new(Line::from(vec![Span::styled(
|
||||||
Cow::from(format!("gitui {}", Version::new(),)),
|
Cow::from(format!("gitui {}", Version::new(),)),
|
||||||
Style::default(),
|
Style::default(),
|
||||||
)]))
|
)]))
|
||||||
|
|
@ -207,15 +207,15 @@ impl HelpComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_text(&self) -> Vec<Spans> {
|
fn get_text(&self) -> Vec<Line> {
|
||||||
let mut txt: Vec<Spans> = Vec::new();
|
let mut txt: Vec<Line> = Vec::new();
|
||||||
|
|
||||||
let mut processed = 0_u16;
|
let mut processed = 0_u16;
|
||||||
|
|
||||||
for (key, group) in
|
for (key, group) in
|
||||||
&self.cmds.iter().group_by(|e| e.text.group)
|
&self.cmds.iter().group_by(|e| e.text.group)
|
||||||
{
|
{
|
||||||
txt.push(Spans::from(Span::styled(
|
txt.push(Line::from(Span::styled(
|
||||||
Cow::from(key.to_string()),
|
Cow::from(key.to_string()),
|
||||||
Style::default().add_modifier(Modifier::REVERSED),
|
Style::default().add_modifier(Modifier::REVERSED),
|
||||||
)));
|
)));
|
||||||
|
|
@ -225,7 +225,7 @@ impl HelpComponent {
|
||||||
|
|
||||||
processed += 1;
|
processed += 1;
|
||||||
|
|
||||||
txt.push(Spans::from(Span::styled(
|
txt.push(Line::from(Span::styled(
|
||||||
Cow::from(if is_selected {
|
Cow::from(if is_selected {
|
||||||
format!(">{}", command_info.text.name)
|
format!(">{}", command_info.text.name)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -235,7 +235,7 @@ impl HelpComponent {
|
||||||
)));
|
)));
|
||||||
|
|
||||||
if is_selected {
|
if is_selected {
|
||||||
txt.push(Spans::from(Span::styled(
|
txt.push(Line::from(Span::styled(
|
||||||
Cow::from(format!(
|
Cow::from(format!(
|
||||||
" {}\n",
|
" {}\n",
|
||||||
command_info.text.desc
|
command_info.text.desc
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ use ratatui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::{Alignment, Rect},
|
layout::{Alignment, Rect},
|
||||||
style::{Modifier, Style},
|
style::{Modifier, Style},
|
||||||
text::{Span, Spans},
|
text::{Line, Span},
|
||||||
widgets::{Block, Borders, Clear, Paragraph},
|
widgets::{Block, Borders, Clear, Paragraph},
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
|
|
@ -57,15 +57,15 @@ impl OptionsPopupComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_text(&self, width: u16) -> Vec<Spans> {
|
fn get_text(&self, width: u16) -> Vec<Line> {
|
||||||
let mut txt: Vec<Spans> = Vec::with_capacity(10);
|
let mut txt: Vec<Line> = Vec::with_capacity(10);
|
||||||
|
|
||||||
self.add_status(&mut txt, width);
|
self.add_status(&mut txt, width);
|
||||||
|
|
||||||
txt
|
txt
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_status(&self, txt: &mut Vec<Spans>, width: u16) {
|
fn add_status(&self, txt: &mut Vec<Line>, width: u16) {
|
||||||
Self::add_header(txt, "Status");
|
Self::add_header(txt, "Status");
|
||||||
|
|
||||||
self.add_entry(
|
self.add_entry(
|
||||||
|
|
@ -111,8 +111,8 @@ impl OptionsPopupComponent {
|
||||||
self.selection == kind
|
self.selection == kind
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_header(txt: &mut Vec<Spans>, header: &'static str) {
|
fn add_header(txt: &mut Vec<Line>, header: &'static str) {
|
||||||
txt.push(Spans::from(vec![Span::styled(
|
txt.push(Line::from(vec![Span::styled(
|
||||||
header,
|
header,
|
||||||
//TODO: use style
|
//TODO: use style
|
||||||
Style::default().add_modifier(Modifier::UNDERLINED),
|
Style::default().add_modifier(Modifier::UNDERLINED),
|
||||||
|
|
@ -121,14 +121,14 @@ impl OptionsPopupComponent {
|
||||||
|
|
||||||
fn add_entry(
|
fn add_entry(
|
||||||
&self,
|
&self,
|
||||||
txt: &mut Vec<Spans>,
|
txt: &mut Vec<Line>,
|
||||||
width: u16,
|
width: u16,
|
||||||
entry: &'static str,
|
entry: &'static str,
|
||||||
value: &str,
|
value: &str,
|
||||||
selected: bool,
|
selected: bool,
|
||||||
) {
|
) {
|
||||||
let half = usize::from(width / 2);
|
let half = usize::from(width / 2);
|
||||||
txt.push(Spans::from(vec![
|
txt.push(Line::from(vec![
|
||||||
Span::styled(
|
Span::styled(
|
||||||
string_width_align(entry, half),
|
string_width_align(entry, half),
|
||||||
self.theme.text(true, false),
|
self.theme.text(true, false),
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ use crossterm::event::Event;
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::{Alignment, Rect},
|
layout::{Alignment, Rect},
|
||||||
text::{Span, Spans},
|
text::{Line, Span},
|
||||||
widgets::{Block, Borders, Clear, Paragraph},
|
widgets::{Block, Borders, Clear, Paragraph},
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
|
|
@ -70,10 +70,10 @@ impl ResetPopupComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_text(&self, _width: u16) -> Vec<Spans> {
|
fn get_text(&self, _width: u16) -> Vec<Line> {
|
||||||
let mut txt: Vec<Spans> = Vec::with_capacity(10);
|
let mut txt: Vec<Line> = Vec::with_capacity(10);
|
||||||
|
|
||||||
txt.push(Spans::from(vec![
|
txt.push(Line::from(vec![
|
||||||
Span::styled(
|
Span::styled(
|
||||||
String::from("Branch: "),
|
String::from("Branch: "),
|
||||||
self.theme.text(true, false),
|
self.theme.text(true, false),
|
||||||
|
|
@ -84,7 +84,7 @@ impl ResetPopupComponent {
|
||||||
),
|
),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
txt.push(Spans::from(vec![
|
txt.push(Line::from(vec![
|
||||||
Span::styled(
|
Span::styled(
|
||||||
String::from("Reset to: "),
|
String::from("Reset to: "),
|
||||||
self.theme.text(true, false),
|
self.theme.text(true, false),
|
||||||
|
|
@ -99,7 +99,7 @@ impl ResetPopupComponent {
|
||||||
|
|
||||||
let (kind_name, kind_desc) = type_to_string(self.kind);
|
let (kind_name, kind_desc) = type_to_string(self.kind);
|
||||||
|
|
||||||
txt.push(Spans::from(vec![
|
txt.push(Line::from(vec![
|
||||||
Span::styled(
|
Span::styled(
|
||||||
String::from("How: "),
|
String::from("How: "),
|
||||||
self.theme.text(true, false),
|
self.theme.text(true, false),
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ use ratatui::{
|
||||||
layout::{
|
layout::{
|
||||||
Alignment, Constraint, Direction, Layout, Margin, Rect,
|
Alignment, Constraint, Direction, Layout, Margin, Rect,
|
||||||
},
|
},
|
||||||
text::{Span, Spans, Text},
|
text::{Line, Span, Text},
|
||||||
widgets::{Block, Borders, Clear, Paragraph},
|
widgets::{Block, Borders, Clear, Paragraph},
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
|
|
@ -399,7 +399,7 @@ impl SubmodulesListComponent {
|
||||||
theme.text(true, selected),
|
theme.text(true, selected),
|
||||||
);
|
);
|
||||||
|
|
||||||
txt.push(Spans::from(vec![span_name, span_hash]));
|
txt.push(Line::from(vec![span_name, span_hash]));
|
||||||
}
|
}
|
||||||
|
|
||||||
Text::from(txt)
|
Text::from(txt)
|
||||||
|
|
@ -438,17 +438,17 @@ impl SubmodulesListComponent {
|
||||||
);
|
);
|
||||||
|
|
||||||
Text::from(vec![
|
Text::from(vec![
|
||||||
Spans::from(vec![span_title_path]),
|
Line::from(vec![span_title_path]),
|
||||||
Spans::from(vec![span_path]),
|
Line::from(vec![span_path]),
|
||||||
Spans::from(vec![]),
|
Line::from(vec![]),
|
||||||
Spans::from(vec![span_title_commit]),
|
Line::from(vec![span_title_commit]),
|
||||||
Spans::from(vec![span_commit]),
|
Line::from(vec![span_commit]),
|
||||||
Spans::from(vec![]),
|
Line::from(vec![]),
|
||||||
Spans::from(vec![span_title_url]),
|
Line::from(vec![span_title_url]),
|
||||||
Spans::from(vec![span_url]),
|
Line::from(vec![span_url]),
|
||||||
Spans::from(vec![]),
|
Line::from(vec![]),
|
||||||
Spans::from(vec![span_title_status]),
|
Line::from(vec![span_title_status]),
|
||||||
Spans::from(vec![span_status]),
|
Line::from(vec![span_status]),
|
||||||
])
|
])
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
@ -456,22 +456,22 @@ impl SubmodulesListComponent {
|
||||||
|
|
||||||
fn get_local_info_text(&self, theme: &SharedTheme) -> Text {
|
fn get_local_info_text(&self, theme: &SharedTheme) -> Text {
|
||||||
let mut spans = vec![
|
let mut spans = vec![
|
||||||
Spans::from(vec![Span::styled(
|
Line::from(vec![Span::styled(
|
||||||
"Current:",
|
"Current:",
|
||||||
theme.text(false, false),
|
theme.text(false, false),
|
||||||
)]),
|
)]),
|
||||||
Spans::from(vec![Span::styled(
|
Line::from(vec![Span::styled(
|
||||||
self.repo_path.to_string(),
|
self.repo_path.to_string(),
|
||||||
theme.text(true, false),
|
theme.text(true, false),
|
||||||
)]),
|
)]),
|
||||||
Spans::from(vec![Span::styled(
|
Line::from(vec![Span::styled(
|
||||||
"Parent:",
|
"Parent:",
|
||||||
theme.text(false, false),
|
theme.text(false, false),
|
||||||
)]),
|
)]),
|
||||||
];
|
];
|
||||||
|
|
||||||
if let Some(parent_info) = &self.submodule_parent {
|
if let Some(parent_info) = &self.submodule_parent {
|
||||||
spans.push(Spans::from(vec![Span::styled(
|
spans.push(Line::from(vec![Span::styled(
|
||||||
parent_info.parent_gitpath.to_string_lossy(),
|
parent_info.parent_gitpath.to_string_lossy(),
|
||||||
theme.text(true, false),
|
theme.text(true, false),
|
||||||
)]));
|
)]));
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ use ratatui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::{Alignment, Rect},
|
layout::{Alignment, Rect},
|
||||||
style::Modifier,
|
style::Modifier,
|
||||||
text::{Spans, Text},
|
text::{Line, Text},
|
||||||
widgets::{Clear, Paragraph},
|
widgets::{Clear, Paragraph},
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
|
|
@ -237,7 +237,7 @@ impl TextInputComponent {
|
||||||
Text::styled(text_before_cursor, style),
|
Text::styled(text_before_cursor, style),
|
||||||
);
|
);
|
||||||
if ends_in_nl {
|
if ends_in_nl {
|
||||||
txt.lines.push(Spans::default());
|
txt.lines.push(Line::default());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -330,7 +330,7 @@ fn text_append<'a>(txt: Text<'a>, append: Text<'a>) -> Text<'a> {
|
||||||
let mut txt = txt;
|
let mut txt = txt;
|
||||||
if let Some(last_line) = txt.lines.last_mut() {
|
if let Some(last_line) = txt.lines.last_mut() {
|
||||||
if let Some(first_line) = append.lines.first() {
|
if let Some(first_line) = append.lines.first() {
|
||||||
last_line.0.extend(first_line.0.clone());
|
last_line.spans.extend(first_line.spans.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
if append.lines.len() > 1 {
|
if append.lines.len() > 1 {
|
||||||
|
|
@ -564,9 +564,12 @@ mod tests {
|
||||||
|
|
||||||
let txt = comp.get_draw_text();
|
let txt = comp.get_draw_text();
|
||||||
|
|
||||||
assert_eq!(txt.lines[0].0.len(), 1);
|
assert_eq!(txt.lines[0].spans.len(), 1);
|
||||||
assert_eq!(get_text(&txt.lines[0].0[0]), Some("a"));
|
assert_eq!(get_text(&txt.lines[0].spans[0]), Some("a"));
|
||||||
assert_eq!(get_style(&txt.lines[0].0[0]), Some(&underlined));
|
assert_eq!(
|
||||||
|
get_style(&txt.lines[0].spans[0]),
|
||||||
|
Some(&underlined)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -590,18 +593,18 @@ mod tests {
|
||||||
|
|
||||||
let txt = comp.get_draw_text();
|
let txt = comp.get_draw_text();
|
||||||
|
|
||||||
assert_eq!(txt.lines[0].0.len(), 2);
|
assert_eq!(txt.lines[0].spans.len(), 2);
|
||||||
assert_eq!(get_text(&txt.lines[0].0[0]), Some("a"));
|
assert_eq!(get_text(&txt.lines[0].spans[0]), Some("a"));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
get_style(&txt.lines[0].0[0]),
|
get_style(&txt.lines[0].spans[0]),
|
||||||
Some(¬_underlined)
|
Some(¬_underlined)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
get_text(&txt.lines[0].0[1]),
|
get_text(&txt.lines[0].spans[1]),
|
||||||
Some(symbol::WHITESPACE)
|
Some(symbol::WHITESPACE)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
get_style(&txt.lines[0].0[1]),
|
get_style(&txt.lines[0].spans[1]),
|
||||||
Some(&underlined_whitespace)
|
Some(&underlined_whitespace)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -627,13 +630,19 @@ mod tests {
|
||||||
let txt = comp.get_draw_text();
|
let txt = comp.get_draw_text();
|
||||||
|
|
||||||
assert_eq!(txt.lines.len(), 2);
|
assert_eq!(txt.lines.len(), 2);
|
||||||
assert_eq!(txt.lines[0].0.len(), 2);
|
assert_eq!(txt.lines[0].spans.len(), 2);
|
||||||
assert_eq!(txt.lines[1].0.len(), 2);
|
assert_eq!(txt.lines[1].spans.len(), 2);
|
||||||
assert_eq!(get_text(&txt.lines[0].0[0]), Some("a"));
|
assert_eq!(get_text(&txt.lines[0].spans[0]), Some("a"));
|
||||||
assert_eq!(get_text(&txt.lines[0].0[1]), Some("\u{21b5}"));
|
assert_eq!(
|
||||||
assert_eq!(get_style(&txt.lines[0].0[1]), Some(&underlined));
|
get_text(&txt.lines[0].spans[1]),
|
||||||
assert_eq!(get_text(&txt.lines[1].0[0]), Some(""));
|
Some("\u{21b5}")
|
||||||
assert_eq!(get_text(&txt.lines[1].0[1]), Some("b"));
|
);
|
||||||
|
assert_eq!(
|
||||||
|
get_style(&txt.lines[0].spans[1]),
|
||||||
|
Some(&underlined)
|
||||||
|
);
|
||||||
|
assert_eq!(get_text(&txt.lines[1].spans[0]), Some(""));
|
||||||
|
assert_eq!(get_text(&txt.lines[1].spans[1]), Some("b"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -656,12 +665,15 @@ mod tests {
|
||||||
let txt = comp.get_draw_text();
|
let txt = comp.get_draw_text();
|
||||||
|
|
||||||
assert_eq!(txt.lines.len(), 2);
|
assert_eq!(txt.lines.len(), 2);
|
||||||
assert_eq!(txt.lines[0].0.len(), 2);
|
assert_eq!(txt.lines[0].spans.len(), 2);
|
||||||
assert_eq!(txt.lines[1].0.len(), 1);
|
assert_eq!(txt.lines[1].spans.len(), 1);
|
||||||
assert_eq!(get_text(&txt.lines[0].0[0]), Some("a"));
|
assert_eq!(get_text(&txt.lines[0].spans[0]), Some("a"));
|
||||||
assert_eq!(get_text(&txt.lines[0].0[1]), Some(""));
|
assert_eq!(get_text(&txt.lines[0].spans[1]), Some(""));
|
||||||
assert_eq!(get_style(&txt.lines[0].0[0]), Some(&underlined));
|
assert_eq!(
|
||||||
assert_eq!(get_text(&txt.lines[1].0[0]), Some("b"));
|
get_style(&txt.lines[0].spans[0]),
|
||||||
|
Some(&underlined)
|
||||||
|
);
|
||||||
|
assert_eq!(get_text(&txt.lines[1].spans[0]), Some("b"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ use crossbeam_channel::Sender;
|
||||||
use crossterm::event::Event;
|
use crossterm::event::Event;
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
layout::{Alignment, Constraint, Direction, Layout},
|
layout::{Alignment, Constraint, Direction, Layout},
|
||||||
text::{Span, Spans},
|
text::{Line, Span},
|
||||||
widgets::{Block, Borders, Paragraph},
|
widgets::{Block, Borders, Paragraph},
|
||||||
};
|
};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
@ -105,7 +105,7 @@ impl Stashing {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_option_text(&self) -> Vec<Spans> {
|
fn get_option_text(&self) -> Vec<Line> {
|
||||||
let bracket_open = Span::raw(Cow::from("["));
|
let bracket_open = Span::raw(Cow::from("["));
|
||||||
let bracket_close = Span::raw(Cow::from("]"));
|
let bracket_close = Span::raw(Cow::from("]"));
|
||||||
let option_on =
|
let option_on =
|
||||||
|
|
@ -115,7 +115,7 @@ impl Stashing {
|
||||||
Span::styled(Cow::from("_"), self.theme.option(false));
|
Span::styled(Cow::from("_"), self.theme.option(false));
|
||||||
|
|
||||||
vec![
|
vec![
|
||||||
Spans::from(vec![
|
Line::from(vec![
|
||||||
bracket_open.clone(),
|
bracket_open.clone(),
|
||||||
if self.options.stash_untracked {
|
if self.options.stash_untracked {
|
||||||
option_on.clone()
|
option_on.clone()
|
||||||
|
|
@ -125,7 +125,7 @@ impl Stashing {
|
||||||
bracket_close.clone(),
|
bracket_close.clone(),
|
||||||
Span::raw(Cow::from(" stash untracked")),
|
Span::raw(Cow::from(" stash untracked")),
|
||||||
]),
|
]),
|
||||||
Spans::from(vec![
|
Line::from(vec![
|
||||||
bracket_open,
|
bracket_open,
|
||||||
if self.options.keep_index {
|
if self.options.keep_index {
|
||||||
option_on
|
option_on
|
||||||
|
|
|
||||||
|
|
@ -132,9 +132,8 @@ impl<'a> StatefulWidget for StatefulParagraph<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let style = self.style;
|
let style = self.style;
|
||||||
let mut styled = self.text.lines.iter().flat_map(|spans| {
|
let mut styled = self.text.lines.iter().flat_map(|line| {
|
||||||
spans
|
line.spans
|
||||||
.0
|
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|span| span.styled_graphemes(style))
|
.flat_map(|span| span.styled_graphemes(style))
|
||||||
// Required given the way composers work but might be refactored out if we change
|
// Required given the way composers work but might be refactored out if we change
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use asyncgit::{
|
||||||
ProgressPercent,
|
ProgressPercent,
|
||||||
};
|
};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use ratatui::text::{Span, Spans};
|
use ratatui::text::{Line, Span};
|
||||||
use scopetime::scope_time;
|
use scopetime::scope_time;
|
||||||
use std::{
|
use std::{
|
||||||
ffi::OsStr,
|
ffi::OsStr,
|
||||||
|
|
@ -164,21 +164,21 @@ impl SyntaxText {
|
||||||
|
|
||||||
impl<'a> From<&'a SyntaxText> for ratatui::text::Text<'a> {
|
impl<'a> From<&'a SyntaxText> for ratatui::text::Text<'a> {
|
||||||
fn from(v: &'a SyntaxText) -> Self {
|
fn from(v: &'a SyntaxText) -> Self {
|
||||||
let mut result_lines: Vec<Spans> =
|
let mut result_lines: Vec<Line> =
|
||||||
Vec::with_capacity(v.lines.len());
|
Vec::with_capacity(v.lines.len());
|
||||||
|
|
||||||
for (syntax_line, line_content) in
|
for (syntax_line, line_content) in
|
||||||
v.lines.iter().zip(v.text.lines())
|
v.lines.iter().zip(v.text.lines())
|
||||||
{
|
{
|
||||||
let mut line_span =
|
let mut line_span: Line =
|
||||||
Spans(Vec::with_capacity(syntax_line.items.len()));
|
Vec::with_capacity(syntax_line.items.len()).into();
|
||||||
|
|
||||||
for (style, _, range) in &syntax_line.items {
|
for (style, _, range) in &syntax_line.items {
|
||||||
let item_content = &line_content[range.clone()];
|
let item_content = &line_content[range.clone()];
|
||||||
let item_style = syntact_style_to_tui(style);
|
let item_style = syntact_style_to_tui(style);
|
||||||
|
|
||||||
line_span
|
line_span
|
||||||
.0
|
.spans
|
||||||
.push(Span::styled(item_content, item_style));
|
.push(Span::styled(item_content, item_style));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue