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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 259020c67c64924be286409faf8308368b2971500689a280ff4d272c9c73f9ae
4
- data.tar.gz: 6b7fbffbbc9509f69be7c94927b5bca8bb6e5e9472a1cf43d2e1904bdb1f0f1b
3
+ metadata.gz: 368708ecd4642fdb6822af7179753c61e517022f5828356ab7fe2550a106deca
4
+ data.tar.gz: f63838dc12e93fcb779389830e23d114b55ed84ecd1bcaa29204dcaf21e0fbf4
5
5
  SHA512:
6
- metadata.gz: f6027004bbd37d5f747a673e974803ea766ae1677f24f3b489fd2a5320fa6ee497a072206d1caec15bb5b546fd31e1be98190ef03c2adc66a0479de020817497
7
- data.tar.gz: 701591ad5de5abfeba0a0b2cde643870fc39006afa4cede6912aaff68d3d997ccb19a47578f218ce1cecdb2ed394742a34eb89e1ef6964225cf12ea7f78e941e
6
+ metadata.gz: 56b6de9ae8e33b21fcd45ce86a212dc83caa9a11090d15afb590909d6f7b6d6160539def6eee0a066b7909270fbffe361e6566db00de1672e91db804ff08f148
7
+ data.tar.gz: 21d431e6546428f2b0391e218953e87ce48fbac6b1e4b31fc10524be5c269a6e1cb246ed7dc98c1cb59f76e30d44b1ec3203ed8542758f6bbc6590fb863c131e
data/CHANGELOG.md CHANGED
@@ -7,6 +7,48 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.0.0] - 2026-11-23
11
+
12
+ ### Added
13
+ - `.csv`, `.tsv` and `.tab` previews are shown as a grid instead of raw text: column letters with the header row, row numbers, the header kept in place while scrolling, and a last line with the row and column counts, the detected character encoding, any truncation and how many columns do not fit. Both the split pane and the fullscreen preview (`P`) use it
14
+ - Character encoding detection for table previews (`Rufio::EncodingDetector`): UTF-8 and UTF-16 BOMs, UTF-8, CP932 and EUC-JP, so Shift_JIS CSV files no longer read as replacement characters. The byte limit is cut at the last newline so a multibyte character is never split
15
+ - `TABLE_PREVIEW` in `config.rb` sets the table preview limits (`max_bytes` up to 4 MiB, `max_rows`, `max_columns`, `max_column_width`) and the `header`, `delimiter` (`'auto'` detects `;`) and `encoding` handling. Omitted or invalid values keep the defaults (512 KiB / 1000 / 256 / 32)
16
+ - In preview mode (`P`) on a table file, `h`/`j`/`k`/`l` and the arrow keys move a cell cursor, `Ctrl+D`/`Ctrl+U` move one screen of rows, `g`/`}` jump to the first and last row and `0`/`$` to the first and last column. The grid scrolls vertically and horizontally to keep the cursor in view, the cursor cell is drawn in the selection colour, and the line under the file name shows the cell address and column name (`R3C2 price`). Cell movement follows the `move_up` / `move_down` / `navigate_parent` / `navigate_enter` keybinds
17
+ - `.xlsx`, `.xlsm` and `.ods` files are previewed as a grid through the `roo` gem that was already a dependency, and SQLite databases are too when the `sqlite3` command is installed, recognised by the file's own signature whatever the extension (without the command they are left as before). `[` and `]` switch between a workbook's sheets or a database's tables, and only the sheet on screen is read, so the others cost nothing until they are opened. A spreadsheet over 10 MiB, or one that cannot be read, falls back to the ZIP entry list
18
+ - `t` in a table preview opens the list of a workbook's sheets or a database's tables: `j`/`k` and the arrow keys move, `Ctrl+D`/`Ctrl+U` page, `g`/`}` jump to the first and last entry, `Enter` opens the selected one and `ESC` closes the list without switching, and the mouse wheel moves through it. The entry on screen is marked with `>`, the heading reads `Tables (3)` for a database and `Sheets (3)` for a workbook, and the list only needs the names, so no table is read until one is opened. A file with a single sheet has no list, and the other keys are ignored while it is open, so the cell cursor behind it does not move
19
+ - `Space` in a table preview selects the column under the cursor, and `y` then copies the cursor row's cells from the selected columns, in column order, joined with commas as one CSV line (`apple,30`), so a cell holding a comma or a newline is still quoted and readable back as CSV. The selected columns' cells are marked the way a selected file is, the line under the file name lists them (`cols A,C`), the copy is reported as `copied 2 cols`, and switching sheets clears the selection. `Space` follows the `select` keybind, and `y` without a selection still copies the cell under the cursor
20
+ - `Y` copies the row under the cursor as one CSV line
21
+ - `y` copies to the clipboard: the cell under the cursor in a table preview (the raw value, newlines inside a cell included), the file path in any other preview, and in the file list the paths of the selected files, or of the file under the cursor when nothing is selected, one per line. The result is shown in the preview's status line or at the bottom of the file list
22
+ - `Rufio::Clipboard` runs `pbcopy`, `clip`, `wl-copy`, `xclip` or `xsel` when one is on `PATH`, and otherwise writes OSC 52, which reaches the terminal over SSH as well (wrapped for tmux and screen; tmux also needs `set-clipboard on`). Commands run through `argv` without a shell. `CLIPBOARD_COMMAND` in `config.rb` sets a command of your own, and `rufio -c` reports which one is used
23
+ - `Rufio::PreviewView`: preview mode now delegates its keys, scroll position and status line to a view (`TextPreviewView`, `TablePreviewView`, or `ImagePreviewView`), so a further preview kind needs no change in `NavigationController` or `UIRenderer`. `Rufio::TableCursor` holds the cell position and the scroll offsets, and `TableLayout#offset_for` computes how far to scroll sideways
24
+ - `Rufio::TableSource` and `Rufio::PreviewRegistry`: a table format implements `supports?` and `open` and returns sheets whose rows are read through `fetch_rows(offset, limit)`, so further formats (Excel, SQLite) need no change to the renderer. The plan is in `docs/csv_cell_preview_design_ja.md`
25
+ - `Rufio::SheetPicker` holds the sheet list's selection and scroll position, and `TableDocument#sheet_label` gives each format its own word for them (`Tables` for SQLite, `Sheets` otherwise)
26
+ - Image previews on terminals that speak the Kitty graphics protocol (kitty, Ghostty, WezTerm, Konsole). `.png`, `.jpg`, `.gif` and `.bmp` are recognised by the file's own signature, and the preview pane (split view and `P`) shows the picture drawn by the terminal while preserving its original aspect ratio (never stretching small pictures to the pane, and omitting `c`/`r` when real cell pixel dimensions are known so the terminal renders at exact pixel size), with the cells behind it kept blank so the list and status line stay readable. The picture is removed when another file is selected, when the help menu, search screen or command mode opens, on a full redraw and on exit. Other terminals, and tmux, show the format, pixel size and file size as text instead. `RUFIO_IMAGE_PREVIEW=0` turns it off. `Rufio::TerminalGraphics` asks the terminal once at startup (graphics query, CSI 16t cell size / native `TIOCGWINSZ`, plus Primary DA), `Rufio::KittyGraphics` builds the escape sequences, `Rufio::GraphicsLayer` decides when to send or delete, and `Screen#reserve` keeps text out of the picture's cells. The design notes are in `docs/image_preview_design_ja.md`
27
+ - The bundled native library now decodes images, so `.jpg` and `.bmp` previews work and every picture is scaled down to the pane before it is sent: a 2000x1500 photo becomes a few hundred KB in about 30 ms, off the main loop (with background completion polled from the main loop so previews appear as soon as decoding finishes), and files up to 32 MiB are read (the pane shows `decoding...` meanwhile). The decoders are written in Zig with no third-party image code and no external tools: PNG (read and write, using the standard library's zlib), baseline JPEG (Huffman, 4:4:4 / 4:2:2 / 4:2:0, restart markers) and uncompressed BMP, plus area-average downscaling. `.gif`, progressive JPEG and interlaced PNG are not decoded and fall back to the text view. Without the library, or with `RUFIO_NATIVE_IMAGE=0`, PNG files up to 8 MiB are still sent as they are. Zooming decodes at the zoomed resolution, so a magnified picture stays sharp
28
+ - `+` and `-` zoom an image preview in 25% steps up to 4x, `0` fits it to the pane again, and `h/j/k/l` or the arrow keys move around while zoomed. Zooming asks the terminal for a part of the picture (`x,y,w,h`), and the status line shows the current scale
29
+ - Image previews are steadier: a picture whose cells were painted over (by a notification or a mode change) is put back, moving to another file removes the old picture at once and sends the new one about 80 ms later so holding `j` through a folder of images does not flood the terminal, and the last few pictures are kept encoded in memory (4 images, 8 MB) so coming back to one costs no disk read and no re-encoding
30
+
31
+ ### Changed
32
+ - `Renderer#render` returns the row numbers it rewrote instead of `true` / `false`, so the image layer can tell whether its area was painted over
33
+ - `/` in a preview searches inside the previewed file: typing jumps to the first match, `Enter` keeps the search, `n` / `N` move between matches (wrapping around) and `ESC` clears it before a second `ESC` leaves the preview. Every match is highlighted and the current one is drawn in its own colour. Preview mode now reads up to 20,000 lines instead of 50, so scrolling and searching reach the whole 64 KiB the preview loads
34
+ - `/` in a table preview filters its rows with conditions written as `price > 100, name a%`: comparisons (`=`, `!=`, `<>`, `>`, `>=`, `<`, `<=`, numeric when both sides are numbers), `LIKE` patterns (`a%`, `a_c`, or a plain word matched anywhere in the column), quoted values that keep their commas (`note "red, sweet"`), and a term without a column searched in every column. Column names ignore case and the column letters work too. `Enter` applies it, the line under the file name shows `filter: price > 100 (2 rows)`, and `ESC` clears it. 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 quoted literals and 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 over the rows that were read (`Rufio::TableQuery`, `TableSheet#filter`)
35
+ - Search is one key. `/` opens the search screen for the current directory tree: `Tab` switches between fuzzy file names and literal contents, `Enter` goes to the file, `ESC` returns. Bookmarks are no longer searched, and the screen reports the directory it is searching
36
+ - `SEARCH_EXCLUDED_EXTENSIONS` in `config.rb` replaces `GLOBAL_SEARCH_EXCLUDED_EXTENSIONS`, which is still read when the new name is not set
37
+ - `rufio -c` checks for `sqlite3` (used by the SQLite preview) instead of `rga`
38
+
39
+ ### Removed
40
+ - G mode is gone: the `G` key, the Search tab and the mode itself. Its search moved to `/`, scoped to the current directory
41
+ - `s` (fuzzy file name search), `/` (its alias) and `F` (rga content search) are gone, with the search screen they used (`FuzzyFinder`), the rga integration (`RgaResultSource`), the file list cache (`FuzzyCandidateCache` and `FUZZY_SEARCH_CACHE`) and its preview pane (`FuzzyPreviewLoader`). `rga` is no longer used at all. The `search` keybind accepts the old action names (`file_search`, `file_search_alt`, `rga_search`, `global_search`, `fzf_search`, `fzf_search_alt`) so existing `KEYBINDS` settings keep working
42
+ - `Tab` / `Shift+Tab` no longer cycle through bookmarks in Files and Config modes; the keys do nothing there. Bookmarks are reached with `1`-`9`, the `B` menu and `0` for the start directory. In the other modes `Shift+Tab` still switches to the previous mode
43
+
44
+ ### Security
45
+ - Hardened image preview and native Zig image decoders against crafted files and terminal escape injection:
46
+ - `KittyGraphics` validates pre-encoded payloads strictly against `[A-Za-z0-9+/=]` and coerces all numeric control keys (including `query`'s `id`) to integers; `TerminalGraphics` bounds probe responses to 4 KiB and rejects out-of-range cell pixel sizes (> 1024)
47
+ - Native image loading rejects embedded NUL bytes, opens POSIX files with `O_NONBLOCK` + `O_CLOEXEC` and verifies `S_ISREG` via `fstat`/`statx` (preventing FIFO hangs and device reads), and verifies `FILE_TYPE_DISK` on Windows; direct Ruby reads also cap `File.binread` against TOCTOU file growth
48
+ - PNG decoder and direct-send fast path enforce pixel/dimension caps (25M pixels, 16384 max dimension), 2 MiB direct-send cap, `IEND` length/trailing-data checks, valid palette bit depth (`8` only), and streaming zlib decompression bomb limits (`inspectVerified` / `inflate`)
49
+ - JPEG decoder validates DHT code-count limits, rejects duplicate SOF / pre-SOF SOS / oversized MCU block counts (> 10), clamps DC/AC coefficients and uses 64-bit IDCT intermediates, and aborts EOF zero-padding loops to prevent small-file DoS; BMP decoder checks `header_size` against integer overflow
50
+ - Area-average downscaling uses `u64` accumulators to prevent `u32` overflow on large-to-tiny resizes, cooperative cancellation stops PNG/JPEG/resize loops promptly, completed native jobs are closed immediately (with an `ObjectSpace` finalizer safety net), and all eight bundled native binaries are built with `-O ReleaseSafe` to keep bounds and overflow checks active
51
+
10
52
  ## [1.6.0] - 2026-11-22
11
53
 
12
54
  ### Added
@@ -21,7 +63,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
21
63
 
22
64
  - `FUZZY_SEARCH_CACHE` in `config.rb` changes the file list cache limits (`max_entries` up to 1,000,000, `max_roots` up to 16, `ttl` up to 86,400 seconds; `0` disables). Omitted or invalid values keep the defaults (200,000 / 4 / 300)
23
65
 
66
+ ### Security
67
+ - Control characters are replaced with a space before anything is stored in the screen buffer (`Rufio::TextUtils.sanitize_for_display`, applied in `Screen#put` / `#put_string`). Previously only colour codes (`\e[…m`) were removed, so an `ESC` in a file name, a file's contents or a table cell reached the terminal: a cell or column name holding `\e]52;c;…\a` silently replaced the viewer's clipboard when the cursor moved onto the file, and `\e[2J` or `\e]0;…\a` could repaint the screen or the title. The table preview, the preview status lines, the file list and text previews all go through the one sanitizing step now
68
+ - Text copied with `y` or `Y` loses its trailing newline and has control characters other than newline and tab replaced, so a cell cannot execute itself when pasted into a shell. A cell holding a newline is reported as `copied, 2 lines`, since the grid draws it on one line
69
+ - SQLite databases are opened by absolute path, so a file named like an option (`-cmd`) cannot be read as one, and with `-safe` where the `sqlite3` command supports it, which refuses `writefile()`, `load_extension()` and `ATTACH`
70
+
24
71
  ### Changed
72
+ - Table previews read up to 512 KiB of a `.csv` or `.tsv` instead of 64 KiB, and `TABLE_PREVIEW`'s `max_bytes` goes up to 4 MiB. Parsing now stops at `max_rows` rows rather than parsing everything that was read, so a wider limit does not cost more time: a 40-column CSV showed 147 rows in 2 ms before and 1000 rows in 14 ms now, where the old code needed 29 ms for the same rows. Cells are measured and drawn from their first 256 characters, which keeps a cell of several hundred thousand characters from slowing the layout
73
+
25
74
  - `s`, `/` and `F` no longer use fzf, and `rufio -c` no longer checks for it. The keybind actions are renamed to `file_search` / `file_search_alt`; the former `fzf_search` / `fzf_search_alt` names in `KEYBINDS` are still accepted as aliases (the new names win when both are set)
26
75
  - G mode file name search uses the same fuzzy matching as `s`: results are ranked, matched characters are highlighted and filtering runs in the background instead of on each keystroke in the UI thread. Content search stays literal. Exclusions, skipped counts and bookmark labels are unchanged
27
76
  - Fuzzy ranking no longer penalizes the distance from the start of the path, and the first character of the file name gets +8, so file names that start with the query rank first (e.g. `Rakefile` for `rakefile`, `gemspec.rb` for `gemspec`). Ruby and native scoring stay identical
data/README.md CHANGED
@@ -8,10 +8,12 @@ Add your own actions in Ruby.
8
8
 
9
9
  [日本語](./README_ja.md) | **English**
10
10
 
11
- Development for 1.6.0 replaces fzf with a built-in fuzzy search screen for `s` / `/` and `F`
12
- (with a file preview and a cached file list for quick reopening),
13
- backed by a Zig fuzzy search core, a Ruby fallback, and an asynchronous search session.
14
- See the [implementation plan and benchmarks](./docs/native_fuzzy_search_design_ja.md).
11
+ 2.0.0 brings grid previews for tabular files (`.csv`, `.tsv`, `.xlsx`, `.ods` and SQLite),
12
+ terminal image previews via the Kitty graphics protocol (`.png`, `.jpg`, `.bmp`, decoded and scaled
13
+ by the bundled native library), and a single `/` search key across the file list, text previews and
14
+ tables (removing the old `G` mode and `rga` dependency).
15
+ See the [table preview notes](./docs/csv_cell_preview_design_ja.md) and
16
+ [image preview notes](./docs/image_preview_design_ja.md).
15
17
 
16
18
  ## What Makes rufio Different
17
19
 
@@ -20,7 +22,7 @@ rufio brings finding files, running scripts, and checking results together in on
20
22
  - **Run scripts where your files are**: Register your script directories, then press `:`, type `@` + part of a script name, press `Tab`, and hit `Enter`. Run Ruby, Python, or PowerShell scripts in the directory you are browsing
21
23
  - **Follow jobs and execution logs**: Keep browsing while scripts run in the background. Press `J` to check jobs and `L` to view execution logs
22
24
  - **Add your own actions in Ruby**: Define custom commands with a small Ruby DSL in `~/.config/rufio/commands.rb`. `~/.rufio/commands.rb` is also supported
23
- - **Use installed tools without extra configuration**: Search contents with rga, highlight previews with bat, and navigate directory history with zoxide
25
+ - **Use installed tools without extra configuration**: Highlight previews with bat, read SQLite databases with `sqlite3`, and navigate directory history with zoxide
24
26
  - **Windows support**: Run PowerShell scripts with keyboard input handling adapted to Windows terminals
25
27
  - **Trace behavior in the source**: The implementation is primarily Ruby, so you can inspect and change the parts you need. Security design is documented in [SECURITY.md](./SECURITY.md)
26
28
 
@@ -38,7 +40,13 @@ rufio brings finding files, running scripts, and checking results together in on
38
40
 
39
41
  - **Vim-like Key Bindings**: Intuitive navigation
40
42
  - **Real-time Preview**: Instantly display file contents with syntax highlighting (via `bat`), including `.zip` entry lists
41
- - **Fast Search**: Built-in fuzzy file name search, rga content search, plus built-in search across all bookmarks that also reads PDF, Excel and PowerPoint
43
+ - **Images in the Terminal**: `.png`, `.jpg` and `.bmp` are drawn in the preview pane with the Kitty graphics protocol (kitty, Ghostty, WezTerm, Konsole). The bundled native library decodes and scales the picture down to the pane first, with no third-party image code and no external tools; other terminals show the format and dimensions as text
44
+ - **Tables as a Grid**: `.csv`, `.tsv`, `.tab`, `.xlsx`, `.xlsm`, `.ods` and SQLite databases (with the `sqlite3` command, recognised by file signature) are shown as rows and columns, with the header row fixed while scrolling and automatic decoding of UTF-8, UTF-16, CP932 and EUC-JP
45
+ - **Sheets and Tables**: `[` and `]` switch between a workbook's sheets or a database's tables and `t` opens the list of sheets or tables to pick from, and only the one on screen is read
46
+ - **Move Between Cells**: In preview mode (`P`), `hjkl` moves a cell cursor through the grid, which scrolls in both directions to follow it
47
+ - **Pick Columns**: `Space` selects columns, and `y` then copies the cursor row's selected columns joined with commas
48
+ - **Copy with `y`**: Copies the cell under the cursor (`Y` for the whole row), or the current and selected file paths in the file list, using your clipboard command or OSC 52 over SSH
49
+ - **One Search Key**: `/` searches where you are. The file list searches the directory tree by name (fuzzy) or contents (also reading PDF, Excel and PowerPoint); a preview searches inside the file (`n`/`N` between matches); a table preview filters its rows with `price > 100, name a%`, and for a SQLite table that runs as a read-only `SELECT ... WHERE` inside the database
42
50
  - **ZIP Archives**: Extract or compress selected items as a background job
43
51
  - **Jump to a Path**: Paste any path into `:cd`
44
52
  - **Bookmarks**: Quick access to frequently used directories
@@ -98,15 +106,14 @@ The most used keys. See the **[User Guide](./docs/guide.md)** for every key and
98
106
  | `m/c/x` | Move / copy / delete selected items |
99
107
  | `z` | Extract or compress selected items (`.zip`); zoxide history when nothing is selected |
100
108
  | `a/A`, `r`, `d` | Create file / directory, rename, delete |
101
- | `f`, `s`, `F` | Filter, fuzzy file name search, rga content search |
102
- | `G` | Search names or contents (PDF, Excel, PowerPoint too) across all bookmarks |
103
- | `b`, `B`, `1-9`, `Tab` | Add bookmark, bookmark menu, jump, next bookmark |
109
+ | `f`, `/` | Filter the list, search under the current directory (names or contents) |
110
+ | `b`, `B`, `1-9` | Add bookmark, bookmark menu, jump to bookmark 1-9 |
104
111
  | `:` | Command mode (`@script`, `rake:task`, `!shell`, `cd <path>`) |
105
112
  | `J`, `L`, `C` | Jobs, logs, config directory |
106
113
  | `?` | Help |
107
114
  | `q`, `T` | Quit, quit and cd the shell to the current directory |
108
115
 
109
- In G mode, use `Up` / `Down` or `Ctrl+J` / `Ctrl+K` to select the next / previous result and `Enter` to open it. Application cursor arrows and extended Ctrl-key sequences are supported, including on Ghostty.
116
+ In the search screen, use `Up` / `Down` or `Ctrl+J` / `Ctrl+K` to select the next / previous result and `Enter` to open it. Application cursor arrows and extended Ctrl-key sequences are supported, including on Ghostty.
110
117
 
111
118
  ## Documentation
112
119
 
data/README_ja.md CHANGED
@@ -8,9 +8,10 @@
8
8
 
9
9
  **日本語** | [English](./README.md)
10
10
 
11
- 1.6.0 の開発では、`s` / `/` と `F` を fzf から内蔵のあいまい検索画面に置き換えました(ファイルのプレビューと、開き直しを速くする一覧キャッシュつき)。
12
- Zig の曖昧検索コア・Ruby フォールバック・非同期検索セッションで動作します。
13
- 詳細は[実装計画と計測結果](./docs/native_fuzzy_search_design_ja.md)を参照してください。
11
+ 2.0.0 では表形式のファイルを行列で表示し(`.csv` / `.tsv` / `.xlsx` / `.ods` と SQLite)、
12
+ Kitty グラフィックスプロトコルによる画像プレビュー(`.png` / `.jpg` / `.bmp`、同梱のネイティブライブラリでデコード・縮小)を追加しました。
13
+ また検索キーを `/` に一本化し、旧 `G` モードと `rga` 依存を廃止しました。
14
+ 詳細は[表プレビューの設計記録](./docs/csv_cell_preview_design_ja.md)と[画像プレビューの設計記録](./docs/image_preview_design_ja.md)を参照してください。
14
15
 
15
16
  ## rufioならではの点
16
17
 
@@ -19,7 +20,7 @@ rufio は、ファイルを探すところからスクリプトの実行、結
19
20
  - **ファイルのある場所からスクリプトを実行**: スクリプトのディレクトリを登録し、`:` → `@` + スクリプト名の一部 → `Tab` → `Enter` で呼び出せます。Ruby・Python・PowerShell を、いま開いているディレクトリで実行できます
20
21
  - **ジョブとログで実行結果を追える**: バックグラウンドで実行しながらファイル操作を続け、`J` でジョブ、`L` で実行ログを確認できます
21
22
  - **自分用の操作を Ruby で追加**: `~/.config/rufio/commands.rb` に小さな Ruby DSL で独自コマンドを定義できます。`~/.rufio/commands.rb` にも対応しています
22
- - **インストール済みのツールと追加設定なしで連携**: rga で内容検索、bat でプレビューのシンタックスハイライト、zoxide でディレクトリ履歴から移動できます
23
+ - **インストール済みのツールと追加設定なしで連携**: bat でプレビューのシンタックスハイライト、`sqlite3` で SQLite の読み取り、zoxide でディレクトリ履歴から移動できます
23
24
  - **Windows にも対応**: PowerShell スクリプトの実行に対応し、Windows のターミナルに合わせたキー入力処理を備えています
24
25
  - **挙動をソースで追いやすい**: Ruby を中心とした実装で、必要な処理を自分で確認・修正できます。セキュリティに関する設計は [SECURITY.md](./SECURITY.md) にまとめています
25
26
 
@@ -37,7 +38,13 @@ rufio は、ファイルを探すところからスクリプトの実行、結
37
38
 
38
39
  - **Vimライクなキーバインド**: 直感的なナビゲーション
39
40
  - **リアルタイムプレビュー**: ファイル内容を即座に表示(`bat` によるシンタックスハイライト対応、`.zip` はエントリ一覧)
40
- - **高速検索**: 内蔵のあいまいファイル名検索とrgaによる内容検索に加え、PDF・Excel・PowerPointも読める全ブックマーク横断検索を内蔵
41
+ - **端末に画像を表示**: Kitty グラフィックスプロトコルで `.png` / `.jpg` / `.bmp` をプレビューペインに描きます(kitty・Ghostty・WezTerm・Konsole)。同梱のネイティブライブラリ(第三者の画像コードも外部ツールも使わない)がペインの大きさまで縮小してから送ります。非対応端末では形式と寸法をテキストで表示します
42
+ - **表を行列で表示**: `.csv` / `.tsv` / `.tab` / `.xlsx` / `.xlsm` / `.ods`、および `sqlite3` コマンドがあれば SQLite のデータベースを、列見出し付きのグリッドで表示します。スクロール中もヘッダ行は固定され、UTF-8・UTF-16・CP932・EUC-JP を自動判定して読み込みます
43
+ - **シート・テーブルの切替**: `[` / `]` で Excel のシートや SQLite のテーブルを切り替えます。`t` を押すとシート/テーブル一覧から選べます。表示しているものだけを読み込みます
44
+ - **セル間を移動**: プレビューモード(`P`)で `hjkl` によりセルカーソルを動かせます。カーソルに合わせて縦横にスクロールします
45
+ - **カラムを選んでコピー**: `Space` でカラムを選び、`y` でカーソル行の選択カラムをカンマ区切りで連結してコピーします
46
+ - **`y` でコピー**: カーソル位置のセルを(`Y` で行全体を)クリップボードへコピーします。ファイル一覧では選択中(またはカーソル位置)のパスをコピーします。コマンドがない環境では OSC 52 を使うので SSH 越しでも動きます
47
+ - **検索キーは `/` だけ**: いる場所によって対象が変わります。ファイル一覧では現在のディレクトリ配下をファイル名(あいまい)か内容(PDF・Excel・PowerPoint も読む)で検索、プレビューではファイルの中を検索(`n`/`N` で前後の一致へ)、表プレビューでは `price > 100, name a%` のように行を絞り込みます。SQLite のテーブルでは読み取り専用の `SELECT ... WHERE` をデータベース側で実行します
41
48
  - **ZIPの展開・圧縮**: 選択したアイテムをバックグラウンドで展開・圧縮
42
49
  - **パスへ移動**: コピーしたパスを `:cd` に貼り付けて移動
43
50
  - **ブックマーク**: よく使うディレクトリに素早くアクセス
@@ -45,6 +52,8 @@ rufio は、ファイルを探すところからスクリプトの実行、結
45
52
 
46
53
  テキストのプレビューは先頭64 KiBまで読み込みます。PDFの本文はプレビューせず、ファイル移動時の読み込みを省きます。
47
54
 
55
+ `.csv` / `.tsv` / `.tab` / `.xlsx` / `.xlsm` / `.ods` と SQLite(`sqlite3` コマンドがある場合。拡張子ではなくファイル先頭のシグネチャで判定します)は行列(グリッド)で表示します。テキスト形式は先頭 512 KiB まで読み込みます。プレビューモード(`P`)では `hjkl` でセルを移動し、`g`/`}` で先頭行・最終行、`0`/`$` で先頭列・最終列へ移動できます。`y` でカーソル位置のセル、`Y` で行全体をクリップボードへコピーでき、`[` / `]` でシートやテーブルを切り替えられます。ファイル名の下の行にセル番地と列名(`R3C2 price`)とコピー結果が出ます。読み込み上限や区切り文字、ヘッダ行の扱い、文字コードは `config.rb` の `TABLE_PREVIEW` で変更できます。
56
+
48
57
  ### クロスプラットフォーム
49
58
 
50
59
  - **macOS**: ネイティブサポート
@@ -97,15 +106,14 @@ rufio /path/to # 指定したディレクトリで起動
97
106
  | `m/c/x` | 選択したアイテムの移動 / コピー / 削除 |
98
107
  | `z` | 選択したアイテムの展開・圧縮(`.zip`)。未選択時は zoxide 履歴 |
99
108
  | `a/A`、`r`、`d` | ファイル / ディレクトリ作成、リネーム、削除 |
100
- | `f`、`s`、`F` | フィルター、あいまいファイル名検索、rga で内容検索 |
101
- | `G` | 全ブックマーク配下のファイル名・内容(PDF・Excel・PowerPoint も)を横断検索 |
102
- | `b`、`B`、`1-9`、`Tab` | ブックマーク追加、メニュー、ジャンプ、次のブックマーク |
109
+ | `f`、`/` | 一覧の絞り込み、現在のディレクトリ配下の検索(ファイル名・内容) |
110
+ | `b`、`B`、`1-9` | ブックマーク追加、メニュー、ブックマーク 1-9 へジャンプ |
103
111
  | `:` | コマンドモード(`@スクリプト`、`rake:タスク`、`!シェル`、`cd <パス>`) |
104
112
  | `J`、`L`、`C` | ジョブ、ログ、設定ディレクトリ |
105
113
  | `?` | ヘルプ |
106
114
  | `q`、`T` | 終了、終了してシェルを現在のディレクトリへ移動 |
107
115
 
108
- Gモードでは `↓` / `↑` または `Ctrl+J` / `Ctrl+K` で次/前の検索結果を選択し、`Enter` で開きます。Ghosttyなどのアプリケーションカーソル形式の矢印キーと拡張Ctrlキー入力にも対応しています。
116
+ 検索画面では `↓` / `↑` または `Ctrl+J` / `Ctrl+K` で次/前の検索結果を選択し、`Enter` で開きます。Ghosttyなどのアプリケーションカーソル形式の矢印キーと拡張Ctrlキー入力にも対応しています。
109
117
 
110
118
  ## ドキュメント
111
119
 
data/SECURITY.md CHANGED
@@ -37,15 +37,19 @@ rufio is a local TUI tool run by you, on files you can already access.
37
37
 
38
38
  - Files and scripts are launched in array form (`system(*argv)`), never through a shell string; paths beginning with `-` are prefixed with `./`
39
39
  - Search queries are passed to rga after `--`
40
+ - Everything drawn to the screen passes through one sanitizing step: control characters (C0 and C1, so `ESC`, `BEL` and the 8-bit `CSI`) are replaced with a space before a cell is stored, so an escape sequence in a file name, a file's contents, a spreadsheet cell, a database table name or a tool's output cannot reach the terminal
41
+ - Text copied to the clipboard has its trailing newline removed, and control characters other than newline and tab replaced, so a value cannot execute on paste
42
+ - SQLite databases are opened read-only, with `-safe` where the `sqlite3` command supports it, by absolute path, and only `SELECT` is issued; table names are quoted as identifiers
40
43
  - YAML is loaded with `YAML.safe_load`
41
44
  - Command execution logs are written with `0600` permissions
42
- - Runtime dependencies are limited to `io-console`, `pastel`, `tty-cursor`, `tty-screen`
45
+ - Runtime dependencies are kept to the terminal libraries (`io-console`, `pastel`, `tty-cursor`, `tty-screen`) and the parsers the previews need (`csv`, `rubyzip`, `roo`, `nokogiri`, `pdf-reader`, `base64`). A parser only ever reads the file being previewed or searched
43
46
  - Gems are published from tagged commits via RubyGems Trusted Publishing (no long-lived API key); CI runs the test suite before publishing
44
47
 
45
48
  ### Known limitations
46
49
 
47
- - Text previews only detect binary files (by control-character ratio); terminal escape sequences inside otherwise-textual files are not explicitly stripped. Avoid previewing untrusted files in a terminal you do not trust
48
- - The optional native extension under `lib_zig` is not shipped in the gem and has not been independently audited
50
+ - A preview reads the file it shows, so a parser bug in a bundled library (`roo` for spreadsheets, Ruby's `csv`) is reachable by moving the cursor onto a file. Previews are bounded (512 KiB of text, 1000 rows, 10 MiB for a spreadsheet) and a file that cannot be parsed falls back to the archive or binary view
51
+ - A SQLite preview runs the `sqlite3` command on the file. A view's body is SQL written by whoever made the file; it is executed read-only and in `-safe` mode where available, and the CLI refuses `writefile()`, `readfile()`, `edit()` and `load_extension()` outside a direct statement. A `sqlite3` older than 3.32 does not carry those refusals
52
+ - The optional native library (`lib_zig`, prebuilt under `lib/rufio/native/` and compiled with `-O ReleaseSafe`) is shipped in the gem for faster search, directory scanning, and image preview decoding, and has not been independently audited. Image preview native decoding can be disabled with `RUFIO_NATIVE_IMAGE=0`, and image preview itself with `RUFIO_IMAGE_PREVIEW=0`
49
53
 
50
54
  ---
51
55
 
@@ -84,12 +88,16 @@ rufioは、あなた自身がアクセスできるファイルに対して、ロ
84
88
 
85
89
  - ファイルやスクリプトは配列形式(`system(*argv)`)で起動し、シェル文字列を介しません。`-` で始まるパスには `./` を付与します
86
90
  - rga には `--` を挟んで検索語を渡します
91
+ - 画面に出す文字列はすべて 1 箇所で無害化します。制御文字(C0 と C1。`ESC`・`BEL`・8 ビットの `CSI` を含む)はバッファに入れる前に空白へ置き換えるため、ファイル名・ファイル内容・表のセル・データベースのテーブル名・ツールの出力に含まれるエスケープシーケンスがターミナルへ届きません
92
+ - クリップボードへコピーする文字列は、末尾の改行を落とし、改行とタブ以外の制御文字を置き換えます(貼り付けた瞬間に実行されるのを防ぐため)
93
+ - SQLite は読み取り専用で開き、`sqlite3` が対応していれば `-safe` を付け、絶対パスで渡し、`SELECT` のみを発行します。テーブル名は識別子としてクォートします
87
94
  - YAML は `YAML.safe_load` で読み込みます
88
95
  - コマンド実行ログは `0600` で保存します
89
- - 実行時依存gemは `io-console`、`pastel`、`tty-cursor`、`tty-screen` のみです
96
+ - 実行時依存gemは、ターミナル操作(`io-console`、`pastel`、`tty-cursor`、`tty-screen`)と、プレビュー・検索に必要な解析ライブラリ(`csv`、`rubyzip`、`roo`、`nokogiri`、`pdf-reader`、`base64`)に限っています。解析ライブラリはプレビュー・検索の対象ファイルを読むためだけに使います
90
97
  - gemはタグ付きコミットからRubyGemsのTrusted Publishingで公開します(長期APIキーなし)。公開前にCIでテストを実行します
91
98
 
92
99
  ### 既知の制約
93
100
 
94
- - テキストのプレビューはバイナリ判定(制御文字の比率)のみで、テキストとして扱われるファイル内のエスケープシーケンスは明示的に除去していません。信頼できないファイルを、信頼できないターミナルでプレビューするのは避けてください
95
- - `lib_zig` のネイティブ拡張(任意機能)はgemに同梱しておらず、第三者による監査も受けていません
101
+ - プレビューは対象ファイルを解析するため、同梱ライブラリ(表計算は `roo`、CSV は Ruby の `csv`)の解析不具合にはカーソルを合わせるだけで到達します。読み込み量には上限があり(テキスト 512 KiB、1000 行、表計算 10 MiB)、解析できないファイルはアーカイブ表示またはバイナリ表示に戻ります
102
+ - SQLite のプレビューは `sqlite3` コマンドをファイルに対して実行します。ビューの本体はファイル作成者が書いた SQL です。読み取り専用かつ(対応していれば)`-safe` で実行し、CLI 側も直接の文以外からの `writefile()`・`readfile()`・`edit()`・`load_extension()` を拒否します。3.32 より古い `sqlite3` にはこの拒否がありません
103
+ - `lib_zig` のネイティブライブラリ(`lib/rufio/native/` に `-O ReleaseSafe` でビルド済みバイナリを同梱)は、検索・ディレクトリ走査・画像プレビューのデコード高速化のために利用され、第三者による監査は受けていません。画像プレビューのネイティブデコードは `RUFIO_NATIVE_IMAGE=0`、画像プレビュー自体は `RUFIO_IMAGE_PREVIEW=0` で無効化できます