switzerland

package module
v0.0.0-...-baff755 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2021 License: MIT Imports: 3 Imported by: 1

README

SIGWINCH compatibility wrapper

It's called Switzerland because only Windows really needs this, so it's WinCH. Do you like my puns?

It enables an application to use an os.Signal-like interface to be notified when the terminal window has been resized.

  • On Unix-like systems:
    • It binds a SIGWINCH handler as usual
  • On Windows:
    • It polls the window size regularly and notifies when a change is detected

Usage

Sample usage without this library - works only on Unix-like systems:

winch := make(chan os.Signal)
signal.Notify(winch, syscall.SIGWINCH)
defer signal.Stop(winch)
defer close(winch)

Sample usage with this library - multiplatform, works on Unix and Windows:

winch := make(chan switzerland.WinchSignal)
switz := switzerland.GetSwitzerland()
switz.Notify(winch)
defer switz.Stop(winch)
defer close(winch)

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Switzerland

type Switzerland interface {
	Notify(chan<- WinchSignal)
	Stop(chan<- WinchSignal)
}

func GetSwitzerland

func GetSwitzerland() Switzerland

type WinchSignal

type WinchSignal = os.Signal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL