Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

select windows to display from CLI #107

Merged
merged 12 commits into from
Jan 16, 2020
Merged

Conversation

chobeat
Copy link
Contributor

@chobeat chobeat commented Jan 10, 2020

No description provided.

@chobeat chobeat changed the title added first version (no tests) select windows to display from CLI(no tests) Jan 10, 2020
@imsnif
Copy link
Owner

imsnif commented Jan 11, 2020

Hey - so this is a really good start. I think before the tests or the CLI arguments and such, we should try to figure out the functionality.

Right now with this code, when I choose one window I see it on only half of the screen. I suggest we start by fixing this and then making sure it behaves well in all the terminal-window sizes. Once we do that, we can figure out how we'd like the CLI arguments to work (and documented in the help), and how to test all this.

What do you think?

@chobeat
Copy link
Contributor Author

chobeat commented Jan 11, 2020

Yes, I have it in plan. I will be able to look into it maybe tomorrow. If we stick to the single window, the math should be simple, since we want the table to take the whole available screen, as long as it's above the minimum.

@chobeat
Copy link
Contributor Author

chobeat commented Jan 12, 2020

Now it should be working fine both for 1 and 2 windows. There are a bunch of if-else that I think can be handled more idiomatically but the logic is there.

@imsnif
Copy link
Owner

imsnif commented Jan 12, 2020

So far I've only looked at the functionality and it looks pretty cool. I like the CLI interface that lets me just add the windows I want by name: simple and straightforward.

When we have just 1 single window now and a large terminal window (eg. full screen terminal), the columns seem a little dense. I'm fine with them not being spread to the whole screen (that would probably be uncomfortable), but I think we can give them more room to "breathe" (this is especially true to the connections table).

Do you think we might be able to spread them out a little? Maybe by adding another breakpoint here and playing around with the column widths somehow?

const FIRST_WIDTH_BREAKPOINT: u16 = 50;

@chobeat
Copy link
Contributor Author

chobeat commented Jan 12, 2020

I did something and it seems to be working fine: if the size is below the third breakpoint, it behaves the same as before, otherwise it expands according to the size and the behavior might slightly differ from the fixed size we had before but I don't see any usability issue in it.

@chobeat chobeat marked this pull request as ready for review January 13, 2020 08:14
@chobeat chobeat changed the title select windows to display from CLI(no tests) select windows to display from CLI Jan 13, 2020
@imsnif imsnif mentioned this pull request Jan 14, 2020
@imsnif imsnif self-assigned this Jan 14, 2020
@chobeat
Copy link
Contributor Author

chobeat commented Jan 15, 2020

@imsnif I think it's ready for review: tests are passing and there are no conflicts.

@imsnif
Copy link
Owner

imsnif commented Jan 15, 2020

@chobeat - my apologies that it's taking me time to get to this. I already started reviewing this last night - this is the next bandwhich thing I'm getting to.

Copy link
Owner

@imsnif imsnif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - solid work!
I really like this functionality, as well as the implementation. I think the idea of allowing the user to pass in as many or as few tables to render as they like is gold. I'm looking forward to releasing this change.

I left some nitpicks in the review. Once these are addressed I'd be very happy to merge this.

fn build_layout(&self, rect: Rect) -> Vec<Rect> {
if self.children.len() == 1 {
// if there's only one element to render, it can take the whole frame
self.progressive_split(rect, vec![])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just return vec![rect] here?

THIRD_COLUMN_WIDTHS[2],
rect.width * 53 / 100,
rect.width * 22 / 100,
rect.width * 23 / 100 - 1,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this approach - do you think it will be possible to place the percentages in static consts for clarity (like the FIRST_COLUMN_WIDTHS etc? Maybe something like MAX_FIRST_COLUMN_WIDTH_PERCENTAGE or preferably a clearer shorter name if you can think of one? :)

let opts = &self.opts;
let mut children: Vec<Table> = Vec::new();
if opts.processes {
children.push(self.build_processes_table());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use Table::create_processes_table(...) here directly? Then we can get rid of the build_*_table methods above.

@@ -112,6 +112,115 @@ fn pause_by_space() {
assert_snapshot!(&terminal_draw_events_mirror[2]);
}

#[test]
fn basic_only_processes() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests are great! Let's add some data to them as well, ok? Just one additional snapshot per test with data. What do you think?

src/main.rs Outdated Show resolved Hide resolved
@chobeat
Copy link
Contributor Author

chobeat commented Jan 16, 2020

all done

Copy link
Owner

@imsnif imsnif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @chobeat - I was about to merge this and then noticed that when running this locally, it overflowed a little for me in certain situations (in a way that overrode the table border). So I pushed a small fix that just reduces the percentages of the second and third column by a bit and adjusted the snapshots.

Once the tests pass, I'll merge this.

This is a really great feature, and you've done great work. Thanks for bearing with me! :)
I very much hope to see more contributions from you if you want.

@imsnif imsnif merged commit ceaf8b8 into imsnif:master Jan 16, 2020
@imsnif
Copy link
Owner

imsnif commented Jan 16, 2020

Also, @chobeat - I would like to add you to the "Authors" section of our Cargo.toml, since you've made some major contributions to the project. Would you be willing for your name and email address to appear there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants