tui

package
v0.23.2 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTerminalWidth  = 180
	DefaultTerminalHeight = 40
	MinTableHeight        = 10
	ModalWidthReduction   = 40 // How much to reduce width for modal
	ModalHeightMargin     = 5  // Margin from bottom for modal
	SplitViewHeight       = 15 // Fixed height for detail view
	SplitViewMargin       = 4  // Margin for split view
	SplitContentHeight    = 11 // Fixed content height inside detail view
	DetailsColumnPercent  = 30 // 30% for details column
	HowToFixColumnPercent = 30 // 30% for how-to-fix column
	SeverityColumnWidth   = 10
	CodeWindowSize        = 3000 // Max lines to show above/below target line
	ViewportPadding       = 4
	ContentHeightMargin   = 4
)

layout constants

Variables

View Source
var (
	SyntaxKeyStyle         lipgloss.Style
	SyntaxStringStyle      lipgloss.Style
	SyntaxNumberStyle      lipgloss.Style
	SyntaxBoolStyle        lipgloss.Style
	SyntaxCommentStyle     lipgloss.Style
	SyntaxDashStyle        lipgloss.Style
	SyntaxRefStyle         lipgloss.Style
	SyntaxDefaultStyle     lipgloss.Style
	SyntaxSingleQuoteStyle lipgloss.Style
	SyntaxStylesInit       bool
)

Functions

func ApplySyntaxHighlightingToLine

func ApplySyntaxHighlightingToLine(line string, isYAML bool) string

ApplySyntaxHighlightingToLine applies syntax highlighting to a single line

func BuildOverlayActionsTable added in v0.23.0

func BuildOverlayActionsTable(actions []*highoverlay.Action, warnings []*overlay.Warning, overlayPath string, terminalWidth int) ([]table.Column, []table.Row)

BuildOverlayActionsTable builds the overlay actions table with responsive column widths

func BuildResultTableData

func BuildResultTableData(results []*model.RuleFunctionResult, fileName string, terminalWidth int, showPath bool) ([]table.Column, []table.Row)

BuildResultTableData builds the violation table data, calculating column widths based on terminal size and content.

func ConvertHugoShortcodesToMarkdown

func ConvertHugoShortcodesToMarkdown(content string) string

ConvertHugoShortcodesToMarkdown is a convenience function that converts Hugo shortcodes to markdown with highlight syntax using the default parser configuration

func ConvertHugoShortcodesToMarkdownWithCustomHandlers

func ConvertHugoShortcodesToMarkdownWithCustomHandlers(content string, customHandlers []ShortcodeHandler) string

ConvertHugoShortcodesToMarkdownWithCustomHandlers allows adding custom handlers before parsing

func CountOverlayActionTypes added in v0.23.0

func CountOverlayActionTypes(actions []*highoverlay.Action) (updates, removes int)

CountOverlayActionTypes counts the number of update and remove actions

func FormatOverlaySummary added in v0.23.0

func FormatOverlaySummary(actions []*highoverlay.Action, warningCount int) string

FormatOverlaySummary formats the summary line for overlay actions

func HighlightJSONLine

func HighlightJSONLine(line string) string

HighlightJSONLine handles JSON syntax highlighting

func HighlightYAMLComment

func HighlightYAMLComment(line string, isYAML bool) (string, bool)

HighlightYAMLComment handles comment highlighting for YAML

func HighlightYAMLKeyValue

func HighlightYAMLKeyValue(line string) (string, bool)

HighlightYAMLKeyValue handles key-value pair highlighting for YAML

func HighlightYAMLListItem

func HighlightYAMLListItem(line string) (string, bool)

HighlightYAMLListItem handles list item highlighting for YAML

func HighlightYAMLRefLine

func HighlightYAMLRefLine(line string) (string, bool)

HighlightYAMLRefLine handles special highlighting for $ref lines

func HighlightYAMLValue

func HighlightYAMLValue(value string) string

HighlightYAMLValue applies appropriate styling to a YAML value

func InitSyntaxStyles

func InitSyntaxStyles()

InitSyntaxStyles initializes the syntax highlighting styles once Now uses centralized styles from styles.go

func RenderError

func RenderError(err error)

func RenderErrorString

func RenderErrorString(format string, args ...interface{})

func RenderInfo

func RenderInfo(format string, args ...interface{})

func RenderMarkdownTable

func RenderMarkdownTable(headers []string, rows [][]string) string

func RenderStyledBox

func RenderStyledBox(message string, boxType BoxType, noStyle bool)

func RenderSuccess

func RenderSuccess(format string, args ...interface{})

func RenderWarning

