Improve table resizing, add terminal workaround, and expose last check.

This commit is contained in:
Overlord committed 2026-10-14 12:37:27 +02:00
1 parent a19e6fa711
commit f2ea1297e8
6 files changed
+43 -5

No files matched your search

+20 -1
View File
@@ -5,10 +5,13 @@ import (
"errors"
"io"
"log/slog"
"os"
"os/signal"
"strings"
"syscall"
tea "charm.land/bubbletea/v2"
"github.com/charmbracelet/colorprofile"
"git.security-command.org/Overlord/dibs/internal/config"
"git.security-command.org/Overlord/dibs/internal/tui"
@@ -26,7 +29,7 @@ func runTUI(cfg *config.Config, stderr io.Writer) int {
w, err := newWatcher(ctx, cfg, logger, slog.LevelDebug)
if err != nil { return fail(stderr, "watch", err) }
p := tea.NewProgram(tui.New(w, cfg.Path, logs), tea.WithContext(ctx))
p := tea.NewProgram(tui.New(w, cfg.Path, logs), append(terminalOptions(), tea.WithContext(ctx))...)
done := make(chan struct{})
go func() {
@@ -46,3 +49,19 @@ func runTUI(cfg *config.Config, stderr io.Writer) int {
return 0
}
// terminalOptions works around terminals that claim to be xterm but are not.
// Under a TERM the renderer does not know, it redraws with plain writes only.
// The color profile is detected from the real environment first, so colors stay.
func terminalOptions() []tea.ProgramOption {
if os.Getenv("TERMINAL_EMULATOR") != "JetBrains-JediTerm" { return nil }
profile := colorprofile.Detect(os.Stdout, os.Environ())
env := []string{"TERM=jediterm"}
for _, kv := range os.Environ() {
if !strings.HasPrefix(kv, "TERM=") { env = append(env, kv) }
}
return []tea.ProgramOption{tea.WithEnvironment(env), tea.WithColorProfile(profile)}
}