github.com/oweisse/u-root@v0.0.0-20181109060735-d005ad25fef1/cmds/elvish/edit/tty/event.go (about)

     1  package tty
     2  
     3  import "github.com/u-root/u-root/cmds/elvish/edit/ui"
     4  
     5  // Event represents an event that can be read from the terminal.
     6  type Event interface {
     7  	isEvent()
     8  }
     9  
    10  // KeyEvent represents a key press.
    11  type KeyEvent ui.Key
    12  
    13  // MouseEvent represents a mouse event (either pressing or releasing).
    14  type MouseEvent struct {
    15  	Pos
    16  	Down bool
    17  	// Number of the Button, 0-based. -1 for unknown.
    18  	Button int
    19  	Mod    ui.Mod
    20  }
    21  
    22  // RawRune represents a rune read in raw mode.
    23  type RawRune rune
    24  
    25  // CursorPosition represents a report of the current cursor position from the
    26  // terminal driver, usually as a response from a cursor position request.
    27  type CursorPosition Pos
    28  
    29  // PasteSetting indicates the start or finish of pasted text.
    30  type PasteSetting bool
    31  
    32  // FatalErrorEvent represents an error that affects the Reader's ability to
    33  // continue reading events. After sending a FatalError, the Reader makes no more
    34  // attempts at continuing to read events and wait for Stop to be called.
    35  type FatalErrorEvent struct{ Err error }
    36  
    37  // NonfatalErrorEvent represents an error that can be gradually recovered. After
    38  // sending a NonfatalError, the Reader will continue to read events. Note that
    39  // one anamoly in the terminal might cause multiple NonfatalError events to be
    40  // sent.
    41  type NonfatalErrorEvent struct{ Err error }
    42  
    43  func (KeyEvent) isEvent()   {}
    44  func (MouseEvent) isEvent() {}
    45  
    46  func (RawRune) isEvent()        {}
    47  func (CursorPosition) isEvent() {}
    48  func (PasteSetting) isEvent()   {}
    49  
    50  func (FatalErrorEvent) isEvent()    {}
    51  func (NonfatalErrorEvent) isEvent() {}