tcell: github.com/gdamore/tcell/views Index | Files | Directories

package views

import "github.com/gdamore/tcell/views"

Index

Package Files

app.go boxlayout.go cellarea.go constants.go panel.go spacer.go sstext.go sstextbar.go text.go textarea.go textbar.go view.go widget.go

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
)

type Alignment Uses

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 Uses

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

Application represents an event-driven application running on a screen.

func (*Application) PostFunc Uses

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 Uses

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 Uses

func (app *Application) Refresh()

Refresh causes the application forcibly redraw everything. Use this to clear up screen corruption, etc.

func (*Application) Run Uses

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 Uses

func (app *Application) SetRootWidget(widget Widget)

SetRootWidget sets the primary (root, main) Widget to be displayed.

func (*Application) SetScreen Uses

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 Uses

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 Uses

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 Uses

func (app *Application) Update()

Update asks the application to draw any screen updates that have not been drawn yet.

func (*Application) Wait Uses

func (app *Application) Wait() error

Wait waits until the application finishes.

type BoxLayout Uses

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 Uses

func NewBoxLayout(orient Orientation) *BoxLayout

NewBoxLayout creates an empty BoxLayout.

func (*BoxLayout) AddWidget Uses

func (b *BoxLayout) AddWidget(widget Widget, fill float64)

AddWidget adds a widget to the end of the BoxLayout.

func (*BoxLayout) Draw Uses

func (b *BoxLayout) Draw()

Draw is called to update the displayed content.

func (*BoxLayout) HandleEvent Uses

func (b *BoxLayout) HandleEvent(ev tcell.Event) bool

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 Uses

func (b *BoxLayout) InsertWidget(index int, widget Widget, fill float64)

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 Uses

func (b *BoxLayout) RemoveWidget(widget Widget)

RemoveWidget removes a Widget from the layout.

func (*BoxLayout) Resize Uses

func (b *BoxLayout) Resize()

Resize adjusts the layout when the underlying View changes size.

func (*BoxLayout) SetOrientation Uses

func (b *BoxLayout) SetOrientation(orient Orientation)

SetOrientation sets the orientation as either Horizontal or Vertical.

func (*BoxLayout) SetStyle Uses

func (b *BoxLayout) SetStyle(style tcell.Style)

SetStyle sets the style used.

func (*BoxLayout) SetView Uses

func (b *BoxLayout) SetView(view View)

SetView sets the View object used for the text bar.

func (*BoxLayout) Size Uses

func (b *BoxLayout) Size() (int, int)

Size returns the preferred size in character cells (width, height).

func (*BoxLayout) Widgets Uses

func (b *BoxLayout) Widgets() []Widget

Widgets returns the list of Widgets for this BoxLayout.

type CellModel Uses

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 Uses

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 NewCellView Uses

func NewCellView() *CellView

NewCellView creates a CellView.

func (*CellView) Draw Uses

func (a *CellView) Draw()

Draw draws the content.

func (*CellView) HandleEvent Uses

func (a *CellView) HandleEvent(e tcell.Event) bool

HandleEvent handles events. In particular, it handles certain key events to move the cursor or pan the view.

func (*CellView) Init Uses

func (a *CellView) Init()

Init initializes a new CellView for use.

func (*CellView) MakeCursorVisible Uses

func (a *CellView) MakeCursorVisible()

MakeCursorVisible ensures that the cursor is visible, panning the ViewPort as necessary, if the cursor is enabled.

func (*CellView) MakeVisible Uses

func (a *CellView) MakeVisible(x, y int)

MakeVisible makes the given coordinates visible, if they are not already. It does this by moving the ViewPort for the CellView.

func (*CellView) Resize Uses

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 Uses

func (a *CellView) SetCursor(x, y int)

SetCursor sets the the cursor position.

func (*CellView) SetCursorX Uses

func (a *CellView) SetCursorX(x int)

SetCursorX sets the the cursor column.

func (*CellView) SetCursorY Uses

func (a *CellView) SetCursorY(y int)

