Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion internal/tui/transitions/flip_right.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package transitions

import (
"log/slog"
"math"
"strings"
"time"
Expand Down Expand Up @@ -67,7 +68,8 @@ func (t flipRight) View(prev string, next string) string {

// assert that slides are always equal height
if len(nextLines) != len(prevLines) {
panic("Slides of not equal height")
slog.Error("Slides of not equal height")
return next
}

for i := range nextLines {
Expand Down
4 changes: 3 additions & 1 deletion internal/tui/transitions/swipe_left.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package transitions

import (
"log/slog"
"math"
"strings"
"time"
Expand Down Expand Up @@ -68,7 +69,8 @@ func (t swipeLeft) View(prev string, next string) string {

// assert that slides are always equal height
if len(nextLines) != len(prevLines) {
panic("Slides of not equal height")
slog.Error("Slides of not equal height")
return next
}

for i := range nextLines {
Expand Down
4 changes: 3 additions & 1 deletion internal/tui/transitions/swipe_right.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package transitions

import (
"log/slog"
"math"
"strings"
"time"
Expand Down Expand Up @@ -68,7 +69,8 @@ func (t swipeRight) View(prev string, next string) string {

// assert that slides are always equal height
if len(nextLines) != len(prevLines) {
panic("Slides of not equal height")
slog.Error("Slides of not equal height")
return next
}

for i := range nextLines {
Expand Down
26 changes: 26 additions & 0 deletions internal/tui/tui.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package tui

import (
"fmt"
"log/slog"
"strings"

"github.com/charmbracelet/bubbles/help"
"github.com/charmbracelet/bubbles/key"
Expand Down Expand Up @@ -349,6 +351,12 @@ func (m model) View() string {
),
)

lines := strings.Split(slideView, "\n")
if len(lines) > m.height {
fmt.Print("\x1b_Ga=d\x1b\\")
return m.exceedScreenSizeView()
}

if m.command != nil && m.command.IsShowing() {
return m.command.Show(slideView, m.width, m.height)
}
Expand All @@ -372,3 +380,21 @@ func (m model) View() string {
func (m model) GetSyncServer() *SyncServer {
return m.syncServer
}

func (m model) exceedScreenSizeView() string {
return lipgloss.Place(
m.width,
m.height,
lipgloss.Center,
lipgloss.Center,
lipgloss.NewStyle().
Width(m.width-2).
Height(m.height-2).
Border(lipgloss.RoundedBorder()).
BorderForeground(lipgloss.Color("1")).
Foreground(lipgloss.Color("9")).
Bold(true).
Align(lipgloss.Center, lipgloss.Center).
Render("Unable to render slide: content exceeds terminal size."),
)
}