diff --git a/internal/tui/transitions/flip_right.go b/internal/tui/transitions/flip_right.go index 77a904f..a8a12c7 100644 --- a/internal/tui/transitions/flip_right.go +++ b/internal/tui/transitions/flip_right.go @@ -1,6 +1,7 @@ package transitions import ( + "log/slog" "math" "strings" "time" @@ -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 { diff --git a/internal/tui/transitions/swipe_left.go b/internal/tui/transitions/swipe_left.go index c858662..bf9e525 100644 --- a/internal/tui/transitions/swipe_left.go +++ b/internal/tui/transitions/swipe_left.go @@ -1,6 +1,7 @@ package transitions import ( + "log/slog" "math" "strings" "time" @@ -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 { diff --git a/internal/tui/transitions/swipe_right.go b/internal/tui/transitions/swipe_right.go index a62fd73..e61b55c 100644 --- a/internal/tui/transitions/swipe_right.go +++ b/internal/tui/transitions/swipe_right.go @@ -1,6 +1,7 @@ package transitions import ( + "log/slog" "math" "strings" "time" @@ -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 { diff --git a/internal/tui/tui.go b/internal/tui/tui.go index 51790b4..b0a3b55 100644 --- a/internal/tui/tui.go +++ b/internal/tui/tui.go @@ -1,7 +1,9 @@ package tui import ( + "fmt" "log/slog" + "strings" "github.com/charmbracelet/bubbles/help" "github.com/charmbracelet/bubbles/key" @@ -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) } @@ -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."), + ) +}