func RenderWarning(format string, args ...interface{})

func ShowViolationTableView

func ShowViolationTableView(results []*model.RuleFunctionResult, fileName string, specContent []byte, watchConfig *WatchConfig, changeStats *utils.ChangeStats, filterStats *utils.ChangeFilterStats) error

ShowViolationTableView displays results in an interactive console table (legacy) If changeStats is non-nil, the dashboard will display "what-changed mode" indicator

Types

type BoxType

type BoxType string
const (
	BoxTypeError      BoxType = "error"
	BoxTypeWarning    BoxType = "warning"
	BoxTypeInfo       BoxType = "info"
	BoxTypeSuccess    BoxType = "success"
	BoxTypeHard       BoxType = "hard"
	BoxTypeComparison BoxType = "comparison"
)

type DocsState

type DocsState int
const (
	DocsStateLoading DocsState = iota
	DocsStateLoaded
	DocsStateError
)

type FilterState

type FilterState int
const (
	FilterAll      FilterState = iota // Show all results
	FilterErrors                      // Show only errors
	FilterWarnings                    // Show only warnings
	FilterInfo                        // Show only info messages
)
const (
	AllSeverity FilterState = iota
	ErrorSeverity
	WarningSeverity
	InfoSeverity
)

func (FilterState) String

func (f FilterState) String() string

String returns the string representation of the FilterState

type ModalType

type ModalType int

ModalType represents which modal is currently open

const (
	ModalNone ModalType = iota
	ModalDocs
	ModalCode
)

type SeverityInfo

type SeverityInfo struct {
	Icon      string
	Text      string
	IconStyle lipgloss.Style
	TextStyle lipgloss.Style
}

SeverityInfo contains all the display information for a severity level

func GetSeverityInfo

func GetSeverityInfo(severity string) SeverityInfo

GetSeverityInfo returns display information for a given severity

func GetSeverityInfoFromText

func GetSeverityInfoFromText(severityText string) SeverityInfo

GetSeverityInfoFromText returns display information for severity text like "✗ error"

type ShortcodeHandler

type ShortcodeHandler struct {
	// Pattern is the regex pattern to match the shortcode
	Pattern *regexp.Regexp
	// Transform is the function that converts matched shortcode to markdown
	Transform func(matches []string) string
}

ShortcodeHandler defines how to transform a shortcode into markdown

type ShortcodeParser

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

ShortcodeParser holds the configuration for parsing shortcodes

func NewShortcodeParser

func NewShortcodeParser() *ShortcodeParser

NewShortcodeParser creates a new shortcode parser with default handlers

func (*ShortcodeParser) AddHandler

func (p *ShortcodeParser) AddHandler(pattern *regexp.Regexp, transform func([]string) string)

AddHandler adds a custom shortcode handler to the parser

func (*ShortcodeParser) Parse

func (p *ShortcodeParser) Parse(input string) string

Parse processes the input text and replaces all shortcodes with their markdown equivalents

type UIState

type UIState struct {
	ViewMode       ViewMode
	ActiveModal    ModalType
	ShowPath       bool
	FilterState    FilterState
	CategoryFilter string
	RuleFilter     string
}

UIState encapsulates all UI state

type ViewMode

type ViewMode int
const (
	ViewModeTable ViewMode = iota
	ViewModeTableWithSplit
)

ViewMode represents the primary view state

type ViolationResultTableModel

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

ViolationResultTableModel holds the state for the interactive table view

func (*ViolationResultTableModel) ApplyFilter

func (m *ViolationResultTableModel) ApplyFilter()

func (*ViolationResultTableModel) BuildCodeView

func (m *ViolationResultTableModel) BuildCodeView() string

BuildCodeView builds the expanded code view modal

func (*ViolationResultTableModel) BuildDetailsView

func (m *ViolationResultTableModel) BuildDetailsView() string

BuildDetailsView builds the details view for a violation when a user presses enter or return on a row.

func (*ViolationResultTableModel) CloseActiveModal

func (m *ViolationResultTableModel) CloseActiveModal()

CloseActiveModal closes the currently open modal

func (*ViolationResultTableModel) ExtractCodeSnippet

func (m *ViolationResultTableModel) ExtractCodeSnippet(result *model.RuleFunctionResult, contextLines int) (string, int)

ExtractCodeSnippet extracts lines around the issue with context

func (*ViolationResultTableModel) FetchOrLoadDocumentation

func (m *ViolationResultTableModel) FetchOrLoadDocumentation() tea.Cmd

FetchOrLoadDocumentation loads documentation from cache or fetches it

func (*ViolationResultTableModel) FormatCodeWithHighlight

