Compare commits
1 commit
d989da659c
...
51fb08a9dc
Author | SHA1 | Date | |
---|---|---|---|
|
51fb08a9dc |
4 changed files with 38 additions and 50 deletions
36
Cargo.lock
generated
36
Cargo.lock
generated
|
@ -1118,7 +1118,7 @@ dependencies = [
|
||||||
"notify",
|
"notify",
|
||||||
"pretty_assertions",
|
"pretty_assertions",
|
||||||
"rand",
|
"rand",
|
||||||
"ratatui 0.29.0",
|
"ratatui",
|
||||||
"regex",
|
"regex",
|
||||||
"rstest 0.23.0",
|
"rstest 0.23.0",
|
||||||
"secrecy 0.10.3",
|
"secrecy 0.10.3",
|
||||||
|
@ -3352,6 +3352,7 @@ dependencies = [
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.6.0",
|
||||||
"cassowary",
|
"cassowary",
|
||||||
"compact_str",
|
"compact_str",
|
||||||
|
"crossterm",
|
||||||
"instability",
|
"instability",
|
||||||
"itertools",
|
"itertools",
|
||||||
"lru",
|
"lru",
|
||||||
|
@ -3360,28 +3361,7 @@ dependencies = [
|
||||||
"strum_macros 0.26.4",
|
"strum_macros 0.26.4",
|
||||||
"unicode-segmentation",
|
"unicode-segmentation",
|
||||||
"unicode-truncate",
|
"unicode-truncate",
|
||||||
"unicode-width 0.1.13",
|
"unicode-width",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ratatui"
|
|
||||||
version = "0.29.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 2.6.0",
|
|
||||||
"cassowary",
|
|
||||||
"compact_str",
|
|
||||||
"crossterm",
|
|
||||||
"indoc",
|
|
||||||
"instability",
|
|
||||||
"itertools",
|
|
||||||
"lru",
|
|
||||||
"paste",
|
|
||||||
"strum 0.26.3",
|
|
||||||
"unicode-segmentation",
|
|
||||||
"unicode-truncate",
|
|
||||||
"unicode-width 0.2.0",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -4421,7 +4401,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "27a65189ac0c5f8af32660c453a1babae3ac7e72791b9dbeb1221073569f44ea"
|
checksum = "27a65189ac0c5f8af32660c453a1babae3ac7e72791b9dbeb1221073569f44ea"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indoc",
|
"indoc",
|
||||||
"ratatui 0.28.1",
|
"ratatui",
|
||||||
"rstest 0.22.0",
|
"rstest 0.22.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -4520,7 +4500,7 @@ checksum = "b3644627a5af5fa321c95b9b235a72fd24cd29c648c2c379431e6628655627bf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itertools",
|
"itertools",
|
||||||
"unicode-segmentation",
|
"unicode-segmentation",
|
||||||
"unicode-width 0.1.13",
|
"unicode-width",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -4529,12 +4509,6 @@ version = "0.1.13"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d"
|
checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode-width"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-xid"
|
name = "unicode-xid"
|
||||||
version = "0.2.5"
|
version = "0.2.5"
|
||||||
|
|
|
@ -5,7 +5,10 @@ use ratatui::{
|
||||||
style::{Color, Style, Stylize as _},
|
style::{Color, Style, Stylize as _},
|
||||||
symbols::border,
|
symbols::border,
|
||||||
text::{Line, Span},
|
text::{Line, Span},
|
||||||
widgets::{Block, Paragraph, StatefulWidget, Widget},
|
widgets::{
|
||||||
|
block::{Position, Title},
|
||||||
|
Block, Paragraph, StatefulWidget, Widget,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use git_next_core::{
|
use git_next_core::{
|
||||||
|
@ -360,19 +363,24 @@ impl StatefulWidget for &State {
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
{
|
{
|
||||||
let block = Block::bordered()
|
let block = Block::bordered()
|
||||||
.title_top(
|
.title(
|
||||||
Line::from(format!(" Git-Next v{} ", clap::crate_version!()).bold())
|
Title::from(format!(" Git-Next v{} ", clap::crate_version!()).bold())
|
||||||
.alignment(Alignment::Center),
|
.alignment(Alignment::Center),
|
||||||
)
|
)
|
||||||
.title_bottom(
|
.title(
|
||||||
Line::from(vec![
|
Title::from(Line::from(vec![
|
||||||
" [q]uit ".into(),
|
" [q]uit ".into(),
|
||||||
self.beating_heart().into(),
|
self.beating_heart().into(),
|
||||||
" ".into(),
|
" ".into(),
|
||||||
])
|
]))
|
||||||
.alignment(Alignment::Center),
|
.alignment(Alignment::Center)
|
||||||
|
.position(Position::Bottom),
|
||||||
|
)
|
||||||
|
.title(
|
||||||
|
Title::from(format!(" {} ", time()))
|
||||||
|
.alignment(Alignment::Right)
|
||||||
|
.position(Position::Bottom),
|
||||||
)
|
)
|
||||||
.title_bottom(Line::from(format!(" {} ", time())).alignment(Alignment::Right))
|
|
||||||
.border_set(border::THICK);
|
.border_set(border::THICK);
|
||||||
let interior = block.inner(area);
|
let interior = block.inner(area);
|
||||||
block.render(area, buf);
|
block.render(area, buf);
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
//
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use git_next_core::ForgeAlias;
|
use git_next_core::ForgeAlias;
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
layout::{Direction, Layout, Rect},
|
layout::{Direction, Layout, Rect, Size},
|
||||||
widgets::{StatefulWidget, Widget},
|
widgets::StatefulWidget,
|
||||||
};
|
};
|
||||||
use tui_scrollview::ScrollViewState;
|
use tui_scrollview::{ScrollView, ScrollViewState};
|
||||||
|
|
||||||
use crate::tui::actor::ForgeState;
|
use crate::tui::actor::ForgeState;
|
||||||
|
|
||||||
|
@ -28,10 +27,16 @@ impl<'a> HeightContraintLength for ConfiguredAppWidget<'a> {
|
||||||
impl<'a> StatefulWidget for ConfiguredAppWidget<'a> {
|
impl<'a> StatefulWidget for ConfiguredAppWidget<'a> {
|
||||||
type State = ScrollViewState;
|
type State = ScrollViewState;
|
||||||
|
|
||||||
fn render(self, area: Rect, buf: &mut Buffer, _state: &mut Self::State)
|
fn render(self, area: Rect, buf: &mut Buffer, state: &mut Self::State)
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
{
|
{
|
||||||
|
let height = self
|
||||||
|
.children()
|
||||||
|
.iter()
|
||||||
|
.map(HeightContraintLength::height_constraint_length)
|
||||||
|
.sum::<u16>();
|
||||||
|
let mut scroll = ScrollView::new(Size::new(area.width - 1, height));
|
||||||
let layout_forge_list = Layout::default()
|
let layout_forge_list = Layout::default()
|
||||||
.direction(Direction::Vertical)
|
.direction(Direction::Vertical)
|
||||||
.constraints(
|
.constraints(
|
||||||
|
@ -39,12 +44,14 @@ impl<'a> StatefulWidget for ConfiguredAppWidget<'a> {
|
||||||
.iter()
|
.iter()
|
||||||
.map(HeightContraintLength::height_constraint_length),
|
.map(HeightContraintLength::height_constraint_length),
|
||||||
)
|
)
|
||||||
.split(area);
|
.split(scroll.area());
|
||||||
|
|
||||||
self.children()
|
self.children()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.for_each(|(i, w)| w.render(layout_forge_list[i], buf));
|
.for_each(|(i, w)| scroll.render_widget(w, layout_forge_list[i]));
|
||||||
|
|
||||||
|
scroll.render(area, buf, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<'a> ConfiguredAppWidget<'a> {
|
impl<'a> ConfiguredAppWidget<'a> {
|
||||||
|
|
|
@ -5,8 +5,7 @@ use git_next_core::{ForgeAlias, RepoAlias};
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
layout::{Alignment, Direction, Layout, Rect},
|
layout::{Alignment, Direction, Layout, Rect},
|
||||||
text::Line,
|
widgets::{block::Title, Block, Widget},
|
||||||
widgets::{Block, Widget},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::tui::{
|
use crate::tui::{
|
||||||
|
@ -32,8 +31,8 @@ impl<'a> Widget for ExpandedForgeWidget<'a> {
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
{
|
{
|
||||||
let block = Block::default().title_top(
|
let block = Block::default().title(
|
||||||
Line::from(format!(" forge: {} ", self.forge_alias)).alignment(Alignment::Left),
|
Title::from(format!(" forge: {} ", self.forge_alias)).alignment(Alignment::Left),
|
||||||
);
|
);
|
||||||
let children = self.children();
|
let children = self.children();
|
||||||
let layout = Layout::default()
|
let layout = Layout::default()
|
||||||
|
|
Loading…
Reference in a new issue