Skip to content

Commit 9316863

Browse files
authored
Bump tui: 0.9 -> 0.12 (#289)
1 parent 8b903ac commit 9316863

File tree

19 files changed

+353
-385
lines changed

19 files changed

+353
-385
lines changed

Cargo.lock

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ scopetime = { path = "./scopetime", version = "0.1" }
2323
asyncgit = { path = "./asyncgit", version = "0.10" }
2424
crossterm = { version = "0.17", features = [ "serde" ] }
2525
clap = { version = "2.33", default-features = false }
26-
tui = { version = "0.9", default-features = false, features = ['crossterm'] }
26+
tui = { version = "0.12", default-features = false, features = ['crossterm'] }
2727
bytesize = { version = "1.0.1", default-features = false}
2828
itertools = "0.9"
2929
rayon-core = "1.8"

src/app.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use std::{
2727
use tui::{
2828
backend::Backend,
2929
layout::{Constraint, Direction, Layout, Margin, Rect},
30+
text::{Span, Spans},
3031
widgets::{Block, Borders, Tabs},
3132
Frame,
3233
};
@@ -599,24 +600,27 @@ impl App {
599600
horizontal: 1,
600601
});
601602

602-
let tabs = &[
603-
strings::tab_status(&self.key_config),
604-
strings::tab_log(&self.key_config),
605-
strings::tab_stashing(&self.key_config),
606-
strings::tab_stashes(&self.key_config),
607-
];
603+
let tabs = [
604+
Span::raw(strings::tab_status(&self.key_config)),
605+
Span::raw(strings::tab_log(&self.key_config)),
606+
Span::raw(strings::tab_stashing(&self.key_config)),
607+
Span::raw(strings::tab_stashes(&self.key_config)),
608+
]
609+
.iter()
610+
.cloned()
611+
.map(Spans::from)
612+
.collect();
608613

609614
f.render_widget(
610-
Tabs::default()
615+
Tabs::new(tabs)
611616
.block(
612617
Block::default()
613618
.borders(Borders::BOTTOM)
614619
.border_style(self.theme.block(false)),
615620
)
616-
.titles(tabs)
617621
.style(self.theme.tab(false))
618622
.highlight_style(self.theme.tab(true))
619-
.divider(&strings::tab_divider(&self.key_config))
623+
.divider(strings::tab_divider(&self.key_config))
620624
.select(self.tab),
621625
r,
622626
);

src/cmdbar.rs

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ use std::borrow::Cow;
66
use tui::{
77
backend::Backend,
88
layout::{Alignment, Rect},
9-
widgets::{Paragraph, Text},
9+
text::{Span, Spans},
10+
widgets::Paragraph,
1011
Frame,
1112
};
1213
use unicode_width::UnicodeWidthStr;
@@ -142,28 +143,44 @@ impl CommandBar {
142143
if r.width < MORE_WIDTH {
143144
return;
144145
}
145-
146-
let splitter = Text::Raw(Cow::from(strings::cmd_splitter(
146+
let splitter = Span::raw(Cow::from(strings::cmd_splitter(
147147
&self.key_config,
148148
)));
149149

150150
let texts = self
151151
.draw_list
152-
.iter()
153-
.map(|c| match c {
154-
DrawListEntry::Command(c) => Text::Styled(
155-
Cow::from(c.txt.as_str()),
156-
self.theme.commandbar(c.enabled, c.line),
157-
),
158-
DrawListEntry::LineBreak => {
159-
Text::Raw(Cow::from("\n"))
160-
}
161-
DrawListEntry::Splitter => splitter.clone(),
152+
.split(|c| match c {
153+
DrawListEntry::LineBreak => true,
154+
_ => false,
162155
})
163-
.collect::<Vec<_>>();
156+
.map(|c_arr| {
157+
Spans::from(
158+
c_arr
159+
.iter()
160+
.map(|c| match c {
161+
DrawListEntry::Command(c) => {
162+
Span::styled(
163+
Cow::from(c.txt.as_str()),
164+
self.theme.commandbar(
165+
c.enabled, c.line,
166+
),
167+
)
168+
}
169+
DrawListEntry::LineBreak => {
170+
// Doesn't exist in split array
171+
Span::raw("")
172+
}
173+
DrawListEntry::Splitter => {
174+
splitter.clone()
175+
}
176+
})
177+
.collect::<Vec<Span>>(),
178+
)
179+
})
180+
.collect::<Vec<Spans>>();
164181

165182
f.render_widget(
166-
Paragraph::new(texts.iter()).alignment(Alignment::Left),
183+
Paragraph::new(texts).alignment(Alignment::Left),
167184
r,
168185
);
169186

@@ -176,14 +193,13 @@ impl CommandBar {
176193
);
177194

178195
f.render_widget(
179-
Paragraph::new(
180-
vec![Text::Raw(Cow::from(if self.expanded {
196+
Paragraph::new(Spans::from(vec![Span::raw(
197+
Cow::from(if self.expanded {
181198
"less [.]"
182199
} else {
183200
"more [.]"
184-
}))]
185-
.iter(),
186-
)
201+
}),
202+
)]))
187203
.alignment(Alignment::Right),
188204
r,
189205
);

src/components/command.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,6 @@ impl CommandInfo {
7878
res
7979
}
8080

81-
///
82-
pub fn print(&self, out: &mut String) {
83-
out.push_str(&self.text.name);
84-
}
85-
8681
///
8782
pub const fn show_in_quickbar(&self) -> bool {
8883
self.quick_bar && self.available

0 commit comments

Comments
 (0)