Crates.io | cursive-aligned-view |
lib.rs | cursive-aligned-view |
version | 0.7.0 |
source | src |
created_at | 2019-09-03 19:25:03.990273 |
updated_at | 2024-08-12 17:55:36.821181 |
description | A view wrapper for gyscos/cursive views which aligns child views |
homepage | |
repository | https://github.com/deinstapel/cursive-aligned-view |
max_upload_size | |
id | 161882 |
size | 165,019 |
A view wrapper for
gyscos/cursive
views which aligns child views
This project provides an AlignedView
for gyscos/cursive views which makes it possible to align the child view (center, left, right, top, bottom). The AlignedView
uses the required_size
reported by the child view and fills the rest of the available space with the views background color.
demo
Simply add to your Cargo.toml
[dependencies]
cursive-aligned-view = "^0"
The easiest way to align a view is via the Alignable
trait:
use cursive_aligned_view::Alignable;
let aligned = child_view.align_center();
This is the preferred way as it is chainable and consistent with cursive's Boxable
and Identifiable
traits.
As an alternative you can use the AlignedView
constructors directly:
use cursive_aligned_view::AlignedView;
let aligned = AlignedView::with_center(child_view);
Look into the documentation for a detailed explanation on the API.
Alignment | Construction method |
---|---|
top left | align_top_left |
top center | align_top_center |
top right | align_top_right |
center left | align_center_left |
center | align_center |
center right | align_center_right |
bottom left | align_bottom_left |
bottom center | align_bottom_center |
bottom right | align_bottom_right |
If you find any bugs/unexpected behaviour or you have a proposition for future changes open an issue describing the current behaviour and what you expected.
To perform the test it's advisable to install cargo-insta
in case your tests fail and you want to inspect the received output.
$ cargo install cargo-insta
You will also need insta to validate new tests you add or update older ones.
Just run
$ cargo test
to execute all available tests.
Or if you want to interactively inspect failed tests
$ cargo insta test
shields.io endpoints are generated inside the ./target/shields
folder. They are used in this README.
Fin Christensen
:octocat:
@fin-ger
:elephant:@fin_ger@weirder.earth
:bird:@fin_ger_github
Johannes Wünsche
:octocat:
@jwuensche
:elephant:@fredowald@mastodon.social
:bird:@Fredowald
Give a :star: if this project helped you!