mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 08:58:21 +00:00
tui upgrade
This commit is contained in:
parent
eb7fc99f67
commit
e50f15f72b
11 changed files with 119 additions and 132 deletions
53
Cargo.lock
generated
53
Cargo.lock
generated
|
|
@ -188,12 +188,12 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "crossterm"
|
||||
version = "0.14.2"
|
||||
version = "0.17.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5750773d74a7dc612eac2ded3f55e9cdeeaa072210cd17c0192aedb48adb3618"
|
||||
checksum = "ccdd8ef63a44e821956c6a276eca0faaa889d6a067dfcdbd5bfe85dce3a1d250"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"crossterm_winapi 0.5.1",
|
||||
"crossterm_winapi",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"mio",
|
||||
|
|
@ -202,31 +202,6 @@ dependencies = [
|
|||
"winapi 0.3.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossterm"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8a3223215bc00c666d6be730e88aef245ad4a4f837e87a16c347e8acf701643"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"crossterm_winapi 0.6.1",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"mio",
|
||||
"parking_lot",
|
||||
"signal-hook",
|
||||
"winapi 0.3.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossterm_winapi"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8777c700901e2d5b50c406f736ed6b8f9e43645c7e104ddb74f8bc42b8ae62f6"
|
||||
dependencies = [
|
||||
"winapi 0.3.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossterm_winapi"
|
||||
version = "0.6.1"
|
||||
|
|
@ -314,9 +289,9 @@ dependencies = [
|
|||
"backtrace",
|
||||
"bitflags",
|
||||
"crossbeam-channel",
|
||||
"crossterm 0.16.0",
|
||||
"crossterm",
|
||||
"dirs",
|
||||
"itertools 0.9.0",
|
||||
"itertools",
|
||||
"log",
|
||||
"rayon-core",
|
||||
"scopeguard",
|
||||
|
|
@ -363,15 +338,6 @@ dependencies = [
|
|||
"winapi 0.3.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.9.0"
|
||||
|
|
@ -804,16 +770,15 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tui"
|
||||
version = "0.8.0"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6b871b61f4c4b81e630215cd12e0ec29953d4545898e21a9e023b7520a74a9f9"
|
||||
checksum = "0a77b392f2666ec0335d2bb38dd80af792d64c2b2aa3c471db9e89335419d2fa"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cassowary",
|
||||
"crossterm 0.14.2",
|
||||
"crossterm",
|
||||
"either",
|
||||
"itertools 0.8.2",
|
||||
"log",
|
||||
"itertools",
|
||||
"unicode-segmentation",
|
||||
"unicode-width",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ keywords = [
|
|||
]
|
||||
|
||||
[dependencies]
|
||||
crossterm = "0.16"
|
||||
tui = { version = "0.8", default-features=false, features = ['crossterm'] }
|
||||
crossterm = "0.17"
|
||||
tui = { version = "0.9", default-features=false, features = ['crossterm'] }
|
||||
itertools = "0.9"
|
||||
rayon-core = "1.7"
|
||||
log = "0.4"
|
||||
|
|
|
|||
29
src/app.rs
29
src/app.rs
|
|
@ -22,7 +22,7 @@ use tui::{
|
|||
backend::Backend,
|
||||
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
||||
style::{Color, Style},
|
||||
widgets::{Block, Borders, Paragraph, Tabs, Text, Widget},
|
||||
widgets::{Block, Borders, Paragraph, Tabs, Text},
|
||||
Frame,
|
||||
};
|
||||
|
||||
|
|
@ -106,13 +106,15 @@ impl App {
|
|||
)
|
||||
.split(f.size());
|
||||
|
||||
Tabs::default()
|
||||
.block(Block::default().borders(Borders::BOTTOM))
|
||||
.titles(&[strings::TAB_STATUS])
|
||||
.style(Style::default().fg(Color::White))
|
||||
.highlight_style(Style::default().fg(Color::Yellow))
|
||||
.divider(strings::TAB_DIVIDER)
|
||||
.render(f, chunks_main[0]);
|
||||
f.render_widget(
|
||||
Tabs::default()
|
||||
.block(Block::default().borders(Borders::BOTTOM))
|
||||
.titles(&[strings::TAB_STATUS])
|
||||
.style(Style::default().fg(Color::White))
|
||||
.highlight_style(Style::default().fg(Color::Yellow))
|
||||
.divider(strings::TAB_DIVIDER),
|
||||
chunks_main[0],
|
||||
);
|
||||
|
||||
let chunks = Layout::default()
|
||||
.direction(Direction::Horizontal)
|
||||
|
|
@ -483,9 +485,14 @@ impl App {
|
|||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
Paragraph::new(texts.iter().intersperse(&splitter))
|
||||
.alignment(Alignment::Left)
|
||||
.render(f, r);
|
||||
// let paragraph =
|
||||
// Paragraph::new(texts.iter().intersperse(&splitter))
|
||||
// .alignment(Alignment::Left);
|
||||
f.render_widget(
|
||||
Paragraph::new(texts.iter().intersperse(&splitter))
|
||||
.alignment(Alignment::Left),
|
||||
r,
|
||||
);
|
||||
}
|
||||
|
||||
fn switch_focus(&mut self, f: Focus) -> NeedsUpdate {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use tui::{
|
|||
backend::Backend,
|
||||
layout::{Alignment, Rect},
|
||||
style::{Color, Style},
|
||||
widgets::{Block, Borders, Paragraph, Text, Widget},
|
||||
widgets::{Block, Borders, Paragraph, Text},
|
||||
Frame,
|
||||
};
|
||||
|
||||
|
|
@ -40,16 +40,18 @@ impl DrawableComponent for CommitComponent {
|
|||
[Text::Raw(Cow::from(self.msg.clone()))]
|
||||
};
|
||||
|
||||
ui::Clear::new(
|
||||
Paragraph::new(txt.iter())
|
||||
.block(
|
||||
Block::default()
|
||||
.title(strings::COMMIT_TITLE)
|
||||
.borders(Borders::ALL),
|
||||
)
|
||||
.alignment(Alignment::Left),
|
||||
)
|
||||
.render(f, ui::centered_rect(60, 20, f.size()));
|
||||
f.render_widget(
|
||||
ui::Clear::new(
|
||||
Paragraph::new(txt.iter())
|
||||
.block(
|
||||
Block::default()
|
||||
.title(strings::COMMIT_TITLE)
|
||||
.borders(Borders::ALL),
|
||||
)
|
||||
.alignment(Alignment::Left),
|
||||
),
|
||||
ui::centered_rect(60, 20, f.size()),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use tui::{
|
|||
layout::{Alignment, Rect},
|
||||
style::{Color, Modifier, Style},
|
||||
symbols,
|
||||
widgets::{Block, Borders, Paragraph, Text, Widget},
|
||||
widgets::{Block, Borders, Paragraph, Text},
|
||||
Frame,
|
||||
};
|
||||
|
||||
|
|
@ -297,16 +297,18 @@ impl DrawableComponent for DiffComponent {
|
|||
style_title = style_title.modifier(Modifier::BOLD);
|
||||
}
|
||||
|
||||
Paragraph::new(self.get_text(r.width, r.height).iter())
|
||||
.block(
|
||||
Block::default()
|
||||
.title(strings::TITLE_DIFF)
|
||||
.borders(Borders::ALL)
|
||||
.border_style(style_border)
|
||||
.title_style(style_title),
|
||||
)
|
||||
.alignment(Alignment::Left)
|
||||
.render(f, r);
|
||||
f.render_widget(
|
||||
Paragraph::new(self.get_text(r.width, r.height).iter())
|
||||
.block(
|
||||
Block::default()
|
||||
.title(strings::TITLE_DIFF)
|
||||
.borders(Borders::ALL)
|
||||
.border_style(style_border)
|
||||
.title_style(style_title),
|
||||
)
|
||||
.alignment(Alignment::Left),
|
||||
r,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use tui::{
|
|||
backend::Backend,
|
||||
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
||||
style::{Color, Style},
|
||||
widgets::{Block, Borders, Paragraph, Text, Widget},
|
||||
widgets::{Block, Borders, Paragraph, Text},
|
||||
Frame,
|
||||
};
|
||||
|
||||
|
|
@ -41,12 +41,14 @@ impl DrawableComponent for HelpComponent {
|
|||
let area =
|
||||
ui::centered_rect_absolute(65, height, f.size());
|
||||
|
||||
ui::Clear::new(
|
||||
Block::default()
|
||||
.title(strings::HELP_TITLE)
|
||||
.borders(Borders::ALL),
|
||||
)
|
||||
.render(f, area);
|
||||
f.render_widget(
|
||||
ui::Clear::new(
|
||||
Block::default()
|
||||
.title(strings::HELP_TITLE)
|
||||
.borders(Borders::ALL),
|
||||
),
|
||||
area,
|
||||
);
|
||||
|
||||
let chunks = Layout::default()
|
||||
.vertical_margin(1)
|
||||
|
|
@ -58,20 +60,24 @@ impl DrawableComponent for HelpComponent {
|
|||
)
|
||||
.split(area);
|
||||
|
||||
Paragraph::new(txt.iter())
|
||||
.scroll(scroll)
|
||||
.alignment(Alignment::Left)
|
||||
.render(f, chunks[0]);
|
||||
f.render_widget(
|
||||
Paragraph::new(txt.iter())
|
||||
.scroll(scroll)
|
||||
.alignment(Alignment::Left),
|
||||
chunks[0],
|
||||
);
|
||||
|
||||
Paragraph::new(
|
||||
vec![Text::Raw(Cow::from(format!(
|
||||
"gitui {}",
|
||||
Version::new(),
|
||||
)))]
|
||||
.iter(),
|
||||
)
|
||||
.alignment(Alignment::Right)
|
||||
.render(f, chunks[1]);
|
||||
f.render_widget(
|
||||
Paragraph::new(
|
||||
vec![Text::Raw(Cow::from(format!(
|
||||
"gitui {}",
|
||||
Version::new(),
|
||||
)))]
|
||||
.iter(),
|
||||
)
|
||||
.alignment(Alignment::Right),
|
||||
chunks[1],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use strings::commands;
|
|||
use tui::{
|
||||
backend::Backend,
|
||||
layout::{Alignment, Rect},
|
||||
widgets::{Block, Borders, Paragraph, Text, Widget},
|
||||
widgets::{Block, Borders, Paragraph, Text},
|
||||
Frame,
|
||||
};
|
||||
|
||||
|
|
@ -24,17 +24,19 @@ impl DrawableComponent for MsgComponent {
|
|||
if self.visible {
|
||||
let txt = vec![Text::Raw(Cow::from(self.msg.as_str()))];
|
||||
|
||||
ui::Clear::new(
|
||||
Paragraph::new(txt.iter())
|
||||
.block(
|
||||
Block::default()
|
||||
.title(strings::MSG_TITLE)
|
||||
.borders(Borders::ALL),
|
||||
)
|
||||
.wrap(true)
|
||||
.alignment(Alignment::Left),
|
||||
)
|
||||
.render(f, ui::centered_rect_absolute(65, 25, f.size()));
|
||||
f.render_widget(
|
||||
ui::Clear::new(
|
||||
Paragraph::new(txt.iter())
|
||||
.block(
|
||||
Block::default()
|
||||
.title(strings::MSG_TITLE)
|
||||
.borders(Borders::ALL),
|
||||
)
|
||||
.wrap(true)
|
||||
.alignment(Alignment::Left),
|
||||
),
|
||||
ui::centered_rect_absolute(65, 25, f.size()),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use tui::{
|
|||
backend::Backend,
|
||||
layout::{Alignment, Rect},
|
||||
style::{Color, Style},
|
||||
widgets::{Block, Borders, Paragraph, Text, Widget},
|
||||
widgets::{Block, Borders, Paragraph, Text},
|
||||
Frame,
|
||||
};
|
||||
|
||||
|
|
@ -34,16 +34,18 @@ impl DrawableComponent for ResetComponent {
|
|||
Style::default().fg(Color::Red),
|
||||
));
|
||||
|
||||
ui::Clear::new(
|
||||
Paragraph::new(txt.iter())
|
||||
.block(
|
||||
Block::default()
|
||||
.title(strings::RESET_TITLE)
|
||||
.borders(Borders::ALL),
|
||||
)
|
||||
.alignment(Alignment::Left),
|
||||
)
|
||||
.render(f, ui::centered_rect(30, 20, f.size()));
|
||||
f.render_widget(
|
||||
ui::Clear::new(
|
||||
Paragraph::new(txt.iter())
|
||||
.block(
|
||||
Block::default()
|
||||
.title(strings::RESET_TITLE)
|
||||
.borders(Borders::ALL),
|
||||
)
|
||||
.alignment(Alignment::Left),
|
||||
),
|
||||
ui::centered_rect(30, 20, f.size()),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ impl<T: Widget> Clear<T> {
|
|||
}
|
||||
|
||||
impl<T: Widget> Widget for Clear<T> {
|
||||
fn draw(&mut self, area: Rect, buf: &mut Buffer) {
|
||||
fn render(self, area: Rect, buf: &mut Buffer) {
|
||||
if area.width < 2 || area.height < 2 {
|
||||
return;
|
||||
}
|
||||
|
|
@ -20,6 +20,6 @@ impl<T: Widget> Widget for Clear<T> {
|
|||
}
|
||||
}
|
||||
|
||||
self.0.draw(area, buf);
|
||||
self.0.render(area, buf);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use tui::{
|
|||
backend::Backend,
|
||||
layout::{Constraint, Direction, Layout, Rect},
|
||||
style::{Color, Modifier, Style},
|
||||
widgets::{Block, Borders, Text, Widget},
|
||||
widgets::{Block, Borders, Text},
|
||||
Frame,
|
||||
};
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ pub fn draw_list<'b, B: Backend, L>(
|
|||
style_border = style_border.fg(Color::Gray);
|
||||
style_title = style_title.modifier(Modifier::BOLD);
|
||||
}
|
||||
ScrollableList::new(items)
|
||||
let list = ScrollableList::new(items)
|
||||
.block(
|
||||
Block::default()
|
||||
.title(title)
|
||||
|
|
@ -81,6 +81,7 @@ pub fn draw_list<'b, B: Backend, L>(
|
|||
.border_style(style_border),
|
||||
)
|
||||
.scroll(select.unwrap_or_default())
|
||||
.style(Style::default().fg(Color::White))
|
||||
.render(f, r);
|
||||
.style(Style::default().fg(Color::White));
|
||||
// .render(f, r);
|
||||
f.render_widget(list, r)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,9 +53,9 @@ impl<'b, L> Widget for ScrollableList<'b, L>
|
|||
where
|
||||
L: Iterator<Item = Text<'b>>,
|
||||
{
|
||||
fn draw(&mut self, area: Rect, buf: &mut Buffer) {
|
||||
fn render(self, area: Rect, buf: &mut Buffer) {
|
||||
let list_area = match self.block {
|
||||
Some(ref mut b) => b.inner(area),
|
||||
Some(b) => b.inner(area),
|
||||
None => area,
|
||||
};
|
||||
|
||||
|
|
@ -68,9 +68,9 @@ where
|
|||
};
|
||||
|
||||
// Render items
|
||||
List::new(self.items.by_ref().skip(offset as usize))
|
||||
List::new(self.items.skip(offset as usize))
|
||||
.block(self.block.unwrap_or_default())
|
||||
.style(self.style)
|
||||
.draw(area, buf);
|
||||
.render(area, buf);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue