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

Added Tab widget, demo, and tests #381

Open
wants to merge 3 commits into
base: devel
Choose a base branch
from

Conversation

keithknott26
Copy link

@keithknott26 keithknott26 commented Sep 18, 2024

Hello Jakub,

I've added Tab support via the Tab widget. It includes a demo of the features including FollowNotifications which switches the active tab automatically whenever there's a notification alarm. I've also added tests and comments.

I'll try to update the README in main in the next few days.

Thanks,
Keith Knott

@keithknott26 keithknott26 marked this pull request as ready for review September 19, 2024 00:12
@keithknott26
Copy link
Author

Screenshot 2024-09-18 at 8 13 18 PM

@mum4k
Copy link
Owner

mum4k commented Sep 21, 2024

Another really cool widget, thank you Keith. I'll get to the review shortly and then we can release both of these (tab and treeview) together.

@mum4k mum4k changed the base branch from master to devel September 21, 2024 15:31
@mum4k
Copy link
Owner

mum4k commented Sep 25, 2024

Before we get into the review here, could you address the failing checks? Looks like the CI identified a few lint errors.

If you can, please also update the README.md with a screenshot or a gif showing off the widget.

@keithknott26
Copy link
Author

Jakub,

You're very welcome i'm happy to contribute I really like your work. I've resolved the linting errors and optimized the code a bit, also added an animated gif and updated the README. If the gifs don't really match perhaps you can try with your normal terminal for treeview and tab I like the orange you have in the other gifs. For the animated gif capture I use liceCAP.

Let me know if you'd like me to make any changes.

Btw - I saw some really interesting 3d engine for the terminal on github like this one: https://github.com/kohkubo/term3d and i'm wondering if I can't integrate it somehow into your project. I'm not sure what to use it for yet but it would involve converting the algorithms over to Go code and then having it read from an obj file... have a look and see if you can spot anything that might be helpful in your project... i'm happy to have a go at it but as I said I'm just not sure how it could be useful for this project, cool nonetheless ;)

Cheers,
Keith Knott

@@ -184,6 +184,28 @@ go run widgets/segmentdisplay/segmentdisplaydemo/segmentdisplaydemo.go

[<img src="./doc/images/segmentdisplaydemo.gif" alt="segmentdisplaydemo" type="image/gif">](widgets/segmentdisplay/segmentdisplaydemo/segmentdisplaydemo.go)

## The TreeView
Copy link
Owner

Choose a reason for hiding this comment

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

Please merge from the devel branch and resolve the conflict.

Copy link
Author

Choose a reason for hiding this comment

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

Will this require a new PR? keithknott26 wants to merge 3 commits into mum4k:devel I thought i was merging to devel

@@ -0,0 +1,548 @@
// Package main provides a system monitor application using tabbed interfaces.
Copy link
Owner

Choose a reason for hiding this comment

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

This widget has a really good potential. Playing a bit with the demo, I think we have some instability that we should track down if you feel like diving in and debugging.

The instability is visible if I am just clicking through the tabs (or just repeatedly pressing tab). Occasionally the tab switches to the previoustab instead to the next and occasionally it switches over multiple tabs. This is likely some racy behavior (lack of locking / serializing of the events).

I did not look at the code in detail. Let me know if you have the cycles to debug the behavior.

Copy link
Owner

Choose a reason for hiding this comment

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

Actually looking deeper, this is just caused by a goroutine in the demo that periodically switches tabs to a random tab.

How would you feel about removing that goroutine as it makes the demo feel unstable. No weird behavior is observed once that goroutine is removed.

Copy link
Author

Choose a reason for hiding this comment

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

It's happening because FollowNotifications has been set to true in the demo, notifications generated by the app will cause a warning symbol to appear on the tab itself notifying the user that some activity or alarm has triggered. FollowNotifications(True) just follows those series of notifications and switches focus/tabs for you. I can certainly set it to False so people don't get confused. Let me know if that makes sense.

// Package main provides a system monitor application using tabbed interfaces.
package main

import (
Copy link
Owner

Choose a reason for hiding this comment

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

A UI nit - I noticed that when a TAB is selected, there is one additional cell highlighted at the beginning of the TAB, i.e. in "| Storage |" the first "|" is also highlighted, while the second isn't. Is that intentional?

Shouls we just highlight the content between the two "| |" ?

Copy link
Author

Choose a reason for hiding this comment

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

yes although i fought with this for some time and couldn't get the alignment quite right. I'll need to take this one away for later I think

Copy link
Owner

Choose a reason for hiding this comment

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

fwiw, we don't have to block the PR on this, it can be fixed later as an improvement either by you or another contributor.

}
}()

// Start a goroutine to periodically trigger tab notifications
Copy link
Owner

Choose a reason for hiding this comment

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

This is the goroutine I am referring to, I would suggest we remove this to make the demo experience more stable.

}

// Options holds the configuration for the Tab.
type Options struct {
Copy link
Owner

Choose a reason for hiding this comment

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

Similar to treeview and the other tabs - can we make all these fields private (starting with lowercase letter)? Or do they need to be part of the API? Looks like users can use the functions below to set them.

@mum4k
Copy link
Owner

mum4k commented Oct 6, 2024

Wen't through the rest of the code, have no major comments. Thank you for the contribution @keithknott26 !

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