Giter Site home page Giter Site logo

cursive_table_view's People

Contributors

alexargoai avatar bonsaiden avatar elyzion avatar gyscos avatar jorian avatar lovebug356 avatar matthiasbeyer avatar ngg avatar rflaperuta avatar thorsteneb 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  avatar  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  avatar  avatar  avatar

cursive_table_view's Issues

with_name issue

Cursive library introduced new trait: https://docs.rs/cursive/0.15.0/cursive/traits/trait.Nameable.html#method.with_name

This breaks this library if I want to use with_name() or NamedView directly.

My example usage gives me this error when I try to wrap table with NamedView:

error[E0277]: the trait bound `cursive_table_view::TableView<ui::images::ImageTableRow, ui::images::ImageTableColumn>: cursive_core::view::view_wrapper::ViewWrapper` is not satisfied
  --> src/ui/images.rs:81:29
   |
81 |       ui.add_fullscreen_layer(NamedView::new(
   |  _____________________________^
82 | |         "images_table",
83 | |         ResizedView::with_full_screen(table),
84 | |     ));
   | |_____^ the trait `cursive_core::view::view_wrapper::ViewWrapper` is not implemented for `cursive_table_view::TableView<ui::images::ImageTableRow, ui::images::ImageTableColumn>`
   |
   = note: required because of the requirements on the impl of `cursive_core::view::view_trait::View` for `cursive_table_view::TableView<ui::images::ImageTableRow, ui::images::ImageTableColumn>`
   = note: required because of the requirements on the impl of `cursive_core::view::view_wrapper::ViewWrapper` for `cursive_core::views::resized_view::ResizedView<cursive_table_view::TableView<ui::images::ImageTableRow, ui::images::ImageTableColumn>>`
   = note: required because of the requirements on the impl of `cursive_core::view::view_trait::View` for `cursive_core::views::resized_view::ResizedView<cursive_table_view::TableView<ui::images::ImageTableRow, ui::images::ImageTableColumn>>`
   = note: required because of the requirements on the impl of `cursive_core::view::view_wrapper::ViewWrapper` for `cursive_core::views::named_view::NamedView<cursive_core::views::resized_view::ResizedView<cursive_table_view::TableView<ui::images::ImageTableRow, ui::images::ImageTableColumn>>>`
   = note: required because of the requirements on the impl of `cursive_core::view::view_trait::View` for `cursive_core::views::named_view::NamedView<cursive_core::views::resized_view::ResizedView<cursive_table_view::TableView<ui::images::ImageTableRow, ui::images::ImageTableColumn>>>`
   = note: required because of the requirements on the impl of `cursive_core::view::into_boxed_view::IntoBoxedView` for `cursive_core::views::named_view::NamedView<cursive_core::views::resized_view::ResizedView<cursive_table_view::TableView<ui::images::ImageTableRow, ui::images::ImageTableColumn>>>`

I'm no expert but Cursive provides convinient macro that can help with this implementation: https://github.com/gyscos/cursive/blob/main/cursive-core/src/view/view_wrapper.rs#L13

horizontal scrolling is missing

While vertical scrolling is present and works great, there is a noticeable lack of horizontal scrolling. When the number of columns exceeds what can be displayed on the screen (or even if a single column contains long-text that exceeds the screen width), the table is truncated all characters beyond the screen's width.

Support styled table columns

Currently, TableViewItem::to_column returns a String. It would be convenient to be able to add some style to the string, or maybe even to be able to use an arbitrary view instead.

set_selected_row does not scroll row into view

There seems to be an off-by-one somewhere that causes set_selected_row to not scroll the row into view (although it does select the correct row). To repro patch this line:

diff --git a/examples/basic.rs b/examples/basic.rs
index 0c2c802..36a1832 100644
--- a/examples/basic.rs
+++ b/examples/basic.rs
@@ -88,6 +88,7 @@ fn main() {
     }

     table.set_items(items);
