d247b19608
Move the Go TUI from github.com/charmbracelet/{bubbletea,lipgloss} to the v2
ecosystem at charm.land/{bubbletea,lipgloss}/v2 (Go 1.25). v2's kitty keyboard
disambiguation is on by default, so Shift+Enter now reliably inserts a newline
in the composer (Ctrl+J / Alt+Enter kept as fallbacks for non-kitty terminals).
Approach: rather than rewrite ~190 key-match sites to v2's (Code, Mod) idiom, a
small shim (internal/app/key.go) converts a v2 KeyPressMsg into the v1-shaped
keyMsg the handlers already expect, at the single Update boundary. The rest is
mechanical:
- key constants tea.Key* → shim consts; tea.KeyMsg → keyMsg.
- lipgloss.Color is now a func returning color.Color, not a type → fields/params
retyped to image/color.Color (theme/diff/overlays/view).
- v2 View() returns tea.View: render() builds the string, View() wraps it and
carries AltScreen (alt-screen is a per-frame View field now, not a program opt).
- WithWhitespaceBackground/Foreground → WithWhitespaceStyle(Style).
- preview: drop lipgloss.SetColorProfile (v2 renders truecolor by default).
Build, vet, gofmt, and the full test suite are green; preview renders truecolor
across kinds.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
43 lines
1021 B
Go
43 lines
1021 B
Go
// Command tui is the correx terminal UI: a Bubble Tea client that speaks the
|
|
// correx WebSocket protocol to apps/server.
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
|
|
tea "charm.land/bubbletea/v2"
|
|
"github.com/correx/tui-go/internal/app"
|
|
"github.com/correx/tui-go/internal/ws"
|
|
)
|
|
|
|
func main() {
|
|
host := flag.String("host", "localhost", "server host")
|
|
port := flag.Int("port", 8080, "server port")
|
|
flag.Parse()
|
|
|
|
if path := os.Getenv("CORREX_TUI_LOG"); path != "" {
|
|
f, err := tea.LogToFile(path, "tui")
|
|
if err != nil {
|
|
fmt.Fprintln(os.Stderr, "correx tui: cannot open log file:", err)
|
|
os.Exit(1)
|
|
}
|
|
defer f.Close()
|
|
app.EnableDebugLog()
|
|
}
|
|
|
|
client := ws.New(*host, *port)
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
defer cancel()
|
|
go client.Run(ctx)
|
|
|
|
// Alt-screen is requested per-frame via the View's AltScreen field in v2.
|
|
p := tea.NewProgram(app.NewModel(client))
|
|
if _, err := p.Run(); err != nil {
|
|
fmt.Fprintln(os.Stderr, "correx tui error:", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|