works now

This commit is contained in:
Robin Olsen
2026-03-18 11:58:31 +01:00
parent 40d25cc716
commit 3e9a903506
24 changed files with 154 additions and 99 deletions

View File

@@ -50,7 +50,7 @@ func newIntroModel() introModel {
key.WithHelp("enter", "start survey"),
),
Continue: key.NewBinding(
key.WithKeys(" ", "j", "l", "down", "right"),
key.WithKeys("space", "j", "l", "down", "right"),
key.WithHelp("space", "continue"),
),
Back: key.NewBinding(
@@ -69,11 +69,11 @@ func newIntroModel() introModel {
}
func (m introModel) Run() error {
model, err := tea.NewProgram(m, tea.WithAltScreen()).Run()
model, err := tea.NewProgram(m).Run()
if err != nil {
return err
}
if m, ok := model.(introModel); ok && m.userQuit {
if im, ok := model.(introModel); ok && im.userQuit {
return models.ErrUserQuit
}
return nil
@@ -87,7 +87,7 @@ func (m introModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.WindowSizeMsg:
m.SetSize(msg.Width, msg.Height)
case tea.KeyMsg:
case tea.KeyPressMsg:
switch {
case key.Matches(msg, m.keys.Start) && m.stage == stages:
return m, tea.Quit
@@ -109,10 +109,13 @@ func (m introModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, nil
}
func (m introModel) View() string {
func (m introModel) View() tea.View {
if m.width < 55 || m.height < 16 {
return lipgloss.Place(m.width, m.height, lipgloss.Center, lipgloss.Center,
content := lipgloss.Place(m.width, m.height, lipgloss.Center, lipgloss.Center,
style.TextStyle.Render("Terminal too small."))
v := tea.NewView(content)
v.AltScreen = true
return v
}
var content string
@@ -122,7 +125,7 @@ func (m introModel) View() string {
case 2:
content = Disclaimer
default:
return ""
return tea.NewView("")
}
boxWidth := min(m.width-10, 120)
@@ -149,7 +152,9 @@ func (m introModel) View() string {
final := lipgloss.Place(m.width, m.height, lipgloss.Center, lipgloss.Center, b.String())
return final
v := tea.NewView(final)
v.AltScreen = true
return v
}
func (m *introModel) SetSize(width, height int) {

View File

@@ -14,7 +14,7 @@ func newIntroQuestionnaire() *IntroQuestionnaire {
func (iq *IntroQuestionnaire) Run() (map[string]any, error) {
model := task.NewQuestionnaireModel(iq.Questions(), iq.Keys())
app := tea.NewProgram(model, tea.WithAltScreen())
app := tea.NewProgram(model)
m, err := app.Run()
if err != nil {

View File

@@ -11,6 +11,7 @@ import (
"github.com/LazyBachelor/LazyPM/cmd/pm/tasks"
"github.com/LazyBachelor/LazyPM/internal/commands/survey"
"github.com/LazyBachelor/LazyPM/internal/storage"
"github.com/LazyBachelor/LazyPM/internal/style"
"github.com/LazyBachelor/LazyPM/pkg/task"
"github.com/spf13/cobra"
)
@@ -54,7 +55,7 @@ func runStartCmd(cmd *cobra.Command, args []string) error {
Title("Do you want to continue without submitting your responses?").
Description("You can fix your database connection and submit your responses later with the submit command.").
Value(&continueWithoutSubmitting).
WithTheme(huh.ThemeBase16(true)).
WithTheme(style.Base16Theme{}).
RunAccessible(cmd.OutOrStdout(), cmd.InOrStdin()); err != nil {
return fmt.Errorf("failed to read user input: %w", err)
}