Add auto-summary settings
This commit is contained in:
@@ -331,6 +331,16 @@ func (st *uiState) drawSidebar() {
|
||||
write(prefix + openStyle + nameCell + styleReset + suffix)
|
||||
}
|
||||
|
||||
if summary := st.activeSummaryText(width - 4); summary != "" && row+2 <= maxRow {
|
||||
write("")
|
||||
for _, line := range wrapSidebarSummary(summary, width-4) {
|
||||
if row > maxRow {
|
||||
break
|
||||
}
|
||||
write(" " + styleDim + line + styleReset)
|
||||
}
|
||||
}
|
||||
|
||||
// Scratchpads list — names only. The preview pane used to live
|
||||
// here and clobbered the main viewport when content overflowed the
|
||||
// rail. Focus moves to a pad via Ctrl+W/S; the content renders in
|
||||
@@ -390,3 +400,42 @@ func (st *uiState) drawSidebar() {
|
||||
fmt.Fprintf(os.Stdout, "\x1b7%s\x1b8", frame)
|
||||
st.outMu.Unlock()
|
||||
}
|
||||
|
||||
func wrapSidebarSummary(s string, width int) []string {
|
||||
if width < 1 {
|
||||
width = 1
|
||||
}
|
||||
words := strings.Fields(s)
|
||||
if len(words) == 0 {
|
||||
return nil
|
||||
}
|
||||
var out []string
|
||||
var cur string
|
||||
for _, word := range words {
|
||||
if visibleLen(word) > width {
|
||||
if cur != "" {
|
||||
out = append(out, cur)
|
||||
cur = ""
|
||||
}
|
||||
out = append(out, clipRunes(word, width-1)+"…")
|
||||
continue
|
||||
}
|
||||
if cur == "" {
|
||||
cur = word
|
||||
continue
|
||||
}
|
||||
if visibleLen(cur)+1+visibleLen(word) <= width {
|
||||
cur += " " + word
|
||||
continue
|
||||
}
|
||||
out = append(out, cur)
|
||||
cur = word
|
||||
}
|
||||
if cur != "" {
|
||||
out = append(out, cur)
|
||||
}
|
||||
if len(out) > 3 {
|
||||
out = out[:3]
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user