rufio 1.6.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +49 -0
  3. data/README.md +17 -10
  4. data/README_ja.md +17 -9
  5. data/SECURITY.md +14 -6
  6. data/docs/csv_cell_preview_design_ja.md +682 -0
  7. data/docs/guide.md +109 -47
  8. data/docs/guide_ja.md +110 -48
  9. data/docs/image_preview_design_ja.md +335 -0
  10. data/docs/native_fuzzy_search_design_ja.md +2 -2
  11. data/examples/config.rb +23 -0
  12. data/info/help.md +32 -27
  13. data/info/keybindings.md +42 -12
  14. data/info/welcome.md +4 -6
  15. data/lib/rufio/background_status.rb +7 -0
  16. data/lib/rufio/bookmark_controller.rb +0 -45
  17. data/lib/rufio/clipboard.rb +162 -0
  18. data/lib/rufio/command_locator.rb +49 -0
  19. data/lib/rufio/config.rb +7 -2
  20. data/lib/rufio/config_loader.rb +56 -21
  21. data/lib/rufio/csv_table_source.rb +125 -0
  22. data/lib/rufio/encoding_detector.rb +152 -0
  23. data/lib/rufio/file_operation_controller.rb +41 -0
  24. data/lib/rufio/file_preview.rb +92 -19
  25. data/lib/rufio/graphics_layer.rb +223 -0
  26. data/lib/rufio/health_checker.rb +27 -10
  27. data/lib/rufio/help_menu.rb +16 -11
  28. data/lib/rufio/image_preview_view.rb +421 -0
  29. data/lib/rufio/image_source.rb +158 -0
  30. data/lib/rufio/keybind_handler.rb +21 -35
  31. data/lib/rufio/kitty_graphics.rb +128 -0
  32. data/lib/rufio/native/aarch64-linux-gnu/librufio_zig.so +0 -0
  33. data/lib/rufio/native/aarch64-linux-musl/librufio_zig.so +0 -0
  34. data/lib/rufio/native/aarch64-macos/librufio_zig.dylib +0 -0
  35. data/lib/rufio/native/aarch64-windows/rufio_zig.dll +0 -0
  36. data/lib/rufio/native/x86_64-linux-gnu/librufio_zig.so +0 -0
  37. data/lib/rufio/native/x86_64-linux-musl/librufio_zig.so +0 -0
  38. data/lib/rufio/native/x86_64-macos/librufio_zig.dylib +0 -0
  39. data/lib/rufio/native/x86_64-windows/rufio_zig.dll +0 -0
  40. data/lib/rufio/native_content_search.rb +1 -1
  41. data/lib/rufio/native_image.rb +177 -0
  42. data/lib/rufio/native_scanner_zig.rb +22 -0
  43. data/lib/rufio/navigation_controller.rb +47 -16
  44. data/lib/rufio/preview_registry.rb +86 -0
  45. data/lib/rufio/preview_view.rb +363 -0
  46. data/lib/rufio/renderer.rb +8 -8
  47. data/lib/rufio/screen.rb +33 -0
  48. data/lib/rufio/search_prompt.rb +50 -0
  49. data/lib/rufio/{global_search.rb → search_screen.rb} +41 -14
  50. data/lib/rufio/sheet_picker.rb +87 -0
  51. data/lib/rufio/sqlite_table_source.rb +205 -0
  52. data/lib/rufio/tab_mode_manager.rb +1 -3
  53. data/lib/rufio/table_cursor.rb +117 -0
  54. data/lib/rufio/table_document.rb +261 -0
  55. data/lib/rufio/table_layout.rb +231 -0
  56. data/lib/rufio/table_preview_view.rb +376 -0
  57. data/lib/rufio/table_query.rb +240 -0
  58. data/lib/rufio/table_source.rb +46 -0
  59. data/lib/rufio/terminal_graphics.rb +168 -0
  60. data/lib/rufio/terminal_ui.rb +63 -111
  61. data/lib/rufio/text_utils.rb +27 -0
  62. data/lib/rufio/ui_renderer.rb +379 -16
  63. data/lib/rufio/version.rb +1 -1
  64. data/lib/rufio/xlsx_table_source.rb +112 -0
  65. data/lib/rufio.rb +19 -5
  66. data/lib_zig/rufio_native/Makefile +6 -4
  67. data/lib_zig/rufio_native/build.zig +10 -0
  68. data/lib_zig/rufio_native/src/image.zig +525 -0
  69. data/lib_zig/rufio_native/src/image_bmp.zig +111 -0
  70. data/lib_zig/rufio_native/src/image_jpeg.zig +878 -0
  71. data/lib_zig/rufio_native/src/image_png.zig +561 -0
  72. data/lib_zig/rufio_native/src/image_resize.zig +170 -0
  73. data/lib_zig/rufio_native/src/image_test.zig +401 -0
  74. data/lib_zig/rufio_native/src/main.zig +1 -0
  75. data/lib_zig/rufio_native/src/search.zig +38 -19
  76. data/lib_zig/rufio_native/src/search_test.zig +35 -0
  77. data/lib_zig/rufio_native/src/testdata/alpha.png +0 -0
  78. data/lib_zig/rufio_native/src/testdata/gradient.bmp +0 -0
  79. data/lib_zig/rufio_native/src/testdata/gradient.jpg +0 -0
  80. data/lib_zig/rufio_native/src/testdata/gradient.png +0 -0
  81. data/retag.sh +4 -4
  82. metadata +37 -9
  83. data/lib/rufio/fuzzy_candidate_cache.rb +0 -258
  84. data/lib/rufio/fuzzy_finder.rb +0 -313
  85. data/lib/rufio/fuzzy_preview_loader.rb +0 -107
  86. data/lib/rufio/rga_result_source.rb +0 -89
  87. data/lib/rufio/search_controller.rb +0 -94
  88. data/lib_zig/rufio_native/src/main.zig.sync +0 -205
