mum4k / termdash

Terminal based dashboard.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: How to modify border title once the widget is instantiated?

miguelmota opened this issue · comments

How to modify border title once the widget is instantiated?

Hello @miguelmota, I am assuming you are asking about the container title? You should be able to utilize the dynamic layout feature.

In short you specify an ID for the container when creating it by passing this option:

// ID sets an identifier for this container.
// This ID can be later used to perform dynamic layout changes by passing new
// options to this container. When provided, it must be a non-empty string that
// is unique among all the containers.
func ID(id string) Option {
return option(func(c *Container) error {
if id == "" {
return errors.New("the ID cannot be an empty string")
}
c.opts.id = id
return nil
})
}

And then you can use the container.Update function, specifying the same ID and providing any set of new options, including a new title:

// Update updates container with the specified id by setting the provided
// options. This can be used to perform dynamic layout changes, i.e. anything
// between replacing the widget in the container and completely changing the
// layout and splits.
// The argument id must match exactly one container with that was created with
// matching ID() option. The argument id must not be an empty string.
func (c *Container) Update(id string, opts ...Option) error {

However if you are asking about title of a specific widget, that might be different, please let me know.

@mum4k makes perfect sense; thanks!