vimsheet.controller.search
Find-and-replace logic for VimSheet.
- class vimsheet.controller.search.SearchState(pattern='', replace='', case_sensitive=False, use_regex=False, whole_cell=False, current_match=None, matches=<factory>)[source]
Bases:
objectHolds the current search/replace state.
- Parameters:
- __init__(pattern='', replace='', case_sensitive=False, use_regex=False, whole_cell=False, current_match=None, matches=<factory>)
- class vimsheet.controller.search.Searcher(sheet)[source]
Bases:
objectPerforms find/replace operations on a Sheet.
- Parameters:
sheet (Sheet)
- find_all(state)[source]
Return all (row, col) positions matching state.pattern.
If the pattern is empty every non-empty cell is returned.
- Parameters:
state (SearchState)
- Return type:
- find_next(state, from_pos)[source]
Return the next match after from_pos, wrapping around.
Returns None when there are no matches at all.
- find_prev(state, from_pos)[source]
Return the previous match before from_pos, wrapping around.
Returns None when there are no matches at all.
- replace_one(state, row, col, max_subs=0)[source]
Replace text in (row, col) using state.replace.
max_subs=0 replaces all occurrences; max_subs=1 replaces only the first. Returns True if a replacement was made.
- Parameters:
state (SearchState)
row (int)
col (int)
max_subs (int)
- Return type:
- collect_replacements(state, rows=None, cols=None)[source]
Return (row, col, new_value, new_formula) for matches without mutating.
If rows and cols are both None, scans the entire sheet. If only rows given, scans those rows entirely. If only cols given, scans those columns entirely. If both given, scans the row×col intersection.
- replace_all(state)[source]
Replace all occurrences of state.pattern with state.replace.
Returns the number of cells where a replacement was made.
- Parameters:
state (SearchState)
- Return type:
- replace_in_cols(state, cols, max_subs=0)[source]
Replace in the given column indices only.
max_subs=0 replaces all occurrences per cell; max_subs=1 replaces the first. Returns the number of cells where a replacement was made.
- Parameters:
state (SearchState)
max_subs (int)
- Return type:
- replace_in_range(state, rows, cols, max_subs=0)[source]
Replace within a specific row+col intersection.
Returns the number of cells where a replacement was made.
- replace_in_rows(state, rows, max_subs=0)[source]
Replace in the given row indices only.
max_subs=0 replaces all occurrences per cell; max_subs=1 replaces the first. Returns the number of cells where a replacement was made.
- Parameters:
state (SearchState)
max_subs (int)
- Return type: