utils

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BinaryDetectionBytes is the number of bytes to read for binary detection
	BinaryDetectionBytes = 8192

	// MaxPreviewLines is the maximum number of lines to show in file preview
	MaxPreviewLines = 50

	// MaxLineLength is the maximum character length for a single line
	MaxLineLength = 120

	// MaxDirectoryEntries is the maximum number of directory entries to show
	MaxDirectoryEntries = 20

	// HistoryContextLinesBefore is the number of history context lines before
	HistoryContextLinesBefore = 3

	// HistoryContextLinesAfter is the number of history context lines after
	HistoryContextLinesAfter = 4
)

Binary detection and preview constants

Variables

This section is empty.

Functions

func FormatFileSize

func FormatFileSize(size int64) string

FormatFileSize formats a file size in bytes to a human-readable string

func FormatRelativeTime

func FormatRelativeTime(timestamp int64) string

FormatRelativeTime formats a Unix timestamp as a human-readable relative time

func FormatTime

func FormatTime(timestamp int64) string

FormatTime formats a Unix timestamp as YYYY-MM-DD HH:MM:SS

func GetFilePreview

func GetFilePreview(path string, maxLines int) string

GetFilePreview returns a preview of the file contents with syntax highlighting

func HighlightCode added in v0.2.5

func HighlightCode(code string, filename string) (string, error)

HighlightCode performs syntax highlighting on code

func IsBinary

func IsBinary(content []byte) bool

IsBinary checks if the given content appears to be binary

func RestoreTTY

func RestoreTTY(origStdoutFd int)

RestoreTTY restores stdout to the original file descriptor

func SetupTTY

func SetupTTY() (origStdoutFd int, err error)

SetupTTY redirects stdin, stdout, stderr to /dev/tty for TUI interaction and returns the original stdout file descriptor for later restoration. The caller must call RestoreTTY with the returned fd when done.

Types

This section is empty.

Jump to

Keyboard shortcuts

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