ui

package
v0.40.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// 基本色
	Cyan    = color.New(color.FgCyan)    // 情報・ヘッダー
	Yellow  = color.New(color.FgYellow)  // 警告・プロンプト
	Green   = color.New(color.FgGreen)   // 成功・追加
	Red     = color.New(color.FgRed)     // エラー・削除
	White   = color.New(color.FgWhite)   // 通常テキスト
	Blue    = color.New(color.FgBlue)    // リンク・参照
	Magenta = color.New(color.FgMagenta) // 特殊・ハイライト

	// Bold variants
	BoldCyan   = color.New(color.FgCyan, color.Bold)
	BoldYellow = color.New(color.FgYellow, color.Bold)
	BoldGreen  = color.New(color.FgGreen, color.Bold)
	BoldRed    = color.New(color.FgRed, color.Bold)
	BoldWhite  = color.New(color.FgWhite, color.Bold)

	// 特殊用途
	Dim   = color.New(color.Faint) // 薄い表示(コンテキスト行など)
	Bold  = color.New(color.Bold)  // 太字
	Faint = color.New(color.Faint) // 薄い表示
)

共通色定義 全パッケージで一貫した色使いを実現するための定義

View Source
var (
	Info    = Cyan     // 情報メッセージ
	Success = Green    // 成功メッセージ
	Warning = Yellow   // 警告メッセージ
	Error   = Red      // エラーメッセージ
	Prompt  = Yellow   // ユーザー入力プロンプト
	Header  = BoldCyan // セクションヘッダー
)

用途別エイリアス(セマンティックカラー)

View Source
var DefaultBoxStyle = BoxStyle{
	TopLeft:     "┌",
	TopRight:    "┐",
	BottomLeft:  "└",
	BottomRight: "┘",
	Horizontal:  "─",
	Vertical:    "│",
	LeftT:       "├",
	RightT:      "┤",
}

DefaultBoxStyle は標準のボックススタイル

View Source
var DefaultDiffOptions = DiffOptions{
	ContextLines:  3,
	ShowLineNums:  true,
	InlineMode:    true,
	MaxTotalLines: 50,
}

DefaultDiffOptions はデフォルトの差分表示オプション

Functions

func ConfirmPromptBox added in v0.31.0

func ConfirmPromptBox(message string)

ConfirmPromptBox は確認プロンプト用のボックスを表示

func IsMultilineMarker added in v0.29.0

func IsMultilineMarker(input string) bool

IsMultilineMarker checks if the input is a multiline marker

func ShowColoredDiff added in v0.31.0

func ShowColoredDiff(oldStr, newStr string, opts *DiffOptions)

ShowColoredDiff は色付きの差分を表示 oldStr: 変更前のテキスト newStr: 変更後のテキスト opts: 表示オプション(nilならデフォルト使用)

func ShowUnifiedDiff added in v0.31.0

func ShowUnifiedDiff(diffOutput string)

ShowUnifiedDiff はUnified Diff形式で色付き表示

func SimpleDivider added in v0.31.0

func SimpleDivider(width int)

SimpleDivider はシンプルな区切り線を表示

func ToolConfirmBox added in v0.31.0

func ToolConfirmBox(toolName string, details []string)

ToolConfirmBox はツール確認用のボックスを表示

func TrimBracketedPasteMarkers added in v0.29.0

func TrimBracketedPasteMarkers(input string) string

TrimBracketedPasteMarkers removes bracketed paste markers from input (both forms)

Types

type BoxStyle added in v0.31.0

type BoxStyle struct {
	TopLeft     string
	TopRight    string
	BottomLeft  string
	BottomRight string
	Horizontal  string
	Vertical    string
	LeftT       string
	RightT      string
}

BoxStyle はボックスの罫線スタイル

type DiffOptions added in v0.31.0

