-
Notifications
You must be signed in to change notification settings - Fork 146
Added Tab widget, demo, and tests #381
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
Open
keithknott26
wants to merge
3
commits into
mum4k:devel
Choose a base branch
from
keithknott26:tab
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| // Package tab provides configuration options for the tabbed interface. | ||
| package tab | ||
|
|
||
| import "github.com/mum4k/termdash/cell" | ||
|
|
||
| // Option represents a configuration option for the Tab. | ||
| type Option interface { | ||
| // set applies the option to the provided Options struct. | ||
| set(*Options) | ||
| } | ||
|
|
||
| // Options holds the configuration for the Tab. | ||
| type Options struct { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| Tabs []*Tab // List of tabs. | ||
| LabelColor cell.Color // Color of the tab labels. | ||
| ActiveTabColor cell.Color // Background color of the active tab. | ||
| InactiveTabColor cell.Color // Background color of inactive tabs. | ||
| ActiveIcon string // Icon for active tabs. | ||
| InactiveIcon string // Icon for inactive tabs. | ||
| NotificationIcon string // Icon for tabs with notifications. | ||
| EnableLogging bool // Enables logging for debugging. | ||
| FollowNotifications bool // Whether to follow notifications automatically. | ||
| } | ||
|
|
||
| // NewOptions initializes default options or applies provided options. | ||
| func NewOptions(opts ...Option) *Options { | ||
| o := &Options{ | ||
| Tabs: []*Tab{}, | ||
| LabelColor: cell.ColorWhite, | ||
| ActiveTabColor: cell.ColorBlue, | ||
| InactiveTabColor: cell.ColorBlack, | ||
| ActiveIcon: "⦿", | ||
| InactiveIcon: "○", | ||
| NotificationIcon: "⚠", | ||
| EnableLogging: false, | ||
| FollowNotifications: false, | ||
| } | ||
| for _, opt := range opts { | ||
| opt.set(o) | ||
| } | ||
| return o | ||
| } | ||
|
|
||
| // option is a function that modifies Options. | ||
| type option func(*Options) | ||
|
|
||
| // set implements Option.set. | ||
| func (o option) set(opts *Options) { | ||
| o(opts) | ||
| } | ||
|
|
||
| // Tabs sets the root tabs of the Tab widget. | ||
| func Tabs(tabs ...*Tab) Option { | ||
| return option(func(o *Options) { | ||
| o.Tabs = tabs | ||
| }) | ||
| } | ||
|
|
||
| // ActiveIcon sets custom icons for the active state. | ||
| func ActiveIcon(active string) Option { | ||
| return option(func(o *Options) { | ||
| o.ActiveIcon = active | ||
| }) | ||
| } | ||
|
|
||
| // InactiveIcon sets custom icons for the inactive state. | ||
| func InactiveIcon(inactive string) Option { | ||
| return option(func(o *Options) { | ||
| o.InactiveIcon = inactive | ||
| }) | ||
| } | ||
|
|
||
| // NotificationIcon sets custom icons for notifications. | ||
| func NotificationIcon(notification string) Option { | ||
| return option(func(o *Options) { | ||
| o.NotificationIcon = notification | ||
| }) | ||
| } | ||
|
|
||
| // LabelColor sets the color of the tab labels. | ||
| func LabelColor(color cell.Color) Option { | ||
| return option(func(o *Options) { | ||
| o.LabelColor = color | ||
| }) | ||
| } | ||
|
|
||
| // ActiveTabColor sets the background color of the active tab. | ||
| func ActiveTabColor(color cell.Color) Option { | ||
| return option(func(o *Options) { | ||
| o.ActiveTabColor = color | ||
| }) | ||
| } | ||
|
|
||
| // InactiveTabColor sets the background color of inactive tabs. | ||
| func InactiveTabColor(color cell.Color) Option { | ||
| return option(func(o *Options) { | ||
| o.InactiveTabColor = color | ||
| }) | ||
| } | ||
|
|
||
| // EnableLogging enables or disables logging for debugging. | ||
| func EnableLogging(enable bool) Option { | ||
| return option(func(o *Options) { | ||
| o.EnableLogging = enable | ||
| }) | ||
| } | ||
|
|
||
| // FollowNotifications sets whether the app should follow notifications automatically. | ||
| func FollowNotifications(enable bool) Option { | ||
| return option(func(o *Options) { | ||
| o.FollowNotifications = enable | ||
| }) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // Package tab provides functionality for managing tabbed interfaces. | ||
| package tab | ||
|
|
||
| import ( | ||
| "github.com/mum4k/termdash/container" | ||
| ) | ||
|
|
||
| // Content displays the content of the active tab. | ||
| type Content struct { | ||
| tm *Manager // Reference to the Tab Manager. | ||
| } | ||
|
|
||
| // NewContent creates a new Content. | ||
| func NewContent(tm *Manager) *Content { | ||
| return &Content{ | ||
| tm: tm, | ||
| } | ||
| } | ||
|
|
||
| // Update updates the content based on the active tab. | ||
| func (c *Content) Update(cont *container.Container) error { | ||
| activeTab := c.tm.GetActiveTab() | ||
| if activeTab == nil { | ||
| return nil | ||
| } | ||
| return cont.Update("tabContent", activeTab.Content) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please merge from the
develbranch and resolve the conflict.There was a problem hiding this comment.
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