highlight

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package highlight renders safe, line-oriented ANSI emphasis for terminal output.

It is deliberately a presentation-only layer. Callers retain the original terminal bytes in Session and pass a separate output stream to Renderer. Its WinTerm-inspired semantic theme adapts to the local terminal's TrueColor, 256-color, or 16-color capability.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Renderer)

Option configures one Renderer.

func WithColorProfile

func WithColorProfile(profile termenv.Profile) Option

WithColorProfile selects the ANSI color capability used for generated presentation styles. Callers should select the profile from the local output terminal; it does not describe the remote terminal.

type Renderer

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

Renderer incrementally renders terminal text to one local output stream.

Renderer is not safe for concurrent use. One attached terminal client must own one Renderer and serialize Write and Flush calls around any unrelated local status output. It never modifies the caller's input slice.

func New

func New(output io.Writer, options ...Option) *Renderer

New creates a Renderer that writes styled terminal output to output. It uses TrueColor unless an Option selects another local color profile.

A nil output discards rendered bytes. It is useful for callers that need to exercise parser behavior without a local terminal writer.

func (*Renderer) Flush

func (r *Renderer) Flush() error

Flush writes any incomplete terminal line and ends prompt-echo state. Callers invoke it before local status output or orderly disconnect so later remote prompts are rendered independently and output remains ordered.

func (*Renderer) Write

func (r *Renderer) Write(p []byte) (int, error)

Write accepts terminal bytes and forwards complete safe lines with ANSI emphasis. Unsafe line controls are forwarded unchanged. Remote escape sequences switch presentation to byte-transparent output until their line and any persistent SGR or alternate-screen state safely end.

A recognized shell prompt is emitted before a newline so a remote shell can remain interactive. The following echoed command is deliberately forwarded unchanged until its newline.

Jump to

Keyboard shortcuts

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