beniya 0.2.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6ab1b0284a8b86ca20e3ba091dec0f285561c297418b922a436e66721a07e5b
4
- data.tar.gz: db0b99cb3adf8534dfa89d2110a02079bad81e04b77ef129884e0cd4aa242c5b
3
+ metadata.gz: 5467834753b4cd28f856d6f2bec367deeca3718af5ac8ee3f538e284552f31b9
4
+ data.tar.gz: 9615cf65617d91c6aa5e69d3768cebe89f9c8a7ec0053a4b2b99b56e04afebc1
5
5
  SHA512:
6
- metadata.gz: a508d6b782f008de95b1c1bc46f0ab1b3ff371c806d277f4bdb7a493134ea0be3ffd678d5a63ea9916afed0256e05f17e08e62178ee1d84b0636e81554bb3c56
7
- data.tar.gz: 4474966812a065d193946935e65392eaa18265be92a3d4935655079ce54dc83c07325aa85b05753da0c0d202479e9db62595048028f6e4e9de978aebcef981be
6
+ metadata.gz: faef534b972dcad18c504fa27baf110eaffb0762620bdb6d41372a546fc438752db973fe7d7703f3fa2e639fc598599afe0721ddf3ac175aff94d804210b1626
7
+ data.tar.gz: 3b351e8907db499aeb4fbabbacfd1ee7c7bdfd3cb716ac98afc80d351c8a12b6c4ce2217783e610157b989fbe59c0b5adaea7632b37d02a2b48c98f439337002
data/CHANGELOG.md ADDED
@@ -0,0 +1,99 @@
1
+ # Changelog
2
+
3
+ All notable changes to beniya will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.4.0] - 2025-01-13
11
+
12
+ ### Added
13
+ - **Floating Dialog System**: Modern floating confirmation dialogs for delete operations
14
+ - **Enhanced Delete Operations**: Comprehensive error handling with file system verification
15
+ - **English-Only Interface**: Complete localization to English, removing multi-language complexity
16
+ - **Character Width Calculation**: Proper Japanese character width handling for UI rendering
17
+ - **Debug Support**: `BENIYA_DEBUG=1` environment variable for detailed logging
18
+ - **Real-time Result Display**: Success/failure counts in floating dialogs
19
+ - **Post-deletion Verification**: File system checks to ensure actual deletion
20
+ - **HSL Color Model Support**: Intuitive color configuration with HSL values
21
+
22
+ ### Changed
23
+ - **All UI messages converted to English** from Japanese
24
+ - **Delete confirmation workflow** now uses floating dialogs instead of command-line prompts
25
+ - **Error messages standardized** to English across all components
26
+ - **Documentation updated** to reflect English-only interface
27
+ - **Code style unified** with single quotes throughout
28
+
29
+ ### Removed
30
+ - **Multi-language support** configuration and related code
31
+ - **Language setting environment variables** (`BENIYA_LANG`)
32
+ - **Language configuration files** support
33
+ - **Japanese UI messages** and localization infrastructure
34
+
35
+ ### Technical
36
+ - **+290 lines** of new functionality in core keybind handler
37
+ - **New test files** for floating dialog system and delete operations
38
+ - **Enhanced error handling** patterns throughout codebase
39
+ - **Improved file system safety** checks and validation
40
+
41
+ For detailed information, see [CHANGELOG_v0.4.0.md](./CHANGELOG_v0.4.0.md)
42
+
43
+ ## [0.3.0] - 2024-XX-XX
44
+
45
+ ### Added
46
+ - Enhanced file operations and management features
47
+ - Improved user interface and navigation
48
+ - Additional configuration options
49
+
50
+ ### Changed
51
+ - Performance improvements
52
+ - Bug fixes and stability enhancements
53
+
54
+ ## [0.2.0] - 2024-XX-XX
55
+
56
+ ### Added
57
+ - New features and functionality improvements
58
+ - Enhanced file management capabilities
59
+
60
+ ### Changed
61
+ - User interface improvements
62
+ - Performance optimizations
63
+
64
+ ## [0.1.0] - 2024-XX-XX
65
+
66
+ ### Added
67
+ - Initial release of beniya
68
+ - Basic file manager functionality
69
+ - Vim-like key bindings
70
+ - File preview capabilities
71
+ - Multi-platform support
72
+
73
+ ---
74
+
75
+ ## Release Links
76
+
77
+ - [v0.4.0 Detailed Release Notes](./CHANGELOG_v0.4.0.md) - Comprehensive changelog with technical details
78
+ - [GitHub Releases](https://github.com/masisz/beniya/releases) - Download releases and view release history
79
+ - [Installation Guide](./README.md#installation) - How to install beniya
80
+ - [Usage Documentation](./README.md#usage) - Complete usage guide
81
+
82
+ ## Version Numbering
83
+
84
+ beniya follows [Semantic Versioning](https://semver.org/):
85
+
86
+ - **MAJOR** version for incompatible API changes
87
+ - **MINOR** version for backwards-compatible functionality additions
88
+ - **PATCH** version for backwards-compatible bug fixes
89
+
90
+ ## Contributing
91
+
92
+ When contributing to beniya:
93
+
94
+ 1. Update the **[Unreleased]** section with your changes
95
+ 2. Follow the existing changelog format
96
+ 3. Link to detailed release notes for major versions
97
+ 4. Include migration notes for breaking changes
98
+
99
+ For more information, see [Contributing Guidelines](./README.md#contributing).
@@ -0,0 +1,146 @@
1
+ # beniya v0.4.0 Release Notes
2
+
3
+ ## 🎉 Major Features & Improvements
4
+
5
+ ### 🪟 Floating Dialog System
6
+ - **New floating confirmation dialogs** for delete operations
7
+ - **Visual feedback** with red borders and warning colors for dangerous operations
8
+ - **Intuitive keyboard controls**: Y/N confirmation, ESC to cancel
9
+ - **Auto-centering** and responsive dialog sizing
10
+ - **Modern UI experience** replacing command-line prompts
11
+
12
+ ### 🗑️ Enhanced Delete Operations
13
+ - **Comprehensive error handling** with detailed error messages
14
+ - **File system verification** to ensure actual deletion before reporting success
15
+ - **Real-time result display** showing success/failure counts in floating dialogs
16
+ - **Post-deletion verification** with 10ms filesystem sync delay
17
+ - **Debug support** with `BENIYA_DEBUG=1` environment variable
18
+ - **Atomic operations** with proper rollback on partial failures
19
+
20
+ ### 🌐 English-Only Interface
21
+ - **Complete localization cleanup** - removed multi-language support
22
+ - **All UI messages converted to English**:
23
+ - `削除確認` → `Delete Confirmation`
24
+ - `移動/コピー` → `Move/Copy`
25
+ - `ファイルが見つかりません` → `File not found`
26
+ - `削除に失敗しました` → `Deletion failed`
27
+ - **Cleaner codebase** without language configuration complexity
28
+ - **Consistent English terminology** throughout the application
29
+
30
+ ### 🎨 UI/UX Improvements
31
+ - **Japanese character width calculation** for proper text rendering
32
+ - **HSL color model support** for intuitive color configuration
33
+ - **Multi-byte character handling** improvements
34
+ - **Better visual hierarchy** with color-coded operation results
35
+ - **Screen-aware positioning** for floating dialogs
36
+
37
+ ## 🔧 Technical Improvements
38
+
39
+ ### Code Quality
40
+ - **Unified code style** with single quotes throughout
41
+ - **Enhanced error handling** patterns
42
+ - **Improved file system safety** checks
43
+ - **Better separation of concerns** between UI and business logic
44
+
45
+ ### Testing & Debugging
46
+ - **New test files**:
47
+ - `test/test_floating_dialog.rb` - Floating dialog system tests
48
+ - `test/debug_delete_timing.rb` - Delete operation timing and verification tests
49
+ - **Debug logging system** with detailed operation tracking
50
+ - **Environment-based debug controls**
51
+
52
+ ### Architecture
53
+ - **Modular floating window system** (`draw_floating_window`, `clear_floating_window_area`)
54
+ - **Character width calculation utilities** (`display_width`, `pad_string_to_width`)
55
+ - **Screen positioning utilities** (`get_screen_center`)
56
+ - **Enhanced deletion workflow** with proper state management
57
+
58
+ ## 📚 Documentation Updates
59
+
60
+ ### README Improvements
61
+ - **Removed multi-language configuration** sections
62
+ - **Added detailed delete operation documentation**:
63
+ - Floating dialog workflow
64
+ - Safety features
65
+ - Error handling
66
+ - Debug support
67
+ - **Updated feature descriptions** to reflect English-only interface
68
+ - **Enhanced safety features documentation**
69
+
70
+ ### Both English and Japanese READMEs Updated
71
+ - **Consistent documentation** across languages
72
+ - **New operation workflow** diagrams
73
+ - **Comprehensive feature descriptions**
74
+ - **Updated installation and usage instructions**
75
+
76
+ ## 🛠️ Breaking Changes
77
+
78
+ ### Removed Features
79
+ - ❌ **Multi-language support** configuration removed
80
+ - ❌ **Language setting environment variables** (`BENIYA_LANG`)
81
+ - ❌ **Language configuration files** support
82
+ - ❌ **Japanese UI messages** (now English-only)
83
+
84
+ ### Configuration Changes
85
+ - 🔄 **Simplified configuration** - no more language settings required
86
+ - 🔄 **Removed language priority system**
87
+ - 🔄 **Streamlined color configuration** (HSL support added)
88
+
89
+ ## 📊 Statistics
90
+
91
+ ### Code Changes
92
+ - **+290 lines** in `lib/beniya/keybind_handler.rb` (586 → 876 lines)
93
+ - **Multiple files updated** across the codebase
94
+ - **New test files** added for quality assurance
95
+ - **Documentation updates** in both languages
96
+
97
+ ### Files Modified
98
+ - `lib/beniya/keybind_handler.rb` - Core functionality expansion
99
+ - `lib/beniya/terminal_ui.rb` - UI message updates
100
+ - `lib/beniya/file_opener.rb` - Error message localization
101
+ - `README.md` & `README_EN.md` - Documentation updates
102
+ - `test/` - New test files added
103
+
104
+ ## 🚀 Migration Guide
105
+
106
+ ### For Users
107
+ 1. **No action required** - existing installations will work seamlessly
108
+ 2. **Language settings** in config files will be ignored (no errors)
109
+ 3. **Environment variables** like `BENIYA_LANG` will have no effect
110
+ 4. **All UI will be in English** regardless of system locale
111
+
112
+ ### For Developers
113
+ 1. **Remove language-related configuration** from your setup
114
+ 2. **Update any scripts** that relied on Japanese output parsing
115
+ 3. **Use new debug environment variable**: `BENIYA_DEBUG=1`
116
+ 4. **Test with new floating dialog system**
117
+
118
+ ## 🎯 What's Next
119
+
120
+ This release establishes beniya as a modern, English-focused file manager with:
121
+ - ✅ **Consistent user experience** across all environments
122
+ - ✅ **Modern UI patterns** with floating dialogs
123
+ - ✅ **Enhanced safety** for file operations
124
+ - ✅ **Better debugging capabilities**
125
+ - ✅ **Improved maintainability** without multi-language complexity
126
+
127
+ ---
128
+
129
+ **Release Date**: 2025-01-13
130
+ **Version**: 0.4.0
131
+ **Previous Version**: 0.3.0
132
+ **Compatibility**: Ruby 2.7.0+
133
+
134
+ ## 📥 Installation
135
+
136
+ ```bash
137
+ gem install beniya --version 0.4.0
138
+ ```
139
+
140
+ ## 🐛 Bug Reports
141
+
142
+ Please report issues at: https://github.com/masisz/beniya/issues
143
+
144
+ ---
145
+
146
+ *This release represents a significant step forward in beniya's evolution, focusing on modern UI patterns, safety, and maintainability while streamlining the user experience.*
data/README.md CHANGED
@@ -13,11 +13,12 @@ beniyaは、Yaziにインスパイアされたターミナル上で動作する
13
13
  - **軽量でシンプル**: Rubyで書かれた軽量なファイルマネージャー
14
14
  - **直感的な操作**: Vimライクなキーバインド
15
15
  - **ファイルプレビュー**: テキストファイルの内容をその場で確認
16
- - **リアルタイムフィルター**: Spaceキーでファイル名の絞り込み表示
16
+ - **ファイル選択・操作**: 複数ファイルの選択、移動、コピー、削除が可能
17
+ - **ベースディレクトリ操作**: 起動ディレクトリへの一括ファイル移動・コピー
18
+ - **リアルタイムフィルター**: sキーでファイル名の絞り込み表示
17
19
  - **高度な検索機能**: fzfとrgaを使った強力な検索
18
20
  - **マルチプラットフォーム**: macOS、Linux、Windowsで動作
19
21
  - **外部エディタ連携**: お気に入りのエディタでファイルを開く
20
- - **多言語対応**: 日本語・英語インターフェース
21
22
  - **ヘルスチェック**: システム依存関係の確認機能
22
23
 
23
24
  ## インストール
@@ -77,6 +78,15 @@ beniya --help # ヘルプメッセージを表示
77
78
  | `a` | 新しいファイルを作成 |
78
79
  | `A` | 新しいディレクトリを作成 |
79
80
 
81
+ #### ファイル選択・操作
82
+
83
+ | キー | 機能 |
84
+ | ------- | ---------------------------------------------------- |
85
+ | `Space` | ファイル・ディレクトリを選択・選択解除(複数選択可) |
86
+ | `m` | 選択したアイテムをベースディレクトリに移動 |
87
+ | `p` | 選択したアイテムをベースディレクトリにコピー |
88
+ | `x` | 選択したアイテムを削除 |
89
+
80
90
  #### リアルタイムフィルター機能
81
91
 
82
92
  | キー | 機能 |
@@ -100,6 +110,56 @@ beniya --help # ヘルプメッセージを表示
100
110
  | ---- | ------------ |
101
111
  | `q` | beniyaを終了 |
102
112
 
113
+ ### ファイル選択・操作機能の詳細
114
+
115
+ #### ファイル・ディレクトリ選択 (`Space`)
116
+
117
+ - **選択・選択解除**: `Space`キーでファイルやディレクトリを選択・選択解除
118
+ - **複数選択**: 複数のファイルやディレクトリを同時に選択可能
119
+ - **視覚的表示**: 選択されたアイテムは✓マークと緑色の背景で表示
120
+ - **選択状態の表示**: 画面上部2行目に選択中のアイテム数が表示
121
+
122
+ #### ベースディレクトリ操作
123
+
124
+ beniya起動時のディレクトリが**ベースディレクトリ**として設定され、選択したファイルの移動・コピー先となります。
125
+
126
+ | 操作 | キー | 機能 |
127
+ | -------- | ---- | ---------------------------------------- |
128
+ | **移動** | `m` | 選択したアイテムをベースディレクトリに移動 |
129
+ | **コピー** | `p` | 選択したアイテムをベースディレクトリにコピー |
130
+ | **削除** | `x` | 選択したアイテムを削除 |
131
+
132
+ #### 削除操作の詳細
133
+
134
+ - **フローティングダイアログ確認**: モダンなフローティングウィンドウで明確な選択肢を表示
135
+ - **視覚的フィードバック**: 赤い枠線と警告色で注意を引く
136
+ - **安全な操作**: 削除前のダブルチェック
137
+ - **包括的エラーハンドリング**: 削除失敗時の詳細なエラーメッセージ
138
+ - **リアルタイム結果表示**: フローティングダイアログで成功/失敗数を表示
139
+ - **ファイルシステム検証**: 成功報告前に実際の削除を確認
140
+ - **デバッグサポート**: BENIYA_DEBUG=1でオプションのデバッグログ出力
141
+
142
+ #### 操作の流れ
143
+
144
+ ```
145
+ 1. Space → ファイル・ディレクトリを選択(複数選択可)
146
+ 2. 操作キーを選択:
147
+ - m → ベースディレクトリに移動
148
+ - p → ベースディレクトリにコピー
149
+ - x → 削除
150
+ 3. フローティングダイアログ → Y/Nで確認、ESCでキャンセル
151
+ 4. 結果表示 → フローティングウィンドウで操作結果を確認
152
+ ```
153
+
154
+ #### 安全機能
155
+
156
+ - **フローティング確認ダイアログ**: 確認用のモダンなフローティングウィンドウインターフェース
157
+ - **視覚警告システム**: 危険な操作時の赤い枠線と警告色
158
+ - **重複チェック**: 同名ファイルがある場合は自動でスキップ
159
+ - **エラーハンドリング**: 権限不足などのエラーに適切に対応
160
+ - **操作ログ**: フローティングダイアログで処理結果を詳細表示
161
+ - **削除後検証**: ファイルシステムから実際に削除されたことを確認
162
+
103
163
  ### フィルター機能の詳細
104
164
 
105
165
  #### リアルタイムフィルター (`s`)
@@ -155,39 +215,6 @@ apt install fzf
155
215
 
156
216
  ## 設定
157
217
 
158
- ### 言語設定
159
-
160
- beniyaは多言語対応しています。言語は以下の方法で設定できます:
161
-
162
- #### 環境変数(推奨)
163
-
164
- ```bash
165
- # 日本語
166
- export BENIYA_LANG=ja
167
-
168
- # 英語(デフォルト)
169
- export BENIYA_LANG=en
170
- ```
171
-
172
- #### 設定ファイル
173
-
174
- ```bash
175
- # 設定ディレクトリを作成
176
- mkdir -p ~/.config/beniya
177
-
178
- # 設定例をコピー
179
- cp config_example.rb ~/.config/beniya/config.rb
180
-
181
- # 設定ファイルを編集
182
- # 日本語の場合は LANGUAGE = 'ja'、英語の場合は LANGUAGE = 'en' を設定
183
- ```
184
-
185
- ### 優先順位
186
-
187
- 1. 設定ファイル(`~/.config/beniya/config.rb`)
188
- 2. `BENIYA_LANG`環境変数
189
- 3. デフォルト(英語)
190
-
191
218
  ### 色設定(カスタマイズ)
192
219
 
193
220
  beniyaではファイルタイプや UI 要素の色をカスタマイズできます。HSLカラーモデルによる直感的な色指定をサポートしています。
data/README_EN.md CHANGED
@@ -13,11 +13,13 @@ beniya is a terminal-based file manager inspired by Yazi. It's implemented in Ru
13
13
  - **Lightweight & Simple**: A lightweight file manager written in Ruby
14
14
  - **Intuitive Operation**: Vim-like key bindings
15
15
  - **File Preview**: View text file contents on the fly
16
- - **Real-time Filter**: Filter files by name using Space key
16
+ - **File Selection & Operations**: Select multiple files, move, copy, and delete
17
+ - **Base Directory Operations**: Batch file operations to startup directory
18
+ - **Real-time Filter**: Filter files by name using s key
17
19
  - **Advanced Search**: Powerful search using fzf and rga
18
20
  - **Multi-platform**: Runs on macOS, Linux, and Windows
19
21
  - **External Editor Integration**: Open files with your favorite editor
20
- - **Multi-language Support**: English and Japanese interface
22
+ - **English Interface**: Clean English interface
21
23
  - **Health Check**: System dependency verification
22
24
 
23
25
  ## Installation
@@ -77,6 +79,15 @@ beniya --help # Show help message
77
79
  | `a` | Create new file |
78
80
  | `A` | Create new directory |
79
81
 
82
+ #### File Selection & Operations
83
+
84
+ | Key | Function |
85
+ | ------- | ------------------------------------------- |
86
+ | `Space` | Select/deselect files and directories |
87
+ | `m` | Move selected items to base directory |
88
+ | `p` | Copy selected items to base directory |
89
+ | `x` | Delete selected items |
90
+
80
91
  #### Real-time Filter
81
92
 
82
93
  | Key | Function |
@@ -100,6 +111,56 @@ beniya --help # Show help message
100
111
  | --- | ----------- |
101
112
  | `q` | Quit beniya |
102
113
 
114
+ ### File Selection & Operations
115
+
116
+ #### File and Directory Selection (`Space`)
117
+
118
+ - **Select/Deselect**: Use `Space` key to select or deselect files and directories
119
+ - **Multiple Selection**: Select multiple files and directories simultaneously
120
+ - **Visual Display**: Selected items are marked with ✓ and highlighted in green
121
+ - **Selection Counter**: The number of selected items is shown on the second line of the screen
122
+
123
+ #### Base Directory Operations
124
+
125
+ The directory where beniya starts becomes the **base directory**, which serves as the destination for move and copy operations.
126
+
127
+ | Operation | Key | Function |
128
+ | --------- | --- | --------------------------------------- |
129
+ | **Move** | `m` | Move selected items to base directory |
130
+ | **Copy** | `p` | Copy selected items to base directory |
131
+ | **Delete** | `x` | Delete selected items |
132
+
133
+ #### Delete Operation Details
134
+
135
+ - **Floating Dialog Confirmation**: Modern floating window with clear options
136
+ - **Visual Feedback**: Red border and warning colors for attention
137
+ - **Safe Operation**: Double confirmation before deletion
138
+ - **Comprehensive Error Handling**: Detailed error messages for failed deletions
139
+ - **Real-time Result Display**: Shows success/failure count in floating dialog
140
+ - **File System Verification**: Confirms actual deletion before reporting success
141
+ - **Debug Support**: Optional debug logging with BENIYA_DEBUG=1
142
+
143
+ #### Operation Workflow
144
+
145
+ ```
146
+ 1. Space → Select files/directories (multiple selection possible)
147
+ 2. Choose operation key:
148
+ - m → Move to base directory
149
+ - p → Copy to base directory
150
+ - x → Delete
151
+ 3. Floating Dialog → Confirm with Y/N, ESC to cancel
152
+ 4. Result Display → Review operation results in floating window
153
+ ```
154
+
155
+ #### Safety Features
156
+
157
+ - **Floating Confirmation Dialog**: Modern floating window interface for confirmations
158
+ - **Visual Warning System**: Red borders and colors for dangerous operations
159
+ - **Duplicate Check**: Automatically skip files with same names
160
+ - **Error Handling**: Proper handling of permission errors and other issues
161
+ - **Operation Log**: Detailed display of operation results in floating dialogs
162
+ - **Post-deletion Verification**: Confirms files are actually deleted from filesystem
163
+
103
164
  ### Filter Feature
104
165
 
105
166
  #### Real-time Filter (`s`)
@@ -155,39 +216,6 @@ apt install fzf
155
216
 
156
217
  ## Configuration
157
218
 
158
- ### Language Settings
159
-
160
- beniya supports multiple languages. You can configure the language in several ways:
161
-
162
- #### Environment Variable (Recommended)
163
-
164
- ```bash
165
- # Japanese
166
- export BENIYA_LANG=ja
167
-
168
- # English (default)
169
- export BENIYA_LANG=en
170
- ```
171
-
172
- #### Configuration File
173
-
174
- ```bash
175
- # Create config directory
176
- mkdir -p ~/.config/beniya
177
-
178
- # Copy example config
179
- cp config_example.rb ~/.config/beniya/config.rb
180
-
181
- # Edit the config file
182
- # Set LANGUAGE = 'ja' for Japanese or LANGUAGE = 'en' for English
183
- ```
184
-
185
- ### Priority Order
186
-
187
- 1. Configuration file (`~/.config/beniya/config.rb`)
188
- 2. `BENIYA_LANG` environment variable
189
- 3. Default (English)
190
-
191
219
  ### Color Configuration (Customization)
192
220
 
193
221
  beniya allows you to customize colors for file types and UI elements. It supports intuitive color specification using the HSL color model.
@@ -12,6 +12,7 @@ module Beniya
12
12
  # 各コンポーネントを初期化
13
13
  directory_listing = DirectoryListing.new(@start_directory)
14
14
  keybind_handler = KeybindHandler.new
15
+ keybind_handler.set_base_directory(@start_directory)
15
16
  file_preview = FilePreview.new
16
17
  terminal_ui = TerminalUI.new
17
18
 
@@ -66,7 +66,7 @@ module Beniya
66
66
  end
67
67
  end
68
68
  rescue StandardError => e
69
- warn "ファイルを開けませんでした: #{e.message}"
69
+ warn "Failed to open file: #{e.message}"
70
70
  false
71
71
  end
72
72
 
@@ -105,7 +105,7 @@ module Beniya
105
105
  end
106
106
  end
107
107
  rescue StandardError => e
108
- warn "ファイルを開けませんでした: #{e.message}"
108
+ warn "Failed to open file: #{e.message}"
109
109
  false
110
110
  end
111
111
 
@@ -132,7 +132,7 @@ module Beniya
132
132
  system("xdg-open #{quoted_path}")
133
133
  end
134
134
  rescue StandardError => e
135
- warn "ディレクトリを開けませんでした: #{e.message}"
135
+ warn "Failed to open directory: #{e.message}"
136
136
  false
137
137
  end
138
138
  end
@@ -19,8 +19,8 @@ module Beniya
19
19
 
20
20
  begin
21
21
  # binary file detection
22
- sample = File.read(file_path, [file_size, 512].min)
23
- return binary_response if binary_file?(sample)
22
+ sample = File.binread(file_path, [file_size, 512].min)
23
+ return binary_response(file_path) if binary_file?(sample)
24
24
 
25
25
  # process as text file
26
26
  lines = read_text_file(file_path, max_lines)
@@ -124,6 +124,14 @@ module Beniya
124
124
  { type: "code", language: "markdown" }
125
125
  when ".txt", ".log"
126
126
  { type: "text", language: nil }
127
+ when ".zip", ".tar", ".gz", ".bz2", ".xz", ".7z"
128
+ { type: "archive", language: nil }
129
+ when ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".svg"
130
+ { type: "image", language: nil }
131
+ when ".pdf"
132
+ { type: "document", language: nil }
133
+ when ".exe", ".dmg", ".deb", ".rpm"
134
+ { type: "executable", language: nil }
127
135
  else
128
136
  { type: "text", language: nil }
129
137
  end
@@ -147,7 +155,19 @@ module Beniya
147
155
  }
148
156
  end
149
157
 
150
- def binary_response
158
+ def binary_response(file_path = nil)
159
+ file_size = file_path ? File.size(file_path) : 0
160
+ modified_time = file_path ? File.mtime(file_path) : Time.now
161
+
162
+ {
163
+ type: "binary",
164
+ message: "#{ConfigLoader.message('file.binary_file')} - #{ConfigLoader.message('file.cannot_preview')}",
165
+ lines: ["(#{ConfigLoader.message('file.binary_file')})"],
166
+ size: file_size,
167
+ modified: modified_time,
168
+ encoding: "binary"
169
+ }
170
+ rescue => e
151
171
  {
152
172
  type: "binary",
153
173
  message: "#{ConfigLoader.message('file.binary_file')} - #{ConfigLoader.message('file.cannot_preview')}",