Documentation ¶
Index ¶
- type Cursor
- type Key
- type Layout
- type Markup
- type Renderer
- type Screen
- func (screen *Screen) Clear() *Screen
- func (screen *Screen) ClearLine(x int, y int) *Screen
- func (screen *Screen) Close() *Screen
- func (screen *Screen) CursorPosition() int
- func (screen *Screen) Flush() *Screen
- func (screen *Screen) MoveCursorDown()
- func (screen *Screen) MoveCursorUp()
- func (screen *Screen) Pause(pause bool) *Screen
- func (screen *Screen) Render(column int, str string)
- func (screen *Screen) RenderLine(x int, y int, str string)
- func (screen *Screen) Resize() *Screen
- func (screen *Screen) Sync() *Screen
- type View
- func (v *View) Buffer() string
- func (v *View) Clear()
- func (v *View) Cursor() (x, y int)
- func (v *View) CursorDown()
- func (v *View) CursorPageDown()
- func (v *View) CursorPageUp()
- func (v *View) CursorUp()
- func (v *View) Line(y int) (string, error)
- func (v *View) MoveCursorToBottom()
- func (v *View) MoveCursorToTop()
- func (v *View) Name() string
- func (v *View) Position() (x, y int)
- func (v *View) Read(p []byte) (n int, err error)
- func (v *View) Render() error
- func (v *View) Rewind()
- func (v *View) ViewBuffer() string
- func (v *View) ViewSize() (x, y int)
- func (v *View) Word(x, y int) (string, error)
- func (v *View) Write(p []byte) (n int, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Markup ¶
type Markup struct { Foreground termbox.Attribute // Foreground color. Background termbox.Attribute // Background color (so far always termbox.ColorDefault). RightAligned bool // True when the string is right aligned. // contains filtered or unexported fields }
Markup implements some minimalistic text formatting conventions that get translated to Termbox colors and attributes. To colorize a string wrap it in <color-name>...</> tags. Unlike HTML each tag sets a new color whereas the </> tag changes color back to default. For example:
<green>Hello, <red>world!</>
The color tags could be combined with the attributes: <b>...</b> for bold, <u>...</u> for underline, and <r>...</r> for reverse. Unlike colors the attributes require matching closing tag.
The <right>...</right> tag is used to right align the enclosed string
func NewMarkup ¶
func NewMarkup() *Markup
Creates markup to define tag to Termbox translation rules and store default colors and column alignments.
func (*Markup) IsTag ¶
IsTag returns true when the given string looks like markup tag. When the tag name matches one of the markup-supported tags it gets translated to relevant Termbox attributes and colors.
type Renderer ¶
type Renderer interface {
Render() string
}
Renderable is a mark for anything worth rendering as text
type Screen ¶
type Screen struct { Width int // Current number of columns. Height int // Current number of rows. Cursor *Cursor // Pointer to cursor (gets created by screen). // contains filtered or unexported fields }
Screen is thin wrapper aroung Termbox library to provide basic display capabilities as required by dry.
func NewScreen ¶
func NewScreen() *Screen
Initializes Termbox, creates screen along with layout and markup, and calculates current screen dimensions. Once initialized the screen is ready for display.
func (*Screen) ClearLine ¶
ClearLine erases the contents of the line starting from (x,y) coordinate till the end of the line.
func (*Screen) CursorPosition ¶
func (*Screen) MoveCursorDown ¶
func (screen *Screen) MoveCursorDown()
func (*Screen) MoveCursorUp ¶
func (screen *Screen) MoveCursorUp()
func (*Screen) Pause ¶
Pause is a toggle function that either creates a timestamp of the pause request or resets it to nil.
func (*Screen) RenderLine ¶
RenderLine takes the incoming string, tokenizes it to extract markup elements, and displays it all starting at (x,y) location.
type View ¶
type View struct {
// BgColor and FgColor allow to configure the background and foreground
// colors of the View.
BgColor, FgColor termbox.Attribute
// If Editable is true, keystrokes will be added to the view's internal
// buffer at the cursor position.
Editable bool
// Overwrite enables or disables the overwrite mode of the view.
Overwrite bool
// If Wrap is true, the content that is written to this View is
// automatically wrapped when it is longer than its width. If true the
// view's x-origin will be ignored.
Wrap bool
// If Autoscroll is true, the View will automatically scroll down when the
// text overflows. If true the view's y-origin will be ignored.
Autoscroll bool
// contains filtered or unexported fields
}
A View is a window. It maintains its own internal buffer and cursor position.
func NewMarkupView ¶
NewMarkupView returns a new View with markup support
func (*View) CursorPageDown ¶
func (v *View) CursorPageDown()
CursorPageDown moves the cursor one page down
func (*View) Line ¶
Line returns a string with the line of the view's internal buffer at the position corresponding to the point (x, y).
func (*View) MoveCursorToBottom ¶
func (v *View) MoveCursorToBottom()
MoveCursorToBottom moves the cursor to the bottom of the view buffer
func (*View) MoveCursorToTop ¶
func (v *View) MoveCursorToTop()
func (*View) Read ¶
Read reads data into p. It returns the number of bytes read into p. At EOF, err will be io.EOF. Calling Read() after Rewind() makes the cache to be refreshed with the contents of the view.
func (*View) Rewind ¶
func (v *View) Rewind()
Rewind sets the offset for the next Read to 0, which also refresh the read cache.
func (*View) ViewBuffer ¶
ViewBuffer returns a string with the contents of the view's buffer that is showed to the user
func (*View) Word ¶
Word returns a string with the word of the view's internal buffer at the position corresponding to the point (x, y).