type DiffOptions struct {
	ContextLines  int  // 差分前後の表示行数
	ShowLineNums  bool // 行番号を表示するか
	InlineMode    bool // インラインモード(追加・削除を連続表示)
	MaxTotalLines int  // 最大表示行数(0=無制限)
}

DiffOptions は差分表示のオプション

type MultilineReader added in v0.29.0

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

MultilineReader handles multiline input with bracketed paste mode and ``` markers

func NewMultilineReader added in v0.29.0

func NewMultilineReader(r io.Reader) *MultilineReader

NewMultilineReader creates a new multiline reader

func (*MultilineReader) DisableBracketedPaste added in v0.29.0

func (m *MultilineReader) DisableBracketedPaste()

DisableBracketedPaste is a no-op (kept for API compatibility)

func (*MultilineReader) EnableBracketedPaste added in v0.29.0

func (m *MultilineReader) EnableBracketedPaste()

EnableBracketedPaste is a no-op (kept for API compatibility) Note: We don't enable bracketed paste mode because some terminals (WSL/Ubuntu) display the escape sequences as literal text. Instead, we just strip markers.

func (*MultilineReader) FlushInput added in v0.31.0

func (m *MultilineReader) FlushInput()

FlushInput discards any buffered input data This should be called after AI output completes to ignore keypresses during output

func (*MultilineReader) ReadInput added in v0.29.0

func (m *MultilineReader) ReadInput(prompt string) (string, error)

ReadInput reads user input, supporting: 1. ``` markers for explicit multiline mode 2. Single line input (default) All bracketed paste markers are automatically stripped from input

func (*MultilineReader) Reader added in v0.31.0

func (m *MultilineReader) Reader() *bufio.Reader

Reader returns the underlying bufio.Reader for sharing with other input handlers

type Pager

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

Pager は長い出力をページング表示

func NewPager

func NewPager() *Pager

NewPager は新しいPagerを作成

func (*Pager) Display

func (p *Pager) Display(content string)

Display はコンテンツをページング表示

type PasteMode added in v0.31.0

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

PasteMode captures multiline input for environments where bracketed paste mode is unreliable. It is also reusable from other input contexts (e.g., comment input during confirmations).

End conditions: - empty line x2 - "END" or "/end" - Ctrl+D (EOF)

Cancel: - "/cancel" or "/c" (content is discarded)

Limits: - max lines / max bytes - idle timeout

Note: This does NOT read from the OS clipboard. It is an interactive capture mode.

func NewPasteMode added in v0.31.0

func NewPasteMode(cfg config.PasteConfig) *PasteMode

func (*PasteMode) Capture added in v0.31.0

func (p *PasteMode) Capture(in io.Reader, out io.Writer) (content string, cancelled bool, err error)

Capture reads multiline input from in and writes prompts/help to out. Returns captured content, cancelled=true when user cancelled, and error when I/O fails. Deprecated: Use CaptureWithReader for better buffer sharing.

func (*PasteMode) CaptureWithReader added in v0.31.0

func (p *PasteMode) CaptureWithReader(reader *bufio.Reader, out io.Writer) (content string, cancelled bool, err error)

CaptureWithReader reads multiline input using an existing bufio.Reader. This avoids buffer conflicts when sharing stdin with other readers. Returns captured content, cancelled=true when user cancelled, and error when I/O fails.

type Spinner

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

Spinner はターミナルでアニメーションを表示

func NewSpinner

func NewSpinner() *Spinner

NewSpinner は新しいSpinnerを作成

func NewSpinnerWithWriter added in v0.31.0

func NewSpinnerWithWriter(w io.Writer) *Spinner

NewSpinnerWithWriter は出力先を指定してSpinnerを作成 run_test などで stdout 出力(コマンド結果)と混ざらないよう、stderr を指定する用途を想定。

func (*Spinner) Start

func (s *Spinner) Start(message string)

Start はスピナーアニメーションを開始

func (*Spinner) Stop

func (s *Spinner) Stop()

Stop はスピナーを停止して行をクリア

Jump to

Keyboard shortcuts

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