-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Philipp Reiter
committed
Sep 7, 2024
1 parent
73303e5
commit d1a1d69
Showing
11 changed files
with
381 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use ratatui::{ | ||
buffer::Buffer, | ||
layout::Rect, | ||
style::{Color, Style, Styled}, | ||
text::Line, | ||
widgets::{Padding, Widget}, | ||
}; | ||
#[allow(dead_code)] | ||
pub type PaddedLine<'a> = ListItemContainer<'a, Line<'a>>; | ||
|
||
pub struct ListItemContainer<'a, W> { | ||
child: W, | ||
block: ratatui::widgets::Block<'a>, | ||
style: Style, | ||
} | ||
|
||
impl<'a, W> ListItemContainer<'a, W> { | ||
pub fn new(child: W, padding: Padding) -> Self { | ||
let block = ratatui::widgets::Block::default().padding(padding); | ||
let style = Style::default().fg(Color::White); | ||
Self { | ||
child, | ||
block, | ||
style, | ||
} | ||
} | ||
} | ||
|
||
impl<T> Styled for ListItemContainer<'_, T> { | ||
type Item = Self; | ||
|
||
fn style(&self) -> Style { | ||
self.style | ||
} | ||
|
||
fn set_style<S: Into<Style>>(mut self, style: S) -> Self::Item { | ||
self.style = style.into(); | ||
self | ||
} | ||
} | ||
|
||
impl<W: Widget> Widget for ListItemContainer<'_, W> { | ||
fn render(self, area: Rect, buf: &mut Buffer) { | ||
let inner_area = self.block.inner(area); | ||
buf.set_style(area, self.style); | ||
self.block.render(area, buf); | ||
self.child.render(inner_area, buf); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# To run this script, install vhs and run `vhs ./examples/tapes/variants.tape` | ||
Output "examples/tapes/variants.gif" | ||
Set Margin 10 | ||
Set Padding 2 | ||
Set BorderRadius 10 | ||
Set Width 2000 | ||
Set Height 1100 | ||
Set PlaybackSpeed 1.0 | ||
|
||
Hide | ||
Type "cargo run --example variants" | ||
Enter | ||
Sleep 0.5s | ||
Show | ||
|
||
Sleep 1.5s | ||
Right@0.5s 1 | ||
Down@0.5s 15 | ||
|
||
Left@0.5s 1 | ||
Down@0.5s 1 | ||
|
||
Right@0.5s 1 | ||
Down@0.5s 20 | ||
|
||
Left@0.5s 1 | ||
Down@0.5s 1 | ||
|
||
Right@0.5s 1 | ||
Down@0.5s 10 | ||
|
||
Sleep 1.5s |
Oops, something went wrong.