views

package
v0.0.0-...-1c8ff3e Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinLevelWidth  = 10
	MinPlayerWidth = 10 + models.PlayerNameMaxLength
	MinModeWidth   = 16
	MinStatsWidth  = 30
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AdventureView

type AdventureView struct {
	Size    tea.WindowSizeMsg
	Level   components.TextDisplay
	Player  components.TextDisplay
	Mode    components.TextDisplay
	Stats   components.TextDisplay
	Info    components.TextDisplay
	GameMap GameMap
	Help    []key.Binding
}

AdventureView represents the adventure mode view

func InitializeAdventureView

func InitializeAdventureView() AdventureView

InitializeAdventureView creates a new instance of AdventureView

func (*AdventureView) RenderScreen

func (av *AdventureView) RenderScreen() string

RenderScreen renders the adventure mode screen

func (*AdventureView) SetInfo

func (av *AdventureView) SetInfo(info string)

SetInfo sets the info text

func (*AdventureView) SetLevel

func (av *AdventureView) SetLevel(level int)

SetLevel sets the level text

func (*AdventureView) SetMode

func (av *AdventureView) SetMode(mode string)

SetMode sets the mode text

func (*AdventureView) SetPlayer

func (av *AdventureView) SetPlayer(player string)

SetPlayer sets the player text

func (*AdventureView) SetStats

func (av *AdventureView) SetStats(keystrokes int, time int)

SetStats sets the stats text with keystrokes and time

func (*AdventureView) UpdateGridDimensions

func (av *AdventureView) UpdateGridDimensions() (int, int)

UpdateGridDimensions updates the grid dimensions

type BaseView

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

BaseView represents the base structure for a views component it contains the window size message, controls, help model, and header

func NewBaseView

func NewBaseView(title string) *BaseView

NewBaseView creates a new instance of BaseView with the specified title

func (*BaseView) Controls

func (bv *BaseView) Controls() components.Controls

Controls returns the Controls associated with the BaseView

type ButtonConfig

type ButtonConfig struct {
	// Label represents the text displayed on the button.
	Label string
	// Inactive determines if the button is rendered.
	Inactive bool
}

ButtonConfig represents the configuration for a button component

type ButtonHandler

type ButtonHandler interface {
	// HandleSelection handles the selection of a button
	HandleSelection() tea.Cmd
}

ButtonHandler defines an interface for handling button selections

type Content

type Content interface {
	View
	SetContent(string)
}

Content represents an interface that extends the View interface it provides a method to set the content of the implementing type

type ContentView

type ContentView struct {
	*BaseView
	// contains filtered or unexported fields
}

ContentView represents a views component that embeds the BaseView struct and includes a content field to manage the content

func NewContentView

func NewContentView(title string) *ContentView

NewContentView returns a new ContentView instance

func (*ContentView) Init

func (cv *ContentView) Init() tea.Cmd

Init initializes the ContentView

func (*ContentView) RenderSections

func (cv *ContentView) RenderSections(sections []models.Section) string

RenderSections takes a slice of Section structs and returns a formatted string representation

func (*ContentView) SetContent

func (cv *ContentView) SetContent(content string)

SetContent sets the content of the ContentView

func (*ContentView) Update

func (cv *ContentView) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages and updates the ContentView accordingly

func (*ContentView) View

func (cv *ContentView) View() string

View renders the ContentView with a fixed title and a scrollable content area

type GameMap

type GameMap struct {
	Field      [][]rune
	Border     lipgloss.Style
	Background lipgloss.Style
}

GameMap represents the game map of the adventure mode

type Menu interface {
	View
	ButtonHandler
}

Menu represents an interface that extends the View interface it provides a method to handle button selection

type MenuView struct {
	*BaseView
	// contains filtered or unexported fields
}

MenuView represents a views component that embeds the BaseView struct and includes a Buttons field to manage the buttons

func NewBaseMenu

func NewBaseMenu(subtitle string, buttonConfigs []ButtonConfig) *MenuView

NewBaseMenu returns a new MenuView instance with the provided subtitle and button configurations

func (mv *MenuView) CurrentButton() *components.Button

CurrentButton returns the currently selected button

func (mv *MenuView) Init() tea.Cmd

Init initializes the MenuView

func (mv *MenuView) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages and updates the MenuView accordingly

func (mv *MenuView) UpdateButtonState(label string, inactive bool)

UpdateButtonState updates the state of a button

func (mv *MenuView) View() string

View renders the MenuView

type SelectionView

type SelectionView struct {
	InsertControls cl.InsertControls
	Help           help.Model
	TextInput      *textinput.Model
	List           *cl.List
	// contains filtered or unexported fields
}

SelectionView is a view that displays a list of items and allows the user to select one of them. It also allows the user to insert a new item.

func NewSelectionView

func NewSelectionView(
	subtitle string,
	list *cl.List,
	textInput *textinput.Model,
	onSelect func(item cl.Item) tea.Cmd,
	onInsert func() tea.Cmd,
) *SelectionView

NewSelectionView creates a new SelectionView

func (*SelectionView) Init

func (sv *SelectionView) Init() tea.Cmd

func (*SelectionView) SelectionControls

func (sv *SelectionView) SelectionControls() cl.SelectionControls

SelectionControls returns the selection controls

func (*SelectionView) Update

func (sv *SelectionView) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*SelectionView) View

func (sv *SelectionView) View() string

type TableView

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

TableView represents a view that displays a table using the bubbles table component

func NewTableView

func NewTableView(subtitle string) *TableView

NewTableView creates a new TableView

func (*TableView) Init

func (tv *TableView) Init() tea.Cmd

func (*TableView) SetColumns

func (tv *TableView) SetColumns(columns []table.Column)

SetColumns sets the columns of the TableView

func (*TableView) SetOnSelect

func (tv *TableView) SetOnSelect(onSelect func(index int) tea.Cmd)

SetOnSelect sets the onSelect function

func (*TableView) SetRows

func (tv *TableView) SetRows(rows []table.Row)

SetRows sets the rows of the TableView

func (*TableView) Update

func (tv *TableView) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*TableView) View

func (tv *TableView) View() string

type View

type View interface {
	tea.Model
	Controls() components.Controls
}

View represents a user interface component that adheres to the tea.Model interface and provides control mechanisms through the Controls method

Jump to

Keyboard shortcuts

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