SetCursorY sets the the cursor row.

func (*CellView) SetModel Uses

func (a *CellView) SetModel(model CellModel)

SetModel sets the model for this CellView.

func (*CellView) SetStyle Uses

func (a *CellView) SetStyle(s tcell.Style)

SetStyle sets the the default fill style.

func (*CellView) SetView Uses

func (a *CellView) SetView(view View)

SetView sets the View context.

func (*CellView) Size Uses

func (a *CellView) Size() (int, int)

Size returns the content size, based on the model.

type EventWidget Uses

type EventWidget interface {
    Widget() Widget
    tcell.Event
}

EventWidget is an event delivered by a specific widget.

type EventWidgetContent Uses

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

EventWidgetContent is fired whenever a widget's content changes.

func (*EventWidgetContent) SetWidget Uses

func (wev *EventWidgetContent) SetWidget(widget Widget)

func (*EventWidgetContent) Widget Uses

func (wev *EventWidgetContent) Widget() Widget

type EventWidgetMove Uses

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

EventWidgetMove is fired whenver a widget changes location.

func (*EventWidgetMove) SetWidget Uses

func (wev *EventWidgetMove) SetWidget(widget Widget)

func (*EventWidgetMove) Widget Uses

func (wev *EventWidgetMove) Widget() Widget

type EventWidgetResize Uses

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

EventWidgetResize is fired whenever a widget is resized.

func (*EventWidgetResize) SetWidget Uses

func (wev *EventWidgetResize) SetWidget(widget Widget)

func (*EventWidgetResize) Widget Uses

func (wev *EventWidgetResize) Widget() Widget

type Orientation Uses

type Orientation int

Orientation represents the direction of a widget or layout.

type Panel Uses

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 Uses

func NewPanel() *Panel

NewPanel creates a new Panel. A zero valued panel can be created too.

func (*Panel) Draw Uses

func (p *Panel) Draw()

Draw draws the Panel.

func (*Panel) SetContent Uses

func (p *Panel) SetContent(w Widget)

SetContent sets the Widget to display in the content area.

func (*Panel) SetMenu Uses

func (p *Panel) SetMenu(w Widget)

SetMenu sets the Widget to display in the menu area, which is just below the title.

func (*Panel) SetStatus Uses

func (p *Panel) SetStatus(w Widget)

SetStatus sets the Widget to display in the status area, which is at the bottom of the panel.

func (*Panel) SetTitle Uses

func (p *Panel) SetTitle(w Widget)

SetTitle sets the Widget to display in the title area.

type SimpleStyledText Uses

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 Uses

func NewSimpleStyledText() *SimpleStyledText

NewSimpleStyledText creates an empty Text.

func (*SimpleStyledText) LookupStyle Uses

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 Uses

func (t *SimpleStyledText) Markup() string

Markup returns the text that was set, including markup.

func (*SimpleStyledText) RegisterStyle Uses

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 Uses

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 Uses

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 Uses

func NewSimpleStyledTextBar() *SimpleStyledTextBar

NewSimpleStyledTextBar creates an empty, initialized TextBar.

func (*SimpleStyledTextBar) Init Uses

func (s *SimpleStyledTextBar) Init()

Init prepares the widget for use, ensuring resources needed are allocated, etc.

func (*SimpleStyledTextBar) RegisterCenterStyle Uses

func (s *SimpleStyledTextBar) RegisterCenterStyle(r rune, style tcell.Style)

func (*SimpleStyledTextBar) RegisterLeftStyle Uses

func (s *SimpleStyledTextBar) RegisterLeftStyle(r rune, style tcell.Style)

func (*SimpleStyledTextBar) RegisterRightStyle Uses

func (s *SimpleStyledTextBar) RegisterRightStyle(r rune, style tcell.Style)

func (*SimpleStyledTextBar) SetCenter Uses

func (s *SimpleStyledTextBar) SetCenter(m string)

SetCenter sets the center text for the textbar. It is always centered.

func (*SimpleStyledTextBar) SetLeft Uses

