Documentation tweak

This commit is contained in:
Matt Low 2024-05-30 18:22:56 +00:00
parent a6522dbcd0
commit 58e1b84fea

View File

@ -14,9 +14,9 @@ import (
type MsgTempfileEditorClosed string type MsgTempfileEditorClosed string
// OpenTempfileEditor opens an $EDITOR on a new temporary file with the given // OpenTempfileEditor opens $EDITOR on a temporary file with the given content.
// content. Upon closing, the contents of the file are read back returned // Upon closing, the contents of the file are read and returned wrapped in a
// wrapped in a msgTempfileEditorClosed returned by the tea.Cmd // MsgTempfileEditorClosed
func OpenTempfileEditor(pattern string, content string, placeholder string) tea.Cmd { func OpenTempfileEditor(pattern string, content string, placeholder string) tea.Cmd {
msgFile, _ := os.CreateTemp("/tmp", pattern) msgFile, _ := os.CreateTemp("/tmp", pattern)
@ -46,7 +46,7 @@ func OpenTempfileEditor(pattern string, content string, placeholder string) tea.
}) })
} }
// similar to lipgloss.Height, except returns 0 on empty strings // similar to lipgloss.Height, except returns 0 instead of 1 on empty strings
func Height(str string) int { func Height(str string) int {
if str == "" { if str == "" {
return 0 return 0
@ -72,9 +72,6 @@ func TruncateToCellWidth(str string, width int, tail string) string {
return str + tail return str + tail
} }
// fraction is the fraction of the total screen height into view the offset
// should be scrolled into view. 0.5 = items will be snapped to middle of
// view
func ScrollIntoView(vp *viewport.Model, offset int, edge int) { func ScrollIntoView(vp *viewport.Model, offset int, edge int) {
currentOffset := vp.YOffset currentOffset := vp.YOffset
if offset >= currentOffset && offset < currentOffset+vp.Height { if offset >= currentOffset && offset < currentOffset+vp.Height {