data/docs/guide.md CHANGED
@@ -13,7 +13,7 @@ Inside rufio, press `?` to open the help menu at any time.
13
13
  - [File Operations](#file-operations)
14
14
  - [ZIP Archives](#zip-archives)
15
15
  - [Filter and Search](#filter-and-search)
16
- - [Global Search (G mode)](#global-search-g-mode)
16
+ - [Search Screen (`/` in the file list)](#search-screen--in-the-file-list)
17
17
  - [Bookmarks and History](#bookmarks-and-history)
18
18
  - [Command Mode](#command-mode)
19
19
  - [Scripts](#scripts)
@@ -69,8 +69,95 @@ The right pane previews the selected file. Code is highlighted when `bat` is ins
69
69
  | `P` | Fullscreen preview (hides the file list) |
70
70
  | `j` / `k` | Scroll |
71
71
  | `Ctrl+D` / `Ctrl+U` | Page down / up |
72
+ | `y` | Copy the file path to the clipboard |
72
73
  | `ESC` | Back to the file list |
73
74
 
75
+ ### Images
76
+
77
+ Images (`.png`, `.jpg`, `.gif`, `.bmp`) are drawn in the preview pane by the terminal itself, using the Kitty graphics protocol. kitty, Ghostty, WezTerm and Konsole support it; rufio asks the terminal once at startup and silently falls back when the answer is no.
78
+
79
+ | Situation | What you see |
80
+ |-----------|--------------|
81
+ | Supported terminal, `.png` / `.jpg` / `.bmp` up to 32 MiB | The picture, fitted to the pane (split view and `P` both work) |
82
+ | No native library (or `RUFIO_NATIVE_IMAGE=0`), PNG up to 8 MiB | The picture, sent as-is and scaled by the terminal |
83
+ | `.gif`, progressive JPEG, interlaced PNG | Format, pixel size and file size as text |
84
+ | Unsupported terminal, or inside tmux | The same text |
85
+
86
+ The bundled native library (Zig, no third-party image code) decodes the image, scales it down to the pane's real pixel size and re-encodes it as PNG before sending, so a 12 MP photo reaches the terminal as a few hundred KB in about 30 ms, off the main loop. While it works the pane shows `decoding...`.
87
+
88
+ In preview mode (`P`) the picture can be zoomed:
89
+
90
+ | Key | Action |
91
+ |-----|--------|
92
+ | `+` / `-` | Zoom in 25% steps, up to 4x (the terminal is asked for part of the picture, so nothing is decoded here) |
93
+ | `0` | Fit the picture to the pane |
94
+ | `h` / `j` / `k` / `l` or arrows | Move around the picture while zoomed |
95
+
96
+ The cells behind a picture are kept blank so the file list and the status line stay readable, and the picture is removed when you select another file, open the help menu, the search screen or command mode, and when rufio exits. Moving to another file removes the picture immediately and sends the new one about 80 ms later, so holding `j` through a folder of images does not flood the terminal; a picture that was painted over (by a notification, say) is put back; and a file you come back to is not read or encoded again. `RUFIO_IMAGE_PREVIEW=0` turns images off entirely. The design and the remaining phases are in [image_preview_design_ja.md](./image_preview_design_ja.md).
97
+
98
+ ### Searching inside a preview (`/`)
99
+
100
+ `/` in a preview searches the previewed file. Type to jump to the first match from where you are, `Enter` keeps the search, `n` and `N` move to the next and previous match (wrapping around), and `ESC` clears it (a second `ESC` leaves the preview). Every match is highlighted and the current one is drawn in a different colour. Preview mode reads up to 20,000 lines of the first 64 KiB of the file, so the search covers what the preview can show.
101
+
102
+ ### Tables as a Grid
103
+
104
+ `.csv`, `.tsv`, `.tab`, `.xlsx`, `.xlsm` and `.ods` files, and SQLite databases when the `sqlite3` command is installed, are shown as rows and columns:
105
+
106
+ ```
107
+ sales.csv [PREVIEW MODE]
108
+ R3C2 price | hjkl: move y: copy ESC: back
109
+ | A name | B price | C stock |
110
+ 1 | apple | 120 | 30 |
111
+ 2 | mikan | 150 | 8 |
112
+ 3 | banana | 80 | 12 |
113
+ 3 rows 3 cols
114
+ ```
115
+
116
+ Column letters sit beside the header names, the header row stays in place while you scroll, and the last line reports the row and column counts, the character encoding that was detected, any limit that was reached and how many columns do not fit the pane.
117
+
118
+ In preview mode the cell cursor moves:
119
+
120
+ | Key | Action |
121
+ |-----|--------|
122
+ | `h` / `j` / `k` / `l` or arrows | Move the cell cursor (the grid scrolls in both directions to follow it) |
123
+ | `Ctrl+D` / `Ctrl+U` | Move one screen of rows |
124
+ | `g` / `}` | First / last row |
125
+ | `0` / `$` | First / last column |
126
+ | `Space` | Select / unselect the column under the cursor |
127
+ | `/` | Filter the rows (see below) |
128
+ | `y` | Copy the cell under the cursor, or the cursor row's selected columns joined with commas |
129
+ | `Y` | Copy the whole row as one CSV line |
130
+ | `[` / `]` | Previous / next sheet, for a workbook's sheets or a database's tables |
131
+ | `t` | Open the list of sheets or tables (`j`/`k` to move, `Enter` to open, `ESC` to close) |
132
+ | `ESC` | Back to the file list |
133
+
134
+ `Space` marks the column under the cursor the way a selected file is marked, and the line under the file name lists the selection (`cols A,C`). With columns selected, `y` copies the cursor row's cells from those columns, in column order, joined with commas as one CSV line (`apple,30`), so a cell holding a comma or a newline is quoted. `Y` still copies the whole row, and switching sheets clears the selection.
135
+
136
+ ### Filtering rows (`/`)
137
+
138
+ `/` in a table preview filters its rows. Write conditions separated by commas:
139
+
140
+ | Input | Means |
141
+ |-------|-------|
142
+ | `price > 100` | A comparison (`=`, `!=`, `<>`, `>`, `>=`, `<`, `<=`); numeric when both sides are numbers |
143
+ | `name a%` | `LIKE 'a%'`: `%` is any text, `_` is one character |
144
+ | `name apple` | `LIKE '%apple%'`: matches anywhere in the column |
145
+ | `note "red, sweet"` | Quote a value to keep its commas and spaces |
146
+ | `apple` | No column named: searched in every column |
147
+ | `price > 100, name a%` | Several conditions, all of which must match |
148
+
149
+ Column names ignore case and the column letters (`A`, `B`, …) work too. `Enter` applies the filter, and the line under the file name shows it (`filter: price > 100 (2 rows)`). `ESC` clears the filter; a second `ESC` leaves the preview. Switching sheets clears it as well.
150
+
151
+ For a SQLite table the conditions become a read-only `SELECT ... WHERE` run inside the database, so the filter finds rows past the preview's row limit. Values are always passed as quoted literals and the column names are resolved against the table's own columns, so the input cannot become SQL of its own. A spreadsheet or CSV is filtered in Ruby over the rows that were read.
152
+
153
+ `t` lists a workbook's sheets or a database's tables, with `>` beside the one on screen; `Ctrl+D`/`Ctrl+U` page through a long list and `g`/`}` jump to its first and last entry. A file with a single sheet has no list.
154
+
155
+ Cell movement follows your `move_up` / `move_down` / `navigate_parent` / `navigate_enter` keybinds, so rebinding `hjkl` applies here too.
156
+
157
+ UTF-8, UTF-16 (with a BOM), CP932 and EUC-JP are decoded automatically, so a Shift_JIS CSV reads as text rather than replacement characters. A `.csv` or `.tsv` is read up to 512 KiB and 1000 rows; only the sheet on screen is read, so a workbook's other sheets and a database's other tables cost nothing until you switch to them. A spreadsheet over 10 MiB, or one that cannot be parsed, falls back to the ZIP entry list.
158
+
159
+ Copying uses `pbcopy`, `clip`, `wl-copy`, `xclip` or `xsel` when one is available, and OSC 52 otherwise, which works over SSH if your terminal supports it (in tmux, also `set -g set-clipboard on`). `CLIPBOARD_COMMAND` in `config.rb` sets a command of your own, and `rufio -c` reports which one is used. `TABLE_PREVIEW` changes the limits and the header, delimiter and encoding handling.
160
+
74
161
  ## File Operations
75
162
 
76
163
  | Key | Action |
@@ -107,32 +194,19 @@ With nothing selected, `z` opens zoxide history instead.
107
194
  | Key | Action |
108
195
  |-----|--------|
109
196
  | `f` | Filter the current list as you type (`Enter` keeps the filter, `ESC` clears it) |
110
- | `s` or `/` | Fuzzy search file names under the current directory (no external tools needed) |
111
- | `F` | Search file contents with rga, then pick a result in the same screen |
112
- | `G` | Global search across all bookmarks (no external tools needed) |
197
+ | `/` | Search, scoped to where you are |
113
198
 
114
- ### Fuzzy Search Screen (`s`, `/`, `F`)
199
+ `/` is the only search key, and what it searches depends on the mode:
115
200
 
116
- `s` and `/` list every file under the current directory, including hidden files and links to regular files, while the list is still being scanned. Typing narrows it with fuzzy matching: the query characters must appear in order but need not be adjacent (`sctrl` finds `search_controller.rb`). ASCII letters ignore case and Japanese text is matched as is. Matches after the last `/`, at word boundaries and in consecutive runs rank higher, and matched characters are highlighted.
201
+ | Where you press `/` | What it searches |
202
+ |---------------------|------------------|
203
+ | The file list | Every file under the current directory: names (fuzzy) or contents (literal) |
204
+ | A preview (`P`) | Inside the previewed file |
205
+ | A table preview | Filters the rows of the sheet or table on screen |
117
206
 
118
- | Key | Action |
119
- |-----|--------|
120
- | Type | Filter the list |
121
- | `Up` / `Down`, `Ctrl+J` / `Ctrl+K`, `Ctrl+N` / `Ctrl+P` | Select a result |
122
- | `Enter` | Open the file (`F`: at the matching line) |
123
- | `Ctrl+U` | Clear the query |
124
- | `Ctrl+R` | Rescan the directory (keeps the query) |
125
- | `ESC` | Return to the file list |
126
-
127
- `F` asks for the text to search, runs rga in the background and streams its `file:line:text` results into this screen; typing then filters those lines. The matching itself uses the bundled Zig library when available and falls back to Ruby otherwise (`RUFIO_NATIVE_FUZZY=0` forces Ruby).
128
-
129
- On screens at least 80 columns wide, the right half shows a preview of the selected file, loaded in the background and limited to the first 64 KiB. `F` results scroll the preview to the matching line and highlight it. `preview_enabled: false` in `UI_OPTIONS` hides it.
207
+ ## Search Screen (`/` in the file list)
130
208
 
131
- Reopening `s` in a directory scanned in the last 5 minutes shows the cached list immediately; the title reads `Cached 2m ago | Ctrl+R: Rescan`. By default the cache keeps up to 4 directories and 200,000 files in total (see `FUZZY_SEARCH_CACHE` below), so new, deleted or changed files may be missing until you press `Ctrl+R`. Selecting a file that no longer exists keeps the screen open and shows `File no longer exists`.
132
-
133
- ## Global Search (G mode)
134
-
135
- `G` searches recursively under every bookmarked directory. Add bookmarks with `b` first. File names use the same fuzzy matching as `s` (best matches first, matched characters highlighted, filtered in the background); content search stays literal.
209
+ `/` searches recursively under the current directory; bookmarks are not searched. File names are matched with fuzzy matching (best matches first, matched characters highlighted, filtered in the background); content search stays literal and case-insensitive. Hidden files and links to regular files are included, and results appear while the tree is still being scanned.
136
210
 
137
211
  | Key | Action |
138
212
  |-----|--------|
@@ -141,11 +215,13 @@ Reopening `s` in a directory scanned in the last 5 minutes shows the cached list
141
215
  | `Up` / `Down`, `Ctrl+J` / `Ctrl+K`, `Ctrl+N` / `Ctrl+P` | Select a result |
142
216
  | `Enter` | Go to the file in Files mode |
143
217
  | `Ctrl+U` | Clear the query |
144
- | `ESC` | Return to the previous mode |
218
+ | `ESC` | Return to Files mode |
145
219
 
220
+ - Fuzzy matching means the query characters must appear in order but need not be adjacent (`sctrl` finds `search_controller.rb`). ASCII letters ignore case and Japanese text is matched as is.
146
221
  - Matches are highlighted. Content results show the file, line number and matching text.
147
222
  - A yellow `Searching...` indicator animates while scanning and turns into a green `Search complete` when done.
148
223
  - Inaccessible directories and directory symlinks are skipped. Plain text is read as UTF-8, and files with NUL bytes in the first 8 KB are treated as binary.
224
+ - The matching uses the bundled Zig library when available and falls back to Ruby otherwise (`RUFIO_NATIVE_FUZZY=0` forces Ruby).
149
225
 
150
226
  ### Documents
151
227
 
@@ -164,7 +240,7 @@ Extracted text is cached in memory (up to 64 documents, about 16 MiB) and re-ext
164
240
  Add this to `~/.config/rufio/config.rb` and restart rufio. It applies to both file names and contents:
165
241
 
166
242
  ```ruby
167
- GLOBAL_SEARCH_EXCLUDED_EXTENSIONS = %w[.png .jpg .zip .tar.gz .log /.git /node_modules /.DS_Store].freeze
243
+ SEARCH_EXCLUDED_EXTENSIONS = %w[.png .jpg .zip .tar.gz .log /.git /node_modules /.DS_Store].freeze
168
244
  ```
169
245
 
170
246
  Extensions ignore case, the leading dot is optional, and the default `[]` excludes nothing. An entry starting with `/` is a name: a directory with that name is skipped with everything under it, and a file with exactly that name is skipped.
@@ -176,7 +252,6 @@ Extensions ignore case, the leading dot is optional, and the default `[]` exclud
176
252
  | `b` | Bookmark the current directory |
177
253
  | `B` | Bookmark menu |
178
254
  | `1`–`9` | Jump to bookmark 1–9 |
179
- | `Tab` / `Shift+Tab` | Next / previous bookmark (Files and Config modes) |
180
255
  | `z` | zoxide history (when nothing is selected) |
181
256
 
182
257
  The `B` menu has four items:
@@ -342,22 +417,11 @@ APPLICATIONS = {
342
417
  :default => 'open'
343
418
  }.freeze
344
419
 
345
- # Extensions (and /names of directories or files) excluded from G mode search
346
- GLOBAL_SEARCH_EXCLUDED_EXTENSIONS = %w[.log /node_modules].freeze
347
-
348
- # File list cache for reopening s / / (omitted keys keep their defaults)
349
- FUZZY_SEARCH_CACHE = { max_entries: 500_000, max_roots: 8, ttl: 900 }.freeze
420
+ # Extensions (and /names of directories or files) excluded from the / search
421
+ SEARCH_EXCLUDED_EXTENSIONS = %w[.log /node_modules].freeze
350
422
  ```
351
423
 
352
- `FUZZY_SEARCH_CACHE` keys:
353
-
354
- | Key | Default | Maximum | Meaning |
355
- |-----|---------|---------|---------|
356
- | `max_entries` | 200,000 | 1,000,000 | Files kept across all cached directories |
357
- | `max_roots` | 4 | 16 | Directories kept (least recently used is dropped first) |
358
- | `ttl` | 300 | 86,400 | Seconds before a cached list is scanned again |
359
-
360
- Values above the maximum are capped, invalid values fall back to the default, and `0` disables caching (`max_entries` / `max_roots`) or expires lists immediately (`ttl`). About 90 bytes are used per cached file.
424
+ The older name `GLOBAL_SEARCH_EXCLUDED_EXTENSIONS` is still read if `SEARCH_EXCLUDED_EXTENSIONS` is not set.
361
425
 
362
426
  Action names for `KEYBINDS`:
363
427
 
@@ -365,11 +429,11 @@ Action names for `KEYBINDS`:
365
429
  |-------|-----------------------|
366
430
  | Navigation | `move_up` (k), `move_down` (j), `navigate_parent` (h), `navigate_enter` (l), `top` (g), `bottom` (}), `refresh` (R) |
367
431
  | Files | `open_file` (o), `preview` (P), `rename` (r), `delete` (d), `create_file` (a), `create_dir` (A), `move_selected` (m), `copy_selected` (c), `delete_selected` (x), `open_explorer` (e) |
368
- | Selection and search | `select` (Space), `filter` (f), `file_search` (s), `file_search_alt` (/), `rga_search` (F) |
432
+ | Selection and search | `select` (Space), `filter` (f), `search` (/) |
369
433
  | Bookmarks | `add_bookmark` (b), `bookmark_menu` (B), `zoxide` (z), `start_dir` (0) |
370
- | Modes | `job_mode` (J), `global_search` (G), `config_mode` (C), `help` (?), `log_viewer` (L), `command_mode` (:), `quit` (q), `quit_cd` (T) |
434
+ | Modes | `job_mode` (J), `config_mode` (C), `help` (?), `log_viewer` (L), `command_mode` (:), `quit` (q), `quit_cd` (T) |
371
435
 
372
- The former names `fzf_search` / `fzf_search_alt` are still accepted as aliases of `file_search` / `file_search_alt`.
436
+ The former names `fzf_search`, `fzf_search_alt`, `file_search`, `file_search_alt`, `rga_search` and `global_search` are all accepted as aliases of `search`.
373
437
 
374
438
  ### script_paths.yml and bookmarks.yml
375
439
 
@@ -404,17 +468,15 @@ All tools are optional. Without them, rufio disables the feature or falls back t
404
468
 
405
469
  | Tool | Used for | Key |
406
470
  |------|----------|-----|
407
- | rga | File content search | `F` |
408
471
  | zoxide | Directory history | `z` |
409
472
  | bat | Syntax highlighting in the preview | — |
410
473
 
411
474
  ```bash
412
475
  # macOS
413
- brew install bat rga zoxide
476
+ brew install bat zoxide
414
477
 
415
478
  # Ubuntu/Debian
416
479
  apt install bat zoxide
417
- # rga: https://github.com/phiresky/ripgrep-all
418
480
  ```
419
481
 
420
482
  ## Command-line Options
@@ -434,7 +496,7 @@ rufio -h # Help
434
496
 
435
497
  The gem bundles a Zig library for macOS (arm64/x86_64), Linux (x86_64/aarch64, glibc 2.17+ or musl) and Windows (x64/arm64). Other platforms use the Ruby implementation automatically.
436
498
 
437
- - **G mode content search**: parallel scanning with an in-memory file cache. Repeated searches are about 10x faster than `rg`. Queries with non-ASCII cased letters use the Ruby search. Set `RUFIO_NATIVE_SEARCH=0` to disable it.
499
+ - **Content search**: parallel scanning with an in-memory file cache. Repeated searches are about 10x faster than `rg`. Queries with non-ASCII cased letters use the Ruby search. Set `RUFIO_NATIVE_SEARCH=0` to disable it.
438
500
  - **ZIP**: decompresses entries and compresses files of 1 MiB or more in parallel (about 4.6x faster to compress and 3.2x faster to extract than Ruby on 8 × 64 MB files with 4 CPUs). Archive validation always stays in Ruby. Set `RUFIO_NATIVE_ZIP=0` to disable it.
439
501
 
440
502
  To rebuild the bundled binaries (requires Zig 0.17):
data/docs/guide_ja.md CHANGED
@@ -13,7 +13,7 @@ rufio の中ではいつでも `?` でヘルプメニューを開けます。
13
13
  - [ファイル操作](#ファイル操作)
14
14
  - [ZIP の展開・圧縮](#zip-の展開圧縮)
15
15
  - [フィルターと検索](#フィルターと検索)
16
- - [横断検索(G モード)](#横断検索g-モード)
16
+ - [検索画面(ファイル一覧の `/`)](#検索画面ファイル一覧の-)
17
17
  - [ブックマークと履歴](#ブックマークと履歴)
18
18
  - [コマンドモード](#コマンドモード)
19
19
  - [スクリプト](#スクリプト)
@@ -69,8 +69,95 @@ Files モードでは、最上段に現在のパス、その下にブックマ
69
69
  | `P` | 全画面プレビュー(ファイル一覧を隠す) |
70
70
  | `j` / `k` | スクロール |
71
71
  | `Ctrl+D` / `Ctrl+U` | 1 ページ下 / 上 |
72
+ | `y` | ファイルパスをクリップボードへコピー |
72
73
  | `ESC` | ファイル一覧に戻る |
73
74
 
75
+ ### 画像
76
+
77
+ 画像(`.png` / `.jpg` / `.gif` / `.bmp`)は、Kitty グラフィックスプロトコルで端末に描かせます。kitty・Ghostty・WezTerm・Konsole が対応しており、起動時に 1 回だけ端末へ問い合わせて、対応していなければ黙ってテキスト表示に戻します。
78
+
79
+ | 状況 | 表示 |
80
+ |------|------|
81
+ | 対応端末・32 MiB までの `.png` / `.jpg` / `.bmp` | ペインに収めた画像(分割表示と `P` のどちらでも) |
82
+ | ネイティブライブラリが無い(または `RUFIO_NATIVE_IMAGE=0`)・8 MiB までの PNG | そのまま送り、端末側で拡縮 |
83
+ | `.gif`・プログレッシブ JPEG・インターレース PNG | 形式・寸法・ファイルサイズをテキストで表示 |
84
+ | 非対応端末・tmux の中 | 同じテキスト表示 |
85
+
86
+ 同梱のネイティブライブラリ(Zig。第三者の画像コードは使っていません)が、画像をペインの実ピクセルまで縮小して PNG に符号化し直してから送ります。1200 万画素の写真でも数百 KB・約 30ms(メインループの外)で端末に届きます。処理中はペインに `decoding...` と出ます。
87
+
88
+ プレビューモード(`P`)では画像を拡大できます。
89
+
90
+ | キー | 操作 |
91
+ |------|------|
92
+ | `+` / `-` | 25% 刻みで拡大・縮小(最大 4 倍)。元画像の一部を端末に出してもらう方式なので、デコードは要りません |
93
+ | `0` | ペインに収める |
94
+ | `h` / `j` / `k` / `l` または矢印 | 拡大中の表示位置を動かす |
95
+
96
+ 画像の下のセルは空白のまま確保するので、ファイル一覧やステータス行が読めなくなりません。別のファイルを選んだとき、ヘルプ・検索画面・コマンドモードを開いたとき、rufio を終了したときには画像を消します。別のファイルへ移るときは先に画像を消し、約 80ms 後に次を送るので、`j` を押し続けて画像のフォルダを辿っても転送が溢れません。通知などでセルが上書きされた画像は置き直し、一度見た画像に戻ったときは読み直しも符号化もしません。`RUFIO_IMAGE_PREVIEW=0` で画像表示を完全に無効化できます。設計と残りのフェーズは [image_preview_design_ja.md](./image_preview_design_ja.md) にあります。
97
+
98
+ ### プレビュー内の検索(`/`)
99
+
100
+ プレビュー中の `/` は、そのファイルの中を検索します。入力すると現在位置以降の最初の一致へ飛び、`Enter` で確定、`n` / `N` で次 / 前の一致へ(端では反対側へ回ります)、`ESC` で解除します(もう一度押すとプレビューを抜けます)。一致箇所はハイライトされ、現在の一致だけ別の色で表示します。プレビューモードではファイルの先頭 64 KiB・最大 20,000 行を読み込むため、検索はその範囲が対象です。
101
+
102
+ ### 表を行列で表示
103
+
104
+ `.csv` / `.tsv` / `.tab` / `.xlsx` / `.xlsm` / `.ods`、および `sqlite3` コマンドがある場合は SQLite のデータベースを、行と列で表示します。
105
+
106
+ ```
107
+ sales.csv [PREVIEW MODE]
108
+ R3C2 price | hjkl: move y: copy ESC: back
109
+ | A name | B price | C stock |
110
+ 1 | apple | 120 | 30 |
111
+ 2 | みかん | 150 | 8 |
112
+ 3 | banana | 80 | 12 |
113
+ 3 rows 3 cols
114
+ ```
115
+
116
+ 見出しには列ラベル(A・B・C…)が付き、スクロール中もヘッダ行は固定されます。最下行には行数・列数・判定した文字コード・読み込み上限に達したか・ペインに収まらない列数が出ます。
117
+
118
+ プレビューモードではセルカーソルを動かせます。
119
+
120
+ | キー | 操作 |
121
+ |------|------|
122
+ | `h` / `j` / `k` / `l` または矢印 | セルを移動(カーソルに合わせて縦横にスクロール) |
123
+ | `Ctrl+D` / `Ctrl+U` | 1 画面分の行移動 |
124
+ | `g` / `}` | 先頭行 / 最終行 |
125
+ | `0` / `$` | 先頭列 / 最終列 |
126
+ | `Space` | カーソル位置のカラムを選択 / 解除 |
127
+ | `/` | 行を絞り込む(下記) |
128
+ | `y` | カーソル位置のセル、またはカーソル行の選択カラムをカンマ区切りでコピー |
129
+ | `Y` | 行全体を CSV の 1 行としてコピー |
130
+ | `[` / `]` | 前 / 次のシート(Excel のシート、SQLite のテーブル) |
131
+ | `t` | シート/テーブル一覧を開く(`j`/`k` で移動、`Enter` で開く、`ESC` で閉じる) |
132
+ | `ESC` | ファイル一覧に戻る |
133
+
134
+ `Space` でカーソル位置のカラムを選択すると、ファイル一覧の選択済みアイテムと同じ印が付き、ファイル名の下の行に選択中のカラム(`cols A,C`)が出ます。カラムを選んでいる状態で `y` を押すと、カーソル行のそのカラムのセルを列の順にカンマ区切りで連結して(`apple,30`)コピーします。カンマや改行を含むセルは CSV として読み戻せるようクォートします。`Y` は選択に関係なく行全体をコピーし、シートを切り替えると選択は解除されます。
135
+
136
+ ### 行の絞り込み(`/`)
137
+
138
+ 表プレビューの `/` は行を絞り込みます。条件はカンマ区切りで並べます。
139
+
140
+ | 入力 | 意味 |
141
+ |------|------|
142
+ | `price > 100` | 比較(`=`、`!=`、`<>`、`>`、`>=`、`<`、`<=`)。両辺が数値なら数値として比較 |
143
+ | `name a%` | `LIKE 'a%'`。`%` は任意の文字列、`_` は 1 文字 |
144
+ | `name apple` | `LIKE '%apple%'`。列のどこかに含まれれば一致 |
145
+ | `note "red, sweet"` | 引用符で囲むと、カンマや空白を含む値をそのまま渡せる |
146
+ | `apple` | 列を書かなければ全列が対象 |
147
+ | `price > 100, name a%` | 複数条件(すべて満たす行だけ残る) |
148
+
149
+ 列名は大文字小文字を区別せず、列ラベル(`A`、`B`…)でも指定できます。`Enter` で適用すると、ファイル名の下の行に `filter: price > 100 (2 rows)` のように出ます。`ESC` で絞り込みを解除し、もう一度押すとプレビューを抜けます。シートを切り替えても解除されます。
150
+
151
+ SQLite のテーブルでは、条件を読み取り専用の `SELECT ... WHERE` に組み立ててデータベース側で実行するため、プレビューの読み込み上限より後ろの行も見つかります。値は必ず引用符付きのリテラルとして渡し、列名は実在する列に解決してから使うので、入力がそのまま SQL になることはありません。Excel や CSV は読み込み済みの行を Ruby 側で判定します。
152
+
153
+ `t` で Excel のシートや SQLite のテーブルの一覧を開けます。表示中のシートには `>` が付き、長い一覧は `Ctrl+D` / `Ctrl+U` でページ送り、`g` / `}` で先頭・末尾へ移動できます。シートが 1 枚だけのファイルには一覧がありません。
154
+
155
+ セル移動は `move_up` / `move_down` / `navigate_parent` / `navigate_enter` のキーバインド設定に従うため、`hjkl` を変更していればそれが反映されます。
156
+
157
+ UTF-8・UTF-16(BOM つき)・CP932・EUC-JP を自動判定するので、Shift_JIS の CSV も文字化けしません。`.csv` / `.tsv` は先頭 512 KiB・1000 行まで読み込みます。表示しているシートだけを読み込むため、Excel の他のシートや SQLite の他のテーブルは切り替えるまで読み込みません。10 MiB を超える表計算ファイルや、解析できないファイルは ZIP のエントリ一覧表示に戻ります。
158
+
159
+ コピーは `pbcopy` / `clip` / `wl-copy` / `xclip` / `xsel` があればそれを使い、無ければ OSC 52 を使います(SSH 越しでも端末が対応していれば動作。tmux では `set -g set-clipboard on` も必要)。`config.rb` の `CLIPBOARD_COMMAND` で任意のコマンドを指定でき、`rufio -c` でどれが使われるか確認できます。読み込み上限や区切り文字、ヘッダ行の扱い、文字コードは `TABLE_PREVIEW` で変更できます。
160
+
74
161
  ## ファイル操作
75
162
 
76
163
  | キー | 操作 |
@@ -107,32 +194,19 @@ Files モードでは、最上段に現在のパス、その下にブックマ
107
194
  | キー | 操作 |
108
195
  |------|------|
109
196
  | `f` | 入力に合わせて一覧を絞り込む(`Enter` で確定、`ESC` で解除) |
110
- | `s` または `/` | 現在のディレクトリ配下のファイル名をあいまい検索(外部ツール不要) |
111
- | `F` | rga でファイル内容を検索し、同じ画面で結果を選択 |
112
- | `G` | 全ブックマークを横断検索(外部ツール不要) |
197
+ | `/` | 検索(いる場所によって対象が変わる) |
113
198
 
114
- ### あいまい検索画面(`s`、`/`、`F`)
199
+ 検索キーは `/` だけで、対象はモードによって変わります。
115
200
 
116
- `s` と `/` は、現在のディレクトリ配下のファイル(隠しファイルと通常ファイルへのリンクを含む)を走査しながら一覧表示します。入力すると、文字が順番どおりに現れれば離れていても一致するあいまい検索で絞り込みます(`sctrl` で `search_controller.rb` が見つかります)。ASCII の英字は大文字小文字を区別せず、日本語はそのまま照合します。最後の `/` 以降・単語の先頭・連続した一致ほど上位に並び、一致した文字はハイライトされます。
201
+ | `/` を押す場所 | 検索する対象 |
202
+ |----------------|--------------|
203
+ | ファイル一覧 | 現在のディレクトリ配下の全ファイル。ファイル名(あいまい)か内容(リテラル) |
204
+ | プレビュー(`P`) | プレビュー中のファイルの中 |
205
+ | 表プレビュー | 表示中のシート/テーブルの行を絞り込む |
117
206
 
118
- | キー | 操作 |
119
- |------|------|
120
- | 入力 | 一覧を絞り込む |
121
- | `↑` / `↓`、`Ctrl+J` / `Ctrl+K`、`Ctrl+N` / `Ctrl+P` | 結果を選択 |
122
- | `Enter` | ファイルを開く(`F` は一致した行で開く) |
123
- | `Ctrl+U` | 検索語をクリア |
124
- | `Ctrl+R` | ディレクトリを走査し直す(検索語は保持) |
125
- | `ESC` | ファイル一覧に戻る |
126
-
127
- `F` は検索する文字列を尋ね、rga をバックグラウンドで実行して `ファイル:行:本文` の結果をこの画面へ流し込みます。入力するとその結果の行を絞り込めます。照合には同梱の Zig ライブラリを使い、利用できない場合は Ruby 実装に切り替えます(`RUFIO_NATIVE_FUZZY=0` で Ruby を強制)。
128
-
129
- 幅 80 桁以上の画面では、右半分に選択中のファイルのプレビューを表示します。読み込みはバックグラウンドで行い、先頭 64 KiB までに制限します。`F` の結果では一致した行までスクロールして強調します。`UI_OPTIONS` の `preview_enabled: false` で非表示にできます。
207
+ ## 検索画面(ファイル一覧の `/`)
130
208
 
131
- 直近 5 分以内に走査したディレクトリで `s` を開き直すと、キャッシュした一覧をすぐに表示し、タイトルに `Cached 2m ago | Ctrl+R: Rescan` と出します。キャッシュは既定で最大 4 ディレクトリ・合計 20 万ファイルまでです(下記 `FUZZY_SEARCH_CACHE` で変更可)。その後に追加・削除・変更されたファイルは `Ctrl+R` で走査し直すまで反映されません。削除済みのファイルを選んだ場合は画面を閉じずに `File no longer exists` と表示します。
132
-
133
- ## 横断検索(G モード)
134
-
135
- `G` で、ブックマークした全ディレクトリの配下を再帰的に検索します。先に `b` でブックマークを登録してください。ファイル名は `s` と同じあいまい検索(よく一致したものから並び、一致文字をハイライト、絞り込みはバックグラウンド)で、内容検索はリテラルのままです。
209
+ `/` は現在のディレクトリ配下を再帰的に検索します(ブックマークは検索しません)。ファイル名はあいまい検索(よく一致したものから並び、一致文字をハイライト、絞り込みはバックグラウンド)で、内容検索は大文字小文字を区別しないリテラル検索です。隠しファイルと通常ファイルへのリンクも含め、走査しながら結果を表示します。
136
210
 
137
211
  | キー | 操作 |
138
212
  |------|------|
@@ -141,11 +215,13 @@ Files モードでは、最上段に現在のパス、その下にブックマ
141
215
  | `↑` / `↓`、`Ctrl+J` / `Ctrl+K`、`Ctrl+N` / `Ctrl+P` | 結果を選択 |
142
216
  | `Enter` | Files モードでそのファイルの場所へ移動 |
143
217
  | `Ctrl+U` | 検索語をクリア |
144
- | `ESC` | 元のモードに戻る |
218
+ | `ESC` | Files モードに戻る |
145
219
 
220
+ - あいまい検索は、文字が順番どおりに現れれば離れていても一致します(`sctrl` で `search_controller.rb` が見つかります)。ASCII の英字は大文字小文字を区別せず、日本語はそのまま照合します。
146
221
  - 一致箇所はハイライトされます。内容検索ではファイル・行番号・一致した行を表示します。
147
222
  - 検索中は黄色の `Searching...` が動き、完了すると緑の `Search complete` に変わります。
148
223
  - アクセスできないディレクトリとディレクトリのシンボリックリンクはスキップします。通常のテキストは UTF-8 として読み、先頭 8 KB に NUL バイトがあるファイルはバイナリとして扱います。
224
+ - 照合には同梱の Zig ライブラリを使い、利用できない場合は Ruby 実装に切り替えます(`RUFIO_NATIVE_FUZZY=0` で Ruby を強制)。
149
225
 
150
226
  ### 文書の内容検索
151
227
 
@@ -164,7 +240,7 @@ Python・Microsoft Office・変換ツールなしで文書の中も検索でき
164
240
  `~/.config/rufio/config.rb` に次を追加して rufio を再起動します。ファイル名・内容の両方に適用されます。
165
241
 
166
242
  ```ruby
167
- GLOBAL_SEARCH_EXCLUDED_EXTENSIONS = %w[.png .jpg .zip .tar.gz .log /.git /node_modules /.DS_Store].freeze
243
+ SEARCH_EXCLUDED_EXTENSIONS = %w[.png .jpg .zip .tar.gz .log /.git /node_modules /.DS_Store].freeze
168
244
  ```
169
245
 
170
246
  大文字・小文字は区別せず、先頭のドットは省略できます。デフォルトの `[]` は何も除外しません。`/` で始まる要素は名前の指定になり、その名前のディレクトリは配下ごと、名前が完全に一致するファイルは単体で除外します。
@@ -176,7 +252,6 @@ GLOBAL_SEARCH_EXCLUDED_EXTENSIONS = %w[.png .jpg .zip .tar.gz .log /.git /node_m
176
252
  | `b` | 現在のディレクトリをブックマーク |
177
253
  | `B` | ブックマークメニュー |
178
254
  | `1`〜`9` | ブックマーク 1〜9 へ移動 |
179
- | `Tab` / `Shift+Tab` | 次 / 前のブックマークへ(Files・Config モード) |
180
255
  | `z` | zoxide 履歴(何も選択していないとき) |
181
256
 
182
257
  `B` のメニュー:
@@ -333,7 +408,7 @@ COLORS = {
333
408
  # キーの変更はアクション名で指定する。値は 1 キーの文字列
334
409
  KEYBINDS = {
335
410
  bottom: 'G',
336
- global_search: 'S'
411
+ search: 'S'
337
412
  }.freeze
338
413
 
339
414
  # `o` で使うアプリ(拡張子ごと)
@@ -342,22 +417,11 @@ APPLICATIONS = {
342
417
  :default => 'open'
343
418
  }.freeze
344
419
 
345
- # G モードの検索から除外する拡張子(/ 始まりはディレクトリ・ファイル名)
346
- GLOBAL_SEARCH_EXCLUDED_EXTENSIONS = %w[.log /node_modules].freeze
347
-
348
- # s / / を開き直すときの一覧キャッシュ(省略したキーは既定値)
349
- FUZZY_SEARCH_CACHE = { max_entries: 500_000, max_roots: 8, ttl: 900 }.freeze
420
+ # `/` の検索から除外する拡張子(/ 始まりはディレクトリ・ファイル名)
421
+ SEARCH_EXCLUDED_EXTENSIONS = %w[.log /node_modules].freeze
350
422
  ```
351
423
 
352
- `FUZZY_SEARCH_CACHE` のキー:
353
-
354
- | キー | 既定値 | 上限 | 意味 |
355
- |------|--------|------|------|
356
- | `max_entries` | 200,000 | 1,000,000 | 全ディレクトリ合計で保持するファイル数 |
357
- | `max_roots` | 4 | 16 | 保持するディレクトリ数(最近使っていないものから捨てる) |
358
- | `ttl` | 300 | 86,400 | 一覧を走査し直すまでの秒数 |
359
-
360
- 上限を超える値は上限に丸め、不正な値は既定値を使います。`0` はキャッシュの無効化(`max_entries` / `max_roots`)または即時期限切れ(`ttl`)です。キャッシュは 1 ファイルあたり約 90 バイトを使います。
424
+ `SEARCH_EXCLUDED_EXTENSIONS` を設定していない場合は、旧名の `GLOBAL_SEARCH_EXCLUDED_EXTENSIONS` も読み込みます。
361
425
 
362
426
  `KEYBINDS` で使えるアクション名:
363
427
 
@@ -365,11 +429,11 @@ FUZZY_SEARCH_CACHE = { max_entries: 500_000, max_roots: 8, ttl: 900 }.freeze
365
429
  |------|------------------------------|
366
430
  | 移動 | `move_up` (k), `move_down` (j), `navigate_parent` (h), `navigate_enter` (l), `top` (g), `bottom` (}), `refresh` (R) |
367
431
  | ファイル | `open_file` (o), `preview` (P), `rename` (r), `delete` (d), `create_file` (a), `create_dir` (A), `move_selected` (m), `copy_selected` (c), `delete_selected` (x), `open_explorer` (e) |
368
- | 選択・検索 | `select` (Space), `filter` (f), `file_search` (s), `file_search_alt` (/), `rga_search` (F) |
432
+ | 選択・検索 | `select` (Space), `filter` (f), `search` (/) |
369
433
  | ブックマーク | `add_bookmark` (b), `bookmark_menu` (B), `zoxide` (z), `start_dir` (0) |
370
- | モード | `job_mode` (J), `global_search` (G), `config_mode` (C), `help` (?), `log_viewer` (L), `command_mode` (:), `quit` (q), `quit_cd` (T) |
434
+ | モード | `job_mode` (J), `config_mode` (C), `help` (?), `log_viewer` (L), `command_mode` (:), `quit` (q), `quit_cd` (T) |
371
435
 
372
- 以前のアクション名 `fzf_search` / `fzf_search_alt` も `file_search` / `file_search_alt` の別名として引き続き使えます。
436
+ 以前のアクション名 `fzf_search`・`fzf_search_alt`・`file_search`・`file_search_alt`・`rga_search`・`global_search` は、いずれも `search` の別名として引き続き使えます。
373
437
 
374
438
  ### script_paths.yml と bookmarks.yml
375
439
 
@@ -404,17 +468,15 @@ script_paths:
404
468
 
405
469
  | ツール | 用途 | キー |
406
470
  |--------|------|------|
407
- | rga | ファイル内容検索 | `F` |
408
471
  | zoxide | ディレクトリ履歴 | `z` |
409
472
  | bat | プレビューのシンタックスハイライト | — |
410
473
 
411
474
  ```bash
412
475
  # macOS
413
- brew install bat rga zoxide
476
+ brew install bat zoxide
414
477
 
415
478
  # Ubuntu/Debian
416
479
  apt install bat zoxide
417
- # rga: https://github.com/phiresky/ripgrep-all
418
480
  ```
419
481
 
420
482
  ## コマンドラインオプション
@@ -434,7 +496,7 @@ rufio -h # ヘルプ
434
496
 
435
497
  gem には macOS(arm64/x86_64)、Linux(x86_64/aarch64、glibc 2.17 以降または musl)、Windows(x64/arm64)向けの Zig ライブラリが同梱されています。その他のプラットフォームでは自動的に Ruby 実装を使います。
436
498
 
437
- - **G モードの内容検索**: 並列スキャンとメモリ上のファイルキャッシュで、再検索は `rg` の約 10 倍速くなります。大文字・小文字のある非 ASCII 文字を含む検索語は Ruby で検索します。`RUFIO_NATIVE_SEARCH=0` で無効化できます。
499
+ - **内容検索**: 並列スキャンとメモリ上のファイルキャッシュで、再検索は `rg` の約 10 倍速くなります。大文字・小文字のある非 ASCII 文字を含む検索語は Ruby で検索します。`RUFIO_NATIVE_SEARCH=0` で無効化できます。
438
500
  - **ZIP**: エントリの伸長と 1 MiB 以上のファイルの圧縮を並列に行います(4 CPU・64 MB × 8 ファイルの計測で、Ruby より圧縮が約 4.6 倍、展開が約 3.2 倍高速)。アーカイブの検証は常に Ruby 側で行います。`RUFIO_NATIVE_ZIP=0` で無効化できます。
439
501
 
440
502
  同梱バイナリの再ビルド(Zig 0.17 が必要):