func (s *SimpleStyledTextBar) SetLeft(m string)

SetLeft sets the left text for the textbar. It is always left-aligned.

func (*SimpleStyledTextBar) SetRight Uses

func (s *SimpleStyledTextBar) SetRight(m string)

SetRight sets the right text for the textbar. It is always right-aligned.

func (*SimpleStyledTextBar) Size Uses

func (s *SimpleStyledTextBar) Size() (int, int)

type Spacer Uses

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 Uses

func NewSpacer() *Spacer

NewSpacer creates an empty Spacer. It's probably easier just to declare it directly.

func (*Spacer) Draw Uses

func (*Spacer) Draw()

Draw is called to update the displayed content.

func (*Spacer) HandleEvent Uses

func (*Spacer) HandleEvent(tcell.Event) bool

HandleEvent implements a tcell.EventHandler, but does nothing.

func (*Spacer) Resize Uses

func (s *Spacer) Resize()

Resize is called when our View changes sizes.

func (*Spacer) SetView Uses

func (*Spacer) SetView(View)

SetView sets the View object used for the text bar.

func (*Spacer) Size Uses

func (*Spacer) Size() (int, int)

Size always returns 0, 0, since no size is ever *requird* to display nothing.

type Text Uses

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 NewText Uses

func NewText() *Text

NewText creates an empty Text.

func (*Text) Alignment Uses

func (t *Text) Alignment() Alignment

Alignment returns the alignment of the Text.

func (*Text) Draw Uses

func (t *Text) Draw()

Draw draws the Text.

func (*Text) HandleEvent Uses

func (t *Text) HandleEvent(tcell.Event) bool

HandleEvent implements a tcell.EventHandler, but does nothing.

func (*Text) Resize Uses

func (t *Text) Resize()

Resize is called when our View changes sizes.

func (*Text) SetAlignment Uses

func (t *Text) SetAlignment(align Alignment)

SetAlignment sets the alignment. Negative values indicate right justification, positive values are left, and zero indicates center aligned.

func (*Text) SetStyle Uses

func (t *Text) SetStyle(style tcell.Style)

SetStyle sets the style used. This applies to every cell in the in the text.

func (*Text) SetStyleAt Uses

func (t *Text) SetStyleAt(pos int, style tcell.Style)

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 Uses

func (t *Text) SetText(s string)

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 Uses

func (t *Text) SetView(view View)

SetView sets the View object used for the text bar.

func (*Text) Size Uses

func (t *Text) Size() (int, int)

Size returns the width and height in character cells of the Text.

func (*Text) Style Uses

func (t *Text) Style() tcell.Style

Style returns the previously set default style. Note that individual characters may have different styles.

func (*Text) StyleAt Uses

func (t *Text) StyleAt(pos int) tcell.Style

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.

func (*Text) Text Uses

func (t *Text) Text() string

Text returns the text that was set.

type TextArea Uses

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 NewTextArea Uses

func NewTextArea() *TextArea

NewTextArea creates a blank TextArea.

func (*TextArea) EnableCursor Uses

func (ta *TextArea) EnableCursor(on bool)

EnableCursor enables a soft cursor in the TextArea.

func (*TextArea) HideCursor Uses

func (ta *TextArea) HideCursor(on bool)

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) Init Uses

func (ta *TextArea) Init()

Init initializes the TextArea.

func (*TextArea) SetContent Uses

func (ta *TextArea) SetContent(text string)

SetContent is used to set the textual content, passed as a single string. Lines within the string are delimited by newlines.

func (*TextArea) SetLines Uses

func (ta *TextArea) SetLines(lines []string)

SetLines sets the content text to display.

func (*TextArea) SetStyle Uses

func (ta *TextArea) SetStyle(style tcell.Style)

type TextBar Uses

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 NewTextBar Uses

func NewTextBar() *TextBar

NewTextBar creates an empty, initialized TextBar.

func (*TextBar) Draw Uses

func (t *TextBar) Draw()

Draw draws the TextBar into its View context.

