tviewimg

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Image

type Image struct {
	*tview.Box
	// contains filtered or unexported fields
}

Image implements a widget that displays one image. The original image (specified with Image.SetImage) is resized according to the specified size (see Image.SetSize), using the specified number of colors (see [Image.SetColors]), while applying dithering if necessary (see [Image.SetDithering]).

Images are approximated by graphical characters in the terminal. The resolution is therefore limited by the number and type of characters that can be drawn in the terminal and the colors available in the terminal. The quality of the final image also depends on the terminal's font and spacing settings, none of which are under the control of this package. Results may vary.

func NewImage

func NewImage() *Image

NewImage returns a new image widget with an empty image (use Image.SetImage to specify the image to be displayed). The image will use the widget's entire available space. The dithering algorithm is set to Floyd-Steinberg dithering. The terminal's cell aspect ratio defaults to 0.5.

func (*Image) Draw

func (i *Image) Draw(screen tcell.Screen)

Draw draws this primitive onto the screen.

func (*Image) Focus

func (i *Image) Focus(delegate func(p tview.Primitive))

Focus is called when this primitive receives focus.

func (*Image) GetFieldHeight

func (i *Image) GetFieldHeight() int

GetFieldHeight returns this primitive's field height. This is the image's height or 8 if the height is 0 or less.

func (*Image) GetFieldWidth

func (i *Image) GetFieldWidth() int

GetFieldWidth returns this primitive's field width. This is the image's width or, if the width is 0 or less, the proportional width of the image based on its height as returned by Image.GetFieldHeight. If there is no image, 0 is returned.

func (*Image) GetLabel

func (i *Image) GetLabel() string

func (*Image) SetDisabled

func (i *Image) SetDisabled(disabled bool) tview.FormItem

SetDisabled sets whether or not the item is disabled / read-only.

func (*Image) SetFinishedFunc

func (i *Image) SetFinishedFunc(handler func(key tcell.Key)) tview.FormItem

SetFinishedFunc sets a callback invoked when the user leaves this form item.

func (*Image) SetFormAttributes

func (i *Image) SetFormAttributes(labelWidth int, labelColor, bgColor, fieldTextColor, fieldBgColor tcell.Color) tview.FormItem

SetFormAttributes sets a number of item attributes at once.

func (*Image) SetImage

func (i *Image) SetImage(image image.Image) *Image

SetImage sets the image to be displayed. If nil, the widget will be empty.

func (*Image) SetSize

func (i *Image) SetSize(rows, columns int) *Image

SetSize sets the size of the image. Positive values refer to cells in the terminal. Negative values refer to a percentage of the available space (e.g. -50 means 50%). A value of 0 means that the corresponding size is chosen automatically based on the other size while preserving the image's aspect ratio. If both are 0, the image uses as much space as possible while still preserving the aspect ratio.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL