Documentation
¶
Index ¶
- Constants
- func AdjustOrigin(v *gocui.View, originY *int)
- func ColorToGocuiAttr(c Color) int
- func CopyToClipboard(text string) error
- func WrapText(text string, maxWidth int, padding string) []string
- type App
- func (a *App) Alert(title string, message string)
- func (a *App) CloseModal()
- func (a *App) Confirm(opts types.ConfirmOpts)
- func (a *App) ErrorHandler(err error) error
- func (a *App) FinishCommand()
- func (a *App) FocusNext()
- func (a *App) FocusPrevious()
- func (a *App) GetCurrentPanel() Panel
- func (a *App) GetGui() *gocui.Gui
- func (a *App) GetTranslationSet() *i18n.TranslationSet
- func (a *App) HandlePanelClick(viewID string)
- func (a *App) HasActiveModal() bool
- func (a *App) LogAction(action string, detail ...string)
- func (a *App) LogCommandBlocked(commandName string)
- func (a *App) Menu(opts types.MenuOpts) error
- func (a *App) OnUIThread(f func() error)
- func (a *App) OpenModal(modal Modal)
- func (a *App) Prompt(opts types.PromptOpts)
- func (a *App) Refresh()
- func (a *App) RefreshAll(onComplete ...func()) bool
- func (a *App) RefreshPanels()
- func (a *App) RegisterKeybindings() error
- func (a *App) RegisterMouseBindings()
- func (a *App) RegisterPanel(panel Panel)
- func (a *App) Run() error
- func (a *App) RunStreamingCommand(opts AsyncCommandOpts) bool
- func (a *App) SetControllers(mc *MigrationsController, gc *GenerateController, sc *StudioController, ...)
- func (a *App) StatusBarState() context.StatusBarState
- func (a *App) Toast(message string)
- func (a *App) TryStartCommand(commandName string) bool
- type AppConfig
- type AsyncCommandOpts
- type BaseModal
- func (b *BaseModal) AcceptsTextInput() bool
- func (b *BaseModal) CalculateDimensions(widthRatio float64, minWidth int) (width int)
- func (b *BaseModal) CenterBox(width, height int) (x0, y0, x1, y1 int)
- func (b *BaseModal) ClosesOnEnter() bool
- func (b *BaseModal) ID() string
- func (b *BaseModal) OnClose()
- func (b *BaseModal) SetStyle(style MessageModalStyle)
- func (b *BaseModal) SetupView(name string, x0, y0, x1, y1 int, zIndex byte, title, footer string) (*gocui.View, bool, error)
- func (b *BaseModal) Style() MessageModalStyle
- type BasePanel
- type ClipboardController
- type Color
- type ConfirmModal
- type GenerateController
- type InputModal
- func (m *InputModal) AcceptsTextInput() bool
- func (m *InputModal) Draw(dim boxlayout.Dimensions) error
- func (m *InputModal) HandleKey(key any, mod gocui.Modifier) error
- func (m *InputModal) OnClose()
- func (m *InputModal) OnValidationFail(callback func(string)) *InputModal
- func (m *InputModal) WithRequired(required bool) *InputModal
- func (m *InputModal) WithStyle(style MessageModalStyle) *InputModal
- func (m *InputModal) WithSubtitle(subtitle string) *InputModal
- type ListModal
- type ListModalItem
- type MessageModal
- type MessageModalStyle
- type MigrationsController
- type Modal
- type Panel
- type StudioController
Constants ¶
const ( ViewWorkspace = "workspace" ViewMigrations = "migrations" ViewDetails = "details" ViewOutputs = "outputs" ViewStatusbar = "statusbar" )
View identifiers
Variables ¶
This section is empty.
Functions ¶
func AdjustOrigin ¶
AdjustOrigin adjusts the origin to ensure it's within valid bounds Call this after content is rendered but before SetOrigin
func ColorToGocuiAttr ¶
ColorToGocuiAttr converts a Color to a gocui color attribute value. Exported so it can be used by any code that needs this conversion.
func CopyToClipboard ¶
CopyToClipboard copies text to the system clipboard
Types ¶
type App ¶
type App struct {
Common *common.Common
Tr *i18n.TranslationSet
// contains filtered or unexported fields
}
func (*App) CloseModal ¶
func (a *App) CloseModal()
CloseModal closes the active modal and restores focus
func (*App) Confirm ¶
func (a *App) Confirm(opts types.ConfirmOpts)
Confirm shows a yes/no confirmation popup. The ConfirmOpts callbacks return error; the underlying ConfirmModal expects func(). We wrap them with adapters that discard the error.
func (*App) ErrorHandler ¶
ErrorHandler shows an error modal with red styling.
func (*App) FinishCommand ¶
func (a *App) FinishCommand()
FinishCommand marks command execution as complete.
func (*App) FocusPrevious ¶
func (a *App) FocusPrevious()
func (*App) GetCurrentPanel ¶
GetCurrentPanel returns the currently focused panel
func (*App) GetTranslationSet ¶
func (a *App) GetTranslationSet() *i18n.TranslationSet
GetTranslationSet returns the current translation set.
func (*App) HandlePanelClick ¶
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 ¶
HasActiveModal returns true if a modal is currently active
func (*App) LogAction ¶
LogAction logs a user-visible action to the output panel. Wrapped in g.Update() for thread safety — OutputContext.LogAction mutates o.content without mutex, so it must run on the UI thread.
func (*App) LogCommandBlocked ¶
LogCommandBlocked logs a message when command execution is blocked.
func (*App) OnUIThread ¶
OnUIThread schedules a function to run on the UI thread.
func (*App) Prompt ¶
func (a *App) Prompt(opts types.PromptOpts)
Prompt shows a text-input popup. The PromptOpts callback returns error; the underlying InputModal expects func(string). We wrap with an adapter that discards the error.
func (*App) Refresh ¶
func (a *App) Refresh()
Refresh triggers a data refresh and re-render of all contexts. This is the controller-facing API; it ignores the return value of RefreshAll.
func (*App) RefreshAll ¶
RefreshAll refreshes all panels asynchronously
func (*App) RefreshPanels ¶
func (a *App) RefreshPanels()
RefreshPanels refreshes all panels (blocking, internal).
func (*App) RegisterKeybindings ¶
func (*App) RegisterMouseBindings ¶
func (a *App) RegisterMouseBindings()
RegisterMouseBindings registers mouse click handlers for all panels
func (*App) RegisterPanel ¶
func (*App) RunStreamingCommand ¶
func (a *App) RunStreamingCommand(opts AsyncCommandOpts) bool
RunStreamingCommand handles the common boilerplate for streaming prisma commands. Returns false if the command could not be started (another command running or panel missing). The helper does NOT call FinishCommand() -- each callback is responsible for calling it.
func (*App) SetControllers ¶
func (a *App) SetControllers(mc *MigrationsController, gc *GenerateController, sc *StudioController, cc *ClipboardController)
SetControllers wires the extracted controllers into the App.
func (*App) StatusBarState ¶
func (a *App) StatusBarState() context.StatusBarState
StatusBarState returns callbacks for the StatusBarContext to access App state.
func (*App) Toast ¶
Toast shows a brief message. Currently delegates to Alert as there is no auto-dismiss toast system yet.
func (*App) TryStartCommand ¶
TryStartCommand attempts to start a command execution. Returns true if command can start, false if another command is already running.
type AsyncCommandOpts ¶
type AsyncCommandOpts struct {
Name string // for tryStartCommand / logCommandBlocked
Args []string // full command args: ["npx", "prisma", "migrate", "deploy"]
LogAction string // log action label (e.g., "Migrate Deploy")
LogDetail string // log detail text (e.g., "Running prisma migrate deploy...")
SkipTryStart bool // true if tryStartCommand was already called by the caller
// Callbacks — each callback is responsible for calling finishCommand() at the appropriate time.
// The helper never calls finishCommand() itself.
OnSuccess func(out *context.OutputContext, cwd string)
OnFailure func(out *context.OutputContext, cwd string, exitCode int)
OnError func(out *context.OutputContext, cwd string, err error)
// ErrorTitle and ErrorStartMsg are used for the default RunAsync failure modal.
// If empty, generic error text is used.
ErrorTitle string
ErrorStartMsg string
}
AsyncCommandOpts configures a streaming async command.
type BaseModal ¶
type BaseModal struct {
// contains filtered or unexported fields
}
BaseModal provides common infrastructure shared by all modal types
func NewBaseModal ¶
NewBaseModal creates a new BaseModal with default style
func (*BaseModal) AcceptsTextInput ¶
AcceptsTextInput returns false by default (most modals don't accept text input).
func (*BaseModal) CalculateDimensions ¶
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 ¶
CenterBox returns centered screen coordinates for a box of the given width and height.
func (*BaseModal) ClosesOnEnter ¶
ClosesOnEnter returns false by default (most modals handle Enter via HandleKey).
func (*BaseModal) SetStyle ¶
func (b *BaseModal) SetStyle(style MessageModalStyle)
SetStyle sets the modal style (used by embedding structs' WithStyle methods)
func (*BaseModal) SetupView ¶
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 ¶
func (b *BaseModal) Style() MessageModalStyle
Style returns the current modal style
type ClipboardController ¶
type ClipboardController struct {
// contains filtered or unexported fields
}
ClipboardController handles clipboard-related operations.
func NewClipboardController ¶
func NewClipboardController( c types.IControllerHost, g *gocui.Gui, migrationsCtx *context.MigrationsContext, openModal func(Modal), closeModal func(), ) *ClipboardController
NewClipboardController creates a new ClipboardController.
func (*ClipboardController) CopyMigrationInfo ¶
func (cc *ClipboardController) CopyMigrationInfo()
CopyMigrationInfo copies migration info to clipboard
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 GenerateController ¶
type GenerateController struct {
// contains filtered or unexported fields
}
GenerateController handles prisma generate operations.
func NewGenerateController ¶
func NewGenerateController( c types.IControllerHost, g *gocui.Gui, outputCtx *context.OutputContext, openModal func(Modal), runStreamCmd func(AsyncCommandOpts) bool, ) *GenerateController
NewGenerateController creates a new GenerateController.
func (*GenerateController) Generate ¶
func (gc *GenerateController) Generate()
Generate runs prisma generate and shows result in modal
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) AcceptsTextInput ¶
func (m *InputModal) AcceptsTextInput() bool
AcceptsTextInput returns true because InputModal uses keyboard for text entry.
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) 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) ClosesOnEnter ¶
func (m *MessageModal) ClosesOnEnter() bool
ClosesOnEnter returns true because MessageModal is dismissed with Enter.
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 MigrationsController ¶
type MigrationsController struct {
// contains filtered or unexported fields
}
MigrationsController handles migration-related operations.
func NewMigrationsController ¶
func NewMigrationsController( c types.IControllerHost, g *gocui.Gui, migrationsCtx *context.MigrationsContext, outputCtx *context.OutputContext, openModal func(Modal), closeModal func(), runStreamCmd func(AsyncCommandOpts) bool, ) *MigrationsController
NewMigrationsController creates a new MigrationsController.
func (*MigrationsController) DeleteMigration ¶
func (mc *MigrationsController) DeleteMigration()
DeleteMigration deletes a pending migration
func (*MigrationsController) MigrateDeploy ¶
func (mc *MigrationsController) MigrateDeploy()
MigrateDeploy runs npx prisma migrate deploy
func (*MigrationsController) MigrateDev ¶
func (mc *MigrationsController) MigrateDev()
MigrateDev opens a list modal to choose migration type
func (*MigrationsController) MigrateResolve ¶
func (mc *MigrationsController) MigrateResolve()
MigrateResolve resolves a failed migration
func (*MigrationsController) SchemaDiffMigration ¶
func (mc *MigrationsController) SchemaDiffMigration()
SchemaDiffMigration performs schema diff-based migration with validation checks
type Modal ¶
type Modal interface {
ID() string
Draw(dim boxlayout.Dimensions) error
HandleKey(key any, mod gocui.Modifier) error
OnClose()
// AcceptsTextInput reports whether the modal uses keyboard input for text entry
// (e.g. InputModal). When true, single-character keys like 'q' are not treated
// as close commands.
AcceptsTextInput() bool
// ClosesOnEnter reports whether pressing Enter should close the modal
// (e.g. MessageModal). When false, Enter is forwarded to HandleKey instead.
ClosesOnEnter() bool
}
Modal represents a modal dialog
type Panel ¶
type Panel interface {
ID() string
Draw(dim boxlayout.Dimensions) error
OnFocus()
OnBlur()
}
type StudioController ¶
type StudioController struct {
// contains filtered or unexported fields
}
StudioController handles Prisma Studio toggle operations.
func NewStudioController ¶
func NewStudioController( c types.IControllerHost, g *gocui.Gui, outputCtx *context.OutputContext, openModal func(Modal), ) *StudioController
NewStudioController creates a new StudioController.
func (*StudioController) GetStudioCmd ¶
func (sc *StudioController) GetStudioCmd() *commands.Command
GetStudioCmd returns the running studio command (for cleanup on app exit).
func (*StudioController) IsStudioRunning ¶
func (sc *StudioController) IsStudioRunning() bool
IsStudioRunning returns whether Prisma Studio is currently running.