func (*TextBar) HandleEvent Uses

func (t *TextBar) HandleEvent(ev tcell.Event) bool

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 Uses

func (t *TextBar) Resize()

Resize is called when the TextBar's View changes size, and updates the layout.

func (*TextBar) SetCenter Uses

func (t *TextBar) SetCenter(s string, style tcell.Style)

SetCenter sets the center text for the textbar. The text is always center aligned.

func (*TextBar) SetLeft Uses

func (t *TextBar) SetLeft(s string, style tcell.Style)

SetLeft sets the left text for the textbar. It is always left-aligned.

func (*TextBar) SetRight Uses

func (t *TextBar) SetRight(s string, style tcell.Style)

SetRight sets the right text for the textbar. It is always right-aligned.

func (*TextBar) SetStyle Uses

func (t *TextBar) SetStyle(style tcell.Style)

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 Uses

func (t *TextBar) SetView(view View)

SetView sets the View drawing context for this TextBar.

func (*TextBar) Size Uses

func (t *TextBar) Size() (int, int)

Size implements the Size method for Widget, returning the width and height in character cells.

type View Uses

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 Uses

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 Uses

func NewViewPort(view View, x, y, width, height int) *ViewPort

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 Uses

func (v *ViewPort) Center(x, y int)

Center centers the point, if possible, in the View.

func (*ViewPort) Clear Uses

func (v *ViewPort) Clear()

Clear clears the displayed content, filling it with spaces of default text attributes.

func (*ViewPort) Fill Uses

func (v *ViewPort) Fill(ch rune, style tcell.Style)

Fill fills the displayed view port with the given character and style.

func (*ViewPort) GetContentSize Uses

func (v *ViewPort) GetContentSize() (int, int)

GetContentSize returns the size of content as width, height in character cells.

func (*ViewPort) GetPhysical Uses

func (v *ViewPort) GetPhysical() (int, int, int, int)

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 Uses

func (v *ViewPort) GetVisible() (int, int, int, int)

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 Uses

func (v *ViewPort) MakeVisible(x, y int)

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 Uses

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 Uses

func (v *ViewPort) Resize(x, y, width, height int)

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 Uses

func (v *ViewPort) ScrollDown(rows int)

ScrollDown moves the view down, showingh higher numbered rows of content.

func (*ViewPort) ScrollLeft Uses

func (v *ViewPort) ScrollLeft(cols int)

ScrollLeft moves the view to the left.

func (*ViewPort) ScrollRight Uses

func (v *ViewPort) ScrollRight(cols int)

ScrollRight moves the view to the left.

func (*ViewPort) ScrollUp Uses

func (v *ViewPort) ScrollUp(rows int)

ScrollUp moves the view up, showing lower numbered rows of content.

func (*ViewPort) SetContent Uses

func (v *ViewPort) SetContent(x, y int, ch rune, comb []rune, s tcell.Style)

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 Uses

func (v *ViewPort) SetContentSize(width, height int, locked bool)

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 Uses

func (v *ViewPort) SetSize(width, height int)

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 Uses

func (v *ViewPort) SetView(view View)

SetView is called during setup, to provide the parent View.

func (*ViewPort) Size Uses

func (v *ViewPort) Size() (int, int)

Size returns the visible size of the ViewPort in character cells.

func (*ViewPort) ValidateView Uses

func (v *ViewPort) ValidateView()

ValidateView does both ValidateViewX and ValidateViewY, ensuring both offsets are valid.

func (*ViewPort) ValidateViewX Uses

func (v *ViewPort) ValidateViewX()

ValidateViewX ensures that the X offset of the view port is limited so that it cannot scroll away from the content.

func (*ViewPort) ValidateViewY Uses

func (v *ViewPort) ValidateViewY()

ValidateViewY ensures that the Y offset of the view port is limited so that it cannot scroll away from the content.

type Widget Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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.

Directories

PathSynopsis
_demos

Package views imports 5 packages (graph) and is imported by 18 packages. Updated 2018-09-24. Refresh now. Tools for package owners.