+    table.set_selected_row(0);

     table.set_on_sort(|siv: &mut Cursive, column: BasicColumn, order: Ordering| {
         siv.add_layer(

Then run cargo run --example basic. Observed view:
Screen Shot 2022-03-31 at 4 24 10 PM

Expected view:
Screen Shot 2022-03-31 at 4 25 15 PM

[feature] Insert item to tableview at index

currently we have pub fn insert_item(&mut self, item: T), for insertion at the end of the tableview,
However, for better user experience, it would be better to have:

pub fn insert_item_at(&mut self, item: T, index: u32)

So that a new item can be inserted at the current selected row.

I have an implementation skeleton in mind:

pub fn insert_item_at(&mut self, item: T, index: u32) {
        self.items.insert(idx, item);
        self.rows_to_items.insert(idx, self.items.len() - 1);
        for i in (idx+1)..self.rows_to_items.len() {
            self.rows_to_items[i] = self.rows_to_items[i] + 1;
        }

        self.scrollbase
            .set_heights(self.last_size.y.saturating_sub(2), self.rows_to_items.len());

        if let Some((column, order)) = self.order() {
            self.sort_by(column, order);
        }
    }

Example basics.rs doesn't build with cursive from git, branch main

As the title says.

The error:

error[E0277]: the trait bound cursive_core::views::Dialog: cursive::view::ViewWrapper is not satisfied
--> src/main.rs:123:19
|
123 | siv.add_layer(Dialog::around(table.with_name("table").min_size((50, 20))).title("Table View"));
| --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait cursive::view::ViewWrapper is not implemented for cursive_core::views::Dialog
| |
| required by a bound introduced by this call

Ownership?

As with the cursive_tree_view crate, it seems like you're not interested in maintaining this any longer.

Would you transfer ownership of this crate to my account and give me access to the crates.io hosting? That would be awesome, I'm really interested in using this crate and continuing its development.

Update for 0.9

0.9 split the sub_printer() method up into components. How would you draws columns now? Can you update this code to work with 0.9?

Dynamic table

Hello, is it possible to create a table at running time dynamically?
or create columns at runtime??

Drawing column from top to bottom

Hi, is there a way to actually draw column from top to bottom not just only for as long as there are items. What I mean by that is that if the table_view is of a size that for example fits 20 items but we only populated it with 3 the column will be drawn next to those 3 items only and the rest of the space is left empty. Perhaps pic will explain that better.
Screenshot at 2020-07-20 07-35-39
Thank you

Error when trying set_items() shorten than actual selection

Steps to reproduce

  1. Apply this diff to basic example
diff --git a/examples/basic.rs b/examples/basic.rs
index 677bb81..5969863 100644
--- a/examples/basic.rs
+++ b/examples/basic.rs
@@ -100,22 +100,20 @@ fn main() {
     });
 
     table.set_on_submit(|siv: &mut Cursive, row: usize, index: usize| {
-        let value = siv
-            .call_on_name("table", move |table: &mut TableView<Foo, BasicColumn>| {
-                format!("{:?}", table.borrow_item(index).unwrap())
+        siv.call_on_name("table", move |table: &mut TableView<Foo, BasicColumn>| {
+                let mut items = Vec::new();
+                let mut rng = rand::thread_rng();
+                for i in 0..49 {
+                    items.push(Foo {
+                        name: format!("Name {}", i),
+                        count: rng.gen_range(0, 255),
+                        rate: rng.gen_range(0, 255),
+                    });
+                }
+
+                table.set_items(items);
             })
             .unwrap();
-
-        siv.add_layer(
-            Dialog::around(TextView::new(value))
-                .title(format!("Removing row # {}", row))
-                .button("Close", move |s| {
-                    s.call_on_name("table", |table: &mut TableView<Foo, BasicColumn>| {
-                        table.remove_item(index);
-                    });
-                    s.pop_layer();
-                }),
-        );
     });
 
     siv.add_layer(Dialog::around(table.with_name("table").min_size((50, 20))).title("Table View"));
  1. Run (redirect output to log file)
  2. Scroll to last item and submit on it

In the log file you will see
thread 'main' panicked at 'index out of bounds: the len is 49 but the index is 49', /tmp/cursive_table_view/src/lib.rs:486:18

cursive_table_view = 0.9.0 -> Is pancurses-backend depreciated?

Hello,

i updated a small programm using cursive and cursive_table_view to [Cargo.toml]


[dependencies.cursive]
version = "0.12"
default-features = false
features = ["pancurses-backend"]

[dependencies.cursive_table_view]
version = "0.9.0"
default-features = false
features = ["pancurses-backend"]

If i do a cargo build/run i get:

11:56 AM Cargo project update failed:
Execution failed (exit code 101).
/usr/bin/cargo metadata --verbose --format-version 1 --all-features
stdout : Updating crates.io index
error: failed to select a version for cursive_table_view.
... required by package msprofit v1.0.2 (/home/andi/code/rust/msprofit)
versions that meet the requirements ^0.9.0 are: 0.9.0

the package "msprofit" depends on "cursive_table_view", with features:
"pancurses-backend" but "cursive_table_view" does not have these features.

Sadly i need windows as a platform so pancurses was my only option. Is the pancurses-backend depreciated?

If i forgot any information or you need anything else please let me know.

Thanks for any information about this.
Have a nice day.
Best regards

Get active table

In case of having multiple tableviews in a Layout, how to check which one is active?

Not enough info in set_on_submit

Hi everyone, I'm using cursive crate along with cursive_table_view crate.
I'm registering callback to each created table and yes, this callback is being triggered, but I believe that there is not enough info in that callback.

//The callback
    fn Enter_Fn(app: &mut cursive::Cursive, row: usize,index: usize)
    {
    //how am I suppose to know which view triggered that callback???
    }
    ////<<<later in the code
    for i in 0..10
    {
//create panels
    let mut panel_left = create_table();//see decl below, it is the same as in examples from the repo
    panel_left.set_on_submit(Enter_Fn);//register callback
    //here I have some code that defines layout etc, so the last line is "pseudo code"
    siv.add_layout(panel_left);
    }

    fn create_table() -> TableView<Foo, BasicColumn> ;//this is function that creates table
//end of code

How to know in the Enter_Fn function which table was active when the enter was pressed, that is, we are inside of the Enter_Fn callback but all we have is app, row and index but not the view which triggered that callback.

Thanks for any help

How do I hide column headers or move them to bottom?

How do I adjust the table to occupy minimal vertical space?

It would be nice to have:

  • Ability to move column headers from top to bottom.
  • Ability to make cursive_table_view prioritise showing content, not column headers if vertical space is limited (e.g. only 3 characters tall).
  • Ability to hide the line dividing content and column headers
  • Ability to hide the column headers altogether. This option should be dynamic, i.e. table should not needed to be re-created to show/hide headers.

Publish update to crates.io?

Hello, thanks for all the great work on this crate as well as the core cursive crates.

I was attempting to integrate this crate into a cursive project based on cursive 0.15, but I was seeing compiler errors until I switched from the crates.io release of this crate (0.12) to pointing directly at github. I suspect this is because the version of this crate in crates.io has not been updated in a while?

In the short term my work is not blocked because I can work against the github/master branch version of this crate, but it would be really great if an updated version could be published to crates.io.

Thanks again for all your work!

Dynamic columns

Hello, I'm planning on using cursive_tables_view to create a TUI music metadata editor, but I'm not sure if I can have a dynamically-created list of columns? I'd like to be able to have user decide which columns they'd like to see, similar to how Puddletag would do it. Is it possible?

Method to get currently active columns.

Currently, we have methods to manipulate columns (add, insert, remove), but there is no method to retrieve a list of current columns.
For example: if I want to remove column Count from this table , or swap Count with Rate, at this time I don't see any way to do it, except keeping table structure in a separate vector.
In case of above example, it would be nice to have a method .columns() returning Vec<BasicColumn>.

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.