Skip to content

Commit bc451cd

Browse files
committed
update column filter
1 parent 354b691 commit bc451cd

File tree

9 files changed

+1872
-1144
lines changed

9 files changed

+1872
-1144
lines changed

README.md

Lines changed: 68 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,9 @@ tv uses vim-inspired keybindings for intuitive navigation.
223223
| `/` | Search |
224224
| `n` | Next search result |
225225
| `N` | Previous search result |
226-
| `Ctrl-/` | Clear search |
227-
| `f` | Filter by column value |
228-
| `r` | Reset/clear filter |
226+
| `Esc` | Clear search highlighting / Close dialogs |
227+
| `f` | Filter by column |
228+
| `r` | Remove filter for current column |
229229
| `s` | Sort ascending |
230230
| `S` | Sort descending |
231231
| `t` | Toggle column type (String → Number → Date) |
@@ -306,30 +306,30 @@ The statistics dialog features a split-pane layout with numerical stats on the l
306306

307307
### Search
308308

309-
### Search
310-
311309
Find text anywhere in your table with full highlighting support and powerful regex pattern matching.
312310

313311
**How to search:**
314312

315313
1. Press `/` to open the search dialog
316-
2. Type your search term (case-insensitive by default)
317-
3. **Optional:** Press Tab to navigate to the checkbox, then Space to enable "Use Regex" for pattern matching with regular expressions
318-
4. Press Enter to execute the search
319-
5. Navigate results with `n` (next) and `N` (previous)
320-
6. Press `Esc` to clear highlighting
314+
2. Type your search term.
315+
3. **Optional:** Press Tab to navigate to the checkboxes, then Space to enable:
316+
- **Use Regex**: for pattern matching with regular expressions.
317+
- **Case Sensitive**: for case-sensitive matching.
318+
4. Press Enter to execute the search.
319+
5. Navigate results with `n` (next) and `N` (previous).
320+
6. Press `Esc` to clear highlighting.
321321

322322
**Search Modes:**
323323

324-
- **Plain Text (default):** Case-insensitive substring matching
325-
- **Regex:** Full regular expression support for advanced pattern matching
324+
- **Plain Text (default):** Case-insensitive substring matching. Enable `Case Sensitive` for exact matching.
325+
- **Regex:** Full regular expression support. By default, regex is case-insensitive. Enable `Case Sensitive` for case-sensitive regex matching.
326326

327327
**Navigation in Search Dialog:**
328-
- Type your search query in the text field
329-
- Press `Tab` to move between the search field, checkbox, and buttons
330-
- Press `Space` to toggle the "Use Regex" checkbox when focused on it
331-
- Press `Enter` from anywhere in the form to execute the search
332-
- Press `Esc` to cancel and close the dialog
328+
- Type your search query in the text field.
329+
- Press `Tab` to move between the search field, checkboxes, and buttons.
330+
- Press `Space` to toggle a checkbox when it is focused.
331+
- Press `Enter` from anywhere in the form to execute the search.
332+
- Press `Esc` to cancel and close the dialog.
333333

334334
**Visual feedback:**
335335
- Current match: bright cyan highlight
@@ -338,45 +338,50 @@ Find text anywhere in your table with full highlighting support and powerful reg
338338

339339
**Example:**
340340
```
341-
# Simple text search
341+
# Simple text search (case-insensitive)
342342
/ → type "error" → Enter → n → n → N → Esc
343343
344+
# Case-sensitive text search
345+
/ → check "Case Sensitive" → type "Error" → Enter
346+
344347
# Regex search examples
345-
/ → check "Use Regex" → type "^ERROR" → Enter # Lines starting with ERROR
346-
/ → check "Use Regex" → type "\d{4}-\d{2}-\d{2}" → Enter # Date patterns (YYYY-MM-DD)
348+
/ → check "Use Regex" → type "^ERROR" → Enter # Lines starting with ERROR (case-insensitive)
349+
/ → check "Use Regex" and "Case Sensitive" → type "^Error" → Enter # Lines starting with Error (case-sensitive)
350+
/ → check "Use Regex" → type "\\d{4}-\\d{2}-\\d{2}" → Enter # Date patterns (YYYY-MM-DD)
347351
/ → check "Use Regex" → type "user(name)?" → Enter # Match "user" or "username"
348352
/ → check "Use Regex" → type "error|warning|critical" → Enter # Match any of these words
349-
/ → check "Use Regex" → type "@.*\.(com|org)$" → Enter # Email domains ending in .com or .org
353+
/ → check "Use Regex" → type "@.*\\.(com|org)$" → Enter # Email domains ending in .com or .org
350354
```
351355

352356
**Common Regex Patterns:**
353357

