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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +49 -0
- data/README.md +17 -10
- data/README_ja.md +17 -9
- data/SECURITY.md +14 -6
- data/docs/csv_cell_preview_design_ja.md +682 -0
- data/docs/guide.md +109 -47
- data/docs/guide_ja.md +110 -48
- data/docs/image_preview_design_ja.md +335 -0
- data/docs/native_fuzzy_search_design_ja.md +2 -2
- data/examples/config.rb +23 -0
- data/info/help.md +32 -27
- data/info/keybindings.md +42 -12
- data/info/welcome.md +4 -6
- data/lib/rufio/background_status.rb +7 -0
- data/lib/rufio/bookmark_controller.rb +0 -45
- data/lib/rufio/clipboard.rb +162 -0
- data/lib/rufio/command_locator.rb +49 -0
- data/lib/rufio/config.rb +7 -2
- data/lib/rufio/config_loader.rb +56 -21
- data/lib/rufio/csv_table_source.rb +125 -0
- data/lib/rufio/encoding_detector.rb +152 -0
- data/lib/rufio/file_operation_controller.rb +41 -0
- data/lib/rufio/file_preview.rb +92 -19
- data/lib/rufio/graphics_layer.rb +223 -0
- data/lib/rufio/health_checker.rb +27 -10
- data/lib/rufio/help_menu.rb +16 -11
- data/lib/rufio/image_preview_view.rb +421 -0
- data/lib/rufio/image_source.rb +158 -0
- data/lib/rufio/keybind_handler.rb +21 -35
- data/lib/rufio/kitty_graphics.rb +128 -0
- data/lib/rufio/native/aarch64-linux-gnu/librufio_zig.so +0 -0
- data/lib/rufio/native/aarch64-linux-musl/librufio_zig.so +0 -0
- data/lib/rufio/native/aarch64-macos/librufio_zig.dylib +0 -0
- data/lib/rufio/native/aarch64-windows/rufio_zig.dll +0 -0
- data/lib/rufio/native/x86_64-linux-gnu/librufio_zig.so +0 -0
- data/lib/rufio/native/x86_64-linux-musl/librufio_zig.so +0 -0
- data/lib/rufio/native/x86_64-macos/librufio_zig.dylib +0 -0
- data/lib/rufio/native/x86_64-windows/rufio_zig.dll +0 -0
- data/lib/rufio/native_content_search.rb +1 -1
- data/lib/rufio/native_image.rb +177 -0
- data/lib/rufio/native_scanner_zig.rb +22 -0
- data/lib/rufio/navigation_controller.rb +47 -16
- data/lib/rufio/preview_registry.rb +86 -0
- data/lib/rufio/preview_view.rb +363 -0
- data/lib/rufio/renderer.rb +8 -8
- data/lib/rufio/screen.rb +33 -0
- data/lib/rufio/search_prompt.rb +50 -0
- data/lib/rufio/{global_search.rb → search_screen.rb} +41 -14
- data/lib/rufio/sheet_picker.rb +87 -0
- data/lib/rufio/sqlite_table_source.rb +205 -0
- data/lib/rufio/tab_mode_manager.rb +1 -3
- data/lib/rufio/table_cursor.rb +117 -0
- data/lib/rufio/table_document.rb +261 -0
- data/lib/rufio/table_layout.rb +231 -0
- data/lib/rufio/table_preview_view.rb +376 -0
- data/lib/rufio/table_query.rb +240 -0
- data/lib/rufio/table_source.rb +46 -0
- data/lib/rufio/terminal_graphics.rb +168 -0
- data/lib/rufio/terminal_ui.rb +63 -111
- data/lib/rufio/text_utils.rb +27 -0
- data/lib/rufio/ui_renderer.rb +379 -16
- data/lib/rufio/version.rb +1 -1
- data/lib/rufio/xlsx_table_source.rb +112 -0
- data/lib/rufio.rb +19 -5
- data/lib_zig/rufio_native/Makefile +6 -4
- data/lib_zig/rufio_native/build.zig +10 -0
- data/lib_zig/rufio_native/src/image.zig +525 -0
- data/lib_zig/rufio_native/src/image_bmp.zig +111 -0
- data/lib_zig/rufio_native/src/image_jpeg.zig +878 -0
- data/lib_zig/rufio_native/src/image_png.zig +561 -0
- data/lib_zig/rufio_native/src/image_resize.zig +170 -0
- data/lib_zig/rufio_native/src/image_test.zig +401 -0
- data/lib_zig/rufio_native/src/main.zig +1 -0
- data/lib_zig/rufio_native/src/search.zig +38 -19
- data/lib_zig/rufio_native/src/search_test.zig +35 -0
- data/lib_zig/rufio_native/src/testdata/alpha.png +0 -0
- data/lib_zig/rufio_native/src/testdata/gradient.bmp +0 -0
- data/lib_zig/rufio_native/src/testdata/gradient.jpg +0 -0
- data/lib_zig/rufio_native/src/testdata/gradient.png +0 -0
- data/retag.sh +4 -4
- metadata +37 -9
- data/lib/rufio/fuzzy_candidate_cache.rb +0 -258
- data/lib/rufio/fuzzy_finder.rb +0 -313
- data/lib/rufio/fuzzy_preview_loader.rb +0 -107
- data/lib/rufio/rga_result_source.rb +0 -89
- data/lib/rufio/search_controller.rb +0 -94
- data/lib_zig/rufio_native/src/main.zig.sync +0 -205
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
# 画像プレビュー(Kitty グラフィックスプロトコル / Zig 版)設計メモ
|
|
2
|
+
|
|
3
|
+
## 1. 目的
|
|
4
|
+
|
|
5
|
+
プレビューペイン(分割・`P` のフルスクリーン)に画像を**そのまま表示**する。文字で近似する ASCII アート方式ではなく、端末のグラフィックス機能(Kitty graphics protocol)にピクセルを渡す。
|
|
6
|
+
|
|
7
|
+
- 対象形式: PNG / JPEG / GIF(1 枚目)/ BMP / TGA
|
|
8
|
+
- 対象端末: kitty、Ghostty、WezTerm、Konsole など Kitty プロトコルに応答する端末
|
|
9
|
+
- 使えない端末では**現状どおり**メタ情報のテキスト(形式・寸法・ファイルサイズ)を出すだけで、操作は一切止めない
|
|
10
|
+
|
|
11
|
+
### 非目標
|
|
12
|
+
|
|
13
|
+
| やらないこと | 理由 |
|
|
14
|
+
|---|---|
|
|
15
|
+
| Sixel / iTerm2 (OSC 1337) プロトコル | まず 1 つに絞る。プロトコル層を差し替え可能にしておき、後から足す(§12 Phase 5) |
|
|
16
|
+
| アニメーション GIF / APNG の再生 | 1 枚目だけ表示する。再生はメインループのフレーム設計に手が入る |
|
|
17
|
+
| SVG・PDF・RAW・HEIC | ベクタ/巨大デコーダが必要。SVG は従来どおりテキスト扱い |
|
|
18
|
+
| 画像の編集・回転・切り出し | ファイルマネージャの役目を越える(EXIF の回転だけは Phase 4 で検討) |
|
|
19
|
+
|
|
20
|
+
## 2. 現状
|
|
21
|
+
|
|
22
|
+
| いまの挙動 | 場所 |
|
|
23
|
+
|---|---|
|
|
24
|
+
| 拡張子で `type: 'image'` に分類されるが、中身は読まず「バイナリ」の文言を出す | `file_preview.rb:259`(`detect_file_type`)、`binary_response` |
|
|
25
|
+
| プレビューペインは 1 セル = 1 文字のバッファに描き、`Renderer` が**変更行だけ**を 1 回の `write` で出す | `screen.rb` / `renderer.rb:26` |
|
|
26
|
+
| プレビュー種別ごとの表示とキー操作は `PreviewView` の派生に閉じている(テキスト / 表) | `preview_view.rb`、`table_preview_view.rb` |
|
|
27
|
+
| 幅に依存する計算(折り返し・列幅・一致行)は `UIRenderer` が毎フレーム求め、ビューへ渡す | `ui_renderer.rb`、`apply_matches` / `visible_rows=` |
|
|
28
|
+
| ネイティブ処理は Zig の単一ライブラリに `core_*` の C ABI で生やし、Fiddle で引く。無い・古い・環境変数で無効なら Ruby にフォールバック | `lib_zig/rufio_native/src/main.zig`、`native_scanner_zig.rb`、`native_zip.rb` |
|
|
29
|
+
|
|
30
|
+
**画像は「セルに文字を書く」モデルから外れる**ので、既存の描画パイプラインに割り込み方を決めるのが設計の中心になる(§6)。
|
|
31
|
+
|
|
32
|
+
## 3. 責務の分割(なぜ Zig か)
|
|
33
|
+
|
|
34
|
+
CLAUDE.md の約束(安全性と方針は Ruby、計算はネイティブ)に合わせる。
|
|
35
|
+
|
|
36
|
+
| 層 | 担当 | 置き場所 |
|
|
37
|
+
|---|---|---|
|
|
38
|
+
| 端末能力の検出 | 問い合わせ・環境変数・tmux 判定・セルのピクセル寸法 | Ruby `terminal_graphics.rb` |
|
|
39
|
+
| プロトコル組み立て | APC シーケンス、Base64 の分割送信、配置・削除、tmux パススルー | Ruby `kitty_graphics.rb` |
|
|
40
|
+
| 配置の管理 | 画像 ID・矩形・再送条件・後片付け | Ruby `graphics_layer.rb` |
|
|
41
|
+
| 画像のデコード・縮小・符号化 | JPEG/GIF/BMP の展開、目標ピクセルへの縮小、PNG 再エンコード、Base64 化 | **Zig** `src/image.zig` |
|
|
42
|
+
| 方針・上限・フォールバック | 読み込み上限、ピクセル上限、形式判定、設定 | Ruby |
|
|
43
|
+
|
|
44
|
+
### Zig に置く理由
|
|
45
|
+
|
|
46
|
+
1. **Ruby に画像デコーダが無い**。`mini_magick` / `vips` を足すと外部コマンドや共有ライブラリへの依存が増え、「無くても動く」方針と合わない。Zig ライブラリは既に全 8 プラットフォーム分を gem に同梱している(`lib/rufio/native/<platform>/`)ので、置き場所が既にある。
|
|
47
|
+
2. **縮小が効く**。6000×4000 の JPEG をそのまま送ると Base64 で十数 MB になり、端末もデコードに時間を使う。ペインの実ピクセル(例 320×320)へ先に落とせば転送量は数十 KB になる。
|
|
48
|
+
3. **GVL の外で回せる**。既存の `AsyncScanner` / ZIP ジョブと同じく、自前スレッド+ハンドルのポーリングで描画ループを止めない。
|
|
49
|
+
|
|
50
|
+
### Zig が無くても動く線
|
|
51
|
+
|
|
52
|
+
> Kitty プロトコルは **PNG を端末側でデコードできる**(`f=100`)。
|
|
53
|
+
|
|
54
|
+
したがって **PNG はファイルのバイト列をそのまま Base64 で送れば表示できる**。これを Zig 無しのフォールバック経路にする。
|
|
55
|
+
|
|
56
|
+
| 条件 | 挙動 |
|
|
57
|
+
|---|---|
|
|
58
|
+
| Kitty 対応 + Zig あり | 全対象形式。ペインに合わせて縮小してから送る |
|
|
59
|
+
| Kitty 対応 + Zig 無し(古いライブラリ・`RUFIO_NATIVE_IMAGE=0`) | PNG だけ直送(`max_bytes` 以下)。他形式はメタ情報テキスト |
|
|
60
|
+
| 非対応端末 / `IMAGE_PREVIEW.enabled = false` | メタ情報テキスト(従来どおり) |
|
|
61
|
+
|
|
62
|
+
「ネイティブ側だけに機能を実装しない」規約を満たすため、**Zig は速さと対応形式を増やすだけ**で、機能の有無を決めない。
|
|
63
|
+
|
|
64
|
+
## 4. 全体構成
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
┌─ 入力層 ────────────────────────────────────────────────┐
|
|
68
|
+
│ FilePreview type: 'image' + メタ情報(形式・寸法・サイズ)│
|
|
69
|
+
│ ImageSource シグネチャで形式を判定(拡張子は信用しない) │
|
|
70
|
+
└──────────────────────────────────────────────────────────┘
|
|
71
|
+
↓ ImageDocument(パス・形式・元寸法・mtime)
|
|
72
|
+
┌─ 表示層 ────────────────────────────────────────────────┐
|
|
73
|
+
│ ImagePreviewView < PreviewView ズーム・状態・ステータス行 │
|
|
74
|
+
│ UIRenderer セル矩形の確保とメタ情報の 1 行 │
|
|
75
|
+
└──────────────────────────────────────────────────────────┘
|
|
76
|
+
↓ 矩形(セル)+ソース
|
|
77
|
+
┌─ 画像層 ────────────────────────────────────────────────┐
|
|
78
|
+
│ GraphicsLayer どの画像をどこに置いたか/再送と削除の判断 │
|
|
79
|
+
│ KittyGraphics APC シーケンスの組み立て(チャンク・tmux) │
|
|
80
|
+
│ TerminalGraphics 対応判定・セルのピクセル寸法 │
|
|
81
|
+
│ NativeImage Zig 呼び出し(非同期)/PNG 直送のフォールバック │
|
|
82
|
+
└──────────────────────────────────────────────────────────┘
|
|
83
|
+
↓ 1 フレームの最後
|
|
84
|
+
Renderer#render(セル差分)→ GraphicsLayer#flush(APC を後から書く)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**原則**: ターミナルへ直接 `print` しない規約は維持する。APC を書くのは `GraphicsLayer#flush` だけで、`Renderer` と同じ出力 IO を受け取り、**セル差分を書いた直後**に 1 回の `write` でまとめて出す。
|
|
88
|
+
|
|
89
|
+
## 5. Kitty プロトコルの使い方
|
|
90
|
+
|
|
91
|
+
### 5.1 送信
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
\e_G a=T, f=100, i=<id>, p=1, c=<cols>, r=<rows>, C=1, q=2, m=1 ; <base64 4096B> \e\\
|
|
95
|
+
\e_G m=1 ; <base64 4096B> \e\\
|
|
96
|
+
...
|
|
97
|
+
\e_G m=0 ; <base64 残り> \e\\
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
| キー | 値 | 意味 |
|
|
101
|
+
|---|---|---|
|
|
102
|
+
| `a=T` | — | 転送して即表示 |
|
|
103
|
+
| `f` | `100` / `24` / `32` | PNG / 生 RGB / 生 RGBA。生のときは `s=<px幅>,v=<px高さ>` も必須 |
|
|
104
|
+
| `t=d` | — | 直接転送(Base64)。既定 |
|
|
105
|
+
| `i` / `p` | 整数 | 画像 ID / 配置 ID。再送・削除の単位 |
|
|
106
|
+
| `c,r` | セル数 | 指定矩形に収める(アスペクト比は端末が保つ) |
|
|
107
|
+
| `C=1` | — | **カーソルを動かさない**(これが無いと行がずれて画面が崩れる) |
|
|
108
|
+
| `q=2` | — | 成功・失敗の応答を抑止(raw モードの入力ループに混ざらせない) |
|
|
109
|
+
| `m` | `1` / `0` | 分割送信の継続 / 最終チャンク。1 チャンクのペイロードは 4096 バイト以下 |
|
|
110
|
+
|
|
111
|
+
左上の位置は「送信時のカーソル位置」なので、`\e[<row>;<col>H` でペイン左上へ移動してから送り、`C=1` で動かさないまま終える。
|
|
112
|
+
|
|
113
|
+
### 5.2 削除・置き換え
|
|
114
|
+
|
|
115
|
+
| 操作 | シーケンス | いつ |
|
|
116
|
+
|---|---|---|
|
|
117
|
+
| 削除 | `\e_Ga=d,d=i,i=<id>,q=2\e\\` | 別のファイルを選んだ、プレビューを抜けた、矩形が変わった |
|
|
118
|
+
| 全削除 | `\e_Ga=d,d=A,q=2\e\\` | 終了処理(`cleanup_terminal`)、画面全体の再描画(`refresh_display`) |
|
|
119
|
+
| 再配置 | 同じ `i` で `a=p`(再送なし) | 画像は同じで矩形だけ動いた(ペイン幅の変更) |
|
|
120
|
+
|
|
121
|
+
**ID の決め方**: 他アプリと衝突させない。`i = 0x52000000 | ((pid & 0xffff) << 8) | slot`(slot は 0..3 の輪番)。`p` は矩形ごとに 1 ずつ増やす。
|
|
122
|
+
|
|
123
|
+
### 5.3 転送方式の選択
|
|
124
|
+
|
|
125
|
+
| 方式 | 使うとき | 注意 |
|
|
126
|
+
|---|---|---|
|
|
127
|
+
| `t=d`(直送) | 既定。SSH 越しでも動く | Base64 で 4/3 倍。縮小してから送るのが前提 |
|
|
128
|
+
| `t=t`(一時ファイル・読み込み後に端末が削除) | ローカルで 1 MB を超えるペイロード | 端末と同じホストでしか使えない。`/tmp` のパスを渡すので `RUFIO_IMAGE_TRANSFER=file` で明示的に有効化する扱い |
|
|
129
|
+
| `t=s`(共有メモリ) | 採らない | プラットフォーム差が大きく、得は小さい |
|
|
130
|
+
|
|
131
|
+
### 5.4 対応判定
|
|
132
|
+
|
|
133
|
+
1. `IMAGE_PREVIEW.enabled` が false なら即終了。
|
|
134
|
+
2. tmux / screen 内(`$TMUX` / `$STY`)は既定で無効。`tmux_passthrough: true` のときだけ `\ePtmux;` で `\e` を二重化して送る(tmux 3.3+ かつ `allow-passthrough on` が必要)。
|
|
135
|
+
3. 問い合わせ(起動直後、メインループに入る前に 1 回だけ):
|
|
136
|
+
```
|
|
137
|
+
送信: \e_Gi=31,s=1,v=1,a=q,t=d,f=24;AAAA\e\\ + \e[c
|
|
138
|
+
受信: \e_Gi=31;OK\e\\ を含めば対応。\e[?… だけ返って来たら非対応
|
|
139
|
+
```
|
|
140
|
+
`\e[c`(Primary DA)を続けて送るのが要点で、**Kitty 非対応端末でも必ず何か返る**ため無応答で待たされない。読み取りは 200ms のタイムアウト付き、`raw` モードのまま `IO.select` で行い、取り切れなかったバイトは捨てる。
|
|
141
|
+
4. 環境変数(`TERM=xterm-kitty`、`KITTY_WINDOW_ID`、`TERM_PROGRAM=ghostty|WezTerm`)は**ヒントに留める**。判定は問い合わせ優先、問い合わせが失敗したときの保険に使う。
|
|
142
|
+
5. セルのピクセル寸法: `TIOCGWINSZ` の `ws_xpixel`/`ws_ypixel`(Zig の `core_image_cell_pixels`)。0 が返る端末では `CSI 16t` を試し、それも駄目なら 1 セル 8×16 と仮定する。
|
|
143
|
+
|
|
144
|
+
結果は `TerminalGraphics.capability`(`:kitty` / `:none`)としてプロセス内に 1 回だけ記憶し、`SIGWINCH` ではピクセル寸法だけ取り直す。
|
|
145
|
+
|
|
146
|
+
## 6. セル描画との整合(要点)
|
|
147
|
+
|
|
148
|
+
画像はセルバッファの外にあるので、**セル側が画像の上に書くと画像が壊れる**。次の 3 つで守る。
|
|
149
|
+
|
|
150
|
+
1. **矩形のセルを確保する**: `UIRenderer` は画像矩形を空白で埋め、`Screen#reserve(x, y, w, h)` で「画像占有」として記録する。確保セルは `put` / `put_string` を無視し(`Screen` 側で弾く)、通知やフッタが割り込んで画像を削るのを防ぐ。
|
|
151
|
+
2. **書き換えられたら再送する**: `Renderer#render` は書き換えた行番号の集合を返すようにする(現在は `true` / `false`)。`GraphicsLayer#flush(output, rewritten_rows:)` は、矩形と交差する行が書き換えられていたら**その画像だけ**再送する。
|
|
152
|
+
3. **変化が無ければ何も書かない**: 矩形・ソース(パス + mtime)・ズームが前フレームと同じで、交差する行も書き換わっていなければ APC を 1 バイトも出さない。これで静止時のコストが 0 になり、既存の「dirty 行だけ描く」方針と揃う。
|
|
153
|
+
|
|
154
|
+
### 再送・削除のきっかけ
|
|
155
|
+
|
|
156
|
+
| 変化 | 対応 |
|
|
157
|
+
|---|---|
|
|
158
|
+
| 選択ファイルが変わった | 旧画像を削除 → 新しい画像を 80ms のデバウンス後に送る(j/k の連打で MB 級の転送を繰り返さない) |
|
|
159
|
+
| プレビューを抜けた / モードが変わった / 検索画面を開いた | 削除のみ |
|
|
160
|
+
| ペイン幅・端末サイズが変わった | 矩形だけの変化なら `a=p` で再配置、ピクセル目標が大きく変わったら再デコード |
|
|
161
|
+
| ズーム(`+` / `-` / `0`) | 再デコードして再送 |
|
|
162
|
+
| 終了(`cleanup_terminal`) | `d=A` で全削除してから alternate screen を抜ける |
|
|
163
|
+
|
|
164
|
+
## 7. Zig 側の設計
|
|
165
|
+
|
|
166
|
+
### 7.1 C ABI(既存の `core_*` 命名・ハンドル方式に合わせる)
|
|
167
|
+
|
|
168
|
+
```c
|
|
169
|
+
const char* core_image_version(void); // API 世代("1")
|
|
170
|
+
int32_t core_image_cell_pixels(uint32_t* w, uint32_t* h); // TIOCGWINSZ(失敗 -1)
|
|
171
|
+
|
|
172
|
+
// デコード+縮小+符号化を別スレッドで始める。戻り値はハンドル(0 は失敗)
|
|
173
|
+
uint64_t core_image_create(const char* path, size_t path_len,
|
|
174
|
+
uint32_t max_w, uint32_t max_h,
|
|
175
|
+
uint8_t format, uint32_t flags);
|
|
176
|
+
uint8_t core_image_state(uint64_t handle); // 0=running 1=done 2=failed
|
|
177
|
+
int32_t core_image_info(uint64_t handle, uint32_t* w, uint32_t* h,
|
|
178
|
+
uint32_t* src_w, uint32_t* src_h, uint8_t* kind);
|
|
179
|
+
const uint8_t* core_image_payload(uint64_t handle, size_t* len); // Base64 済み
|
|
180
|
+
void core_image_cancel(uint64_t handle);
|
|
181
|
+
void core_image_destroy(uint64_t handle);
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
| 引数 | 意味 |
|
|
185
|
+
|---|---|
|
|
186
|
+
| `max_w` / `max_h` | 出力の上限ピクセル(ペインのセル数 × セルのピクセル)。超えるときだけ縮小し、拡大はしない |
|
|
187
|
+
| `format` | `0`=PNG 再エンコード(`f=100`)、`1`=RGB(`f=24`)、`2`=RGBA(`f=32`)、`3`=無変換の直送(PNG のみ) |
|
|
188
|
+
| `flags` | bit0: アルファを保つ、bit1: EXIF の回転を適用(Phase 4) |
|
|
189
|
+
| `kind` | 判定した形式(0=PNG 1=JPEG 2=GIF 3=BMP 4=TGA 255=非対応) |
|
|
190
|
+
|
|
191
|
+
- **戻りは Base64 済み**にする。数 MB の Base64 化を Ruby でやると GVL を握ったまま時間を使うため。4096 バイトごとの分割は Ruby 側で `byteslice` するだけにする。
|
|
192
|
+
- `format=1/2`(生ピクセル)は PNG 再エンコード(zlib 圧縮)を省けるので速い。ただし転送量は増える。**既定は `1`(RGB)**、アルファのある画像は `2`、`IMAGE_PREVIEW.transfer: 'png'` のときだけ `0`。
|
|
193
|
+
- エラーは state=failed と `kind=255` で表し、例外・ログは出さない(描画中に呼ばれるため)。
|
|
194
|
+
|
|
195
|
+
### 7.2 デコーダ(自前実装にした経緯)
|
|
196
|
+
|
|
197
|
+
当初は `stb` 系の単一ヘッダを同梱する前提だったが、実装前に調べて 2 点が分かったため**第三者コードを使わず Zig で書いた**。
|
|
198
|
+
|
|
199
|
+
| 分かったこと | 判断 |
|
|
200
|
+
|---|---|
|
|
201
|
+
| stb の上流が `.NO_AI` / CONTRIBUTING.md で「LLM の使用禁止」を掲げている(public domain なので利用はライセンス上問題ないが、LLM が取り込んで配るのは上流の意向に反する) | 採らない |
|
|
202
|
+
| 縮小用の `stb_image_resize2.h` が上流の root から消えている(別経路の調達が必要) | 同上 |
|
|
203
|
+
| Zig 標準ライブラリに inflate / deflate がある(`std.compress.flate`。`zip.zig` で既に使用) | PNG の読み書きは標準ライブラリで足りる |
|
|
204
|
+
|
|
205
|
+
| ファイル | 役割 | 行数の目安 |
|
|
206
|
+
|---|---|---|
|
|
207
|
+
| `src/image_png.zig` | PNG の読み書き(zlib は `std.compress.flate`)。8/16bit のグレー・RGB・パレット・アルファ付き。書きはフィルタ 0 固定 | 約 330 |
|
|
208
|
+
| `src/image_jpeg.zig` | baseline JPEG(SOF0・ハフマン・4:4:4 / 4:2:2 / 4:2:0・リスタートマーカー・複数表) | 約 530 |
|
|
209
|
+
| `src/image_bmp.zig` | 無圧縮の 24/32bit と 8bit パレット(上下どちらの行順も) | 約 110 |
|
|
210
|
+
| `src/image_resize.zig` | 面積平均(box filter)での縮小。拡大はしない | 約 80 |
|
|
211
|
+
| `src/image.zig` | 形式判定・デコードの振り分け・縮小・PNG 符号化・Base64・スレッド・C ABI | 約 380 |
|
|
212
|
+
|
|
213
|
+
- メモリは `std.heap.c_allocator`(既存コードと同じ)。ファイル読みは `os.zig` の読み取り口を使う(Windows でも同じ経路)。
|
|
214
|
+
- 非対応: GIF(LZW 未実装)・プログレッシブ JPEG・算術符号・12bit・CMYK・インターレース PNG。いずれも failed を返し、Ruby 側がテキスト表示に落とす。
|
|
215
|
+
- テストは `src/image_test.zig`(`src/testdata/` の実画像を `@embedFile`)。`make test` に入れた。
|
|
216
|
+
- 将来 WebP / AVIF を足すなら、`decodeImage` の分岐に実装を 1 つ増やすだけで済む形にしてある。
|
|
217
|
+
|
|
218
|
+
### 7.3 安全性
|
|
219
|
+
|
|
220
|
+
| 危険 | 対策 |
|
|
221
|
+
|---|---|
|
|
222
|
+
| 細工した画像での巨大確保(decompression bomb) | デコード前に `stbi_info` で寸法を取り、`max_pixels`(既定 64M px = 8192×8192 相当)超は拒否。確保サイズは `w*h*4` を u64 で計算し桁溢れを検査 |
|
|
223
|
+
| 不正ファイルでのクラッシュ | stb は戻り値 NULL で失敗を返す設計。`kind=255` / failed に落とすだけで、プロセスは落とさない |
|
|
224
|
+
| 巨大ファイルの読み込み | `max_bytes`(既定 32 MiB)を超えるファイルは読まない(Ruby 側でも先に弾く) |
|
|
225
|
+
| パスの扱い | Ruby が渡す絶対パスのみ。Zig 側ではパスを組み立てない・書き込まない(読み取り専用で開く) |
|
|
226
|
+
| スレッド競合 | 既存 `AsyncScanner` と同じ mutex。`destroy` は実行中スレッドを join してから解放 |
|
|
227
|
+
|
|
228
|
+
## 8. Ruby 側の構成
|
|
229
|
+
|
|
230
|
+
| ファイル | 役割 |
|
|
231
|
+
|---|---|
|
|
232
|
+
| `lib/rufio/terminal_graphics.rb` | 対応判定(問い合わせ・環境変数・tmux)、セルのピクセル寸法、`supported?` / `cell_pixels` |
|
|
233
|
+
| `lib/rufio/kitty_graphics.rb` | `transmit(id:, payload:, format:, cols:, rows:, pixels:)` / `place` / `delete` / `delete_all` の**文字列組み立てだけ**(IO を持たない=テストしやすい) |
|
|
234
|
+
| `lib/rufio/graphics_layer.rb` | 配置状態(id・矩形・ソース・ズーム)と `flush(output, rewritten_rows:)`、`clear_all` |
|
|
235
|
+
| `lib/rufio/native_image.rb` | Zig バインディング(`available?` / `decode_async` / ポーリング)と PNG 直送のフォールバック |
|
|
236
|
+
| `lib/rufio/image_source.rb` | シグネチャでの形式判定(PNG/JPEG/GIF/BMP)と寸法の読み取り(ヘッダだけ・Ruby で十分) |
|
|
237
|
+
| `lib/rufio/image_preview_view.rb` | `PreviewView` の種別。`image?`、ズーム、`y` でパスコピー、ステータス行 |
|
|
238
|
+
| 既存への追記 | `FilePreview`(`type: 'image'` にメタ情報)、`PreviewRegistry`(`image?`)、`PreviewView.build`、`UIRenderer`(矩形確保と登録)、`Screen#reserve`、`Renderer#render` の戻り値、`ConfigLoader.image_preview`、`HealthChecker`、`help_menu` と `info/` |
|
|
239
|
+
|
|
240
|
+
### 設定(`~/.config/rufio/config.rb`)
|
|
241
|
+
|
|
242
|
+
```ruby
|
|
243
|
+
IMAGE_PREVIEW = {
|
|
244
|
+
enabled: true, # false で完全に無効(従来のメタ情報表示)
|
|
245
|
+
max_bytes: 32 * 1024 * 1024,
|
|
246
|
+
max_pixels: 64_000_000,
|
|
247
|
+
transfer: 'rgb', # 'rgb' | 'rgba' | 'png'
|
|
248
|
+
quality: 'fast', # 'fast'(box)| 'high'(Mitchell)
|
|
249
|
+
tmux_passthrough: false,
|
|
250
|
+
debounce_ms: 80
|
|
251
|
+
}.freeze
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
`TABLE_PREVIEW` と同じく `DEFAULT_IMAGE_PREVIEW` / `MIN_` / `MAX_` で丸め、不正値は既定値のままにする。環境変数 `RUFIO_NATIVE_IMAGE=0` で Zig 経路だけを切る。
|
|
255
|
+
|
|
256
|
+
### キー操作(プレビューモード中)
|
|
257
|
+
|
|
258
|
+
| キー | 動作 |
|
|
259
|
+
|---|---|
|
|
260
|
+
| `+` / `-` | ズーム(等倍→ペイン収まりの倍率を 25% 刻み) |
|
|
261
|
+
| `0` | ペインに収める(既定) |
|
|
262
|
+
| `y` | ファイルパスをコピー(他のプレビューと同じ) |
|
|
263
|
+
| `ESC` | プレビューを抜ける(画像は削除) |
|
|
264
|
+
| `/` | 画像では検索しない(キーを食わずに `false` を返す) |
|
|
265
|
+
|
|
266
|
+
ステータス行(ファイル名の下): `PNG 1920x1080 1.2 MB → 640x360 (40x20 cells) | +/-: zoom 0: fit ESC: back`
|
|
267
|
+
|
|
268
|
+
## 9. フォールバックの階段
|
|
269
|
+
|
|
270
|
+
```
|
|
271
|
+
IMAGE_PREVIEW.enabled?
|
|
272
|
+
└─ no → メタ情報テキスト
|
|
273
|
+
TerminalGraphics.supported? (問い合わせ → 環境変数 → tmux 判定)
|
|
274
|
+
└─ no → メタ情報テキスト(「この端末は画像表示に対応していません」を 1 行)
|
|
275
|
+
NativeImage.available? (ライブラリ有無・API 世代・RUFIO_NATIVE_IMAGE)
|
|
276
|
+
├─ yes → 全形式・縮小あり
|
|
277
|
+
└─ no → PNG だけ直送(max_bytes 以下)/他形式はメタ情報テキスト
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
どの段でも**操作は止めない**。デコード中は「読み込み中」の 1 行を出し、完了したフレームで画像を出す。
|
|
281
|
+
|
|
282
|
+
## 10. 性能目標
|
|
283
|
+
|
|
284
|
+
| 項目 | 目標 |
|
|
285
|
+
|---|---|
|
|
286
|
+
| 2000×1500 JPEG → 320×320 px のデコード+縮小 | 30 ms 以下(別スレッド。描画ループは止めない)→ **実測 32 ms**(PNG は 30 ms) |
|
|
287
|
+
| 転送量(上と同じ条件) | 400 KB 以下(Base64 込み)→ **実測 283 KB**(PNG 再エンコード。試験画像が高エントロピーなので、実際の写真やスクリーンショットではさらに小さい) |
|
|
288
|
+
| 静止時の 1 フレームあたり追加出力 | 0 バイト(変化が無ければ APC を出さない) |
|
|
289
|
+
| j/k で画像を連続で移動 | デバウンス 80 ms。移動中は削除のみ出し、止まってから 1 枚送る |
|
|
290
|
+
| キャッシュ | パス + mtime + 目標ピクセルで直近 4 枚、合計 8 MB まで(Base64 済みを保持) |
|
|
291
|
+
|
|
292
|
+
計測は `bench.sh` に倣って `lib_zig/rufio_native/bench_image.sh`(デコード+縮小の単体)と、Ruby 側の「転送バイト数とフレーム数」を数えるベンチを置く。
|
|
293
|
+
|
|
294
|
+
## 11. テスト計画
|
|
295
|
+
|
|
296
|
+
| テスト | 内容 |
|
|
297
|
+
|---|---|
|
|
298
|
+
| `test/test_kitty_graphics.rb` | シーケンス組み立て: チャンク分割(4096 境界・最終チャンクの `m=0`)、`C=1`/`q=2` が必ず入る、削除、tmux パススルーの二重化 |
|
|
299
|
+
| `test/test_terminal_graphics.rb` | 擬似 IO に `\e_Gi=31;OK\e\\` を与えたら対応、`\e[?62;c` だけなら非対応、無応答はタイムアウトで非対応、`$TMUX` 時は既定で無効 |
|
|
300
|
+
| `test/test_graphics_layer.rb` | 変化が無ければ出力 0 バイト、矩形と交差する行が書き換えられたら再送、ファイル変更で削除+再送、`clear_all` |
|
|
301
|
+
| `test/test_image_source.rb` | シグネチャでの形式判定(拡張子が嘘でも正しい)、ヘッダからの寸法読み取り、壊れたファイルは nil |
|
|
302
|
+
| `test/test_image_preview.rb` | `PreviewView.build` が画像で `ImagePreviewView` を返す、ズーム、`UIRenderer` が矩形を空白で確保しメタ情報を出す、非対応端末ではテキストに落ちる |
|
|
303
|
+
| Zig `src/image_test.zig` | PNG/JPEG の寸法、縮小のアスペクト比と上限、`max_pixels` 超の拒否、壊れた入力で failed、`destroy` 後にリークしない |
|
|
304
|
+
| パリティ | 同じ PNG を「直送」と「再エンコード」で送ったとき、`c,r` と見た目の寸法が一致する |
|
|
305
|
+
| CI | Windows・Linux の CI は端末が非対応なので、対応判定が false になり既存テストが落ちないことを確認(画像テストはスキップ扱い) |
|
|
306
|
+
|
|
307
|
+
## 12. 実装フェーズ
|
|
308
|
+
|
|
309
|
+
| Phase | 内容 | 目安 |
|
|
310
|
+
|---|---|---|
|
|
311
|
+
| 1 | **実装済み**: `TerminalGraphics`(検出)、`KittyGraphics`(組み立て)、`ImageSource`、`ImagePreviewView`、`GraphicsLayer`(最小)、`UIRenderer` の矩形確保、`Screen#reserve`、`Renderer#render` の戻り値、**PNG 直送だけ**で表示(Zig なしで動く)。直送の上限は 8 MiB(縮小が入る Phase 3 で広げる)。オーバーレイ(ヘルプ・検索画面・コマンドモード)中は画像を消す | 中 |
|
|
312
|
+
| 2 | **実装済み**: `GraphicsLayer` の再送(`Renderer#render` が返す行と矩形の交差)・削除・デバウンス(別ファイルへ移ったら先に消して 80ms 待つ)・Base64 キャッシュ(4 枚 / 8 MB、LRU)、終了処理と `refresh_display` の後片付け、ズーム(`+` / `-` / `0` と拡大中の `hjkl`。元画像の切り出し `x,y,w,h` を使うのでデコード不要)。矩形だけ変わったときの `a=p` 再配置は、部分実装の端末で表示が消える恐れがあるため採らず、キャッシュで転送を避ける方針にした | 中 |
|
|
313
|
+
| 3 | **実装済み**: Zig の `image.zig` / `image_png.zig` / `image_jpeg.zig` / `image_bmp.zig` / `image_resize.zig`、`core_image_*` API、`NativeImage`、PNG / baseline JPEG / BMP の対応と縮小、8 プラットフォームのビルド更新。**stb は採らず自前実装にした**(§7.2) | 大 |
|
|
314
|
+
| 4 | 設定(`IMAGE_PREVIEW`)、`HealthChecker` の端末グラフィックス検出、ヘルプ・`info/`・ガイド・README、EXIF 回転 | 小〜中 |
|
|
315
|
+
| 5 | (将来)Sixel / iTerm2 プロトコル、WebP、検索画面のプレビューへの展開 | 中 |
|
|
316
|
+
|
|
317
|
+
Phase 1 だけでも「PNG が端末で見える」価値が出る。Phase 3 を飛ばしても壊れないよう、Phase 1 の時点でフォールバックを先に作る。
|
|
318
|
+
|
|
319
|
+
## 13. 既知の制約
|
|
320
|
+
|
|
321
|
+
- **tmux / screen**: 既定で無効。`allow-passthrough on` の tmux 3.3+ でのみ設定で有効化でき、ペイン切り替え時に画像が残る端末がある
|
|
322
|
+
- **SSH 越し**: 直送のみ(`t=f` は使えない)。縮小前提で転送量を抑える
|
|
323
|
+
- **Windows**: Windows Terminal は Kitty プロトコル非対応。検出で無効になるだけ
|
|
324
|
+
- **アニメーション**: GIF は未対応(LZW 未実装。テキスト表示に落ちる)
|
|
325
|
+
- **プログレッシブ JPEG / インターレース PNG**: 未対応(テキスト表示に落ちる)
|
|
326
|
+
- **SVG / PDF / HEIC / RAW**: 非対応(SVG はテキスト扱いのまま)
|
|
327
|
+
- **半透明**: アルファは端末の背景と合成されるため、見た目は端末依存
|
|
328
|
+
- **フォントの行間**: セル寸法が取れない端末では 8×16 と仮定するため、アスペクト比がわずかにずれる
|
|
329
|
+
|
|
330
|
+
## 14. 参考
|
|
331
|
+
|
|
332
|
+
- Kitty graphics protocol: <https://sw.kovidgoyal.net/kitty/graphics-protocol/>
|
|
333
|
+
- Ghostty のグラフィックス対応: <https://ghostty.org/docs/vt/apc/kitty-graphics>
|
|
334
|
+
- `stb_image` / `stb_image_resize2` / `stb_image_write`: <https://github.com/nothings/stb>
|
|
335
|
+
- 既存の設計メモ: `docs/native_fuzzy_search_design_ja.md`(Zig と Ruby の分担・ベンチの作り方)、`docs/csv_cell_preview_design_ja.md`(`PreviewView` / `PreviewRegistry` の拡張点)
|
|
@@ -354,7 +354,7 @@ macOS(Darwin 27.2)・arm64・同梱 ReleaseFast ライブラリ、`~/devs`
|
|
|
354
354
|
|
|
355
355
|
### G のファイル名検索
|
|
356
356
|
|
|
357
|
-
- `
|
|
357
|
+
- `SearchScreen::FileNameSource` が既存の走査(Zig の `scan_files_natively` / Ruby の `scan_roots`)のイベントを
|
|
358
358
|
候補バッチに変換し、`FuzzySearchSession`(上位 1,000 件)に流す。除外設定・ブックマーク名・skipped の数は従来どおり。
|
|
359
359
|
停止要求は次のイベントで走査を打ち切り、Zig 走査は `each_batch(cancelled:)` で待機中も止まる。
|
|
360
360
|
ファイル名検索では `Thread#kill` を使わない(本文検索の走査スレッドは従来どおり)。
|
|
@@ -507,7 +507,7 @@ Ruby 2.7 には Ractor がない。Fiddle の呼び出しは GVL を外すので
|
|
|
507
507
|
- `FuzzyCandidateCache`: 走査が出したブロックをそのまま保存し、再表示するセッションにも同じブロックを渡す。
|
|
508
508
|
展開もコピーもしない(従来は「表示名 NUL パス NUL」を保存用に詰め直し、再表示のたびに 256 件ずつ行へ展開していた)。
|
|
509
509
|
行の配列を出すソースは従来どおり text と path だけを 4,096 件ごとのブロックに詰める。
|
|
510
|
-
- G のファイル名検索(`
|
|
510
|
+
- G のファイル名検索(`SearchScreen::FileNameSource`): 同じブックマークが続く間は 1 つのブロックに詰め、
|
|
511
511
|
行(text・path・bookmark・relative_path)は結果に出すときに作る。追加順(= ID)は従来と同じ。
|
|
512
512
|
- 候補がまだ 1 件もない状態で照合した直後は、候補追加の集約(50ms)を始めない。開いた直後の空の検索が
|
|
513
513
|
集約の待ち時間を使い、最初の候補の表示が約 50ms 遅れていた。
|
data/examples/config.rb
CHANGED
|
@@ -74,3 +74,26 @@ COMMAND_HISTORY_SIZE = 1000
|
|
|
74
74
|
#
|
|
75
75
|
# These files are automatically loaded by rufio.
|
|
76
76
|
# You can edit them manually or manage via rufio's UI.
|
|
77
|
+
|
|
78
|
+
# ========================================
|
|
79
|
+
# Table Preview (.csv / .tsv / .tab)
|
|
80
|
+
# ========================================
|
|
81
|
+
# Limits and display settings for the grid preview.
|
|
82
|
+
# Omitted or out-of-range values fall back to the defaults shown here.
|
|
83
|
+
TABLE_PREVIEW = {
|
|
84
|
+
max_bytes: 512 * 1024, # Bytes read from a .csv / .tsv (up to 4 MiB)
|
|
85
|
+
max_rows: 1000, # Rows parsed
|
|
86
|
+
max_columns: 256, # Columns parsed
|
|
87
|
+
max_column_width: 32, # Display width of one column
|
|
88
|
+
header: true, # Treat the first row as the header
|
|
89
|
+
delimiter: 'auto', # 'auto' (extension, then ';' detection), ',', "\t", ';' ...
|
|
90
|
+
encoding: 'auto' # 'auto' (BOM / UTF-8 / CP932 / EUC-JP), 'UTF-8', 'CP932' ...
|
|
91
|
+
}.freeze
|
|
92
|
+
|
|
93
|
+
# ========================================
|
|
94
|
+
# Clipboard Command (y)
|
|
95
|
+
# ========================================
|
|
96
|
+
# Command that receives the copied text on stdin, as a string or an argv array.
|
|
97
|
+
# Leave it unset to use pbcopy / clip / wl-copy / xclip / xsel when available,
|
|
98
|
+
# and OSC 52 otherwise (works over SSH; in tmux also set -g set-clipboard on).
|
|
99
|
+
# CLIPBOARD_COMMAND = ['xclip', '-selection', 'clipboard'].freeze
|
data/info/help.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
- [Bookmarks & Navigation](#bookmarks--navigation)
|
|
12
12
|
- [Command Mode](#command-mode)
|
|
13
13
|
- [Tool Runtime](#tool-runtime)
|
|
14
|
-
- [
|
|
14
|
+
- [Search & Config Mode](#search--config-mode)
|
|
15
15
|
- [Modes & Help Menu](#modes--help-menu)
|
|
16
16
|
|
|
17
17
|
---
|
|
@@ -41,13 +41,26 @@
|
|
|
41
41
|
| `d` | Delete file or directory (with confirmation) |
|
|
42
42
|
| `a` | Create new file |
|
|
43
43
|
| `A` | Create new directory |
|
|
44
|
+
| `y` | Copy the current or selected paths to the clipboard |
|
|
44
45
|
|
|
45
|
-
In a preview, `j/k` scroll, `Ctrl+D/U` page down/up and `ESC` returns to the file list.
|
|
46
|
+
In a preview, `j/k` scroll, `Ctrl+D/U` page down/up and `ESC` returns to the file list. `/` searches inside the file: type to jump to the first match, `Enter` keeps it, `n` / `N` move between matches and `ESC` clears the search (another `ESC` leaves the preview). Matches are highlighted, the current one in a different colour.
|
|
47
|
+
|
|
48
|
+
In a table preview, `h/j/k/l` and the arrow keys move a cell cursor instead, `g/}` jump to the first and last row, `0/$` to the first and last column, `Space` selects the column under the cursor (its cells are marked like a selected file), `y` copies the cell under the cursor, or the cursor row's selected columns joined with commas when any column is selected, `Y` the whole row as a CSV line, `[`/`]` switch between a workbook's sheets or a database's tables, `t` opens the list of sheets or tables (`j`/`k` to move, `Enter` to open the selected one, `ESC` to close), `/` filters the rows (see below), and the line under the file name shows the cell address and column name (`R3C2 price`). The grid scrolls in both directions to keep the cursor visible.
|
|
49
|
+
|
|
50
|
+
Copying uses `pbcopy`, `clip`, `wl-copy`, `xclip` or `xsel` when available and OSC 52 otherwise; `CLIPBOARD_COMMAND` in `config.rb` overrides it and `rufio -c` shows which one is used.
|
|
46
51
|
|
|
47
52
|
Text previews read at most the first 64 KiB. PDF bodies are not previewed, keeping file navigation responsive.
|
|
48
53
|
|
|
54
|
+
Images (`.png`, `.jpg`, `.bmp`, recognised by the file's own signature) are shown in the preview pane on terminals that speak the Kitty graphics protocol (kitty, Ghostty, WezTerm, Konsole). The pane's cells are left blank and the picture is drawn by the terminal, so the file list stays readable. The bundled native library decodes the image and scales it down to the pane before sending, so a 12 MP photo travels as a few hundred KB; files up to 32 MiB are read. Without that library (or with `RUFIO_NATIVE_IMAGE=0`) PNG files up to 8 MiB are still sent as they are, since terminals decode PNG themselves. On other terminals, inside tmux, for `.gif`, for progressive JPEG or for an interlaced PNG, the format, size and pixel dimensions are shown as text instead. `RUFIO_IMAGE_PREVIEW=0` turns images off.
|
|
55
|
+
|
|
56
|
+
In preview mode (`P`) on an image, `+` and `-` zoom in 25% steps up to 4x, `0` fits the picture to the pane again, and `h/j/k/l` or the arrow keys move around while zoomed (the terminal is asked for a part of the picture, so no decoding is needed). Moving to another file removes the picture first and sends the new one a moment later, so holding `j` through a folder of images does not flood the terminal, and a picture that was painted over by a notification is put back.
|
|
57
|
+
|
|
49
58
|
`.zip` previews list the archive entries (size, method, modified time, name) without extracting them.
|
|
50
59
|
|
|
60
|
+
`/` in a table preview filters its rows. Write conditions separated by commas: `price > 100, name a%` keeps the rows where price is over 100 and the name starts with `a`. A term without a column (`apple`) is searched in every column, `=`, `!=`, `<>`, `>`, `>=`, `<` and `<=` compare (numerically when both sides are numbers), and anything else matches with `LIKE`: `a%` and `a_c` use the wildcards as written, a plain word matches anywhere in the column. Quote a value to keep its commas and spaces (`note "red, sweet"`). 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 it. For a SQLite table the filter runs as a read-only `SELECT ... WHERE` inside the database, so it finds rows past the preview's row limit; a spreadsheet or CSV is filtered over the rows that were read.
|
|
61
|
+
|
|
62
|
+
`.csv`, `.tsv`, `.tab`, `.xlsx`, `.xlsm` and `.ods` files, and SQLite databases when the `sqlite3` command is installed (recognised by the file's own signature, whatever its extension), are shown as a grid with column letters, the header row kept in place while you scroll, and a last line reporting the row and column counts, the detected character encoding and any truncation. UTF-8, UTF-16 (with BOM), CP932 and EUC-JP files are decoded automatically. A `.csv` or `.tsv` is read up to 512 KiB.
|
|
63
|
+
|
|
51
64
|
### File Selection & Bulk Operations
|
|
52
65
|
|
|
53
66
|
| Key | Action |
|
|
@@ -65,19 +78,14 @@ ZIP jobs show progress in Jobs mode (`J`). `x`: Cancel the selected job there; a
|
|
|
65
78
|
| Key | Action |
|
|
66
79
|
|-----|--------|
|
|
67
80
|
| `f` | Start filter mode |
|
|
68
|
-
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
- `
|
|
75
|
-
-
|
|
76
|
-
- `Up/Down` or `Ctrl+J/K or Ctrl+N/P`: Select | `Enter`: Open | `Ctrl+U`: Clear | `ESC`: Back
|
|
77
|
-
- `F` asks for text, runs rga in the background and shows its `file:line:text` results in the same screen. `Enter` opens the file at that line
|
|
78
|
-
- Screens at least 80 columns wide show a preview of the selected file on the right (`F` centers and highlights the matching line). Set `preview_enabled: false` in `UI_OPTIONS` to hide it
|
|
79
|
-
- Reopening `s` in the same directory within 5 minutes shows the cached list (`Cached ... ago` in the title). `Ctrl+R`: Rescan. A file deleted since then shows `File no longer exists`
|
|
80
|
-
- The cache keeps 4 directories, 200,000 files and 5 minutes by default. Change it with `FUZZY_SEARCH_CACHE = { max_entries: 500_000, max_roots: 8, ttl: 900 }` in `~/.config/rufio/config.rb` (up to 1,000,000 files, 16 directories and 86,400 seconds; `0` disables)
|
|
81
|
+
| `/` | Search, scoped to where you are |
|
|
82
|
+
|
|
83
|
+
**Search (`/`):**
|
|
84
|
+
- `/` is the only search key. What it searches depends on the mode: the file list searches the current directory tree, a preview searches inside the file, and a table preview filters its rows
|
|
85
|
+
- In the file list it opens the search screen over every file under the current directory (hidden files included); no external tools are needed. Bookmarks are not searched
|
|
86
|
+
- `Tab`: Switch between fuzzy (in-order, non-contiguous) file names and literal, case insensitive contents. Matched characters are highlighted
|
|
87
|
+
- `Up/Down` or `Ctrl+J/K or Ctrl+N/P`: Select | `Enter`: Go to the file in Files mode | `Ctrl+U`: Clear | `ESC`: Back
|
|
88
|
+
- Content results show the file, the line number and the matching text, and also read `.pdf` (page), `.xlsx` (sheet/cell) and `.pptx` (slide)
|
|
81
89
|
|
|
82
90
|
**Filter Mode:**
|
|
83
91
|
- Type characters to filter files in real-time
|
|
@@ -92,8 +100,6 @@ ZIP jobs show progress in Jobs mode (`J`). `x`: Cancel the selected job there; a
|
|
|
92
100
|
| `B` | Bookmark menu (view/add/remove/script paths) |
|
|
93
101
|
| `0` | Jump to startup directory |
|
|
94
102
|
| `1-9` | Jump to bookmark 1-9 |
|
|
95
|
-
| `Tab` | Cycle to next bookmark (Files mode) |
|
|
96
|
-
| `Shift+Tab` | Cycle to previous bookmark (Files mode) |
|
|
97
103
|
| `z` | Navigate using zoxide history (when nothing is selected) |
|
|
98
104
|
|
|
99
105
|
---
|
|
@@ -148,17 +154,17 @@ Press `B` then select script path management to:
|
|
|
148
154
|
|
|
149
155
|
---
|
|
150
156
|
|
|
151
|
-
##
|
|
157
|
+
## Search & Config Mode
|
|
152
158
|
|
|
153
|
-
###
|
|
159
|
+
### Search (`/`)
|
|
154
160
|
|
|
155
|
-
Search file names or text
|
|
161
|
+
Search file names or text under the current directory.
|
|
156
162
|
|
|
157
|
-
- `Tab`: Switch between fuzzy file names (
|
|
163
|
+
- `Tab`: Switch between fuzzy file names (best matches first) and literal content (case insensitive)
|
|
158
164
|
- Content search also reads `.pdf` (page), `.xlsx` (sheet/cell) and `.pptx` (slide)
|
|
159
165
|
- `Up/Down` or `Ctrl+J/K or Ctrl+N/P`: Select a result | `Enter`: Go to the file in Files mode
|
|
160
|
-
- `Ctrl+U`: Clear the query | `ESC`: Return to
|
|
161
|
-
- Exclude extensions (or `/name` directories and files) with `
|
|
166
|
+
- `Ctrl+U`: Clear the query | `ESC`: Return to Files mode
|
|
167
|
+
- Exclude extensions (or `/name` directories and files) with `SEARCH_EXCLUDED_EXTENSIONS` in `~/.config/rufio/config.rb` (the older `GLOBAL_SEARCH_EXCLUDED_EXTENSIONS` is still read)
|
|
162
168
|
|
|
163
169
|
### Config Mode (`C`)
|
|
164
170
|
|
|
@@ -171,7 +177,6 @@ and file operations as Files mode. Leaving the directory returns to Files mode.
|
|
|
171
177
|
|
|
172
178
|
| Key | Action |
|
|
173
179
|
|-----|--------|
|
|
174
|
-
| `G` | Global search mode |
|
|
175
180
|
| `C` | Config mode: open `~/.config/rufio/` |
|
|
176
181
|
| `J` | Job mode |
|
|
177
182
|
| `L` | Execution logs |
|
|
@@ -180,7 +185,7 @@ and file operations as Files mode. Leaving the directory returns to Files mode.
|
|
|
180
185
|
| `q` | Quit rufio (with confirmation) |
|
|
181
186
|
| `T` | Quit rufio and cd the shell to the current directory (requires `rufio --shell-init`) |
|
|
182
187
|
|
|
183
|
-
In
|
|
188
|
+
In modes other than Files and Config, `Shift+Tab` switches to the previous mode.
|
|
184
189
|
|
|
185
190
|
### Help Menu
|
|
186
191
|
|
|
@@ -196,11 +201,11 @@ In Files mode, `Tab` / `Shift+Tab` cycle bookmarks. In other modes, `Shift+Tab`
|
|
|
196
201
|
|
|
197
202
|
1. **Quick navigation**: Use `g` and `G` to jump to top/bottom
|
|
198
203
|
2. **Bulk operations**: Select multiple files with `Space`, then use `m/c/x`
|
|
199
|
-
3. **Filter + Search**: Use `f` for real-time filtering,
|
|
204
|
+
3. **Filter + Search**: Use `f` for real-time filtering, `/` to search the directory tree
|
|
200
205
|
4. **Bookmarks**: Save frequently used directories with `b`, access with `1-9`
|
|
201
206
|
5. **Rake tasks**: If your project has a Rakefile, use `:rake:` with Tab completion
|
|
202
207
|
6. **Background jobs**: Long-running commands and ZIP jobs execute in background, view with `J`
|
|
203
|
-
7. **
|
|
208
|
+
7. **Search**: Press `/` to search names or contents under the current directory
|
|
204
209
|
|
|
205
210
|
---
|
|
206
211
|
|