Improve text selection preview mode

This commit is contained in:
vrubelroman 2026-04-22 23:26:45 +03:00
parent 1d5704d5b3
commit 35a14b09ee

View file

@ -311,7 +311,9 @@ func (m Model) View() string {
gap := strings.Repeat(" ", m.cfg.UI.PaneGap) gap := strings.Repeat(" ", m.cfg.UI.PaneGap)
var panels string var panels string
if m.infoMode { if m.selectMode && m.infoMode {
panels = renderSelectionPane(m.previewData, &m.previewModel, m.palette, m.width, bodyHeight)
} else if m.infoMode {
if m.active == PaneLeft { if m.active == PaneLeft {
panels = lipgloss.JoinHorizontal( panels = lipgloss.JoinHorizontal(
lipgloss.Top, lipgloss.Top,
@ -949,6 +951,20 @@ func renderPreviewPane(preview vfs.Preview, viewportModel *viewport.Model, cfg c
return box.Render(lipgloss.JoinVertical(lipgloss.Left, parts...)) return box.Render(lipgloss.JoinVertical(lipgloss.Left, parts...))
} }
func renderSelectionPane(preview vfs.Preview, viewportModel *viewport.Model, palette theme.Palette, width int, height int) string {
content := preview.Body
viewportModel.Width = max(width, 1)
viewportModel.Height = max(height, 1)
viewportModel.SetContent(content)
return lipgloss.NewStyle().
Width(width).
Height(height).
Background(palette.Panel).
Foreground(palette.Text).
Render(viewportModel.View())
}
func renderMetadata(meta vfs.Metadata, palette theme.Palette, width int) string { func renderMetadata(meta vfs.Metadata, palette theme.Palette, width int) string {
leftRows := []string{ leftRows := []string{
fmt.Sprintf("kind: %s", fallback(meta.Kind, "n/a")), fmt.Sprintf("kind: %s", fallback(meta.Kind, "n/a")),