(title, body, pane string, minBodyLines int)
| 1063 | } |
| 1064 | |
| 1065 | func (b *FullscreenRendererBackend) renderPanel(title, body, pane string, minBodyLines int) string { |
| 1066 | width := b.panelWidth() |
| 1067 | inner := maxInt(12, width-2) |
| 1068 | active := b.FocusedPane == pane |
| 1069 | borderStyle, titleStyle, marker := b.panelStyles(pane, body, active) |
| 1070 | headerPlain := fmt.Sprintf(" %s %s ", marker, title) |
| 1071 | header := titleStyle + headerPlain + fullscreenReset + borderStyle |
| 1072 | topFill := maxInt(0, inner-runewidth.StringWidth(headerPlain)-1) |
| 1073 | |
| 1074 | lines := []string{ |
| 1075 | borderStyle + "╭─" + header + strings.Repeat("─", topFill) + "╮" + fullscreenReset, |
| 1076 | } |
| 1077 | bodyLines := strings.Split(body, "\n") |
| 1078 | if strings.TrimSpace(stripANSI(body)) == "" { |
| 1079 | bodyLines = []string{fullscreenDim + "暂无内容" + fullscreenReset} |
| 1080 | } |
| 1081 | for len(bodyLines) < maxInt(1, minBodyLines) { |
| 1082 | bodyLines = append(bodyLines, "") |
| 1083 | } |
| 1084 | if len(bodyLines) > maxInt(1, minBodyLines) { |
| 1085 | bodyLines = bodyLines[:maxInt(1, minBodyLines)] |
| 1086 | } |
| 1087 | for _, line := range bodyLines { |
| 1088 | line = truncateVisible(line, inner-2) |
| 1089 | lines = append(lines, borderStyle+"│"+fullscreenReset+" "+padVisible(line, inner-2)+" "+borderStyle+"│"+fullscreenReset) |
| 1090 | } |
| 1091 | lines = append(lines, borderStyle+"╰"+strings.Repeat("─", inner)+"╯"+fullscreenReset) |
| 1092 | return strings.Join(lines, "\n") |
| 1093 | } |
| 1094 | |
| 1095 | func (b *FullscreenRendererBackend) panelStyles(pane, body string, active bool) (string, string, string) { |
| 1096 | borderStyle := fullscreenDim |
no test coverage detected