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