package uv

import (
	
	

	
)

// SizeNotifier represents a notifier that listens for window size
// changes using the SIGWINCH signal and notifies the given channel.
type SizeNotifier struct {
	// Channel that receives terminal size change notifications.
	C <-chan os.Signal

	f   term.File
	sig chan os.Signal
	m   sync.Mutex
}

// NewSizeNotifier creates a new [SizeNotifier] that listens for window size
// changes on the given TTY file through SIGWINCH signals.
func ( term.File) *SizeNotifier {
	if  == nil {
		panic("no file set")
	}
	 := make(chan os.Signal)
	return &SizeNotifier{
		f:   ,
		sig: ,
		C:   ,
	}
}

// Start starts listening for window size changes and notifies [SizeNotifier.C]
// about any changes.
func ( *SizeNotifier) () error {
	return .start()
}

// Stop stops the notifier and cleans up resources.
func ( *SizeNotifier) () error {
	return .stop()
}

// GetWindowSize returns the current size of the terminal window.
func ( *SizeNotifier) () ( Size,  Size,  error) {
	return .getWindowSize()
}

// GetSize returns the current cell size of the terminal window.
func ( *SizeNotifier) () (,  int,  error) {
	.m.Lock()
	defer .m.Unlock()

	, ,  = term.GetSize(.f.Fd())
	if  != nil {
		return 0, 0,  //nolint:wrapcheck
	}

	return , , nil
}