Improve text selection preview mode
This commit is contained in:
parent
1d5704d5b3
commit
35a14b09ee
1 changed files with 17 additions and 1 deletions
|
|
@ -311,7 +311,9 @@ func (m Model) View() string {
|
|||
gap := strings.Repeat(" ", m.cfg.UI.PaneGap)
|
||||
|
||||
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 {
|
||||
panels = lipgloss.JoinHorizontal(
|
||||
lipgloss.Top,
|
||||
|
|
@ -949,6 +951,20 @@ func renderPreviewPane(preview vfs.Preview, viewportModel *viewport.Model, cfg c
|
|||
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 {
|
||||
leftRows := []string{
|
||||
fmt.Sprintf("kind: %s", fallback(meta.Kind, "n/a")),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue