Giter Site home page Giter Site logo

deinstapel / cursive-aligned-view Goto Github PK

View Code? Open in Web Editor NEW
16.0 4.0 3.0 162 KB

A view wrapper for gyscos/cursive views which aligns child views πŸ–₯️

License: BSD 3-Clause "New" or "Revised" License

Shell 9.42% Rust 87.69% jq 2.89%
cursive-views cursive terminal alignment align

cursive-aligned-view's Introduction

Welcome to cursive-aligned-view πŸ‘‹

stable build nightly build crates.io Docs.rs GitHub PRs Welcome
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.

How does it look like? demo terminalizer

Expand to view aligned-view demo

Usage

Simply add to your Cargo.toml

[dependencies]
cursive-aligned-view = "^0"

Aligning a child view

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.

Supported Alignments

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

Troubleshooting

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.

Development cargo test

Running the tests

Preparing integration tests

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.

Running all test suites

Just run

$ cargo test

to execute all available tests.


Or if you want to interactively inspect failed tests

$ cargo insta test

shields.io endpoints

shields.io endpoints are generated inside the ./target/shields folder. They are used in this README.

Authors

Fin Christensen

:octocat: @fin-ger
🐘 @[email protected]
🐦 @fin_ger_github


Johannes WΓΌnsche

:octocat: @jwuensche
🐘 @[email protected]
🐦 @Fredowald

Show your support

Give a ⭐ if this project helped you!

cursive-aligned-view's People

Contributors

colonelthirtytwo avatar fin-ger avatar gyscos avatar jwuensche avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cursive-aligned-view's Issues

The view takes more space than it needs to

I'm working on a project where I found this crate to be useful, but the first time I tried using it I found that it worked in terms of aligning the views, but at the same time it took literally all of the space that was available instead of just what it needs to take.
Here's how it looked the first time around:
bad_layout
And here's how it was supposed to look:
good_layout

As you can see, I did make it do what I wanted it to do. I did it by changing your required_size() function so it returns 'self.last_size' instead of 'constraint'. Doing that fixes the issue for me completely, so I've decided to leave that info here in case you find it useful (not making a pull request since I'm not sure whether that's a good fix in general or just in my case).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.