input

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: MIT Imports: 5 Imported by: 2

README

hexes event listener

Read the ECMA-48 standard

Documentation

Index

Constants

View Source
const (
	ESCAPE        rune = 27
	CSI           rune = '['
	ENTER         rune = 10
	BACKSPACE     rune = 127
	TAB           rune = 9
	KEY_UP        rune = -2
	KEY_DOWN      rune = -3
	KEY_LEFT      rune = -4
	KEY_RIGHT     rune = -5
	KEY_INSERT    rune = -6
	KEY_HOME      rune = -7
	KEY_PAGE_UP   rune = -8
	KEY_PAGE_DOWN rune = -9
	KEY_DELETE    rune = -10
	KEY_END       rune = -11
	KEY_F1        rune = -12
	KEY_F2        rune = -13
	KEY_F3        rune = -14
	KEY_F4        rune = -15
	KEY_F5        rune = -16
	KEY_F6        rune = -17
	KEY_F7        rune = -18
	KEY_F8        rune = -19
	KEY_F9        rune = -20
	KEY_F10       rune = -21
	KEY_F11       rune = -22
	KEY_F12       rune = -23
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	EventType EventType
	Chr       rune
	X         int
	Y         int
}

Represents an event. KeyPressed events have the Chr populated with the pressed key, while mouse events use the X and Y field to show the location (0 indexed).

type EventType added in v0.4.0

type EventType int
const (
	KeyPressed EventType = iota
	MouseMove
	MouseLeftClick
	MouseLeftRelease
	MouseRightClick
	MouseRightRelease
	MouseMiddleClick
	MouseMiddleRelease
	ScrollUp
	ScrollDown
	Unknown
)

type Listener

type Listener struct {
	// contains filtered or unexported fields
}

Allows to listen for Events given by the user, like keypresses.

func New

func New(in io.Reader) *Listener

Creates a new Listener from the given reader (e.g. os.Stdin)

func (*Listener) DisableMouseTracking

func (l *Listener) DisableMouseTracking(out io.Writer)

Ends the support for mouse events, necessary before exiting the program.

func (*Listener) EnableMouseTracking

func (l *Listener) EnableMouseTracking(out io.Writer)

Enables the listener to listen to mouse events. Don't forget to DisableMouseTracking when finished, or the terminal will be broken afterwards.

func (*Listener) GetEvent

func (l *Listener) GetEvent() *Event

Blockingly waits for an event

Jump to

Keyboard shortcuts

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