354358
| Pattern | Description | Example Match |
355359
|---------|-------------|---------------|
356360
| `^start` | Match at beginning of cell | `^Error` matches "Error: failed" |
357-
| `end$` | Match at end of cell | `\.txt$` matches "file.txt" |
358-
| `\d+` | Match one or more digits | `\d+` matches "123" |
359-
| `\w+@\w+\.\w+` | Match email pattern | Matches "user@example.com" |
360-
| `word1\|word2` | Match either word (OR) | `success\|complete` matches either |
361+
| `end$` | Match at end of cell | `\\.txt$` matches "file.txt" |
362+
| `\\d+` | Match one or more digits | `\\d+` matches "123" |
363+
| `\\w+@\\w+\\.\\w+` | Match email pattern | Matches "user@example.com" |
364+
| `word1\\|word2` | Match either word (OR) | `success\\|complete` matches either |
361365
| `[A-Z]+` | Match uppercase letters | `[A-Z]{3}` matches "USA" |
362366
| `.*` | Match any characters | `start.*end` matches "start...end" |
363-
| `\s+` | Match whitespace | `\s{2,}` matches 2+ spaces |
367+
| `\\s+` | Match whitespace | `\\s{2,}` matches 2+ spaces |
364368

365-
**Note:** Regex mode is case-sensitive. Use `(?i)` at the start of your pattern for case-insensitive matching (e.g., `(?i)error`).
369+
**Note:** For case-insensitive regex search, the `(?i)` flag is automatically added to your pattern. For case-sensitive regex, this flag is omitted.
366370

367371
### Column Filter
368372

369-
Show only rows where specific columns match your criteria. **Supports filtering on multiple columns simultaneously** with powerful OR, AND, and ROR operators for complex filtering.
373+
Show only rows where specific columns match your criteria. **Supports filtering on multiple columns simultaneously**.
370374

371375
**How to filter:**
372376

373377
1. Navigate to the column you want to filter
374378
2. Press `f` to open the filter dialog
375-
3. Type filter text (case-insensitive, partial match)
376-
4. Use operators for complex queries (must be UPPERCASE with spaces)
377-
5. Press Enter to apply
378-
6. **Repeat on other columns to add more filters**
379-
7. Press `r` on a filtered column to remove that column's filter
379+
3. Use the dropdown to select an operator (e.g., `contains`, `equals`, `regex`, `>`).
380+
4. Enter the value to filter by.
381+
5. Optionally, check the `Case Sensitive` box.
382+
6. Press Enter to apply the filter.
383+
7. **Repeat on other columns to add more filters**
384+
8. Press `r` on a filtered column to remove that column's filter
380385

381386
**Multi-Column Filtering:**
382387

@@ -389,90 +394,61 @@ Show only rows where specific columns match your criteria. **Supports filtering
389394

390395
**Operators:**
391396

392-
| Operator | Syntax | Behavior | Example |
393-
|----------|--------|----------|---------|
394-
| **Simple** | `term` | Matches cells containing the term | `active` → matches "Active", "Inactive" |
395-
| **OR** | `term1 OR term2` | Same cell contains either term | `error OR warning` → cell has "error" or "warning" |
396-
| **AND** | `term1 AND term2` | Same cell contains both terms | `user AND admin` → cell has both words |
397-
| **ROR** | `term1 ROR term2` | Keeps all rows matching any term | `high ROR critical` → rows with "high" + rows with "critical" |
398-
| **>** | `>value` | Numeric: greater than (number columns only) | `>30` → values greater than 30 |
399-
| **<** | `<value` | Numeric: less than (number columns only) | `<50` → values less than 50 |
400-
| **>=** | `>=value` | Numeric: greater than or equal (number columns only) | `>=100` → values 100 or more |
401-
| **<=** | `<=value` | Numeric: less than or equal (number columns only) | `<=75` → values 75 or less |
402-
403-
**Key Differences:**
404-
- **OR vs ROR**: OR checks if a single cell contains either term. ROR combines rows where any cell matches any term (row-level union).
397+
| Operator | Description |
398+
|---|---|
399+
| `contains` | Matches cells containing the term |
400+
| `equals` | Matches cells that are exactly the term |
401+
| `starts with` | Matches cells that start with the term |
402+
| `ends with` | Matches cells that end with the term |
403+
| `regex` | Matches cells based on a regular expression |
404+
| `>` | Numeric: greater than (number columns only) |
405+
| `<` | Numeric: less than (number columns only) |
406+
| `>=` | Numeric: greater than or equal (number columns only) |
407+
| `<=` | Numeric: less than or equal (number columns only) |
408+
409+
**Key Features:**
405410
- **Numeric operators** (`>`, `<`, `>=`, `<=`): Only work on numeric and date columns (automatically detected). Perform numeric comparisons instead of text matching.
406-
- All operators must be **UPPERCASE** and surrounded by spaces (except numeric operators)
407-
- Search terms are case-insensitive (except numeric comparisons)
408-
- All matching is partial (substring) for text, exact comparison for numeric operators
409-
- **Visual indicator**: Filtered column headers show 🔎 icons and orange background
411+
- **Regex**: Provides the full power of regular expressions for complex pattern matching.
412+
- **Case-Insensitive by default**: All string-based comparisons are case-insensitive unless the `Case Sensitive` box is checked.
413+
- **Visual indicator**: Filtered column headers show 🔎 icons and an orange background
410414

