app

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ViewWorkspace  = "workspace"
	ViewMigrations = "migrations"
	ViewDetails    = "details"
	ViewOutputs    = "outputs"
	ViewStatusbar  = "statusbar"
)

View identifiers

Variables

View Source
var (
	PrimaryFrameColor = gocui.ColorWhite
	FocusedFrameColor = gocui.ColorGreen

	PrimaryTitleColor = gocui.ColorWhite | gocui.AttrNone
	FocusedTitleColor = gocui.ColorGreen | gocui.AttrBold

	// Tab styling
	FocusedActiveTabColor = gocui.ColorGreen | gocui.AttrBold // Active tab when panel is focused
	PrimaryActiveTabColor = gocui.ColorGreen | gocui.AttrNone // Active tab when panel is not focused

	// List selection color
	SelectionBgColor = gocui.ColorBlue
)

Frame and title styling

Functions

func AdjustOrigin

func AdjustOrigin(v *gocui.View, originY *int)

AdjustOrigin adjusts the origin to ensure it's within valid bounds Call this after content is rendered but before SetOrigin

func Black

func Black(text string) string

Black colors text black

func Blink(text string) string

Blink makes text blink

func Blue

func Blue(text string) string

Blue colors text blue

func Bold

func Bold(text string) string

Bold makes text bold

func ColorToGocuiAttr added in v0.3.0

func ColorToGocuiAttr(c Color) int

ColorToGocuiAttr converts a Color to a gocui color attribute value. Exported so it can be used by any code that needs this conversion.

func Colorize

func Colorize(text string, color Color) string

Colorize applies a foreground color to text

func CopyToClipboard

func CopyToClipboard(text string) error

CopyToClipboard copies text to the system clipboard

func Cyan

func Cyan(text string) string

Cyan colors text cyan

func Dim

func Dim(text string) string

Dim makes text dim/faint

func Gray

func Gray(text string) string

Gray colors text gray (using 256-color ANSI code)

func Green

func Green(text string) string

Green colors text green

func Italic

func Italic(text string) string

Italic makes text italic

func Magenta

func Magenta(text string) string

Magenta colors text magenta

func Orange

func Orange(text string) string

Orange colors text orange (using 256-color ANSI code)

func Red

func Red(text string) string

Red colors text red

func Reverse

func Reverse(text string) string

Reverse reverses foreground and background colors

func StrikeThru

func StrikeThru(text string) string

StrikeThru strikes through text

func Stylize

func Stylize(text string, style Style) string

Stylize applies the given style to text using ANSI escape codes

func Underline

func Underline(text string) string

Underline underlines text

func White

func White(text string) string

White colors text white

func WrapText added in v0.3.0

func WrapText(text string, maxWidth int, padding string) []string

WrapText wraps text to fit within the specified width. Each resulting line is prefixed with the given padding string. Handles multiple paragraphs separated by newlines.

func Yellow

func Yellow(text string) string

Yellow colors text yellow

Types

type App

type App struct {
	Common *common.Common
	Tr     *i18n.TranslationSet
	// contains filtered or unexported fields
}

func NewApp

func NewApp(config AppConfig) (*App, error)

func (*App) CloseModal

func (a *App) CloseModal()

CloseModal closes the active modal and restores focus

func (*App) CopyMigrationInfo

func (a *App) CopyMigrationInfo()

CopyMigrationInfo copies migration info to clipboard

func (*App) DeleteMigration

func (a *App) DeleteMigration()

DeleteMigration deletes a pending migration

func (*App) FocusNext

func (a *App) FocusNext()

func (*App) FocusPrevious

func (a *App) FocusPrevious()

func (*App) Generate

func (a *App) Generate()

Generate runs prisma generate and shows result in modal

func (*App) GetCurrentPanel

func (a *App) GetCurrentPanel() Panel

GetCurrentPanel returns the currently focused panel

func (*App) GetGui

func (a *App) GetGui() *gocui.Gui

func (*App) HandlePanelClick added in v0.3.0

func (a *App) HandlePanelClick(viewID string)

HandlePanelClick is the public wrapper for panel-click focus switching. It is used as a callback by contexts that manage their own mouse events.

func (*App) HasActiveModal

func (a *App) HasActiveModal() bool

HasActiveModal returns true if a modal is currently active

func (*App) MigrateDeploy

func (a *App) MigrateDeploy()

MigrateDeploy runs npx prisma migrate deploy

func (*App) MigrateDev

func (a *App) MigrateDev()

MigrateDev opens a list modal to choose migration type

