grefcore

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ColorRed   = lipgloss.Color("9")   // Bright red for highlights
	ColorGreen = lipgloss.Color("10")  // Bright green for replacements
	ColorCyan  = lipgloss.Color("6")   // Cyan for selection
	ColorGrey  = lipgloss.Color("240") // Dark grey for help and less important text
)

ANSI escape codes for coloring terminal output

Variables

This section is empty.

Functions

func InitModel

func InitModel(results []SearchResult, patternStr, replacement string, pattern *regexp.Regexp, mode AppMode) model

InitModel returns a new model with the initial state

func IsExcluded

func IsExcluded(path string, excludeList []string) bool

Check if path matches any exclude pattern

func ParseExcludeList

func ParseExcludeList(excludeStr string) []string

parseExcludeList parses comma separated exclude patterns

func ReplaceInFile

func ReplaceInFile(filePath string, resultsInFile []SearchResult, pattern *regexp.Regexp, replacementStr string) error

replaceInFile reads a file, applies replacements to selected lines, and writes the result

Types

type AppMode

type AppMode int

AppMode represents the different modes the application provides

const (
	Default AppMode = iota
	SearchOnly
)

type AppState

type AppState int

AppState represents the different UI states of the application

const (
	StateBrowse     AppState = iota // User is browsing search results
	StateConfirming                 // User is confirming replacements
	StateReplacing                  // Replacements are being performed
	StateDone                       // All replacements are done or user quit
)

type SearchResult

type SearchResult struct {
	FilePath  string
	LineNum   int
	LineText  string
	MatchText string
}

SearchResult holds information about a found match

func PerformSearchAdaptive

func PerformSearchAdaptive(rootPath string, pattern *regexp.Regexp, excludeList []string) ([]SearchResult, error)

Choose best approach based on file characteristics and exclusions

Jump to

Keyboard shortcuts

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