411415
**Examples:**
412416

413417
```bash
414418
# Simple filter - partial match
415-
Navigate to "Status" column → f → type "pending" → Enter
419+
Navigate to "Status" column → f → select 'contains'type "pending" → Enter
416420
# Result: Matches "Pending", "Pending Review", etc.
417421

418-
# OR filter - same cell matches either term
419-
Navigate to "Status" column → f → type "active OR pending" → Enter
420-
# Result: Rows where Status contains "active" OR "pending"
422+
# Exact match filter
423+
Navigate to "Status" column → f → select 'equals'type "active" → Enter
424+
# Result: Rows where Status is exactly "active" (case-insensitive)
421425

422-
# AND filter - same cell must contain both terms
423-
Navigate to "Description" column → f → type "user AND admin" → Enter
424-
# Result: Rows where Description has both "user" AND "admin"
425-
426-
# ROR filter - combines separate result sets
427-
Navigate to "Priority" column → f → type "high ROR critical" → Enter
428-
# Result: All rows with "high" + all rows with "critical" (union)
426+
# Regex filter
427+
Navigate to "Email" column → f → select 'regex'type "^.+@gmail\.com$" → Enter
428+
# Result: Rows where Email ends with "@gmail.com"
429429

430430
# Numeric comparison - greater than
431-
Navigate to "Age" column → f → type ">30" → Enter
431+
Navigate to "Age" column → f → select '>'type "30" → Enter
432432
# Result: Rows where Age is greater than 30
433433

434-
# Numeric comparison - less than or equal
435-
Navigate to "Score" column → f → type "<=85" → Enter
436-
# Result: Rows where Score is 85 or less
437-
438-
# Numeric comparison - greater than or equal
439-
Navigate to "Salary" column → f → type ">=50000" → Enter
440-
# Result: Rows where Salary is 50000 or more
441-
442434
# Multi-column filtering
443-
Navigate to "City" column → f → type "New York" → Enter
444-
Navigate to "Department" column → f → type "Engineering" → Enter
445-
# Result: Rows where City="New York" AND Department contains "Engineering"
446-
447-
# Multi-column with numeric filter
448-
Navigate to "Age" column → f → type ">25" → Enter
449-
Navigate to "Score" column → f → type ">80" → Enter
450-
# Result: Rows where Age > 25 AND Score > 80
435+
Navigate to "City" column → f → select 'equals'type "New York" → Enter
436+
Navigate to "Department" column → f → select 'contains'type "Engineering" → Enter
437+
# Result: Rows where City is "New York" AND Department contains "Engineering"
451438

452439
# Edit existing filter
453-
Navigate to filtered column → f → modify text → Enter
440+
Navigate to filtered column → f → modify operator/value → Enter
454441
# Or enter empty text to remove that column's filter
455442

456443
# Remove a specific filter
457444
Navigate to filtered column → Press r
458445
# Result: That column's filter removed, other filters remain
459-
460-
# Remove all filters one by one
461-
Navigate to each filtered column → Press r on each
462-
# Or press f and enter empty text
463446
```
464447
465-
**Use Cases:**
466-
- Use **OR** when a single field can have alternative values
467-
- Use **AND** when a single field must meet multiple criteria
468-
- Use **ROR** when you want to combine different categories of results
469-
- Use **numeric operators** (`>`, `<`, `>=`, `<=`) to filter by numeric ranges on number or date columns
470-
- Use **multi-column filters** to narrow down data by multiple dimensions (e.g., location AND department AND status)
471-
472448
**Visual Feedback:**
473449
- When a filter is active, the filtered column header displays 🔎 icons and an orange background
474-
- A dedicated **filter strip** appears above the main footer **only when cursor is on the filtered column**
475-
- Filter strip format: `🔎 Filter Active: [Column Name] = "query" | Press 'r' to clear`
450+
- A dedicated **filter strip** appears above the main footer showing the active filter on the current column.
451+
- Filter strip format: `🔎 Filter Active: [Column Name] [operator] "query" | Press 'r' to clear`
476452
- The strip automatically hides when you move to a different column
477453
- Press `r` to clear the filter and return to normal view
478454

0 commit comments

Comments
 (0)