objects

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const TRIANGLE_DOWN string = "🔻"

Variables

View Source
var ARROW_MAPPING map[tcell.Key]Point = map[tcell.Key]Point{
	tcell.KeyUp:    {0, -1},
	tcell.KeyDown:  {0, +1},
	tcell.KeyLeft:  {-1, 0},
	tcell.KeyRight: {+1, 0},
}

Mapping event keys arrow to direction (x, y)

View Source
var DIRECTIONS map[tcell.Key]int = map[tcell.Key]int{
	tcell.KeyUp:   -1,
	tcell.KeyDown: 1,
}

Functions

This section is empty.

Types

type MultiOptionBox

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

func MultiOptionBox_new

func MultiOptionBox_new(title string, x, y, size_w, size_h int, content map[string]string) *MultiOptionBox

func (*MultiOptionBox) Display

func (mob *MultiOptionBox) Display(screen tcell.Screen)

func (*MultiOptionBox) GetContent

func (mob *MultiOptionBox) GetContent() string

func (*MultiOptionBox) GetCursorPosition

func (mob *MultiOptionBox) GetCursorPosition() (int, int)

Returns the current cursor position relative to the object

func (*MultiOptionBox) HandleEventKey

func (mob *MultiOptionBox) HandleEventKey(screen tcell.Screen, event *tcell.EventKey)

func (*MultiOptionBox) HandleEventMouse

func (mob *MultiOptionBox) HandleEventMouse(screen tcell.Screen, event *tcell.EventMouse)

func (*MultiOptionBox) HasFocus

func (mob *MultiOptionBox) HasFocus() bool

func (*MultiOptionBox) IsColliding

func (mob *MultiOptionBox) IsColliding(x, y int) bool

func (*MultiOptionBox) SetFocus

func (mob *MultiOptionBox) SetFocus(value bool)

type Object

type Object interface {
	Display(tcell.Screen)
	IsColliding(int, int) bool
	SetFocus(bool)
	HasFocus() bool
	GetCursorPosition() (int, int)
	GetContent() string
	HandleEventKey(tcell.Screen, *tcell.EventKey)
	HandleEventMouse(tcell.Screen, *tcell.EventMouse)
}

type Point

type Point struct {
	X int // X Position
	Y int // Y Position
}

type Rectangle

type Rectangle struct {
	Width   int // The width of the rectangle
	Height  int // The height of the rectangle
	Start_x int // The starting x position
	Start_y int // The starting y position
}

A simple rectangle

func (Rectangle) DrawRectangle

func (rec Rectangle) DrawRectangle(screen tcell.Screen)

Draw a simple rectangle

type TextBox

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

func TextBox_new

func TextBox_new(title string, x, y, size_w, size_h int) *TextBox

Create a simple text box using a rectangle and leaving one single space for writing text into

func (*TextBox) CheckNextCursorPosition

func (tb *TextBox) CheckNextCursorPosition(next_x, next_y int) bool

func (*TextBox) Display

func (tb *TextBox) Display(screen tcell.Screen)

Display the text box

func (*TextBox) GetContent

func (tb *TextBox) GetContent() string

func (*TextBox) GetCursorPosition

func (tb *TextBox) GetCursorPosition() (int, int)

Returns the current cursor position relative to the object

func (*TextBox) HandleEventKey

func (tb *TextBox) HandleEventKey(screen tcell.Screen, event *tcell.EventKey)

func (*TextBox) HandleEventMouse

func (tb *TextBox) HandleEventMouse(screen tcell.Screen, event *tcell.EventMouse)

func (*TextBox) HasFocus

func (tb *TextBox) HasFocus() bool

func (*TextBox) IsColliding

func (tb *TextBox) IsColliding(x, y int) bool

Check if the textbox collides with input coordinates

func (*TextBox) SetCursorPosition

func (tb *TextBox) SetCursorPosition(x, y int)

func (*TextBox) SetFocus

func (tb *TextBox) SetFocus(value bool)

func (*TextBox) SetNextCursorPosition

func (tb *TextBox) SetNextCursorPosition(x, y int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