GithubHelp home page GithubHelp logo

deinstapel / cursive-tabs Goto Github PK

View Code? Open in Web Editor NEW
24.0 24.0 8.0 473 KB

Tabs for gyscos/cursive views 🖥️

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

Shell 3.73% Rust 95.12% jq 1.15%
cursive cursive-views gyscos tabs tui view

cursive-tabs's People

Contributors

fin-ger avatar gyscos avatar jwuensche avatar matthiasbeyer avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

cursive-tabs's Issues

Active `TabBar` is not highlighted initially

Hello, I'm following the example verbatim.

use cursive::view::{Nameable, Resizable};
use cursive::views::{Button, LinearLayout, PaddedView, TextArea, TextView};
use cursive_tabs::{Align, TabPanel};
const TAB_0: &str =
"With using the TabPanel you get a TabView and TabBar, preconfigured for you to use!
Simply create it with:
`cursive_tabs::TabPanel::new()`";
const TAB_1: &str = "You then can add views and configure your panel.";
const TAB_2: &str =
"Ofcourse you can also use the provided TabView without the panel, simply create it with:
`cursive_tabs::TabView::new()`";
const TAB_3: &str = "All you have to do is add:
cursive-tabs = \"^0\"
to your Cargo.toml!
";
fn main() {
let mut siv = cursive::default();
let panel = TabPanel::new()
.with_tab(TextView::new(TAB_0).with_name("0"))
.with_tab(TextView::new(TAB_1).with_name("1"))
.with_tab(TextView::new(TAB_2).with_name("2"))
.with_tab(TextView::new(TAB_3).with_name("3"))
.with_tab(PaddedView::lrtb(2, 2, 1, 1, TextArea::new()).with_name("4"))
.with_bar_alignment(Align::End)
.with_active_tab("0")
.unwrap_or_else(|_| {
panic!("Could not set the first tab as active tab! This is probably an issue with the implementation in the lib. Please report!");
});
siv.add_fullscreen_layer(
LinearLayout::vertical()
.child(panel.with_name("Tabs").full_screen())
.child(
LinearLayout::horizontal()
.child(Button::new("Prev", |siv| {
let mut tabs: cursive::views::ViewRef<TabPanel> =
siv.find_name("Tabs").expect("id not found");
tabs.prev();
}))
.child(Button::new("Next", |siv| {
let mut tabs: cursive::views::ViewRef<TabPanel> =
siv.find_name("Tabs").expect("id not found");
tabs.next();
})),
),
);
siv.add_global_callback('q', |siv| siv.quit());
siv.run();
}

The active tab name is not highlighted initially even though active tab is being set.

.with_active_tab("0")

Image to illustrate potential bug and expected behavior.

Screenshot from 2022-02-18 12-51-53 png-mh

Could be the same issue as #4

Package info: cursive-tabs = "0.7.0"

K: Copy is really inconvenient

Hi,

I find K: Copy really inconvenient as I cannot use String as K.

Is there a way to make the current situation better?

Position of tab-names?

Hi,

is it possible to define the location of the tab names? If not, consider this as a feature request.

Also: Would be nice to be able to actually have a vertical listing of tab names!


Awesome crate, please keep up the good work!

tests with puppet backend

Hi! Some time ago I commited a puppet backend to Cursive to facilitate automated tests. There are some examples in njskalski/sly-editor . Have you considered trying this way of testing? It's 100% Rust.

Consider moving end2end tests to `examples` or `tests`

I am trying to update cursive-tabs to depend on cursive_core rather than cursive (cursive_core is basically cursive without backends, so should be enough for libraries and have fewer breaking changes). Dependencies would still pull the full cursive crate.

Currently end2end test binaries are in src/bin/. This means that they use the same dependencies as the library itself; but (like other tests) they require the full cursive crate and not just cursive_core.

(There is a RFC for per-bin dependencies, but it's not looking good yet, and probably not really the right thing™ anyway.)

Moving it to tests or examples would make them use dev-dependencies.

Another (probably better) solution is the puppet-backend-tests branch, which replaces these with direct individual tests.

can't placed `TextArea` inside tabs

I'm trying to add tabs with TextArea, and its not a named

error[E0308]: mismatched types
   --> tui/src/views/tab_bar.rs:7:18
    |
7   |         .add_tab(TextArea::new())
    |          ------- ^^^^^^^^^^^^^^^ expected `NamedView<_>`, found `TextArea`
    |          |
    |          arguments to this method are incorrect
    |
    = note: expected struct `NamedView<_>`
               found struct `TextArea`
note: method defined here
   --> /home/redhawk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cursive-tabs-0.7.0/src/panel.rs:142:12
    |
142 |     pub fn add_tab<T: View>(&mut self, view: NamedView<T>) {

TabView fails to build on the latest branches of `cursive` and `cursive-tabs`

In Cargo.toml:

cursive = { git = "https://github.com/gyscos/cursive.git" }
cursive-tabs = { git = "https://github.com/deinstapel/cursive-tabs.git" }

https://github.com/htejun/resctl-demo/tree/on-cursive-tip fails:

$ cargo check                                                                                                                                                                                  
    Checking resctl-demo v1.0.0 (/home/htejun/os/resctl-demo/resctl-demo)                                                                                                                                            
error[E0277]: the trait bound `cursive_tabs::TabView<usize>: cursive::view::ViewWrapper` is not satisfied                                                                                                            
  --> resctl-demo/src/graph.rs:82:9                                                                                                                                                                                  
   |                                                                                                                                                                                                                 
82 |     siv.call_on_name("graph-tabs", |v: &mut TabView<usize>| {                                                                                                                                                   
   |         ^^^^^^^^^^^^ the trait `cursive::view::ViewWrapper` is not implemented for `cursive_tabs::TabView<usize>`                                                                                               
   |                                                                                                                                                                                                                 
   = note: required because of the requirements on the impl of `cursive::View` for `cursive_tabs::TabView<usize>`      
...                                                                                              

Thank you so much.

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.