Documentation
¶
Index ¶
- Constants
- func InitModel(results []SearchResult, patternStr, replacement string, pattern *regexp.Regexp, ...) model
- func IsExcluded(path string, excludeList []string) bool
- func ParseExcludeList(excludeStr string) []string
- func PerformReplacements(allResults []SearchResult, selected map[int]struct{}, pattern *regexp.Regexp, ...) error
- func ReplaceInFile(filePath string, resultsInFile []SearchResult, pattern *regexp.Regexp, ...) (err error)
- type AppMode
- type AppState
- type SearchResult
Constants ¶
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 ¶
IsExcluded checks if a given file or directory path matches any pattern in the exclusion list. It handles directory suffixes (ending with /), file extensions (*.ext), and exact filename matches.
func ParseExcludeList ¶
ParseExcludeList converts a comma-separated string of patterns into a slice.
func PerformReplacements ¶ added in v1.2.0
func PerformReplacements(allResults []SearchResult, selected map[int]struct{}, pattern *regexp.Regexp, replacementStr string) error
PerformReplacements coordinates the replacement process across multiple files. It groups results by file path to ensure each file is opened and written only once.
func ReplaceInFile ¶
func ReplaceInFile(filePath string, resultsInFile []SearchResult, pattern *regexp.Regexp, replacementStr string) (err error)
ReplaceInFile streams the file line-by-line to a temporary file, applying replacements. This approach is memory-efficient and works on files of any size.
Types ¶
type SearchResult ¶
type SearchResult struct {
FilePath string // Full path to the file
LineNum int // 1-based line number
LineText string // Full text of the line containing the match
MatchText string // The specific text substring that triggered the regex
}
SearchResult holds information about a specific pattern match within a file.
func PerformSearchAdaptive ¶
func PerformSearchAdaptive(rootPath string, pattern *regexp.Regexp, excludeList []string) ([]SearchResult, error)
PerformSearchAdaptive traverses a directory tree and searches for a regex pattern. It uses a pool of worker goroutines to process files in parallel and selects the optimal search strategy based on file size and regex complexity.