mirror of
https://github.com/siderolabs/talos.git
synced 2025-10-10 15:11:15 +02:00
Linux 5.15.79, containerd 1.6.10 Other changes come from: * https://github.com/siderolabs/toolchain/pull/57 * https://github.com/siderolabs/tools/pull/244 * https://github.com/siderolabs/pkgs/pull/619 * https://github.com/siderolabs/extras/pull/67 Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
61 lines
1.3 KiB
Go
61 lines
1.3 KiB
Go
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
package components
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/gdamore/tcell/v2"
|
|
"github.com/rivo/tview"
|
|
)
|
|
|
|
// NewFormLabel creates a new FormLabel.
|
|
func NewFormLabel(label string) *FormLabel {
|
|
res := &FormLabel{
|
|
tview.NewTextView().SetText(label),
|
|
}
|
|
|
|
return res
|
|
}
|
|
|
|
// FormLabel text paragraph that can be used in form.
|
|
type FormLabel struct {
|
|
*tview.TextView
|
|
}
|
|
|
|
// SetFormAttributes sets form attributes.
|
|
func (b *FormLabel) SetFormAttributes(labelWidth int, labelColor, bgColor, fieldTextColor, fieldBgColor tcell.Color) tview.FormItem {
|
|
b.SetTextColor(labelColor)
|
|
b.SetBackgroundColor(bgColor)
|
|
s := strings.TrimSpace(b.GetText(false))
|
|
|
|
for i := 0; i < labelWidth; i++ {
|
|
s = " " + s
|
|
}
|
|
b.SetText(s)
|
|
|
|
return b
|
|
}
|
|
|
|
// GetFieldWidth implements tview.FormItem.
|
|
func (b *FormLabel) GetFieldWidth() int {
|
|
return 0
|
|
}
|
|
|
|
// SetFinishedFunc implements tview.FormItem.
|
|
func (b *FormLabel) SetFinishedFunc(handler func(key tcell.Key)) tview.FormItem {
|
|
return b
|
|
}
|
|
|
|
// GetLabel implements tview.FormItem.
|
|
func (b *FormLabel) GetLabel() string {
|
|
return ""
|
|
}
|
|
|
|
// GetFieldHeight implements tview.FormItem.
|
|
func (b *FormLabel) GetFieldHeight() int {
|
|
return 1
|
|
}
|