Skip to content

Commit

Permalink
upgrade ratatui
Browse files Browse the repository at this point in the history
  • Loading branch information
extrawurst committed Jun 19, 2023
1 parent 195a6f2 commit 4f3be69
Show file tree
Hide file tree
Showing 21 changed files with 134 additions and 123 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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)
Expand All @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions src/cmdbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
use ratatui::{
backend::Backend,
layout::{Alignment, Rect},
text::{Span, Spans},
text::{Line, Span},
widgets::Paragraph,
Frame,
};
Expand Down Expand Up @@ -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 {
Expand All @@ -174,7 +174,7 @@ impl CommandBar {
.collect::<Vec<Span>>(),
)
})
.collect::<Vec<Spans>>();
.collect::<Vec<Line>>();

f.render_widget(
Paragraph::new(texts).alignment(Alignment::Left),
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/components/branch_find_popup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -233,7 +233,7 @@ impl DrawableComponent for BranchFindPopup {
&self.branches[*idx],
width,
);
Spans::from(
Line::from(
full_text
.char_indices()
.map(|(c_idx, c)| {
Expand Down
6 changes: 3 additions & 3 deletions src/components/branchlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
10 changes: 5 additions & 5 deletions src/components/commit_details/compare_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down Expand Up @@ -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!(
Expand All @@ -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(
Expand All @@ -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(
Expand Down
22 changes: 11 additions & 11 deletions src/components/commit_details/details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand All @@ -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()),
)])
Expand All @@ -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!(
Expand All @@ -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(
Expand All @@ -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!(
Expand All @@ -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(
Expand All @@ -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),
Expand All @@ -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(
Expand Down
10 changes: 5 additions & 5 deletions src/components/commitlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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 },
);
Expand Down Expand Up @@ -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();

Expand Down
14 changes: 7 additions & 7 deletions src/components/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use ratatui::{
backend::Backend,
layout::Rect,
symbols,
text::{Span, Spans},
text::{Line, Span},
widgets::{Block, Borders, Paragraph},
Frame,
};
Expand Down Expand Up @@ -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!(
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -465,7 +465,7 @@ impl DiffComponent {
format!("{content}\n")
};

Spans::from(vec![
Line::from(vec![
left_side_of_line,
Span::styled(
Cow::from(filled),
Expand Down Expand Up @@ -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),
)])]
Expand Down
4 changes: 2 additions & 2 deletions src/components/externaleditor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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| {
Expand Down
4 changes: 2 additions & 2 deletions src/components/file_find_popup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -243,7 +243,7 @@ impl DrawableComponent for FileFindPopup {
.unwrap_or_default(),
width,
);
Spans::from(
Line::from(
full_text
.char_indices()
.map(|(c_idx, c)| {
Expand Down
Loading

0 comments on commit 4f3be69

Please sign in to comment.