Documentation ¶
Index ¶
- Constants
- type Alignment
- type Application
- func (app *Application) PostFunc(fn func())
- func (app *Application) Quit()
- func (app *Application) Refresh()
- func (app *Application) Run() error
- func (app *Application) SetRootWidget(widget Widget)
- func (app *Application) SetScreen(scr tcell.Screen)
- func (app *Application) SetStyle(style tcell.Style)
- func (app *Application) Start()
- func (app *Application) Update()
- func (app *Application) Wait() error
- type BoxLayout
- func (b *BoxLayout) AddWidget(widget Widget, fill float64)
- func (b *BoxLayout) Draw()
- func (b *BoxLayout) HandleEvent(ev tcell.Event) bool
- func (b *BoxLayout) InsertWidget(index int, widget Widget, fill float64)
- func (b *BoxLayout) RemoveWidget(widget Widget)
- func (b *BoxLayout) Resize()
- func (b *BoxLayout) SetOrientation(orient Orientation)
- func (b *BoxLayout) SetStyle(style tcell.Style)
- func (b *BoxLayout) SetView(view View)
- func (b *BoxLayout) Size() (int, int)
- func (b *BoxLayout) Widgets() []Widget
- type CellModel
- type CellView
- func (a *CellView) Draw()
- func (a *CellView) HandleEvent(e tcell.Event) bool
- func (a *CellView) Init()
- func (a *CellView) MakeCursorVisible()
- func (a *CellView) MakeVisible(x, y int)
- func (a *CellView) Resize()
- func (a *CellView) SetCursor(x, y int)
- func (a *CellView) SetCursorX(x int)
- func (a *CellView) SetCursorY(y int)
- func (a *CellView) SetModel(model CellModel)
- func (a *CellView) SetStyle(s tcell.Style)
- func (a *CellView) SetView(view View)
- func (a *CellView) Size() (int, int)
- type EventWidget
- type EventWidgetContent
- type EventWidgetMove
- type EventWidgetResize
- type Orientation
- type Panel
- type SimpleStyledText
- type SimpleStyledTextBar
- func (s *SimpleStyledTextBar) Init()
- func (s *SimpleStyledTextBar) RegisterCenterStyle(r rune, style tcell.Style)
- func (s *SimpleStyledTextBar) RegisterLeftStyle(r rune, style tcell.Style)
- func (s *SimpleStyledTextBar) RegisterRightStyle(r rune, style tcell.Style)
- func (s *SimpleStyledTextBar) SetCenter(m string)
- func (s *SimpleStyledTextBar) SetLeft(m string)
- func (s *SimpleStyledTextBar) SetRight(m string)
- func (s *SimpleStyledTextBar) Size() (int, int)
- type Spacer
- type Text
- func (t *Text) Alignment() Alignment
- func (t *Text) Draw()
- func (t *Text) HandleEvent(tcell.Event) bool
- func (t *Text) Resize()
- func (t *Text) SetAlignment(align Alignment)
- func (t *Text) SetStyle(style tcell.Style)
- func (t *Text) SetStyleAt(pos int, style tcell.Style)
- func (t *Text) SetText(s string)
- func (t *Text) SetView(view View)
- func (t *Text) Size() (int, int)
- func (t *Text) Style() tcell.Style
- func (t *Text) StyleAt(pos int) tcell.Style
- func (t *Text) Text() string
- type TextArea
- type TextBar
- func (t *TextBar) Draw()
- func (t *TextBar) HandleEvent(ev tcell.Event) bool
- func (t *TextBar) Resize()
- func (t *TextBar) SetCenter(s string, style tcell.Style)
- func (t *TextBar) SetLeft(s string, style tcell.Style)
- func (t *TextBar) SetRight(s string, style tcell.Style)
- func (t *TextBar) SetStyle(style tcell.Style)
- func (t *TextBar) SetView(view View)
- func (t *TextBar) Size() (int, int)
- type View
- type ViewPort
- func (v *ViewPort) Center(x, y int)
- func (v *ViewPort) Clear()
- func (v *ViewPort) Fill(ch rune, style tcell.Style)
- func (v *ViewPort) GetContentSize() (int, int)
- func (v *ViewPort) GetPhysical() (int, int, int, int)
- func (v *ViewPort) GetVisible() (int, int, int, int)
- func (v *ViewPort) MakeVisible(x, y int)
- func (v *ViewPort) Reset()
- func (v *ViewPort) Resize(x, y, width, height int)
- func (v *ViewPort) ScrollDown(rows int)
- func (v *ViewPort) ScrollLeft(cols int)
- func (v *ViewPort) ScrollRight(cols int)
- func (v *ViewPort) ScrollUp(rows int)
- func (v *ViewPort) SetContent(x, y int, ch rune, comb []rune, s tcell.Style)
- func (v *ViewPort) SetContentSize(width, height int, locked bool)
- func (v *ViewPort) SetSize(width, height int)
- func (v *ViewPort) SetView(view View)
- func (v *ViewPort) Size() (int, int)
- func (v *ViewPort) ValidateView()
- func (v *ViewPort) ValidateViewX()
- func (v *ViewPort) ValidateViewY()
- type Widget
- type WidgetWatchers
- func (ww *WidgetWatchers) PostEvent(wev EventWidget)
- func (ww *WidgetWatchers) PostEventWidgetContent(w Widget)
- func (ww *WidgetWatchers) PostEventWidgetMove(w Widget)
- func (ww *WidgetWatchers) PostEventWidgetResize(w Widget)
- func (ww *WidgetWatchers) Unwatch(handler tcell.EventHandler)
- func (ww *WidgetWatchers) Watch(handler tcell.EventHandler)
Constants ¶
const ( // AlignBegin indicates alignment at the top left corner. AlignBegin = HAlignLeft | VAlignTop // AlignEnd indicates alignment at the bottom right corner. AlignEnd = HAlignRight | VAlignBottom // AlignMiddle indicates full centering. AlignMiddle = HAlignCenter | VAlignCenter )
const ( // Horizontal indicates left to right orientation. Horizontal = iota // Vertical indicates top to bottom orientation. Vertical )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Alignment ¶
type Alignment int
Alignment represents the alignment of an object, and consists of either or both of horizontal and vertical alignment.
const ( // HAlignLeft indicates alignment on the left edge. HAlignLeft Alignment = 1 << iota // HAlignCenter indicates horizontally centered. HAlignCenter // HAlignRight indicates alignment on the right edge. HAlignRight // VAlignTop indicates alignment on the top edge. VAlignTop // VAlignCenter indicates vertically centered. VAlignCenter // VAlignBottom indicates alignment on the bottom edge. VAlignBottom )
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
Application represents an event-driven application running on a screen.
func (*Application) PostFunc ¶
func (app *Application) PostFunc(fn func())
PostFunc posts a function to be executed in the context of the application's event loop. Functions that need to update displayed state, etc. can do this to avoid holding locks.
func (*Application) Quit ¶
func (app *Application) Quit()
Quit causes the application to shutdown gracefully. It does not wait for the application to exit, but returns immediately.
func (*Application) Refresh ¶
func (app *Application) Refresh()
Refresh causes the application forcibly redraw everything. Use this to clear up screen corruption, etc.
func (*Application) Run ¶
func (app *Application) Run() error
Run runs the application, waiting until the application loop exits. It is equivalent to app.Start() followed by app.Wait()
func (*Application) SetRootWidget ¶
func (app *Application) SetRootWidget(widget Widget)
SetRootWidget sets the primary (root, main) Widget to be displayed.
func (*Application) SetScreen ¶
func (app *Application) SetScreen(scr tcell.Screen)
SetScreen sets the screen to use for the application. This must be done before the application starts to run or is initialized.
func (*Application) SetStyle ¶
func (app *Application) SetStyle(style tcell.Style)
SetStyle sets the default style (background) to be used for Widgets that have not specified any other style.
func (*Application) Start ¶
func (app *Application) Start()
Start starts the application loop, initializing the screen and starting the Event loop. The application will run in a goroutine until Quit is called.
func (*Application) Update ¶
func (app *Application) Update()
Update asks the application to draw any screen updates that have not been drawn yet.
func (*Application) Wait ¶
func (app *Application) Wait() error
Wait waits until the application finishes.
type BoxLayout ¶
type BoxLayout struct { WidgetWatchers // contains filtered or unexported fields }
BoxLayout is a container Widget that lays out its child widgets in either a horizontal row or a vertical column.
func NewBoxLayout ¶
func NewBoxLayout(orient Orientation) *BoxLayout
NewBoxLayout creates an empty BoxLayout.
func (*BoxLayout) AddWidget ¶
AddWidget adds a widget to the end of the BoxLayout.
func (*BoxLayout) HandleEvent ¶
HandleEvent implements a tcell.EventHandler. The only events we care about are Widget change events from our children. We watch for those so that if the child changes, we can arrange to update our layout.
func (*BoxLayout) InsertWidget ¶
InsertWidget inserts a widget at the given offset. Offset 0 is the front. If the index is longer than the number of widgets, then it just gets appended to the end.
func (*BoxLayout) RemoveWidget ¶
RemoveWidget removes a Widget from the layout.
func (*BoxLayout) Resize ¶
func (b *BoxLayout) Resize()
Resize adjusts the layout when the underlying View changes size.
func (*BoxLayout) SetOrientation ¶
func (b *BoxLayout) SetOrientation(orient Orientation)
SetOrientation sets the orientation as either Horizontal or Vertical.
func (*BoxLayout) SetStyle ¶
SetStyle sets the style used.
func (*BoxLayout) SetView ¶
SetView sets the View object used for the text bar.
func (*BoxLayout) Size ¶
Size returns the preferred size in character cells (width, height).
type CellModel ¶
type CellModel interface { GetCell(x, y int) (rune, tcell.Style, []rune, int) GetBounds() (int, int) SetCursor(int, int) GetCursor() (int, int, bool, bool) MoveCursor(offx, offy int) }
CellModel models the content of a CellView. The dimensions used within a CellModel are always logical, and have origin 0, 0.
type CellView ¶
type CellView struct { WidgetWatchers // contains filtered or unexported fields }
CellView is a flexible view of a CellModel, offering both cursor management and a panning.
func (*CellView) HandleEvent ¶
HandleEvent handles events. In particular, it handles certain key events to move the cursor or pan the view.
func (*CellView) MakeCursorVisible ¶
func (a *CellView) MakeCursorVisible()
MakeCursorVisible ensures that the cursor is visible, panning the ViewPort as necessary, if the cursor is enabled.
func (*CellView) MakeVisible ¶
MakeVisible makes the given coordinates visible, if they are not already. It does this by moving the ViewPort for the CellView.
func (*CellView) Resize ¶
func (a *CellView) Resize()
Resize is called when the View is resized. It will ensure that the cursor is visible, if present.
func (*CellView) SetCursor ¶
SetCursor sets the the cursor position.
func (*CellView) SetCursorX ¶
SetCursorX sets the the cursor column.
func (*CellView) SetCursorY ¶
SetCursorY sets the the cursor row.
func (*CellView) SetModel ¶
SetModel sets the model for this CellView.
func (*CellView) SetStyle ¶
SetStyle sets the the default fill style.
type EventWidget ¶
EventWidget is an event delivered by a specific widget.
type EventWidgetContent ¶
type EventWidgetContent struct {
// contains filtered or unexported fields
}
EventWidgetContent is fired whenever a widget's content changes.
type EventWidgetMove ¶
type EventWidgetMove struct {
// contains filtered or unexported fields
}
EventWidgetMove is fired whenver a widget changes location.
type EventWidgetResize ¶
type EventWidgetResize struct {
// contains filtered or unexported fields
}
EventWidgetResize is fired whenever a widget is resized.
type Panel ¶
type Panel struct { BoxLayout // contains filtered or unexported fields }
Panel is a modified Layout that includes a primary content pane, prefixed with an optional title, and an optional menubar, and then suffixed by an optional status.
Only the content pane is resizable. The panel will be formatted like this:
+---------- | title | menu | content.... | <padding> | status +----------
Each of these components may be any valid widget; their names are only meant to be indicative of conventional use, not prescriptive.
func NewPanel ¶
func NewPanel() *Panel
NewPanel creates a new Panel. A zero valued panel can be created too.
func (*Panel) SetContent ¶
SetContent sets the Widget to display in the content area.
func (*Panel) SetMenu ¶
SetMenu sets the Widget to display in the menu area, which is just below the title.
func (*Panel) SetStatus ¶
SetStatus sets the Widget to display in the status area, which is at the bottom of the panel.
type SimpleStyledText ¶
type SimpleStyledText struct { Text // contains filtered or unexported fields }
SimpleStyledText is a form of Text that offers highlighting of the text using simple in-line markup. Its intention is to make it easier to mark up hot // keys for menubars, etc.
func NewSimpleStyledText ¶
func NewSimpleStyledText() *SimpleStyledText
NewSimpleStyledText creates an empty Text.
func (*SimpleStyledText) LookupStyle ¶
func (t *SimpleStyledText) LookupStyle(r rune) tcell.Style
LookupStyle returns the style registered for the given rune. Returns tcell.StyleDefault if no style was previously registered for the rune.
func (*SimpleStyledText) Markup ¶
func (t *SimpleStyledText) Markup() string
Markup returns the text that was set, including markup.
func (*SimpleStyledText) RegisterStyle ¶
func (t *SimpleStyledText) RegisterStyle(r rune, style tcell.Style)
Registers a style for the given rune. This style will be used for text marked with %<r>. See SetMarkup() for more detail. Note that this must be done before using any of the styles with SetMarkup(). Only letters may be used when registering styles, and be advised that the system may have predefined uses for upper case letters.
func (*SimpleStyledText) SetMarkup ¶
func (t *SimpleStyledText) SetMarkup(s string)
SetMarkup sets the text used for the string. It applies markup as follows (modeled on tcsh style prompt markup):
* %% - emit a single % in current style * %N - normal style * %A - alternate style * %S - start standout (reverse) style * %B - start bold style * %U - start underline style
Other styles can be set using %<rune>, if styles are registered. Upper case characters and punctuation are reserved for use by the system. Lower case are available for use by the user. (Users may define mappings for upper case letters to override system defined styles.)
Note that for simplicity, combining styles is not supported. By default the alternate style is the same as standout (reverse) mode.
Arguably we could have used Markdown syntax instead, but properly doing all of Markdown is not trivial, and these escape sequences make it clearer that we are not even attempting to do that.
type SimpleStyledTextBar ¶
type SimpleStyledTextBar struct { BoxLayout // contains filtered or unexported fields }
SimpleStyledTextBar is a Widget that provides a single line of text, but with distinct left, center, and right areas. Each of the areas can be styled differently, and can contain internal style markup. They align to the left, center, and right respectively. This is basically a convenience type on top SimpleStyledText and BoxLayout.
func NewSimpleStyledTextBar ¶
func NewSimpleStyledTextBar() *SimpleStyledTextBar
NewSimpleStyledTextBar creates an empty, initialized TextBar.
func (*SimpleStyledTextBar) Init ¶
func (s *SimpleStyledTextBar) Init()
Init prepares the widget for use, ensuring resources needed are allocated, etc.
func (*SimpleStyledTextBar) RegisterCenterStyle ¶
func (s *SimpleStyledTextBar) RegisterCenterStyle(r rune, style tcell.Style)
func (*SimpleStyledTextBar) RegisterLeftStyle ¶
func (s *SimpleStyledTextBar) RegisterLeftStyle(r rune, style tcell.Style)
func (*SimpleStyledTextBar) RegisterRightStyle ¶
func (s *SimpleStyledTextBar) RegisterRightStyle(r rune, style tcell.Style)
func (*SimpleStyledTextBar) SetCenter ¶
func (s *SimpleStyledTextBar) SetCenter(m string)
SetCenter sets the center text for the textbar. It is always centered.
func (*SimpleStyledTextBar) SetLeft ¶
func (s *SimpleStyledTextBar) SetLeft(m string)
SetLeft sets the left text for the textbar. It is always left-aligned.
func (*SimpleStyledTextBar) SetRight ¶
func (s *SimpleStyledTextBar) SetRight(m string)
SetRight sets the right text for the textbar. It is always right-aligned.
func (*SimpleStyledTextBar) Size ¶
func (s *SimpleStyledTextBar) Size() (int, int)
type Spacer ¶
type Spacer struct {
WidgetWatchers
}
Spacer is a Widget that occupies no visible real-estate. It is useful to add this to layouts when expansion space is required. It expands as needed with blank space.
func NewSpacer ¶
func NewSpacer() *Spacer
NewSpacer creates an empty Spacer. It's probably easier just to declare it directly.
func (*Spacer) HandleEvent ¶
HandleEvent implements a tcell.EventHandler, but does nothing.
func (*Spacer) SetView ¶
SetView sets the View object used for the text bar.
type Text ¶
type Text struct { WidgetWatchers // contains filtered or unexported fields }
Text is a Widget with containing a block of text, which can optionally be styled.
func (*Text) Alignment ¶
Alignment returns the alignment of the Text.
func (*Text) HandleEvent ¶
HandleEvent implements a tcell.EventHandler, but does nothing.
func (*Text) SetAlignment ¶
SetAlignment sets the alignment. Negative values indicate right justification, positive values are left, and zero indicates center aligned.
func (*Text) SetStyle ¶
SetStyle sets the style used. This applies to every cell in the in the text.
func (*Text) SetStyleAt ¶
SetStyleAt sets the style at the given rune index. Note that for strings containing combining characters, it is not possible to change the style at the position of the combining character, but those positions *do* count for calculating the index. A lot of complexity can be avoided by avoiding the use of combining characters.
func (*Text) SetText ¶
SetText sets the text used for the string. Any previously set styles on individual rune indices are reset, and the default style for the widget is set.
func (*Text) SetView ¶
SetView sets the View object used for the text bar.
func (*Text) Size ¶
Size returns the width and height in character cells of the Text.
func (*Text) Style ¶
Style returns the previously set default style. Note that individual characters may have different styles.
func (*Text) StyleAt ¶
StyleAt gets the style at the given rune index. If an invalid index is given, or the index is a combining character, then tcell.StyleDefault is returned.
type TextArea ¶
type TextArea struct { CellView // contains filtered or unexported fields }
TextArea is a pannable 2 dimensional text widget. It wraps both the view and the model for text in a single, convenient widget. Text is provided as an array of strings, each of which represents a single line to display. All text in the TextArea has the same style. An optional soft cursor is available.
func (*TextArea) EnableCursor ¶
EnableCursor enables a soft cursor in the TextArea.
func (*TextArea) HideCursor ¶
HideCursor hides or shows the cursor in the TextArea. If on is true, the cursor is hidden. Note that a cursor is only shown if it is enabled.
func (*TextArea) SetContent ¶
SetContent is used to set the textual content, passed as a single string. Lines within the string are delimited by newlines.
func (*TextArea) SetLines ¶
SetLines sets the content text to display.
type TextBar ¶
type TextBar struct { WidgetWatchers // contains filtered or unexported fields }
TextBar is a Widget that provides a single line of text, but with distinct left, center, and right areas. Each of the areas can be styled differently, and they align to the left, center, and right respectively. This is basically a convenience type on top Text and BoxLayout.
func (*TextBar) HandleEvent ¶
HandleEvent handles incoming events. The only events handled are those for the Text objects; when those change, the TextBar adjusts the layout to accommodate.
func (*TextBar) Resize ¶
func (t *TextBar) Resize()
Resize is called when the TextBar's View changes size, and updates the layout.
func (*TextBar) SetCenter ¶
SetCenter sets the center text for the textbar. The text is always center aligned.
func (*TextBar) SetLeft ¶
SetLeft sets the left text for the textbar. It is always left-aligned.
func (*TextBar) SetRight ¶
SetRight sets the right text for the textbar. It is always right-aligned.
func (*TextBar) SetStyle ¶
SetStyle is used to set a default style to use for the textbar, including areas where no text is present. Note that this will not change the text already displayed, so call this before changing or setting text.
func (*TextBar) SetView ¶
SetView sets the View drawing context for this TextBar.
type View ¶
type View interface { // SetContent is used to update the content of the View at the given // location. This will generally be called by the Draw() method of // a Widget. SetContent(x int, y int, ch rune, comb []rune, style tcell.Style) // Size represents the visible size. The actual content may be // larger or smaller. Size() (int, int) // Resize tells the View that its visible dimensions have changed. // It also tells it that it has a new offset relative to any parent // view. Resize(x, y, width, height int) // Fill fills the displayed content with the given rune and style. Fill(rune, tcell.Style) // Clear clears the content. Often just Fill(' ', tcell.StyleDefault) Clear() }
View represents a logical view on an area. It will have some underlying physical area as well, generally. Views are operated on by Widgets.
type ViewPort ¶
type ViewPort struct {
// contains filtered or unexported fields
}
ViewPort is an implementation of a View, that provides a smaller logical view of larger content area. For example, a scrollable window of text, the visible window would be the ViewPort, on the underlying content. ViewPorts have a two dimensional size, and a two dimensional offset.
In some ways, as the underlying content is not kept persistently by the view port, it can be thought perhaps a little more precisely as a clipping region.
func NewViewPort ¶
NewViewPort returns a new ViewPort (and hence also a View). The x and y coordinates are an offset relative to the parent. The origin 0,0 represents the upper left. The width and height indicate a width and height. If the value -1 is supplied, then the dimension is calculated from the parent.
func (*ViewPort) Center ¶
Center centers the point, if possible, in the View.
func (*ViewPort) Clear ¶
func (v *ViewPort) Clear()
Clear clears the displayed content, filling it with spaces of default text attributes.
func (*ViewPort) Fill ¶
Fill fills the displayed view port with the given character and style.
func (*ViewPort) GetContentSize ¶
GetContentSize returns the size of content as width, height in character cells.
func (*ViewPort) GetPhysical ¶
GetPhysical returns the upper left and lower right coordinates of the visible content in the coordinate space of the parent. This is may be the physical coordinates of the screen, if the screen is the view's parent.
func (*ViewPort) GetVisible ¶
GetVisible returns the upper left and lower right coordinates of the visible content. That is, it will return x1, y1, x2, y2 where the upper left cell is position x1, y1, and the lower right is x2, y2. These coordinates are in the space of the content, that is the content area uses coordinate 0,0 as its first cell position.
func (*ViewPort) MakeVisible ¶
MakeVisible moves the ViewPort the minimum necessary to make the given point visible. This should be called before any content is changed with SetContent, since otherwise it may be possible to move the location onto a region whose contents have been discarded.
func (*ViewPort) Reset ¶
func (v *ViewPort) Reset()
Reset resets the record of content, and also resets the offset back to the origin. It doesn't alter the dimensions of the view port, nor the physical location relative to its parent.
func (*ViewPort) Resize ¶
Resize is called by the enclosing view to change the size of the ViewPort, usually in response to a window resize event. The x, y refer are the ViewPort's location relative to the parent View. A negative value for either width or height will cause the ViewPort to expand to fill to the end of parent View in the relevant dimension.
func (*ViewPort) ScrollDown ¶
ScrollDown moves the view down, showingh higher numbered rows of content.
func (*ViewPort) ScrollLeft ¶
ScrollLeft moves the view to the left.
func (*ViewPort) ScrollRight ¶
ScrollRight moves the view to the left.
func (*ViewPort) ScrollUp ¶
ScrollUp moves the view up, showing lower numbered rows of content.
func (*ViewPort) SetContent ¶
SetContent is used to place data at the given cell location. Note that since the ViewPort doesn't retain this data, if the location is outside of the visible area, it is simply discarded.
Generally, this is called during the Draw() phase by the object that represents the content.
func (*ViewPort) SetContentSize ¶
SetContentSize sets the size of the content area; this is used to limit scrolling and view moment. If locked is true, then the content size will not automatically grow even if content is placed outside of this area with the SetContent() method. If false, and content is drawn outside of the existing size, then the size will automatically grow to include the new content.
func (*ViewPort) SetSize ¶
SetSize is used to set the visible size of the view. Enclosing views or layout managers can use this to inform the View of its correct visible size.
func (*ViewPort) SetView ¶
SetView is called during setup, to provide the parent View.
func (*ViewPort) Size ¶
Size returns the visible size of the ViewPort in character cells.
func (*ViewPort) ValidateView ¶
func (v *ViewPort) ValidateView()
ValidateView does both ValidateViewX and ValidateViewY, ensuring both offsets are valid.
type Widget ¶
type Widget interface { // Draw is called to inform the widget to draw itself. A containing // Widget will generally call this during the application draw loop. Draw() // Resize is called in response to a resize of the View. Unlike with // other events, Resize performed by parents first, and they must // then call their children. This is because the children need to // see the updated sizes from the parents before they are called. // In general this is done *after* the views have updated. Resize() // HandleEvent is called to ask the widget to handle any events. // If the widget has consumed the event, it should return true. // Generally, events are handled by the lower layers first, that // is for example, a button may have a chance to handle an event // before the enclosing window or panel. // // Its expected that Resize events are consumed by the outermost // Widget, and the turned into a Resize() call. HandleEvent(ev tcell.Event) bool // SetView is used by callers to set the visual context of the // Widget. The Widget should use the View as a context for // drawing. SetView(view View) // Size returns the size of the widget (content size) as width, height // in columns. Layout managers should attempt to ensure that at least // this much space is made available to the View for this Widget. Extra // space may be allocated on as an needed basis. Size() (int, int) // Watch is used to register an interest in this widget's events. // The handler will receive EventWidget events for this widget. // The order of event delivery when there are multiple watchers is // not specified, and may change from one event to the next. Watch(handler tcell.EventHandler) // Unwatch is used to urnegister an interest in this widget's events. Unwatch(handler tcell.EventHandler) }
Widget is the base object that all onscreen elements implement.
type WidgetWatchers ¶
type WidgetWatchers struct {
// contains filtered or unexported fields
}
WidgetWatchers provides a common implementation for base Widget Watch and Unwatch interfaces, suitable for embedding in more concrete widget implementations.
func (*WidgetWatchers) PostEvent ¶
func (ww *WidgetWatchers) PostEvent(wev EventWidget)
PostEvent delivers the EventWidget to all registered watchers. It is to be called by the Widget implementation.
func (*WidgetWatchers) PostEventWidgetContent ¶
func (ww *WidgetWatchers) PostEventWidgetContent(w Widget)
PostEventWidgetContent is called by the Widget when its content is changed, delivering EventWidgetContent to all watchers.
func (*WidgetWatchers) PostEventWidgetMove ¶
func (ww *WidgetWatchers) PostEventWidgetMove(w Widget)
PostEventWidgetMove is called by the Widget when it is moved to a new location, delivering EventWidgetMove to all watchers.
func (*WidgetWatchers) PostEventWidgetResize ¶
func (ww *WidgetWatchers) PostEventWidgetResize(w Widget)
PostEventWidgetResize is called by the Widget when the underlying View has resized, delivering EventWidgetResize to all watchers.
func (*WidgetWatchers) Unwatch ¶
func (ww *WidgetWatchers) Unwatch(handler tcell.EventHandler)
Unwatch stops monitoring this WidgetWatcher. The handler will no longer be fired for Widget events.
func (*WidgetWatchers) Watch ¶
func (ww *WidgetWatchers) Watch(handler tcell.EventHandler)
Watch monitors this WidgetWatcher, causing the handler to be fired with EventWidget as they are occur on the watched Widget.