Documentation ¶
Index ¶
- Variables
- func Blue(text string) string
- func Cyan(text string) string
- func EventChannel() (<-chan tcell.Event, chan struct{})
- func NewList(theme *ColorTheme) *termui.List
- func NewPar(s string, theme *ColorTheme) *termui.Paragraph
- func Red(text string) string
- func Tokenize(str string, regex *regexp.Regexp) []string
- func White(text string) string
- func Yellow(text string) string
- type Color
- type ColorTheme
- type Cursor
- func (cursor *Cursor) Bottom()
- func (cursor *Cursor) Max(max int)
- func (cursor *Cursor) MovingDown() bool
- func (cursor *Cursor) Position() int
- func (cursor *Cursor) Reset()
- func (cursor *Cursor) ScrollCursorDown()
- func (cursor *Cursor) ScrollCursorUp()
- func (cursor *Cursor) ScrollTo(pos int)
- func (cursor *Cursor) String() string
- func (cursor *Cursor) Top()
- type Dimensions
- type EventSource
- type ExpiringMessageWidget
- type Focusable
- type InputBox
- func (eb *InputBox) AdjustVOffset(width int)
- func (eb *InputBox) CursorX() int
- func (eb *InputBox) Delete()
- func (eb *InputBox) DeleteRuneBackward()
- func (eb *InputBox) DeleteRuneForward()
- func (eb *InputBox) DeleteTheRestOfTheLine()
- func (eb *InputBox) Draw(x, y, w, h int)
- func (eb *InputBox) Focus()
- func (eb *InputBox) InsertRune(r rune)
- func (eb *InputBox) MoveCursorOneRuneBackward()
- func (eb *InputBox) MoveCursorOneRuneForward()
- func (eb *InputBox) MoveCursorTo(boffset int)
- func (eb *InputBox) MoveCursorToBeginningOfTheLine()
- func (eb *InputBox) MoveCursorToEndOfTheLine()
- func (eb *InputBox) RuneBeforeCursor() (rune, int)
- func (eb *InputBox) RuneUnderCursor() (rune, int)
- func (eb *InputBox) String() string
- type Key
- type Less
- type Markup
- type Screen
- func (screen *Screen) Clear() *Screen
- func (screen *Screen) ClearAndFlush() *Screen
- func (screen *Screen) Close() *Screen
- func (screen *Screen) Closing() bool
- func (screen *Screen) ColorTheme(theme *ColorTheme) *Screen
- func (screen *Screen) Cursor() *Cursor
- func (screen *Screen) Dimensions() *Dimensions
- func (screen *Screen) Fill(x, y, w, h int, r rune)
- func (screen *Screen) Flush() *Screen
- func (screen *Screen) HideCursor()
- func (screen *Screen) Render(row int, str string)
- func (screen *Screen) RenderAtColumn(column, initialRow int, str string)
- func (screen *Screen) RenderBufferer(bs ...termui.Bufferer)
- func (screen *Screen) RenderLine(x int, y int, str string)
- func (screen *Screen) RenderRune(x, y int, r rune)
- func (screen *Screen) Resize()
- func (screen *Screen) ShowCursor(x, y int)
- func (screen *Screen) Sync() *Screen
- type ScreenTextRenderer
- type TextRenderer
- type View
- func (v *View) Clear()
- func (v *View) Cursor() (x, y int)
- func (v *View) CursorDown()
- func (v *View) CursorToBottom()
- func (v *View) CursorToTop()
- func (v *View) CursorUp()
- func (v *View) Line(y int) (string, error)
- func (v *View) MarkupSupport()
- func (v *View) Name() string
- func (v *View) PageDown()
- func (v *View) PageUp()
- func (v *View) Position() (x, y int)
- func (v *View) ViewSize() (width, height 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 ¶
var SupportedTags = supportedTagsRegexp()
SupportedTags maps supported tags to a tcell.Attribute
Functions ¶
func EventChannel ¶
EventChannel returns a channel on which termbox's events are published.
func NewList ¶
func NewList(theme *ColorTheme) *termui.List
NewList returns a new list using the given ColorTheme
func NewPar ¶
func NewPar(s string, theme *ColorTheme) *termui.Paragraph
NewPar creates a new termui paragraph with the given content and with a look and feel based on the given theme.
Types ¶
type Color ¶
type Color uint32
Color representation
const ( ColorBlack Color = iota ColorMaroon ColorGreen ColorOlive ColorPurple ColorTeal ColorSilver ColorGray ColorRed ColorLime ColorYellow ColorBlue ColorFuchsia ColorAqua ColorWhite Color16 Color17 Color18 Color19 Color20 Color21 Color22 Color23 Color24 Color25 Color26 Color27 Color28 Color29 Color30 Color31 Color32 Color33 Color34 Color35 Color36 Color37 Color38 Color39 Color40 Color41 Color42 Color43 Color44 Color45 Color46 Color47 Color48 Color49 Color50 Color51 Color52 Color53 Color54 Color55 Color56 Color57 Color58 Color59 Color60 Color61 Color62 Color63 Color64 Color65 Color66 Color67 Color68 Color69 Color70 Color71 Color72 Color73 Color74 Color75 Color76 Color77 Color78 Color79 Color80 Color81 Color82 Color83 Color84 Color85 Color86 Color87 Color88 Color89 Color90 Color91 Color92 Color93 Color94 Color95 Color96 Color97 Color98 Color99 Color100 Color101 Color102 Color103 Color104 Color105 Color106 Color107 Color108 Color109 Color110 Color111 Color112 Color113 Color114 Color115 Color116 Color117 Color118 Color119 Color120 Color121 Color122 Color123 Color124 Color125 Color126 Color127 Color128 Color129 Color130 Color131 Color132 Color133 Color134 Color135 Color136 Color137 Color138 Color139 Color140 Color141 Color142 Color143 Color144 Color145 Color146 Color147 Color148 Color149 Color150 Color151 Color152 Color153 Color154 Color155 Color156 Color157 Color158 Color159 Color160 Color161 Color162 Color163 Color164 Color165 Color166 Color167 Color168 Color169 Color170 Color171 Color172 Color173 Color174 Color175 Color176 Color177 Color178 Color179 Color180 Color181 Color182 Color183 Color184 Color185 Color186 Color187 Color188 Color189 Color190 Color191 Color192 Color193 Color194 Color195 Color196 Color197 Color198 Color199 Color200 Color201 Color202 Color203 Color204 Color205 Color206 Color207 Color208 Color209 Color210 Color211 Color212 Color213 Color214 Color215 Color216 Color217 Color218 Color219 Color220 Color221 Color222 Color223 Color224 Color225 Color226 Color227 Color228 Color229 Color230 Color231 Color232 Color233 Color234 Color235 Color236 Color237 Color238 Color239 Color240 Color241 Color242 Color243 Color244 Color245 Color246 Color247 Color248 Color249 Color250 Color251 Color252 Color253 Color254 Color255 ColorAliceBlue ColorAntiqueWhite ColorAquaMarine ColorAzure ColorBeige ColorBisque ColorBlanchedAlmond ColorBlueViolet ColorBrown ColorBurlyWood ColorCadetBlue ColorChartreuse ColorChocolate ColorCoral ColorCornflowerBlue ColorCornsilk ColorCrimson ColorDarkBlue ColorDarkCyan ColorDarkGoldenrod ColorDarkGray ColorDarkGreen ColorDarkKhaki ColorDarkMagenta ColorDarkOliveGreen ColorDarkOrange ColorDarkOrchid ColorDarkRed ColorDarkSalmon ColorDarkSeaGreen ColorDarkSlateBlue ColorDarkSlateGray ColorDarkTurquoise ColorDarkViolet ColorDeepPink ColorDeepSkyBlue ColorDimGray ColorDodgerBlue ColorFireBrick ColorFloralWhite ColorForestGreen ColorGainsboro ColorGhostWhite ColorGold ColorGoldenrod ColorGreenYellow ColorHoneydew ColorHotPink ColorIndianRed ColorIndigo ColorIvory ColorKhaki ColorLavender ColorLavenderBlush ColorLawnGreen ColorLemonChiffon ColorLightBlue ColorLightCoral ColorLightCyan ColorLightGoldenrodYellow ColorLightGray ColorLightGreen ColorLightPink ColorLightSalmon ColorLightSeaGreen ColorLightSkyBlue ColorLightSlateGray ColorLightSteelBlue ColorLightYellow ColorLimeGreen ColorLinen ColorMediumAquamarine ColorMediumBlue ColorMediumOrchid ColorMediumPurple ColorMediumSeaGreen ColorMediumSlateBlue ColorMediumSpringGreen ColorMediumTurquoise ColorMediumVioletRed ColorMidnightBlue ColorMintCream ColorMistyRose ColorMoccasin ColorOldLace ColorOliveDrab ColorOrange ColorOrangeRed ColorOrchid ColorPaleGoldenrod ColorPaleGreen ColorPaleTurquoise ColorPaleVioletRed ColorPapayaWhip ColorPeachPuff ColorPeru ColorPink ColorPlum ColorPowderBlue ColorRebeccaPurple ColorRosyBrown ColorRoyalBlue ColorSaddleBrown ColorSalmon ColorSandyBrown ColorSeaGreen ColorSeashell ColorSienna ColorSkyblue ColorSlateBlue ColorSlateGray ColorSnow ColorSpringGreen ColorSteelBlue ColorTan ColorThistle ColorTomato ColorTurquoise ColorViolet ColorWheat ColorWhiteSmoke ColorYellowGreen )
First 256 entries correspond to Colors from the color palette as defined by the standard https://en.wikipedia.org/wiki/ANSI_escape_code#Colors. Order is important. Below that, a few colors from the TrueColor palette are defined.
func ColorFromName ¶
ColorFromName returns the Color that corresponds to the given color name
type ColorTheme ¶
type ColorTheme struct { Fg Color Bg Color DarkBg Color Prompt Color Key Color Current Color CurrentMatch Color Spinner Color Info Color Cursor Color Selected Color Header Color ListItem Color CursorLineBg Color }
ColorTheme represents a color theme
type Cursor ¶
Cursor represents the cursor position on the screen
func (*Cursor) Bottom ¶
func (cursor *Cursor) Bottom()
Bottom moves the cursor to the bottom, if max is not set this a noop
func (*Cursor) MovingDown ¶
MovingDown returns true if the cursor is moving downwards after the last movement.
func (*Cursor) Reset ¶
func (cursor *Cursor) Reset()
Reset sets the cursor to its initial state (position 0, direction downwards).
func (*Cursor) ScrollCursorDown ¶
func (cursor *Cursor) ScrollCursorDown()
ScrollCursorDown moves the cursor to the pos below the current one
func (*Cursor) ScrollCursorUp ¶
func (cursor *Cursor) ScrollCursorUp()
ScrollCursorUp moves the cursor to the pos above the current one
type Dimensions ¶
type Dimensions struct {
Height, Width int
}
Dimensions is the width and height of a ui element.
type EventSource ¶
type EventSource struct { Events <-chan *tcell.EventKey EventHandledCallback func(*tcell.EventKey) error }
EventSource defines a source of keypress events.
type ExpiringMessageWidget ¶
ExpiringMessageWidget shows some text for an amount time then clears itself
func NewExpiringMessageWidget ¶
func NewExpiringMessageWidget(y int, screen *Screen) *ExpiringMessageWidget
NewExpiringMessageWidget creates a new ExpiringMessageWidget struct
func (*ExpiringMessageWidget) Message ¶
func (s *ExpiringMessageWidget) Message(msg string, clearDelay time.Duration)
Message sets the message to show for the given duration
func (*ExpiringMessageWidget) Pause ¶
func (s *ExpiringMessageWidget) Pause()
Pause pauses this widget from showing any output, setting a new status message will activate it again
func (*ExpiringMessageWidget) Render ¶
func (s *ExpiringMessageWidget) Render()
Render renders the status message
type InputBox ¶
type InputBox struct {
// contains filtered or unexported fields
}
InputBox captures user input
func NewInputBox ¶
func NewInputBox(x, y int, prompt string, output chan<- string, keyboardQueue chan *tcell.EventKey, theme *ColorTheme, screen *Screen) *InputBox
NewInputBox creates an input box, located at position x,y in the screen.
func (*InputBox) AdjustVOffset ¶
AdjustVOffset adjusts line visual offset to a proper value depending on width
func (*InputBox) CursorX ¶
CursorX Please, keep in mind that cursor depends on the value of lineVOffset, which is being set on Draw() call, so.. call this method after Draw() one.
func (*InputBox) DeleteRuneBackward ¶
func (eb *InputBox) DeleteRuneBackward()
DeleteRuneBackward deletes a rune moving the cursor backwards
func (*InputBox) DeleteRuneForward ¶
func (eb *InputBox) DeleteRuneForward()
DeleteRuneForward deletes a rune and moving the cursor forward
func (*InputBox) DeleteTheRestOfTheLine ¶
func (eb *InputBox) DeleteTheRestOfTheLine()
DeleteTheRestOfTheLine deletes the conent of the line where the cursor is from the cursor position until the end of the line
func (*InputBox) Focus ¶
func (eb *InputBox) Focus()
Focus is set on the inputbox, it starts handling terminal events and responding to user actions.
func (*InputBox) InsertRune ¶
InsertRune adds the given rune to the inputbox
func (*InputBox) MoveCursorOneRuneBackward ¶
func (eb *InputBox) MoveCursorOneRuneBackward()
MoveCursorOneRuneBackward moves the cursor one rune backwards
func (*InputBox) MoveCursorOneRuneForward ¶
func (eb *InputBox) MoveCursorOneRuneForward()
MoveCursorOneRuneForward moves the cursor one rune forward
func (*InputBox) MoveCursorTo ¶
MoveCursorTo moves the cursor
func (*InputBox) MoveCursorToBeginningOfTheLine ¶
func (eb *InputBox) MoveCursorToBeginningOfTheLine()
MoveCursorToBeginningOfTheLine moves the cursor to the beginning of the line
func (*InputBox) MoveCursorToEndOfTheLine ¶
func (eb *InputBox) MoveCursorToEndOfTheLine()
MoveCursorToEndOfTheLine moves the cursor to the end of the line
func (*InputBox) RuneBeforeCursor ¶
RuneBeforeCursor returns the rune from the inputbox placed before the cursor
func (*InputBox) RuneUnderCursor ¶
RuneUnderCursor returns the rune from the inputbox where the cursor is
type Less ¶
Less is a View specialization with less-like behavior and characteristics, meaning: * The cursor is always shown at the bottom of the screen. * Navigation is done using less keybindings. * Basic search is supported.
func NewLess ¶
func NewLess(theme *ColorTheme) *Less
NewLess creates a view that partially simulates less.
func (*Less) Focus ¶
Focus sets the view as active, so it starts handling terminal events and user actions
func (*Less) ScrollPageDown ¶
func (less *Less) ScrollPageDown()
ScrollPageDown moves the buffer position down by the length of the screen, at the end of buffer it also moves the cursor position to the bottom of the screen
func (*Less) ScrollPageUp ¶
func (less *Less) ScrollPageUp()
ScrollPageUp moves the buffer position up by the length of the screen, at the beginning of buffer it also moves the cursor position to the beginning of the screen
func (*Less) ScrollToBottom ¶
func (less *Less) ScrollToBottom()
ScrollToBottom moves the cursor to the bottom of the view buffer
func (*Less) ScrollToTop ¶
func (less *Less) ScrollToTop()
ScrollToTop moves the cursor to the top of the view buffer
type Markup ¶
type Markup struct { Foreground termbox.Attribute Background termbox.Attribute // 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!</>
func NewMarkup ¶
func NewMarkup(theme *ColorTheme) *Markup
NewMarkup creates a markup processor that uses the given theme for default colors.
type Screen ¶
Screen is where text is rendered
var ActiveScreen *Screen
ActiveScreen is the currently active screen
func NewScreen ¶
func NewScreen(theme *ColorTheme) (*Screen, error)
NewScreen creates a new Screen and sets the ActiveScreen
func (*Screen) ClearAndFlush ¶
ClearAndFlush cleares the screen and then flushes internal buffers
func (*Screen) ColorTheme ¶
func (screen *Screen) ColorTheme(theme *ColorTheme) *Screen
ColorTheme changes the color theme of the screen to the given one.
func (*Screen) Dimensions ¶
func (screen *Screen) Dimensions() *Dimensions
Dimensions returns the screen dimensions
func (*Screen) Fill ¶
Fill fills the squared portion of the screen delimited by the given positions with the provided rune. It uses this screen style.
func (*Screen) RenderAtColumn ¶
RenderAtColumn renders the given content starting from the given row at the given column
func (*Screen) RenderBufferer ¶
RenderBufferer renders all Bufferer in the given order from left to right, right could overlap on left ones. This allows usage of termui widgets.
func (*Screen) RenderLine ¶
RenderLine renders the given string, removing markup elements, at the given location.
func (*Screen) RenderRune ¶
RenderRune renders the given rune on the given pos
func (*Screen) ShowCursor ¶
ShowCursor shows the cursor on the given position
type ScreenTextRenderer ¶
type ScreenTextRenderer struct {
// contains filtered or unexported fields
}
ScreenTextRenderer renders text on a screen
func NewRenderer ¶
func NewRenderer(s styledRuneRenderer) ScreenTextRenderer
NewRenderer creates ScreenTextRenderer
func (ScreenTextRenderer) On ¶
func (renderer ScreenTextRenderer) On(x, y int) ScreenTextRenderer
On returns a renderer that will start rendering on the given positions of the screen.
func (ScreenTextRenderer) Render ¶
func (renderer ScreenTextRenderer) Render(s string) int
Render renders the given text on this renderer screen
func (ScreenTextRenderer) WithStyle ¶
func (renderer ScreenTextRenderer) WithStyle(style tcell.Style) ScreenTextRenderer
WithStyle returns a renderer that will use the provided style on rendering
func (ScreenTextRenderer) WithWidth ¶
func (renderer ScreenTextRenderer) WithWidth(w int) ScreenTextRenderer
WithWidth returns a renderer with its width set
type View ¶
type View struct {
// contains filtered or unexported fields
}
A View is a region of the screen where text can be rendered. It maintains its own internal buffer and cursor position.
func NewMarkupView ¶
func NewMarkupView(name string, x0, y0, x1, y1 int, showCursor bool, theme *ColorTheme) *View
NewMarkupView returns a new View with markup support
func NewView ¶
func NewView(name string, x0, y0, x1, y1 int, showCursor bool, theme *ColorTheme) *View
NewView returns a new View
func (*View) CursorToBottom ¶
func (v *View) CursorToBottom()
CursorToBottom moves the cursor to the bottom of the view buffer
func (*View) CursorToTop ¶
func (v *View) CursorToTop()
CursorToTop moves the cursor to the top of the view buffer
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) MarkupSupport ¶
func (v *View) MarkupSupport()
MarkupSupport sets markup support in the view
func (*View) PageDown ¶
func (v *View) PageDown()
PageDown moves the buffer position down by the length of the screen, at the end of buffer it also moves the cursor position to the bottom of the screen
func (*View) PageUp ¶
func (v *View) PageUp()
PageUp moves the buffer position up by the length of the screen, at the beginning of buffer it also moves the cursor position to the beginning of the screen