Documentation ¶
Overview ¶
Package vaxis is a terminal user interface for modern terminals
Index ¶
- Constants
- func EncodeCells(cells []Cell) string
- type AttributeMask
- type CSIuBitMask
- type Cell
- type Character
- type Color
- type ColorThemeMode
- type ColorThemeUpdate
- type CursorStyle
- type Event
- type EventType
- type FocusIn
- type FocusOut
- type FullBlockImage
- type HalfBlockImage
- type Image
- type Key
- type KittyImage
- type ModifierMask
- type Mouse
- type MouseButton
- type MouseShape
- type Options
- type PasteEndEvent
- type PasteStartEvent
- type QuitEvent
- type Redraw
- type Resize
- type Segment
- type Sixel
- type Style
- type StyledString
- type SyncFunc
- type UnderlineStyle
- type Vaxis
- func (vx *Vaxis) Bell()
- func (vx *Vaxis) CanDisplayGraphics() bool
- func (vx *Vaxis) CanKittyGraphics() bool
- func (vx *Vaxis) CanReportBackgroundColor() bool
- func (vx *Vaxis) CanSetAppID() bool
- func (vx *Vaxis) CanSixel() bool
- func (vx *Vaxis) ClipboardPop(ctx context.Context) (string, error)
- func (vx *Vaxis) ClipboardPush(s string)
- func (vx *Vaxis) Close()
- func (vx *Vaxis) CursorPosition() (row int, col int)
- func (vx *Vaxis) Events() chan Event
- func (vx *Vaxis) HideCursor()
- func (vx *Vaxis) NewFullBlockImage(img image.Image) *FullBlockImage
- func (vx *Vaxis) NewHalfBlockImage(img image.Image) *HalfBlockImage
- func (vx *Vaxis) NewImage(img image.Image) (Image, error)
- func (vx *Vaxis) NewKittyGraphic(img image.Image) *KittyImage
- func (vx *Vaxis) NewSixel(img image.Image) *Sixel
- func (vx *Vaxis) NewStyledString(s string, defaultStyle Style) *StyledString
- func (vx *Vaxis) Notify(title string, body string)
- func (vx *Vaxis) PollEvent() Event
- func (vx *Vaxis) PostEvent(ev Event)
- func (vx *Vaxis) PostEventBlocking(ev Event)
- func (vx *Vaxis) QueryBackground() Color
- func (vx *Vaxis) Refresh()
- func (vx *Vaxis) Render()
- func (vx *Vaxis) RenderedWidth(s string) int
- func (vx *Vaxis) Resize()
- func (vx *Vaxis) Resume() error
- func (vx *Vaxis) SetAppID(s string)
- func (vx *Vaxis) SetMouseShape(shape MouseShape)
- func (vx *Vaxis) SetTitle(s string)
- func (vx *Vaxis) ShowCursor(col int, row int, style CursorStyle)
- func (vx *Vaxis) Suspend() error
- func (vx *Vaxis) SyncFunc(fn func())
- func (vx *Vaxis) TerminalID() string
- func (vx *Vaxis) Window() Window
- type Window
- func (win Window) Clear()
- func (win Window) Fill(cell Cell)
- func (win Window) New(col, row, cols, rows int) Window
- func (win Window) Origin() (int, int)
- func (win Window) Print(segs ...Segment) (col int, row int)
- func (win Window) PrintTruncate(row int, segs ...Segment)
- func (win Window) Println(row int, segs ...Segment)
- func (win Window) SetCell(col int, row int, cell Cell)
- func (win Window) SetStyle(col int, row int, style Style)
- func (win Window) ShowCursor(col int, row int, style CursorStyle)
- func (win Window) Size() (width int, height int)
- func (win Window) Wrap(segs ...Segment) (col int, row int)
Examples ¶
Constants ¶
const ( KeyUp rune = extended + 1 + iota KeyRight KeyDown KeyLeft KeyInsert KeyDelete KeyPgDown KeyPgUp KeyHome KeyEnd KeyF00 KeyF01 KeyF02 KeyF03 KeyF04 KeyF05 KeyF06 KeyF07 KeyF08 KeyF09 KeyF10 KeyF11 KeyF12 KeyF13 KeyF14 KeyF15 KeyF16 KeyF17 KeyF18 KeyF19 KeyF20 KeyF21 KeyF22 KeyF23 KeyF24 KeyF25 KeyF26 KeyF27 KeyF28 KeyF29 KeyF30 KeyF31 KeyF32 KeyF33 KeyF34 KeyF35 KeyF36 KeyF37 KeyF38 KeyF39 KeyF40 KeyF41 KeyF42 KeyF43 KeyF44 KeyF45 KeyF46 KeyF47 KeyF48 KeyF49 KeyF50 KeyF51 KeyF52 KeyF53 KeyF54 KeyF55 KeyF56 KeyF57 KeyF58 KeyF59 KeyF60 KeyF61 KeyF62 KeyF63 // F63 is max defined in terminfo KeyClear KeyDownLeft KeyDownRight KeyUpLeft KeyUpRight KeyCenter KeyBegin KeyCancel KeyClose KeyCommand KeyCopy KeyExit KeyPrint KeyRefresh // notcurses says these are only avaialbe in kitty kbp KeyCapsLock KeyScrollLock KeyNumlock KeyPrintScreen KeyPause KeyMenu // Media keys, also generally only kitty kbp KeyMediaPlay KeyMediaPause KeyMediaPlayPause KeyMediaRev KeyMediaStop KeyMediaFF KeyMediaRewind KeyMediaNext KeyMediaPrev KeyMediaRecord KeyMediaVolDown KeyMediaVolUp KeyMediaMute // Modifiers, when pressed by themselves KeyLeftShift KeyLeftControl KeyLeftAlt KeyLeftSuper KeyLeftHyper KeyLeftMeta KeyRightShift KeyRightControl KeyRightAlt KeyRightSuper KeyRightHyper KeyRightMeta KeyL3Shift KeyL5Shift // Numerical pad keys, also generally only kitty kbp KeyKeyPad0 KeyKeyPad1 KeyKeyPad2 KeyKeyPad3 KeyKeyPad4 KeyKeyPad5 KeyKeyPad6 KeyKeyPad7 KeyKeyPad8 KeyKeyPad9 KeyKeyPadDecimal KeyKeyPadDivide KeyKeyPadMultiply KeyKeyPadSubtract KeyKeyPadAdd KeyKeyPadEnter KeyKeyPadEqual KeyKeyPadSeparator KeyKeyPadLeft KeyKeyPadRight KeyKeyPadUp KeyKeyPadDown KeyKeyPadPageUp KeyKeyPadPageDown KeyKeyPadHome KeyKeyPadEnd KeyKeyPadInsert KeyKeyPadDelete KeyKeyPadBegin // Aliases KeyEnter = 0x0D KeyReturn = KeyEnter KeyTab = 0x09 KeyEsc = 0x1B KeySpace = 0x20 KeyBackspace = 0x7F )
const ( CursorDefault = iota CursorBlockBlinking CursorBlock CursorUnderlineBlinking CursorUnderline CursorBeamBlinking CursorBeam )
Variables ¶
This section is empty.
Functions ¶
func EncodeCells ¶ added in v0.6.2
Types ¶
type AttributeMask ¶
type AttributeMask uint8
AttributeMask represents a bitmask of boolean attributes to style a cell
const ( AttrNone = 0 AttrBold AttributeMask = 1 << iota AttrDim AttrItalic AttrBlink AttrReverse AttrInvisible AttrStrikethrough )
type CSIuBitMask ¶ added in v0.8.0
type CSIuBitMask int
const ( CSIuDisambiguate CSIuBitMask = 1 << iota CSIuReportEvents CSIuAlternateKeys CSIuAllKeys CSIuAssociatedText )
type Cell ¶
Cell represents a single cell in a terminal window. It contains a Character and a Style, which fully defines the value. The zero value is rendered as an empty space
func ParseStyledString ¶ added in v0.6.2
Parses an SGR styled string into a slice of [Cell]s. This function does not depend on a Vaxis instance. The underlying cells will always be measured using correct unicode methods. If you are directly using these in a Vaxis window, you should either properly measure the graphemes based on your terminals capabilities or set the widths to 0 to enable vaxis to measure them
type Character ¶
Character is a single extended-grapheme-cluster. It also contains the width of the EGC
func Characters ¶
Converts a string into a slice of Characters suitable to assign to terminal cells
type Color ¶
type Color uint32
Color is a terminal color. The zero value represents the default foreground or background color
func HexColor ¶
HexColor creates a new Color based on the supplied 24-bit hex value
Example ¶
package main import ( "git.sr.ht/~rockorager/vaxis" ) func main() { vx, _ := vaxis.New(vaxis.Options{}) // Creates an RGB color from a hex value color := vaxis.HexColor(0x00AABB) vx.Window().Fill(vaxis.Cell{ Character: vaxis.Character{ Grapheme: " ", Width: 1, }, Style: vaxis.Style{ Background: color, }, }) }
Output:
func IndexColor ¶
IndexColor creates a new Color from the supplied 8 bit value. Values 0-255 are valid
Example ¶
package main import ( "git.sr.ht/~rockorager/vaxis" ) func main() { vx, _ := vaxis.New(vaxis.Options{}) // Index 1 is usually a red color := vaxis.IndexColor(1) vx.Window().Fill(vaxis.Cell{ Character: vaxis.Character{ Grapheme: " ", Width: 1, }, Style: vaxis.Style{ Background: color, }, }) }
Output:
func RGBColor ¶
RGBColor creates a new Color based on the supplied RGB values
Example ¶
package main import ( "git.sr.ht/~rockorager/vaxis" ) func main() { vx, _ := vaxis.New(vaxis.Options{}) color := vaxis.RGBColor(1, 2, 3) vx.Window().Fill(vaxis.Cell{ Character: vaxis.Character{ Grapheme: "a", }, Style: vaxis.Style{ Background: color, }, }) }
Output:
type ColorThemeMode ¶ added in v0.1.2
type ColorThemeMode int
ColorThemeMode is the current color theme of the terminal. The raw value is equivalent to the DSR response value for each mode.
const ( // The terminal has a dark color theme DarkMode ColorThemeMode = 1 // The terminal has a light color theme LightMode ColorThemeMode = 2 )
type ColorThemeUpdate ¶ added in v0.1.2
type ColorThemeUpdate struct {
Mode ColorThemeMode
}
ColorThemeUpdate is sent when the terminal color scheme has changed. This event is only delivered if supported by the terminal
type Event ¶
type Event interface{}
Event is an empty interface used to pass data within a Vaxis application. Vaxis will emit user input events as well as other input-related events. Users can use PostEvent to post their own events into the loop
type FullBlockImage ¶ added in v0.3.0
type FullBlockImage struct {
// contains filtered or unexported fields
}
FullBlockImage is an image composed of 0x20 characters. This is the most primitive graphics protocol
func (*FullBlockImage) CellSize ¶ added in v0.3.0
func (fb *FullBlockImage) CellSize() (int, int)
func (*FullBlockImage) Destroy ¶ added in v0.3.0
func (fb *FullBlockImage) Destroy()
func (*FullBlockImage) Draw ¶ added in v0.3.0
func (fb *FullBlockImage) Draw(win Window)
func (*FullBlockImage) Resize ¶ added in v0.3.0
func (fb *FullBlockImage) Resize(w int, h int)
Resize resizes and re-encodes an image
type HalfBlockImage ¶ added in v0.3.0
type HalfBlockImage struct {
// contains filtered or unexported fields
}
HalfBlockImage is an image composed of half block characters.
func (*HalfBlockImage) CellSize ¶ added in v0.3.0
func (hb *HalfBlockImage) CellSize() (int, int)
func (*HalfBlockImage) Destroy ¶ added in v0.3.0
func (hb *HalfBlockImage) Destroy()
func (*HalfBlockImage) Draw ¶ added in v0.3.0
func (hb *HalfBlockImage) Draw(win Window)
func (*HalfBlockImage) Resize ¶ added in v0.3.0
func (hb *HalfBlockImage) Resize(w int, h int)
Resize resizes and re-encodes an image
type Image ¶ added in v0.3.0
type Image interface { // Draw draws the [Image] to the [Window]. The image will not be drawn // if it is larger than the window Draw(Window) // Destroy removes an image from memory. Call when done with this image Destroy() // Resizes the image to fit within the provided area. The image will not // be upscaled, nor will it's aspect ratio be changed Resize(w int, h int) // CellSize is the current cell size of the encoded image CellSize() (w int, h int) }
Image is a static image on the screen
Example ¶
package main import ( "image/png" "os" "git.sr.ht/~rockorager/vaxis" ) func main() { // Open our image f, err := os.Open("/home/rockorager/pic.png") if err != nil { panic(err) } // Decode into an image.Image img, err := png.Decode(f) if err != nil { panic(err) } vx, err := vaxis.New(vaxis.Options{}) if err != nil { panic(err) } // Create a graphic with Vaxis. Depending on the terminal, this will // either send the graphic to the terminal or create a sixel encoded // version of the image vimg, err := vx.NewImage(img) if err != nil { panic(err) } // Resize to whatever size we want, in cell values w := 20 h := 10 vimg.Resize(w, h) // Create a window. The window should fully contain the image win := vx.Window().New(0, 0, w, h) // Draw the graphic in the window vimg.Draw(win) vx.Render() }
Output:
type Key ¶
type Key struct { // Text is text that the keypress generated Text string // Keycode is our primary key press. In alternate layouts, this will be // the lowercase value of the unicode point Keycode rune // The shifted keycode of this key event. This will only be non-zero if // the shift-modifier was used to generate the event ShiftedCode rune // BaseLayoutCode is the keycode that would have been generated on a // standard PC-101 layout BaseLayoutCode rune // Modifiers are any key modifier used to generate the event Modifiers ModifierMask // EventType is the type of key event this was (press, release, repeat, // or paste) EventType EventType }
Key is a key event. Codepoint can be either the literal codepoint of the keypress, or a value set by Vaxis to indicate special keys. Special keys have their codepoints outside of the valid unicode range
Example ¶
package main import ( "git.sr.ht/~rockorager/vaxis" ) func main() { vx, _ := vaxis.New(vaxis.Options{}) msg := vx.PollEvent() switch msg := msg.(type) { case vaxis.Key: switch msg.String() { case "Ctrl+c": vx.Close() case "Ctrl+l": vx.Refresh() case "j": // Down? default: // handle the key } } }
Output:
func (Key) MatchString ¶ added in v0.5.0
MatchString parses a string and matches to the Key event. The syntax for strings is: <modifier>[+<modifer>]+<key>. For example:
Ctrl+p Shift+Alt+Up
All modifiers will be matched lowercase
func (Key) Matches ¶ added in v0.4.7
func (k Key) Matches(key rune, modifiers ...ModifierMask) bool
Matches returns true if there is any way for the passed key and mods to match the Key. Before matching, ModCapsLock and ModNumLock are removed from the modifier mask. Returns true if any of the following are true
1. Keycode and Modifiers are exact matches 2. Text and Modifiers are exact matches 3. ShiftedCode and Modifiers (with ModShift removed) are exact matches 4. BaseLayoutCode and Modifiers are exact matches
If key is not a letter, but still a graphic: (so we can match ':', which is shift+; but we don't want to match "shift+tab" as the same as "tab")
5. Keycode and Modifers (without ModShift) are exact matches 6. Shifted Keycode and Modifers (without ModShift) are exact matches
If key is lowercase or not a letter and mods includes ModShift, uppercase Key, remove ModShift and continue
6. Text and Modifiers are exact matches
type KittyImage ¶ added in v0.3.0
type KittyImage struct {
// contains filtered or unexported fields
}
func (*KittyImage) CellSize ¶ added in v0.3.0
func (k *KittyImage) CellSize() (w int, h int)
func (*KittyImage) Destroy ¶ added in v0.3.0
func (k *KittyImage) Destroy()
Destroy deletes this image from memory
func (*KittyImage) Draw ¶ added in v0.3.0
func (k *KittyImage) Draw(win Window)
type ModifierMask ¶
type ModifierMask int
ModifierMask is a bitmask for which modifier keys were held when a key was pressed
const ( // Values equivalent to kitty keyboard protocol ModShift ModifierMask = 1 << iota ModAlt ModCtrl ModSuper ModHyper ModMeta ModCapsLock ModNumLock )
type Mouse ¶
type Mouse struct { Button MouseButton Row int Col int EventType EventType Modifiers ModifierMask }
Mouse is a mouse event
type MouseButton ¶
type MouseButton int
MouseButton represents a mouse button
const ( MouseLeftButton MouseButton = iota MouseMiddleButton MouseRightButton MouseNoButton MouseWheelUp MouseButton = 64 MouseWheelDown MouseButton = 65 MouseButton8 MouseButton = 128 MouseButton9 MouseButton = 129 MouseButton10 MouseButton = 130 MouseButton11 MouseButton = 131 )
type MouseShape ¶
type MouseShape string
MouseShape is used with OSC 22 to change the shape of the mouse cursor
const ( MouseShapeDefault MouseShape = "default" MouseShapeTextInput MouseShape = "text" MouseShapeClickable MouseShape = "pointer" MouseShapeHelp MouseShape = "help" MouseShapeBusyBackground MouseShape = "progress" MouseShapeBusy MouseShape = "wait" MouseShapeResizeHorizontal MouseShape = "ew-resize" MouseShapeResizeVertical MouseShape = "ns-resize" // The thick plus sign cursor that's typically used in spread-sheet applications to select cells. MouseShapeCell MouseShape = "cell" )
type Options ¶
type Options struct { // DisableKittyKeyboard disables the use of the Kitty Keyboard protocol. // By default, if support is detected the protocol will be used. DisableKittyKeyboard bool // Deprecated Use CSIuBitMask instead // // ReportKeyboardEvents will report key release and key repeat events if // KittyKeyboardProtocol is enabled and supported by the terminal ReportKeyboardEvents bool // The size of the event queue channel. This will default to 1024 to // prevent any blocking on writes. EventQueueSize int // Disable mouse events DisableMouse bool // WithTTY passes an absolute path to use for the TTY Vaxis will draw // on. If the file is not a TTY, an error will be returned when calling // New WithTTY string // NoSignals causes Vaxis to not install any signal handlers NoSignals bool // CSIuBitMask is the bit mask to use for CSIu key encoding, when // available. This has no effect if DisableKittyKeyboard is true CSIuBitMask CSIuBitMask }
Options are the runtime options which must be supplied to a new Vaxis object at instantiation
type PasteEndEvent ¶
type PasteEndEvent struct{}
PasteEndEvent is sent at the end of a bracketed paste. Each Key within the paste will also have the EventPaste set as the EventType
type PasteStartEvent ¶
type PasteStartEvent struct{}
PasteStartEvent is sent at the beginning of a bracketed paste. Each Key within the paste will also have the EventPaste set as the EventType
type QuitEvent ¶
type QuitEvent struct{}
QuitEvent is sent when the application is closing. It is emitted when the application calls vaxis.Close, and often times won't be seen by the application.
type Redraw ¶
type Redraw struct{}
Redraw is a generic event which can be sent to the host application to tell it some update has occurred it may not know about otherwise and it must redraw. These are always issued after a SyncFunc has been called
type Sixel ¶ added in v0.3.0
type Sixel struct {
// contains filtered or unexported fields
}
func (*Sixel) Destroy ¶ added in v0.3.0
func (s *Sixel) Destroy()
Destroy removes an image from memory. Call when done with this image
type Style ¶
type Style struct { // Hyperlink is used for adding OSC 8 information to the cell or // segment. Hyperlink string // HyperlinkParams is passed as the param string for OSC 8 sequences. // Typically this will be something like "id=<some-id>" to signal // non-contiguous links which are the same (IE when a link may be // wrapped on lines) HyperlinkParams string // Foreground is the color to apply to the foreground of this cell Foreground Color // Background is the color to apply to the background of this cell Background Color // UnderlineColor is the color to apply to the underline of this cell, // if supported UnderlineColor Color // UnderlineStyle is the type of underline to apply (single, double, // curly, etc). If a particular style is not supported, Vaxis will // fallback to single underlines UnderlineStyle UnderlineStyle // Attribute represents all other style information for this cell (bold, // dim, italic, etc) Attribute AttributeMask }
Style contains all the data required to style a Cell or Segment
type StyledString ¶ added in v0.7.0
type StyledString struct {
Cells []Cell
}
func (*StyledString) Encode ¶ added in v0.7.0
func (ss *StyledString) Encode() string
func (*StyledString) Len ¶ added in v0.7.0
func (ss *StyledString) Len() int
Returns the rendered width of the styled string
type SyncFunc ¶ added in v0.2.0
type SyncFunc func()
SyncFunc is a function which will be called in the main thread. vaxis will call the function and send an empty SyncFunc event to the application to signal that something has been updated (probably the application needs to redraw itself)
type UnderlineStyle ¶
type UnderlineStyle uint8
UnderlineStyle represents the style of underline to apply
const ( UnderlineOff UnderlineStyle = iota UnderlineSingle UnderlineDouble UnderlineCurly UnderlineDotted UnderlineDashed )
type Vaxis ¶
type Vaxis struct {
// contains filtered or unexported fields
}
func New ¶
New creates a new Vaxis instance. Calling New will query the underlying terminal for supported features and enter the alternate screen
func (*Vaxis) CanDisplayGraphics ¶ added in v0.1.2
func (*Vaxis) CanKittyGraphics ¶ added in v0.1.2
func (*Vaxis) CanReportBackgroundColor ¶ added in v0.9.0
func (*Vaxis) CanSetAppID ¶ added in v0.9.0
func (*Vaxis) ClipboardPop ¶
ClipboardPop requests the content from the system clipboard. ClipboardPop works by requesting the data from the underlying terminal, which responds back with the data. Depending on usage, this could take some time. Callers can provide a context to set a deadline for this function to return. An error will be returned if the context is cancelled.
func (*Vaxis) ClipboardPush ¶
ClipboardPush copies the provided string to the system clipboard
func (*Vaxis) Close ¶
func (vx *Vaxis) Close()
Close shuts down the event loops and returns the terminal to it's original state
func (*Vaxis) CursorPosition ¶
Reports the current cursor position. 0,0 is the upper left corner. Reports -1,-1 if the query times out or fails
func (*Vaxis) NewFullBlockImage ¶ added in v0.3.0
func (vx *Vaxis) NewFullBlockImage(img image.Image) *FullBlockImage
func (*Vaxis) NewHalfBlockImage ¶ added in v0.3.0
func (vx *Vaxis) NewHalfBlockImage(img image.Image) *HalfBlockImage
func (*Vaxis) NewImage ¶ added in v0.3.0
NewImage creates a new image using the highest quality renderer the terminal is capable of
func (*Vaxis) NewKittyGraphic ¶ added in v0.3.0
func (vx *Vaxis) NewKittyGraphic(img image.Image) *KittyImage
func (*Vaxis) NewStyledString ¶ added in v0.7.0
func (vx *Vaxis) NewStyledString(s string, defaultStyle Style) *StyledString
func (*Vaxis) Notify ¶
Notify (attempts) to send a system notification. If title is the empty string, OSC9 will be used - otherwise osc777 is used
func (*Vaxis) PostEventBlocking ¶ added in v0.10.2
PostEventBlocking inserts an event into the Vaxis event loop. The call will block if the queue is full. This method should only be used from a different goroutine than the main thread.
func (*Vaxis) QueryBackground ¶ added in v0.9.0
QueryBackground queries the host terminal for background color and returns it as an instance of vaxis.Color. If the host terminal doesn't support this, Color(0) is returned instead. Make sure not to run this in the same goroutine as Vaxis runs in or deadlock will occur.
func (*Vaxis) Refresh ¶
func (vx *Vaxis) Refresh()
Refresh forces a full render of the entire screen. Traditionally, this should be bound to Ctrl+l
func (*Vaxis) RenderedWidth ¶
RenderedWidth returns the rendered width of the provided string. The result is dependent on if your terminal can support unicode properly.
This is best effort. It will usually be correct, and in the few cases it's wrong will end up wrong in the nicer-rendering way (complex emojis will have extra space after them. This is preferable to messing up the internal model)
This call can be expensive, callers should consider caching the result for strings or characters which will need to be measured frequently
func (*Vaxis) Resize ¶ added in v0.2.0
func (vx *Vaxis) Resize()
Resize manually triggers a resize event. Normally, vaxis listens to SIGWINCH for resize events, however in some use cases a manual resize trigger may be needed
func (*Vaxis) Resume ¶ added in v0.1.2
Resume returns the application to it's fullscreen state, re-enters raw mode, and reenables input parsing. Upon resuming, a Resize event will be delivered. It is entirely possible the terminal was resized while suspended.
func (*Vaxis) SetMouseShape ¶
func (vx *Vaxis) SetMouseShape(shape MouseShape)
SetMouseShape sets the shape of the mouse
func (*Vaxis) ShowCursor ¶
func (vx *Vaxis) ShowCursor(col int, row int, style CursorStyle)
ShowCursor shows the cursor at the given colxrow, with the given style. The passed column and row are 0-indexed and global. To show the cursor relative to a window, use Window.ShowCursor
func (*Vaxis) Suspend ¶ added in v0.1.2
Suspend takes Vaxis out of fullscreen state, disables all terminal modes, stops listening for signals, and returns the terminal to it's original state. Suspend can be useful to, for example, drop out of the full screen TUI and run another TUI. The state of vaxis will be retained, so you can reenter the original state by calling Resume
func (*Vaxis) SyncFunc ¶
func (vx *Vaxis) SyncFunc(fn func())
SyncFunc queues a function to be called from the main thread. vaxis will call the function when the event is received in the main thread either through PollEvent or Events. A Redraw event will be sent to the host application after the function is completed
func (*Vaxis) TerminalID ¶ added in v0.9.0
TerminalID returns the terminal name and version advertised by the terminal, if supported. The actual format is implementation-defined, but it is safe to assume that the ID will start with the terminal name. Some examples: "foot(1.17.2)"; "WezTerm 20210502-154244-3f7122cb"
type Window ¶
type Window struct { // Vx is a reference to the [Vx] instance Vx *Vaxis // Parent is a reference to a parent [Window], if nil then the offsets // and size will be relative to the underlying terminal window Parent *Window Column int // col offset from parent Row int // row offset from parent Width int // width of the surface, in cols Height int // height of the surface, in rows }
Window is a Window with an offset from an optional parent and a specified size. A Window can be instantiated directly, however the provided constructor methods are recommended as they will enforce size constraints
func (Window) Clear ¶
func (win Window) Clear()
Clear fills the Window with spaces with the default colors and removes all graphics placements
func (Window) Print ¶
Print prints [Segment]s, with each block having a given style. Text will be wrapped, line breaks will begin a new line at the first column of the surface. If the text overflows the height of the surface then only the top portion will be shown
func (Window) PrintTruncate ¶
PrintTruncate prints a single line of text to the specified row. If the text is wider than the width of the window, the line will be truncated with "…":
"This line has mo…"
If the row is outside the bounds of the window, nothing will be printed
func (Window) Println ¶
Println prints a single line of text to the specified row. If the text is wider than the width of the window, the line will be truncated with "…":
"This line has mo…"
If the row is outside the bounds of the window, nothing will be printed
func (Window) SetCell ¶
SetCell is used to place data at the given cell location. Note that since the Window doesn't retain this data, if the location is outside of the visible area, it is simply discarded.
func (Window) SetStyle ¶ added in v0.4.6
SetStyle changes the style at a given location, leaving the text in place.
func (Window) ShowCursor ¶
func (win Window) ShowCursor(col int, row int, style CursorStyle)
ShowCursor shows the cursor at colxrow, relative to this Window's location
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
_examples
|
|
cmd
|
|
vtwidth
vtwidth is a utility to measure the width of a string as it will be rendered in the terminal
|
vtwidth is a utility to measure the width of a string as it will be rendered in the terminal |
Package octreequant implements an image quantizer, for transforming bitmap images to palette images, before encoding them to SIXEL.
|
Package octreequant implements an image quantizer, for transforming bitmap images to palette images, before encoding them to SIXEL. |
widgets
|
|