tui

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

AGPL v3 License Copyright (c) 2026 Project Backplane

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

AGPL v3 License Copyright (c) 2026 Project Backplane

Index

Constants

This section is empty.

Variables

View Source
var Registry = map[string]UIStrategy{
	"int":    &NumericStrategy{},
	"bool":   &ToggleStrategy{},
	"string": &TextStrategy{},
}

StrategyRegistry maps type names to UI strategies

Functions

func MakeHandler

func MakeHandler(b *bridge.Bridge, l *logger.RingLogger, c *stats.Cache) func(ssh.Session) (tea.Model, []tea.ProgramOption)

MakeHandler creates a bubbletea middleware handler with injected dependencies

Types

type EditorModel

type EditorModel struct {
	Bridge *bridge.Bridge
	// contains filtered or unexported fields
}

Editor Model

func InitialEditor

func InitialEditor(b *bridge.Bridge) EditorModel

func (*EditorModel) Refresh

func (m *EditorModel) Refresh()

func (EditorModel) Update

func (m EditorModel) Update(msg tea.Msg, subject auth.Subject) (EditorModel, tea.Cmd)

func (EditorModel) View

func (m EditorModel) View() string

type NumericStrategy added in v2.0.1

type NumericStrategy struct{}

NumericStrategy handles integers (inc/dec/edit).

func (*NumericStrategy) HandleKey added in v2.0.1

func (s *NumericStrategy) HandleKey(msg tea.KeyMsg, val interface{}, buf string, sub auth.Subject) (interface{}, string, bool)

func (*NumericStrategy) Render added in v2.0.1

func (s *NumericStrategy) Render(val interface{}, isEditing bool, buf string) string

type StatsMsg

type StatsMsg stats.Snapshot

type TextStrategy added in v2.0.1

type TextStrategy struct{}

TextStrategy handles strings.

func (*TextStrategy) HandleKey added in v2.0.1

func (s *TextStrategy) HandleKey(msg tea.KeyMsg, val interface{}, buf string, sub auth.Subject) (interface{}, string, bool)

func (*TextStrategy) Render added in v2.0.1

func (s *TextStrategy) Render(val interface{}, isEditing bool, buf string) string

type ToggleStrategy added in v2.0.1

type ToggleStrategy struct{}

ToggleStrategy handles booleans.

func (*ToggleStrategy) HandleKey added in v2.0.1

func (s *ToggleStrategy) HandleKey(msg tea.KeyMsg, val interface{}, buf string, sub auth.Subject) (interface{}, string, bool)

func (*ToggleStrategy) Render added in v2.0.1

func (s *ToggleStrategy) Render(val interface{}, isEditing bool, buf string) string

type UIStrategy added in v2.0.1

type UIStrategy interface {
	// Render returns the display string for a value.
	Render(val interface{}, isEditing bool, inputBuffer string) string

	// HandleKey processes a key event for a value.
	// Returns (newValue, cmd, doneEditing).
	// If newValue is nil, no change occurred (or input buffer was updated).
	HandleKey(msg tea.KeyMsg, currentVal interface{}, inputBuffer string, subject auth.Subject) (interface{}, string, bool)
}

UIStrategy defines how a specific type is rendered and edited.

Jump to

Keyboard shortcuts

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