Documentation
¶
Index ¶
- type DraggableWidget
- type EventHandler
- type Manager
- type Modal
- func (m *Modal) Draw(cvs *canvas.Canvas, meta *widgetapi.Meta) error
- func (m *Modal) HandleMouse(event *terminalapi.Mouse)
- func (m *Modal) Keyboard(k *terminalapi.Keyboard, meta *widgetapi.EventMeta) error
- func (m *Modal) Mouse(event *terminalapi.Mouse, meta *widgetapi.EventMeta) error
- func (m *Modal) Options() widgetapi.Options
- func (m *Modal) SetDirty(dirty bool)
- type Option
- func Border(border bool) Option
- func DockGap(gap int) Option
- func EnableLogging(enable bool) Optiondeprecated
- func LogPrefix(prefix string) Optiondeprecated
- func MinimizeGlyphs(minimize, restore rune) Option
- func MinimumSize(size image.Point) Option
- func TitleBarCellOpts(opts ...cell.Option) Option
- func TitleCellOpts(opts ...cell.Option) Option
- func TitleControlCellOpts(opts ...cell.Option) Option
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DraggableWidget ¶
type DraggableWidget struct {
ID string
Title string
Widget widgetapi.Widget
X int
Y int
Width int
Height int
ZIndex int
Border bool
Minimizable bool
// contains filtered or unexported fields
}
DraggableWidget is a widget that can be repositioned with the mouse.
func NewDraggableWidget ¶
func NewDraggableWidget(id string, widget widgetapi.Widget, x, y, width, height int, opts *Options) *DraggableWidget
NewDraggableWidget creates a draggable child widget configured for the modal.
func (*DraggableWidget) HandleMouse ¶
func (dw *DraggableWidget) HandleMouse(event *terminalapi.Mouse, maxZIndexFunc func() int, canvasWidth, canvasHeight int, modal *Modal) bool
HandleMouse updates drag state and position for the draggable widget.
type EventHandler ¶
type EventHandler struct {
// contains filtered or unexported fields
}
EventHandler routes mouse and keyboard events used by the modal demo.
func NewEventHandler ¶
func NewEventHandler(ctx context.Context, cancel context.CancelFunc, rootContainer *container.Container, modalManager *Manager) *EventHandler
NewEventHandler creates an event handler for a modal manager and root container.
func (*EventHandler) HandleKeyboard ¶
func (eh *EventHandler) HandleKeyboard(k *terminalapi.Keyboard)
HandleKeyboard closes the active modal on Escape and quits on q, Q, or Ctrl+C.
func (*EventHandler) HandleMouse ¶
func (eh *EventHandler) HandleMouse(event *terminalapi.Mouse)
HandleMouse intentionally ignores mouse events.
Modal widgets receive mouse input through the standard termdash widget event path, which provides coordinates relative to the modal canvas. Forwarding raw terminal mouse events from the demo would bypass that translation and make dragging inaccurate.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager tracks the currently visible modal.
func (*Manager) HandleMouse ¶
func (mm *Manager) HandleMouse(event *terminalapi.Mouse) bool
HandleMouse forwards a mouse event to the active modal.
func (*Manager) HasActiveModal ¶
HasActiveModal reports whether a modal is currently visible.
type Modal ¶
type Modal struct {
// ID identifies the container that hosts the modal.
ID string
// DraggableItems holds the widgets drawn inside the modal.
DraggableItems []*DraggableWidget
// Opts holds the modal configuration.
Opts *Options
// contains filtered or unexported fields
}
Modal renders and manages a set of draggable child widgets.
func NewModal ¶
func NewModal(id string, items []*DraggableWidget, opts *Options) *Modal
NewModal creates a modal widget.
func (*Modal) HandleMouse ¶
func (m *Modal) HandleMouse(event *terminalapi.Mouse)
HandleMouse updates the top-most matching draggable widget.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option configures modal widget options.
func EnableLogging
deprecated
func MinimizeGlyphs ¶
MinimizeGlyphs sets the glyphs used for minimize and restore controls.
func MinimumSize ¶
MinimumSize sets the minimum canvas size requested by the modal widget.
func TitleBarCellOpts ¶
TitleBarCellOpts sets the cell styling used for the title bar background.
func TitleCellOpts ¶
TitleCellOpts sets the cell styling used for the window title text.
func TitleControlCellOpts ¶
TitleControlCellOpts sets the cell styling used for title bar control glyphs.
type Options ¶
type Options struct {
// Border controls whether draggable items draw a rounded border.
Border bool
// MinimumSize is the smallest canvas that the modal will request.
MinimumSize image.Point
// TitleBarCellOpts styles the draggable window title bar background.
TitleBarCellOpts []cell.Option
// TitleCellOpts styles the draggable window title text.
TitleCellOpts []cell.Option
// TitleControlCellOpts styles the title-bar control glyphs.
TitleControlCellOpts []cell.Option
// MinimizeGlyph is drawn in the title bar while the window is expanded.
MinimizeGlyph rune
// RestoreGlyph is drawn in the title bar while the window is minimized.
RestoreGlyph rune
// DockGap is the spacing used between minimized windows in the bottom dock.
DockGap int
}
Options holds modal configuration.
func NewOptions ¶
NewOptions creates an Options value with the provided options applied.