All Projects → deinstapel → cursive-tabs

deinstapel / cursive-tabs

Licence: BSD-3-Clause license
Tabs for gyscos/cursive views 🖥️

Programming Languages

rust
11053 projects
shell
77523 projects
jq
24 projects

Projects that are alternatives of or similar to cursive-tabs

chords
A Kotlin multi-platform view library for displaying stringed instrument chord diagrams
Stars: ✭ 25 (+19.05%)
Mutual labels:  view, tabs
wiki-tui
A simple and easy to use Wikipedia Text User Interface
Stars: ✭ 74 (+252.38%)
Mutual labels:  tui, cursive
IndicatorView
IndicatorView Library For Android
Stars: ✭ 41 (+95.24%)
Mutual labels:  view, tabs
guitar
🎸 Online guitar toy and tablature recorder/player
Stars: ✭ 80 (+280.95%)
Mutual labels:  tabs
mdebug
基于React开发的新一代web调试工具,支持React组件调试,类似于Chrome Devtools。A Lightweight, Easy To Extend Web Debugging Tool Build With React
Stars: ✭ 237 (+1028.57%)
Mutual labels:  tabs
octotui
🐙🐱🖥️ GitHub stats in your terminal
Stars: ✭ 202 (+861.9%)
Mutual labels:  tui
ShadowDrawable
为View 和 ViewGroup 添加阴影效果--Android,Add shadow for single view or viewgroup layout.
Stars: ✭ 22 (+4.76%)
Mutual labels:  view
blade
🏃 A library for using Laravel Blade templates in WordPlate.
Stars: ✭ 28 (+33.33%)
Mutual labels:  view
SlipperyLayout
A layout that supports sliding.
Stars: ✭ 44 (+109.52%)
Mutual labels:  view
view-admin-as
View the WordPress admin as a different role, switch between users, temporarily change your capabilities, set default screen settings for roles, manage your roles and capabilities.
Stars: ✭ 44 (+109.52%)
Mutual labels:  view
anchored-behavior
A CoordinatorLayout Behavior to anchor views with an animation.
Stars: ✭ 17 (-19.05%)
Mutual labels:  view
onionjuggler
Manage your Onion Services via CLI or TUI on Unix-like operating system with a POSIX compliant shell.
Stars: ✭ 31 (+47.62%)
Mutual labels:  tui
titik
A cross platform minimalistic text user interface
Stars: ✭ 112 (+433.33%)
Mutual labels:  tui
inquire
A Rust library for building interactive prompts
Stars: ✭ 419 (+1895.24%)
Mutual labels:  tui
react-headless-tabs
Headless and highly flexible tab-like primitives built with react hooks
Stars: ✭ 107 (+409.52%)
Mutual labels:  tabs
RDGliderViewController
Control for a floating view gliding over a ViewController
Stars: ✭ 31 (+47.62%)
Mutual labels:  view
smart-webcomponents-community
Material & Bootstrap Web Components built with Smart
Stars: ✭ 30 (+42.86%)
Mutual labels:  tabs
react-responsive-tabs
React responsive tabs http://maslianok.github.io/react-responsive-tabs/
Stars: ✭ 118 (+461.9%)
Mutual labels:  tabs
vue-magic-line
A flexible tabs-component for Vue
Stars: ✭ 40 (+90.48%)
Mutual labels:  tabs
dflat20
D-Flat Windowing System (SAA/CUA Interface) Version 20
Stars: ✭ 42 (+100%)
Mutual labels:  tui

Welcome to cursive-tabs 👋

stable build nightly build crates.io Docs.rs GitHub PRs Welcome
A tab view wrapper for gyscos/cursive views


This project is work-in-progress

This project provides a wrapper view to be able to easily handle multiple tabs that can be switched to at any time without having to change the order of the views for gyscos/cursive views.

How does it look like? demo terminalizer

Expand to view tabs demo

Usage

Simply add to your Cargo.toml

[dependencies]
cursive-tabs = "^0"

Creating a TabPanel

The easiest way to use this crate is by creating a TabPanel and add your views to it. In the TabPanel included is a bar that shows all tabs and allows to switch between them by clicking the desired tab. Below it is the TabView showing the current tab.

It can be created by simply calling new on TabPanel and views and customize it as you want, have a look at the documentation to see all options.

use cursive::views::TextView;
use cursive_tabs::TabPanel;
use cursive::view::Nameable;

let mut siv = cursive::default();

//Create your panel and add tabs
let mut panel = TabPanel::new()
    .with_tab(TextView::new("This is the first view!").with_name("First"))
    .with_tab(TextView::new("This is the second view!").with_name("Second"));
siv.add_layer(panel);
siv.run();

Creating a TabView

This crate also provides a struct TabView you can use to add tabs and switch between them, if you do not need a separate bar to switch and e.g. want to switch programmatically.

The TabView can also be used to create your own Panel/Bar if you want to design your cursive environment a different way.

use cursive::{views::TextView};
use cursive_tabs::TabView;
use cursive::view::Nameable;

let mut siv = cursive::default();
let tabs = TabView::new().with_tab(TextView::new("Our first tab!").with_name("0"));
// We can continue to add as many tabs as we want!

siv.add_layer(tabs);
siv.run();

Look into the documentation for more examples and a detailed explanation.

Creating your own Panel 🔨🚧

When you create a TabBar it will more or less look similar to the view e.g. also used in the example. To customize it you then need to create a view, creating a TabBar and a TabView events between them can be exchanged e.g. with channels. Channels have been chosen in this case by us, because they provide the easiest way to communicate between to instances of views in cursive.

To make these channels work you have to create two separate channels transmitting both keys, once for the direction from the bar to the tab view, transmitting keys that have been selected by e.g. buttons, and the other from the tab view to the bar.

An example for such a button would look like this.

let button_tx_clone = button_tx.clone();
let button = Button::new_raw(format!(" {} ", key), move |_| {
                match button_tx_clone.send(key) {
                    Ok(_) => {}
                    Err(err) => {
                        debug!("button could not send key: {:?}", err);
                    }
                }
            });

To make the TabView respond to messages over this channel pass the receiving end to the tab view via the method set_bar_rx.

The other direction can be set by passing the Sender to TabView via the method set_active_key_tx. In this channel the currently active is send everytime a switch between tabs occurs. You can use this to register switches in your tab bar.

The rest is depending on how you want to style your panel, but if you have anymore questions or problems have a look at the source of the provided TabPanel.

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

Running all test suites

Just run

$ cargo test

to execute all available tests.

Investigating failed tests

In case some test fails with your changes, you can use the cargo-insta tool to investigate the test case.

To install

$ cargo install cargo-insta

and to run the tests and investigate all failing tests interactively.

$ cargo insta review

Any changes between the expected and received screen will be then displayed.

shields.io endpoints

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

Public API naming

The current public API of this crate is not consistent with RFC 344. This is due to cursive itself not being consistent with RFC 344. This crate tries to implement a smooth user experience for cursive users. Therefore, the cursive naming convention was adapted. When cursive upstream converts their API to a RFC 344 consistent naming scheme, this crate will adapt to the changes.

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!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].