refactor: adding comments, unexport private functions

This commit is contained in:
Dieter Eickstaedt 2023-01-08 09:09:14 +01:00
parent 256b833d95
commit 1fddcfc9c1
6 changed files with 10 additions and 10 deletions

View file

@ -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 {

View file

@ -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)
}
}

View file

@ -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)

View file

@ -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")
}

View file

@ -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" {

View file

@ -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
}