zot/packages/tui/resize_unix.go
patriceckhart fa7d8d8be5 refactor: split source into packages/{provider,core,tui,agent}
Single Go module, four top-level packages under packages/. Import
paths become github.com/patriceckhart/zot/packages/<name>; downstream
consumers can depend on individual packages without pulling the rest.

Layout:
  packages/provider/     LLM clients + catalog
  packages/provider/auth/ credential store + OAuth + login server
  packages/core/         agent loop, sessions, cost
  packages/tui/          terminal toolkit + chat view
  packages/agent/        CLI wiring, system prompt
    extensions/ extproto/ modes/ tools/ skills/ swarm/
    sdk/  (was pkg/zotcore, package renamed zotcore -> sdk)
    ext/  (was pkg/zotext, package renamed zotext -> ext)

internal/ and pkg/ removed. The internal/assets logo moved into
packages/provider/auth/assets.

Public Go SDK identifiers renamed:
  pkg/zotcore (package zotcore) -> packages/agent/sdk (package sdk)
  pkg/zotext  (package zotext)  -> packages/agent/ext (package ext)

This breaks Go-based extensions and embedders; the JSON wire protocol
for extensions and RPC is unchanged, so non-Go extensions, already-
built extension binaries, and zot rpc consumers are unaffected.

Docs, examples, and the built-in write-zot-extension skill updated
for the new paths and identifiers. Shadow-bug fixes in code samples
(ext := ext.New -> e := ext.New).
2026-05-27 09:07:15 +02:00

58 lines
1.3 KiB
Go

//go:build !windows
package tui
import (
"os"
"os/signal"
"syscall"
"time"
"golang.org/x/sys/unix"
)
func (p *ProcTerm) installResizeHandler() {
ch := make(chan os.Signal, 1)
signal.Notify(ch, syscall.SIGWINCH)
go func() {
for range ch {
for _, cb := range p.resizeCBs {
cb()
}
}
}()
}
func (p *ProcTerm) SetNonblock(enable bool) error {
return syscall.SetNonblock(int(p.in.Fd()), enable)
}
// peekStdin polls the stdin fd for up to d; if a byte is ready, reads
// and returns it. Returns (0, false, nil) on timeout.
//
// Uses golang.org/x/sys/unix so the syscall signatures line up on both
// linux (syscall.Select returns (int, error), Timeval.Usec is int64)
// and darwin (Select returns error only, Timeval.Usec is int32) —
// pulling this through the x/sys wrappers makes both builds happy.
func peekStdin(in *os.File, d time.Duration) (byte, bool, error) {
fd := int(in.Fd())
var rset unix.FdSet
rset.Set(fd)
tv := unix.NsecToTimeval(int64(d))
_, err := unix.Select(fd+1, &rset, nil, nil, &tv)
if err != nil {
if err == unix.EINTR {
return 0, false, nil
}
return 0, false, err
}
if !rset.IsSet(fd) {
return 0, false, nil
}
var b [1]byte
_, rerr := in.Read(b[:])
if rerr != nil {
return 0, false, rerr
}
return b[0], true, nil
}