func (*App) MigrateResolve

func (a *App) MigrateResolve()

MigrateResolve resolves a failed migration

func (*App) OpenModal

func (a *App) OpenModal(modal Modal)

OpenModal opens a modal and saves current focus state

func (*App) RefreshAll

func (a *App) RefreshAll(onComplete ...func()) bool

RefreshAll refreshes all panels asynchronously

func (*App) RegisterKeybindings

func (a *App) RegisterKeybindings() error

func (*App) RegisterMouseBindings

func (a *App) RegisterMouseBindings()

RegisterMouseBindings registers mouse click handlers for all panels

func (*App) RegisterPanel

func (a *App) RegisterPanel(panel Panel)

func (*App) Run

func (a *App) Run() error

func (*App) SchemaDiffMigration

func (a *App) SchemaDiffMigration()

SchemaDiffMigration performs schema diff-based migration with validation checks

func (*App) StatusBarState added in v0.3.0

func (a *App) StatusBarState() context.StatusBarState

StatusBarState returns callbacks for the StatusBarContext to access App state.

func (*App) Studio

func (a *App) Studio()

Studio toggles Prisma Studio

type AppConfig

type AppConfig struct {
	DebugMode bool
	AppName   string
	Version   string
	Developer string
	Language  string
}

type BaseModal added in v0.3.0

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

BaseModal provides common infrastructure shared by all modal types

func NewBaseModal added in v0.3.0

func NewBaseModal(id string, g *gocui.Gui, tr *i18n.TranslationSet) *BaseModal

NewBaseModal creates a new BaseModal with default style

func (*BaseModal) CalculateDimensions added in v0.3.0

func (b *BaseModal) CalculateDimensions(widthRatio float64, minWidth int) (width int)

CalculateDimensions computes centered coordinates for a modal view. widthRatio is the fraction of screen width (e.g., 4.0/7.0). heightContent is the number of content lines (borders added by caller). minWidth is the minimum width for the modal.

func (*BaseModal) CenterBox added in v0.3.0

func (b *BaseModal) CenterBox(width, height int) (x0, y0, x1, y1 int)

CenterBox returns centered screen coordinates for a box of the given width and height.

func (*BaseModal) ID added in v0.3.0

func (b *BaseModal) ID() string

ID returns the modal's view ID

func (*BaseModal) OnClose added in v0.3.0

func (b *BaseModal) OnClose()

OnClose deletes the modal's primary view

func (*BaseModal) SetStyle added in v0.3.0

func (b *BaseModal) SetStyle(style MessageModalStyle)

