|
| 1 | +package src |
| 2 | + |
| 3 | +import ( |
| 4 | + "strings" |
| 5 | + |
| 6 | + "github.com/charmbracelet/lipgloss" |
| 7 | +) |
| 8 | + |
| 9 | +func (m Model) View() string { |
| 10 | + if m.quitting { |
| 11 | + return "Goodbye!\n" |
| 12 | + } |
| 13 | + if m.subShell { |
| 14 | + return "" |
| 15 | + } |
| 16 | + title := titleStyle.Render(appName + " " + version) |
| 17 | + help := subtitleStyle.Render(strings.Join([]string{ |
| 18 | + helpString(m.keys.quit), |
| 19 | + helpString(m.keys.execute), |
| 20 | + helpString(m.keys.refresh), |
| 21 | + helpString(m.keys.back), |
| 22 | + helpString(m.keys.selectIt), |
| 23 | + helpString(m.keys.filter), |
| 24 | + helpString(m.keys.tab), |
| 25 | + helpString(m.keys.copy), |
| 26 | + helpString(m.keys.move), |
| 27 | + helpString(m.keys.delete), |
| 28 | + helpString(m.keys.fuzzy), |
| 29 | + helpString(m.keys.bulkRename), |
| 30 | + helpString(m.keys.suspend), |
| 31 | + helpString(m.keys.subshell), |
| 32 | + helpString(m.keys.help), |
| 33 | + }, " • ")) |
| 34 | + fBar := fBarStyle.Render(fBarContent) |
| 35 | + if m.mode == progressMode { |
| 36 | + return lipgloss.JoinVertical(lipgloss.Left, title, m.progress.View(), m.statusMsg, fBar, help) |
| 37 | + } |
| 38 | + if m.mode == editorMode { |
| 39 | + help = subtitleStyle.Render(helpString(m.keys.save) + " • " + helpString(m.keys.cancel)) |
| 40 | + editorView := editorStyle.Render(m.editor.View()) |
| 41 | + status := m.statusMsg |
| 42 | + return lipgloss.JoinVertical(lipgloss.Left, title, subtitleStyle.Render("Editing: "+m.editorFile), editorView, status, fBar, help) |
| 43 | + } |
| 44 | + if m.mode == fuzzyMode { |
| 45 | + fuzzyView := inputStyle.Render(m.fuzzyInput.View()) |
| 46 | + listView := listStyle.Render(m.panels[m.activePanel].fileList.View()) |
| 47 | + return lipgloss.JoinVertical(lipgloss.Left, title, fuzzyView, listView, m.statusMsg, fBar, help) |
| 48 | + } |
| 49 | + if m.mode == bulkRenameMode { |
| 50 | + inputView := inputStyle.Render(m.commandInput.View()) |
| 51 | + return lipgloss.JoinVertical(lipgloss.Left, title, "Bulk Rename", inputView, m.statusMsg, fBar, help) |
| 52 | + } |
| 53 | + leftList := listStyle.Width(m.panels[0].fileList.Width()).Render(m.panels[0].fileList.View()) |
| 54 | + rightList := listStyle.Width(m.panels[1].fileList.Width()).Render(m.panels[1].fileList.View()) |
| 55 | + content := lipgloss.JoinHorizontal(lipgloss.Top, leftList, rightList) |
| 56 | + leftPwd := subtitleStyle.Render("Left: " + m.panels[0].currentDir) |
| 57 | + if m.panels[0].gitBranch != "" { |
| 58 | + leftPwd += " [Branch: " + m.panels[0].gitBranch + "]" |
| 59 | + } |
| 60 | + rightPwd := subtitleStyle.Render("Right: " + m.panels[1].currentDir) |
| 61 | + if m.panels[1].gitBranch != "" { |
| 62 | + rightPwd += " [Branch: " + m.panels[1].gitBranch + "]" |
| 63 | + } |
| 64 | + pwds := lipgloss.JoinHorizontal(lipgloss.Top, leftPwd, rightPwd) |
| 65 | + inputView := inputStyle.Render(m.commandInput.View()) |
| 66 | + status := m.statusMsg |
| 67 | + return lipgloss.JoinVertical(lipgloss.Left, title, pwds, content, inputView, status, fBar, help) |
| 68 | +} |
0 commit comments