rufio 0.83.1 → 0.90.1

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: c96ef480cab0968de6e595b56af26baeb59c0fd0542a85e2ccc0e4d1970bd696
4
- data.tar.gz: 50366b86a8ef40df39f00a58e7a4e4d86d8314c919855acd96cdc0a03f39a156
3
+ metadata.gz: bd49ffece8a5770afb544c9b8ab5af6a0eba85accad094f7c19c892ae56107fa
4
+ data.tar.gz: 0b40bdff2394bfc08902a488be62f141705625ed54304a1c90ae7dc32bcb35a5
5
5
  SHA512:
6
- metadata.gz: dd1d2a5f82340c12caf57184b90cf3ad0773ef905caf07214376eab6b41d2af5c99fec088bd6e4dc51c20b928c3640d62c8b1d3681d08724fdb32e719e4205cd
7
- data.tar.gz: d38b805a6592cae4b6cc1c8e08ea587c3f88ebdadd605561b1cef67a3700009f5d656df61548a2f755db659c89b995dfabdd38a29e14c8e728280d22f12fe337
6
+ metadata.gz: 3f1d67a559eb62f96ec5b6011ed546b6c7686a1e6299b937f9df31fc862ab3be35dc20c0e7c4b878c22c210578bcf2b82acf968757ac0b04c0a8873b89fcd427
7
+ data.tar.gz: cd96a42f6032304e441397b5f5ea1a304ef15656725f80f277c920c2b2ac43f530fea462abba5b7a9170609a969e052c1db4c8d84ae7747e68c5b49608b1ea2e
data/CHANGELOG.md CHANGED
@@ -5,6 +5,20 @@ All notable changes to rufio will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.90.1] - 2026-03-28
9
+
10
+ ### Fixed
11
+ - **Windows: `STD_INPUT_HANDLE` bignum error**: Passing `0xFFFFFFF6` (unsigned 32-bit) to `Fiddle::TYPE_INT` (signed 32-bit) raised `bignum too big to convert into 'long'`; changed to the equivalent signed value `-10`
12
+
13
+ ## [0.90.0] - 2026-03-22
14
+
15
+ ### Added
16
+ - **Multibyte character input support (Japanese and other languages)**: Command mode (`:`) and filter mode now accept multibyte characters such as Japanese
17
+ - `MultibyteInputReader` class introduced to read UTF-8 multibyte sequences as a single character, replacing the previous `read_nonblock(1)` single-byte approach that caused mojibake
18
+ - Supports 1–4 byte UTF-8 sequences: ASCII, 2-byte (Latin extensions), 3-byte (Hiragana, Katakana, Kanji, etc.), 4-byte (emoji, etc.)
19
+ - ESC key (`0x1B`) remains in the ASCII range and does not trigger extra byte reads, avoiding conflicts with ESC sequence handling
20
+ - Invalid or incomplete byte sequences are safely discarded (returns `nil`)
21
+
8
22
  ## [0.83.1] - 2026-03-20
9
23
 
10
24
  ### Changed
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rufio
4
+ # ターミナルからのマルチバイト入力(UTF-8)を読み込むクラス。
5
+ # read_nonblock(1) は1バイトずつしか読まないため、日本語などのマルチバイト文字が
6
+ # 複数のイベントに分割される問題を解決する。
7
+ class MultibyteInputReader
8
+ def initialize(io = STDIN)
9
+ @io = io
10
+ end
11
+
12
+ # 1文字(マルチバイト対応)を読み込む。
13
+ # 読み込めない場合は nil を返す。
14
+ def read_char
15
+ byte = @io.read_nonblock(1)
16
+ return nil if byte.nil?
17
+
18
+ remaining = utf8_remaining_bytes(byte.ord)
19
+ return byte.force_encoding(Encoding::UTF_8) if remaining == 0
20
+
21
+ buf = byte.b
22
+ remaining.times do
23
+ next_byte = @io.read_nonblock(1)
24
+ return nil if next_byte.nil?
25
+
26
+ buf << next_byte.b
27
+ end
28
+
29
+ result = buf.force_encoding(Encoding::UTF_8)
30
+ result.valid_encoding? ? result : nil
31
+ rescue IO::WaitReadable, IO::EAGAINWaitReadable, EOFError
32
+ nil
33
+ end
34
+
35
+ private
36
+
37
+ def utf8_remaining_bytes(byte_val)
38
+ case byte_val
39
+ when 0x00..0x7F then 0 # ASCII(ESC 0x1B を含む)
40
+ when 0xC0..0xDF then 1 # 2バイト文字
41
+ when 0xE0..0xEF then 2 # 3バイト文字(日本語など)
42
+ when 0xF0..0xF7 then 3 # 4バイト文字(絵文字など)
43
+ else 0
44
+ end
45
+ end
46
+ end
47
+ end
@@ -47,6 +47,7 @@ module Rufio
47
47
  end
