nt

A sensible note-taking program
git clone git://git.laack.co/nt.git
Log | Files | Refs | README

primitive.go (2905B)


      1 package tview
      2 
      3 import "github.com/gdamore/tcell/v2"
      4 
      5 // Primitive is the top-most interface for all graphical primitives.
      6 type Primitive interface {
      7 	// Draw draws this primitive onto the screen. Implementers can call the
      8 	// screen's ShowCursor() function but should only do so when they have focus.
      9 	// (They will need to keep track of this themselves.)
     10 	Draw(screen tcell.Screen)
     11 
     12 	// GetRect returns the current position of the primitive, x, y, width, and
     13 	// height.
     14 	GetRect() (int, int, int, int)
     15 
     16 	// SetRect sets a new position of the primitive.
     17 	SetRect(x, y, width, height int)
     18 
     19 	// InputHandler returns a handler which receives key events when it has focus.
     20 	// It is called by the Application class.
     21 	//
     22 	// A value of nil may also be returned, in which case this primitive cannot
     23 	// receive focus and will not process any key events.
     24 	//
     25 	// The handler will receive the key event and a function that allows it to
     26 	// set the focus to a different primitive, so that future key events are sent
     27 	// to that primitive.
     28 	//
     29 	// The Application's Draw() function will be called automatically after the
     30 	// handler returns.
     31 	//
     32 	// The Box class provides functionality to intercept keyboard input. If you
     33 	// subclass from Box, it is recommended that you wrap your handler using
     34 	// Box.WrapInputHandler() so you inherit that functionality.
     35 	InputHandler() func(event *tcell.EventKey, setFocus func(p Primitive))
     36 
     37 	// Focus is called by the application when the primitive receives focus.
     38 	// Implementers may call delegate() to pass the focus on to another primitive.
     39 	Focus(delegate func(p Primitive))
     40 
     41 	// HasFocus determines if the primitive has focus. This function must return
     42 	// true also if one of this primitive's child elements has focus.
     43 	HasFocus() bool
     44 
     45 	// Blur is called by the application when the primitive loses focus.
     46 	Blur()
     47 
     48 	// MouseHandler returns a handler which receives mouse events.
     49 	// It is called by the Application class.
     50 	//
     51 	// A value of nil may also be returned to stop the downward propagation of
     52 	// mouse events.
     53 	//
     54 	// The Box class provides functionality to intercept mouse events. If you
     55 	// subclass from Box, it is recommended that you wrap your handler using
     56 	// Box.WrapMouseHandler() so you inherit that functionality.
     57 	MouseHandler() func(action MouseAction, event *tcell.EventMouse, setFocus func(p Primitive)) (consumed bool, capture Primitive)
     58 
     59 	// PasteHandler returns a handler which receives pasted text.
     60 	// It is called by the Application class.
     61 	//
     62 	// A value of nil may also be returned to stop the downward propagation of
     63 	// paste events.
     64 	//
     65 	// The Box class may provide functionality to intercept paste events in the
     66 	// future. If you subclass from Box, it is recommended that you wrap your
     67 	// handler using Box.WrapPasteHandler() so you inherit that functionality.
     68 	PasteHandler() func(text string, setFocus func(p Primitive))
     69 }