Skip to main content

Module logfilter

Module logfilter 

Source
Expand description

A terminal filter UI for scoping streamed process output to one process name.

Ported from internal/logfilter/tui.go. Go builds this on charm.land/bubbletea (the Elm-architecture TUI framework) and charm.land/lipgloss for styling; this port uses ratatui with an inline viewport (ratatui::Viewport::Inline(1) plus Terminal::insert_before), which is the direct equivalent of Go’s tea.Println-above-a-persistent-view pattern: a one-line status bar stays pinned at the bottom while log lines scroll permanently above it. See PORT_NOTES.md.

Structs§

Context
A narrow stand-in for Go’s context.Context-carried TUI handle. Ported from NewContext/FromContext. See crate::exec::context for the broader discussion of why Go’s ambient context doesn’t translate 1:1 to Rust. Context::default() carries no Tui, matching Go’s zero context.Context having nothing stored under contextKey{}.
Tui
Ported from TUI. Go’s program/ready/done fields (the Bubble Tea program handle and its lifecycle channels) become, respectively: a channel Sender<TuiEvent> the running event loop listens on (tx), and two AtomicBools (ready/done) standing in for Go’s closed-channel-as-signal idiom. filter is unchanged from the pre-existing port.
TuiError
Ported from the error returned by TUI.Start.
TuiWriter
Ported from tuiWriter.

Functions§

colorize_process
Ported from ColorizeProcess. Returns line unchanged if it doesn’t start with a [name] prefix; otherwise wraps the [name] prefix in a truecolor ANSI SGR escape, picking the color the same way Go’s lipgloss-rendered version does. Built from plain ANSI escapes (rather than threading anstream/anstyle through here) because this function has no access to the eventual output stream to detect NO_COLOR/non-TTY – that detection already happens one layer up, at the ratatui CrosstermBackend the colorized text is rendered into (ratatui only emits color escapes when the backend supports it), and at TuiWriter’s direct-write-after-done fallback, which inherits whatever styling policy its destination writer already applies (matching Go, which never strips color from ColorizeProcess’s output either).
from_context
Ported from FromContext.
new_context
Ported from NewContext.