48
48
  @running = false
49
49
  @test_mode = test_mode
50
+ @multibyte_reader = MultibyteInputReader.new(STDIN)
50
51
  @command_mode_active = false
51
52
  @command_input = ""
52
53
  @command_mode = CommandMode.new
@@ -219,7 +220,7 @@ module Rufio
219
220
  @win32_kernel32['GetNumberOfConsoleInputEvents'],
220
221
  [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP], Fiddle::TYPE_INT
221
222
  )
222
- handle = @win32_get_std_handle.call(0xFFFFFFF6) # STD_INPUT_HANDLE = (DWORD)(-10)
223
+ handle = @win32_get_std_handle.call(-10) # STD_INPUT_HANDLE = (DWORD)(-10)
223
224
  count_ptr = Fiddle::Pointer.malloc(4)
224
225
  @win32_get_num_events.call(handle, count_ptr)
225
226
  count_ptr[0, 4].unpack1('L') > 0
@@ -437,9 +438,8 @@ module Rufio
437
438
  end
438
439
 
439
440
  begin
440
- input = STDIN.read_nonblock(1)
441
- rescue IO::WaitReadable, IO::EAGAINWaitReadable
442
- return false
441
+ input = @multibyte_reader.read_char
442
+ return false if input.nil?
443
443
  rescue Errno::ENOTTY, Errno::ENODEV
444
444
  return false
445
445
  end
@@ -777,8 +777,8 @@ module Rufio
777
777
  # Backspace
778
778
  @command_input.chop! unless @command_input.empty?
779
779
  else
780
- # 通常の文字を追加
781
- @command_input += input if input.length == 1
780
+ # 通常の文字を追加(マルチバイト文字含む)
781
+ @command_input += input unless input.nil? || input.empty?
782
782
  end
783
783
  end
784
784
 
data/lib/rufio/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rufio
4
- VERSION = '0.83.1'
4
+ VERSION = '0.90.1'
5
5
  end
data/lib/rufio.rb CHANGED
@@ -47,6 +47,7 @@ require_relative 'rufio/native_scanner_zig'
47
47
  require_relative 'rufio/async_scanner_promise'
48
48
  require_relative 'rufio/async_scanner_fiber'
49
49
  require_relative 'rufio/parallel_scanner'
50
+ require_relative 'rufio/multibyte_input_reader'
50
51
  require_relative 'rufio/screen'
51
52
  require_relative 'rufio/renderer'
52
53
  require_relative 'rufio/tab_mode_manager'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rufio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.83.1
4
+ version: 0.90.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - masisz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-03-20 00:00:00.000000000 Z
11
+ date: 2026-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: io-console
@@ -182,6 +182,7 @@ files:
182
182
  - lib/rufio/keybind_handler.rb
183
183
  - lib/rufio/local_script_scanner.rb
184
184
  - lib/rufio/logger.rb
185
+ - lib/rufio/multibyte_input_reader.rb
185
186
  - lib/rufio/native/rufio_zig.bundle
186
187
  - lib/rufio/native_scanner.rb
187
188
  - lib/rufio/native_scanner_zig.rb