mirror of
https://github.com/charmbracelet/gum
synced 2024-06-15 20:15:08 +02:00
refactor: adding comments, unexport private functions
This commit is contained in:
parent
256b833d95
commit
1fddcfc9c1
|
@ -171,7 +171,7 @@ func (m model) View() string {
|
|||
|
||||
if item.selected {
|
||||
if m.hasTimeout {
|
||||
timeoutStr = timeout.TimeoutStr(m.timeout)
|
||||
timeoutStr = timeout.Str(m.timeout)
|
||||
}
|
||||
s.WriteString(m.selectedItemStyle.Render(m.selectedPrefix + item.text + timeoutStr))
|
||||
} else if i == m.index%m.height {
|
||||
|
|
|
@ -92,9 +92,9 @@ func (m model) View() string {
|
|||
timeoutStrYes = ""
|
||||
if m.hasTimeout {
|
||||
if m.defvalue {
|
||||
timeoutStrYes = timeout.TimeoutStr(m.timeout)
|
||||
timeoutStrYes = timeout.Str(m.timeout)
|
||||
} else {
|
||||
timeoutStrNo = timeout.TimeoutStr(m.timeout)
|
||||
timeoutStrNo = timeout.Str(m.timeout)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ func (m model) View() string {
|
|||
}
|
||||
var timeStr string
|
||||
if m.hasTimeout {
|
||||
timeStr = timeout.TimeoutStr(m.timeout)
|
||||
timeStr = timeout.Str(m.timeout)
|
||||
}
|
||||
if m.header != "" {
|
||||
header := m.headerStyle.Render(m.header)
|
||||
|
|
|
@ -98,7 +98,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
func (m model) View() string {
|
||||
var timeoutStr string
|
||||
if m.hasTimeout {
|
||||
timeoutStr = timeout.TimeoutStr(m.timeout) + " "
|
||||
timeoutStr = timeout.Str(m.timeout) + " "
|
||||
}
|
||||
return m.viewport.View() + m.helpStyle.Render("\n"+timeoutStr+"↑/↓: Navigate • q: Quit")
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ func (m model) Init() tea.Cmd {
|
|||
func (m model) View() string {
|
||||
var str string
|
||||
if m.hasTimeout {
|
||||
str = timeout.TimeoutStr(m.timeout)
|
||||
str = timeout.Str(m.timeout)
|
||||
}
|
||||
|
||||
if m.align == "left" {
|
||||
|
|
|
@ -52,12 +52,12 @@ func Tick(timeoutValue time.Duration, data interface{}) tea.Cmd {
|
|||
})
|
||||
}
|
||||
|
||||
// TimeoutStr produce Timeout String to be rendered.
|
||||
func TimeoutStr(timeout time.Duration) string {
|
||||
return fmt.Sprintf(" (%d)", Max(0, int(timeout.Seconds())))
|
||||
// Str produce Timeout String to be rendered.
|
||||
func Str(timeout time.Duration) string {
|
||||
return fmt.Sprintf(" (%d)", max(0, int(timeout.Seconds())))
|
||||
}
|
||||
|
||||
func Max(a, b int) int {
|
||||
func max(a, b int) int {
|
||||
if a > b {
|
||||
return a
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue