okami.mom/ultraviolet

git clone https://git.nkp.pet/okami.mom/ultraviolet

Ayman Bagabasfeat: add cross-platform console I/O interface (#78)6ea2266

upstream
1.3 KiB42 linesraw
1package uv
2
3import (
4	"context"
5	"os"
6)
7
8// OpenTTY opens the terminal's input and output file descriptors.
9// It returns the input and output files, or an error if the terminal is not
10// available.
11//
12// This is useful for applications that need to interact with the terminal
13// directly while piping or redirecting input/output.
14func OpenTTY() (inTty, outTty *os.File, err error) {
15	return openTTY()
16}
17
18// Suspend suspends the current process group.
19func Suspend() error {
20	return suspend()
21}
22
23// NotifyWinch sets up a channel to receive window size change signals and any
24// other signals needed. This is a drop-in replacement for os/signal.Notify to
25// ensure that SIGWINCH is included.
26//
27// On Windows, this will be a no-op for SIGWINCH, but other signals may still
28// be handled.
29func NotifyWinch(c chan os.Signal, sigs ...os.Signal) {
30	notifyWinch(c, sigs...)
31}
32
33// NotifyWinchContext sets up a channel to receive window size change signals
34// and any other signals needed, with context cancellation support. This is a
35// drop-in replacement for os/signal.NotifyContext to ensure that SIGWINCH is
36// included.
37//
38// On Windows, this will be a no-op for SIGWINCH, but other signals may still
39// be handled.
40func NotifyWinchContext(ctx context.Context, sigs ...os.Signal) (context.Context, context.CancelFunc) {
41	return notifyWinchContext(ctx, sigs...)
42}