Documentation
¶
Index ¶
- Variables
- func AskConfirm(confirm *bool, format string, a ...any) error
- func AskInput(value *string, format string, a ...any) error
- func AskPassword(password *string, format string, a ...any) error
- func EncoderOptions(level term.Level) []diferenco.EncoderOption
- func SetDiffTheme(theme DiffTheme)
- type DiffTheme
- type Pager
- type StringObject
Constants ¶
This section is empty.
Variables ¶
var ( // GitHub theme (default). GitHub = DiffTheme{ Dark: map[color.ColorKey]string{ color.Old: "\x1b[38;2;248;81;73m", color.New: "\x1b[38;2;63;185;80m", color.Frag: "\x1b[38;2;88;166;255m", color.Commit: "\x1b[38;2;210;153;34m", }, Light: map[color.ColorKey]string{ color.Old: "\x1b[38;2;215;58;73m", color.New: "\x1b[38;2;40;167;69m", color.Frag: "\x1b[38;2;0;92;197m", color.Commit: "\x1b[38;2;176;136;0m", }, } // Dracula theme. Dracula = DiffTheme{ Dark: map[color.ColorKey]string{ color.Old: "\x1b[38;2;255;85;85m", color.New: "\x1b[38;2;80;250;123m", color.Frag: "\x1b[38;2;139;233;253m", color.Commit: "\x1b[38;2;241;250;140m", }, Light: map[color.ColorKey]string{ color.Old: "\x1b[38;2;215;58;73m", color.New: "\x1b[38;2;40;167;69m", color.Frag: "\x1b[38;2;0;92;197m", color.Commit: "\x1b[38;2;176;136;0m", }, } // OneDark theme. OneDark = DiffTheme{ Dark: map[color.ColorKey]string{ color.Old: "\x1b[38;2;224;108;117m", color.New: "\x1b[38;2;152;195;121m", color.Frag: "\x1b[38;2;97;175;239m", color.Commit: "\x1b[38;2;209;154;102m", }, Light: map[color.ColorKey]string{ color.Old: "\x1b[38;2;228;86;73m", color.New: "\x1b[38;2;80;161;79m", color.Frag: "\x1b[38;2;56;125;203m", color.Commit: "\x1b[38;2;188;122;0m", }, } // Catppuccin theme. Catppuccin = DiffTheme{ Dark: map[color.ColorKey]string{ color.Old: "\x1b[38;2;243;139;168m", color.New: "\x1b[38;2;166;227;161m", color.Frag: "\x1b[38;2;137;180;250m", color.Commit: "\x1b[38;2;249;226;175m", }, Light: map[color.ColorKey]string{ color.Old: "\x1b[38;2;210;15;57m", color.New: "\x1b[38;2;64;160;43m", color.Frag: "\x1b[38;2;30;102;245m", color.Commit: "\x1b[38;2;223;142;29m", }, } // Nord theme. Nord = DiffTheme{ Dark: map[color.ColorKey]string{ color.Old: "\x1b[38;2;191;97;106m", color.New: "\x1b[38;2;163;190;140m", color.Frag: "\x1b[38;2;136;192;208m", color.Commit: "\x1b[38;2;235;203;139m", }, Light: map[color.ColorKey]string{ color.Old: "\x1b[38;2;191;97;106m", color.New: "\x1b[38;2;163;190;140m", color.Frag: "\x1b[38;2;136;192;208m", color.Commit: "\x1b[38;2;235;203;139m", }, } )
Predefined diff themes.
var ErrInterrupted = errors.New("interrupted")
ErrInterrupted is returned when user presses Ctrl+C or Ctrl+D.
Functions ¶
func AskConfirm ¶
AskConfirm prompts for a confirmation using huh library. It provides a user-friendly yes/no confirmation dialog.
Note: Output goes to stderr to avoid interfering with stdout piping.
func AskInput ¶
AskInput prompts for a text input with proper CJK/emoji backspace handling.
Note: Output goes to stderr to avoid interfering with stdout piping.
func AskPassword ¶
AskPassword prompts for a password input with asterisk masking. It properly handles UTF-8, CJK characters, emoji, and terminal control sequences. Cross-platform support: Windows, Linux, macOS (via golang.org/x/term).
Note: Output goes to stderr to avoid interfering with stdout piping.
func EncoderOptions ¶ added in v0.23.0
func EncoderOptions(level term.Level) []diferenco.EncoderOption
EncoderOptions returns diferenco.EncoderOption slice with appropriate color configuration based on the terminal's color level.
func SetDiffTheme ¶ added in v0.23.0
func SetDiffTheme(theme DiffTheme)
SetDiffTheme sets the current diff theme.
Types ¶
type Pager ¶
type Pager struct {
// contains filtered or unexported fields
}
Pager represents a simple terminal pager built with viewport. It implements io.Writer and must be closed to display content.
func NewPager ¶
NewPager creates a new pager with given color mode and alt screen setting. The pager implements io.Writer, content is accumulated via Write calls. Close must be called to display the content in the pager. useAltScreen controls whether to use alternate screen buffer (default true).
func (*Pager) Close ¶
Close finalizes the pager and displays the content. For short content that fits in the terminal, it outputs directly without starting the pager. For longer content, it starts an interactive pager with viewport. Close is idempotent - calling it multiple times is safe.
type StringObject ¶ added in v0.23.0
type StringObject string
StringObject implements viewport.Object for a single line
func (StringObject) GetItem ¶ added in v0.23.0
func (s StringObject) GetItem() item.Item