func (m *ViolationResultTableModel) FormatCodeWithHighlight(targetLine int, maxWidth int) string

FormatCodeWithHighlight formats the spec content with line numbers and highlights the error line

func (*ViolationResultTableModel) HandleCodeViewKeys

func (m *ViolationResultTableModel) HandleCodeViewKeys(key string) (bool, tea.Cmd)

HandleCodeViewKeys handles keyboard input when code view is open

func (*ViolationResultTableModel) HandleDocsMessages

func (m *ViolationResultTableModel) HandleDocsMessages(msg tea.Msg) (bool, tea.Cmd)

HandleDocsMessages processes documentation-related messages

func (*ViolationResultTableModel) HandleDocsModalKeys

func (m *ViolationResultTableModel) HandleDocsModalKeys(key string) (bool, tea.Cmd)

HandleDocsModalKeys handles keyboard input when modal is open

func (*ViolationResultTableModel) HandleEscapeKey

func (m *ViolationResultTableModel) HandleEscapeKey() (tea.Model, tea.Cmd)

HandleEscapeKey handles the escape key with context-aware behavior

func (*ViolationResultTableModel) HandleFilterKeys

func (m *ViolationResultTableModel) HandleFilterKeys(key string) (bool, tea.Cmd)

HandleFilterKeys handles filter-related keyboard shortcuts

func (*ViolationResultTableModel) HandleToggleKeys

func (m *ViolationResultTableModel) HandleToggleKeys(key string) (bool, tea.Cmd)

HandleToggleKeys handles view toggle keyboard shortcuts

func (*ViolationResultTableModel) HandleWindowResize

func (m *ViolationResultTableModel) HandleWindowResize(msg tea.WindowSizeMsg) tea.Cmd

HandleWindowResize handles terminal resize events

func (*ViolationResultTableModel) Init

func (m *ViolationResultTableModel) Init() tea.Cmd

func (*ViolationResultTableModel) OpenModal

func (m *ViolationResultTableModel) OpenModal(modal ModalType)

OpenModal opens a modal and closes any existing modal

func (*ViolationResultTableModel) PrepareCodeViewport

func (m *ViolationResultTableModel) PrepareCodeViewport()

PrepareCodeViewport prepares the code viewport with the full spec and highlights the error line

func (*ViolationResultTableModel) ReCenterCodeView

func (m *ViolationResultTableModel) ReCenterCodeView()

ReCenterCodeView re-centers the viewport on the highlighted error line

func (*ViolationResultTableModel) TogglePathColumn

func (m *ViolationResultTableModel) TogglePathColumn()

TogglePathColumn toggles the path column visibility with viewport preservation

func (*ViolationResultTableModel) ToggleSplitView

func (m *ViolationResultTableModel) ToggleSplitView()

ToggleSplitView toggles between table and table with split view

func (*ViolationResultTableModel) Update

func (m *ViolationResultTableModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*ViolationResultTableModel) UpdateCategoryFilter

func (m *ViolationResultTableModel) UpdateCategoryFilter(category string)

UpdateCategoryFilter updates category filter

func (*ViolationResultTableModel) UpdateDetailsViewContent

func (m *ViolationResultTableModel) UpdateDetailsViewContent()

UpdateDetailsViewContent updates split view content when cursor changes

func (*ViolationResultTableModel) UpdateFilterState

func (m *ViolationResultTableModel) UpdateFilterState(filter FilterState)

UpdateFilterState updates filter state

func (*ViolationResultTableModel) UpdateRuleFilter

func (m *ViolationResultTableModel) UpdateRuleFilter(rule string)

UpdateRuleFilter updates rule filter

func (*ViolationResultTableModel) View

type WatchConfig

type WatchConfig struct {
	Enabled           bool
	BaseFlag          string
	SkipCheckFlag     bool
	TimeoutFlag       int
	HardModeFlag      bool
	RemoteFlag        bool
	IgnoreFile        string
	FunctionsFlag     string
	RulesetFlag       string
	CertFile          string
	KeyFile           string
	CAFile            string
	Insecure          bool
	Silent            bool
	CustomFunctions   map[string]model.RuleFunction // Pre-loaded custom functions
	OriginalSpecPath  string                        // Path to original spec for what-changed mode (--original)
	ChangesReportPath string                        // Path to JSON change report for what-changed mode (--changes)
}

WatchConfig holds configuration for file watching

type WatchState

type WatchState int
const (
	WatchStateIdle WatchState = iota
	WatchStateProcessing
	WatchStateError
	WatchDebounceDelay = 200 * time.Millisecond
)

Jump to

Keyboard shortcuts

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