summaryrefslogtreecommitdiffhomepage
path: root/internal/tui
diff options
context:
space:
mode:
Diffstat (limited to 'internal/tui')
-rw-r--r--internal/tui/components/dialog/permission.go87
-rw-r--r--internal/tui/tui.go15
2 files changed, 82 insertions, 20 deletions
diff --git a/internal/tui/components/dialog/permission.go b/internal/tui/components/dialog/permission.go
index 085744dda..17b3fba07 100644
--- a/internal/tui/components/dialog/permission.go
+++ b/internal/tui/components/dialog/permission.go
@@ -92,16 +92,7 @@ func formatDiff(diffText string) string {
}
// Join all formatted lines
- content := strings.Join(formattedLines, "\n")
-
- // Create a bordered box for the content
- contentStyle := lipgloss.NewStyle().
- MarginTop(1).
- Padding(0, 1).
- Border(lipgloss.RoundedBorder()).
- BorderForeground(styles.Flamingo)
-
- return contentStyle.Render(content)
+ return strings.Join(formattedLines, "\n")
}
func (p *permissionDialogCmp) Init() tea.Cmd {
@@ -241,12 +232,46 @@ func (p *permissionDialogCmp) render() string {
headerParts = append(headerParts, keyStyle.Render("Update"))
// Recreate header content with the updated headerParts
headerContent = lipgloss.NewStyle().Padding(0, 1).Render(lipgloss.JoinVertical(lipgloss.Left, headerParts...))
- // Format the diff with colors instead of using markdown code block
+
+ // Format the diff with colors
formattedDiff := formatDiff(pr.Diff)
+
+ // Set up viewport for the diff content
+ p.contentViewPort.Width = p.width - 2 - 2
+
+ // Calculate content height dynamically based on window size
+ maxContentHeight := p.height - lipgloss.Height(headerContent) - lipgloss.Height(form) - 2 - 2 - 1
+ p.contentViewPort.Height = maxContentHeight
+ p.contentViewPort.SetContent(formattedDiff)
+
+ // Style the viewport
+ var contentBorder lipgloss.Border
+ var borderColor lipgloss.TerminalColor
+
+ if p.isViewportFocus {
+ contentBorder = lipgloss.DoubleBorder()
+ borderColor = styles.Blue
+ } else {
+ contentBorder = lipgloss.RoundedBorder()
+ borderColor = styles.Flamingo
+ }
+
+ contentStyle := lipgloss.NewStyle().
+ MarginTop(1).
+ Padding(0, 1).
+ Border(contentBorder).
+ BorderForeground(borderColor)
+
+ if p.isViewportFocus {
+ contentStyle = contentStyle.BorderBackground(styles.Surface0)
+ }
+
+ contentFinal := contentStyle.Render(p.contentViewPort.View())
+
return lipgloss.JoinVertical(
lipgloss.Top,
headerContent,
- formattedDiff,
+ contentFinal,
form,
)
@@ -255,12 +280,46 @@ func (p *permissionDialogCmp) render() string {
headerParts = append(headerParts, keyStyle.Render("Content"))
// Recreate header content with the updated headerParts
headerContent = lipgloss.NewStyle().Padding(0, 1).Render(lipgloss.JoinVertical(lipgloss.Left, headerParts...))
- // Format the diff with colors instead of using markdown code block
+
+ // Format the diff with colors
formattedDiff := formatDiff(pr.Content)
+
+ // Set up viewport for the content
+ p.contentViewPort.Width = p.width - 2 - 2
+
+ // Calculate content height dynamically based on window size
+ maxContentHeight := p.height - lipgloss.Height(headerContent) - lipgloss.Height(form) - 2 - 2 - 1
+ p.contentViewPort.Height = maxContentHeight
+ p.contentViewPort.SetContent(formattedDiff)
+
+ // Style the viewport
+ var contentBorder lipgloss.Border
+ var borderColor lipgloss.TerminalColor
+
+ if p.isViewportFocus {
+ contentBorder = lipgloss.DoubleBorder()
+ borderColor = styles.Blue
+ } else {
+ contentBorder = lipgloss.RoundedBorder()
+ borderColor = styles.Flamingo
+ }
+
+ contentStyle := lipgloss.NewStyle().
+ MarginTop(1).
+ Padding(0, 1).
+ Border(contentBorder).
+ BorderForeground(borderColor)
+
+ if p.isViewportFocus {
+ contentStyle = contentStyle.BorderBackground(styles.Surface0)
+ }
+
+ contentFinal := contentStyle.Render(p.contentViewPort.View())
+
return lipgloss.JoinVertical(
lipgloss.Top,
headerContent,
- formattedDiff,
+ contentFinal,
form,
)
diff --git a/internal/tui/tui.go b/internal/tui/tui.go
index 97f876a2d..8785b5ab2 100644
--- a/internal/tui/tui.go
+++ b/internal/tui/tui.go
@@ -123,8 +123,6 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
a.status, _ = a.status.Update(msg)
case util.ErrorMsg:
a.status, _ = a.status.Update(msg)
- case util.ClearStatusMsg:
- a.status, _ = a.status.Update(msg)
case tea.KeyMsg:
if a.editorMode == vimtea.ModeNormal {
switch {
@@ -163,16 +161,21 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
}
}
+
+ var cmds []tea.Cmd
+ s, cmd := a.status.Update(msg)
+ a.status = s
+ cmds = append(cmds, cmd)
if a.dialogVisible {
d, cmd := a.dialog.Update(msg)
a.dialog = d.(core.DialogCmp)
- return a, cmd
+ cmds = append(cmds, cmd)
+ return a, tea.Batch(cmds...)
}
- s, _ := a.status.Update(msg)
- a.status = s
p, cmd := a.pages[a.currentPage].Update(msg)
a.pages[a.currentPage] = p
- return a, cmd
+ cmds = append(cmds, cmd)
+ return a, tea.Batch(cmds...)
}
func (a *appModel) ToggleHelp() {