SetStyle sets the modal style (used by embedding structs' WithStyle methods)

func (*BaseModal) SetupView added in v0.3.0

func (b *BaseModal) SetupView(name string, x0, y0, x1, y1 int, zIndex byte, title, footer string) (*gocui.View, bool, error)

SetupView creates (or retrieves) a gocui view and applies common frame settings. It handles the "unknown view" error from SetView, applies frame runes, title, footer, and style colours. Returns the view and whether it was newly created.

func (*BaseModal) Style added in v0.3.0

func (b *BaseModal) Style() MessageModalStyle

Style returns the current modal style

type BasePanel

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

func NewBasePanel

func NewBasePanel(id string, g *gocui.Gui) BasePanel

func (*BasePanel) ID

func (bp *BasePanel) ID() string

func (*BasePanel) OnBlur

func (bp *BasePanel) OnBlur()

func (*BasePanel) OnFocus

func (bp *BasePanel) OnFocus()

func (*BasePanel) SetupView

func (bp *BasePanel) SetupView(v *gocui.View, title string)

SetupView handles common view setup

type Color

type Color int

Color represents terminal colors

const (
	ColorDefault Color = iota
	ColorBlack
	ColorRed
	ColorGreen
	ColorYellow
	ColorBlue
	ColorMagenta
	ColorCyan
	ColorWhite
)

type ConfirmModal

type ConfirmModal struct {
	*BaseModal
	// contains filtered or unexported fields
}

ConfirmModal displays a confirmation dialog with Yes/No options

func NewConfirmModal

func NewConfirmModal(g *gocui.Gui, tr *i18n.TranslationSet, title string, message string, onYes func(), onNo func()) *ConfirmModal

NewConfirmModal creates a new confirmation modal

func (*ConfirmModal) Draw

func (m *ConfirmModal) Draw(dim boxlayout.Dimensions) error

Draw renders the modal

func (*ConfirmModal) HandleKey

func (m *ConfirmModal) HandleKey(key any, mod gocui.Modifier) error

HandleKey handles keyboard input

func (*ConfirmModal) OnClose

func (m *ConfirmModal) OnClose()

OnClose is called when the modal is closed

func (*ConfirmModal) WithStyle

func (m *ConfirmModal) WithStyle(style MessageModalStyle) *ConfirmModal

WithStyle sets the modal style

type InputModal

type InputModal struct {
	*BaseModal
	// contains filtered or unexported fields
}

InputModal displays an input field for user text entry

func NewInputModal

func NewInputModal(g *gocui.Gui, tr *i18n.TranslationSet, title string, onSubmit func(string), onCancel func()) *InputModal

NewInputModal creates a new input modal

func (*InputModal) Draw

func (m *InputModal) Draw(dim boxlayout.Dimensions) error

Draw renders the input modal

func (*InputModal) HandleKey

func (m *InputModal) HandleKey(key any, mod gocui.Modifier) error

HandleKey handles keyboard input

func (*InputModal) OnClose

func (m *InputModal) OnClose()

OnClose is called when the modal is closed

func (*InputModal) OnValidationFail

func (m *InputModal) OnValidationFail(callback func(string)) *InputModal

OnValidationFail sets the callback for validation failures

func (*InputModal) WithRequired

func (m *InputModal) WithRequired(required bool) *InputModal

WithRequired sets whether the input is required (non-empty)

func (*InputModal) WithStyle

func (m *InputModal) WithStyle(style MessageModalStyle) *InputModal

WithStyle sets the modal style

func (*InputModal) WithSubtitle

func (m *InputModal) WithSubtitle(subtitle string) *InputModal

WithSubtitle sets the modal subtitle

type ListModal

type ListModal struct {
	*BaseModal
	// contains filtered or unexported fields
}

ListModal displays a list of items with descriptions

func NewListModal

func NewListModal(g *gocui.Gui, tr *i18n.TranslationSet, title string, items []ListModalItem, onCancel func()) *ListModal

NewListModal creates a new list modal

func (*ListModal) Draw

func (m *ListModal) Draw(dim boxlayout.Dimensions) error

Draw renders the list modal with two views (list on top, description on bottom)

func (*ListModal) HandleKey

func (m *ListModal) HandleKey(key any, mod gocui.Modifier) error

HandleKey handles keyboard input

func (*ListModal) OnClose

func (m *ListModal) OnClose()

OnClose is called when the modal is closed

func (*ListModal) WithStyle

func (m *ListModal) WithStyle(style MessageModalStyle) *ListModal

WithStyle sets the modal style

type ListModalItem

type ListModalItem struct {
	Label       string       // Display text in the list
	Description string       // Description shown in the bottom view
	OnSelect    func() error // Callback when item is selected with Enter
}

ListModalItem represents a selectable item in the list modal

type MessageModal

type MessageModal struct {
	*BaseModal
	// contains filtered or unexported fields
}

MessageModal displays a message with title and content

func NewMessageModal

func NewMessageModal(g *gocui.Gui, tr *i18n.TranslationSet, title string, lines ...string) *MessageModal

NewMessageModal creates a new message modal

func (*MessageModal) Draw

func (m *MessageModal) Draw(dim boxlayout.Dimensions) error

Draw renders the modal

func (*MessageModal) HandleKey

func (m *MessageModal) HandleKey(key any, mod gocui.Modifier) error

HandleKey handles keyboard input

func (*MessageModal) OnClose

func (m *MessageModal) OnClose()

OnClose is called when the modal is closed

func (*MessageModal) WithStyle

func (m *MessageModal) WithStyle(style MessageModalStyle) *MessageModal

WithStyle sets the modal style

type MessageModalStyle

type MessageModalStyle struct {
	TitleColor  Color // Color for title (default: ColorDefault)
	BorderColor Color // Color for border (default: ColorDefault)
}

MessageModalStyle holds styling options for the modal

type Modal interface {
	ID() string
	Draw(dim boxlayout.Dimensions) error
	HandleKey(key any, mod gocui.Modifier) error
	OnClose()
}

Modal represents a modal dialog

type Panel

type Panel interface {
	ID() string
	Draw(dim boxlayout.Dimensions) error
	OnFocus()
	OnBlur()
}

type Style

type Style struct {
	FgColor    Color
	BgColor    Color
	Bold       bool
	Italic     bool
	Underline  bool
	Dim        bool
	Blink      bool
	Reverse    bool
	StrikeThru bool
}

Style represents text styling options

Jump to

Keyboard shortcuts

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