beniya 0.6.2 → 0.6.3

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: c82332a61b93f69a73371f2f9d4aa4488d04fc45b12f5db958bd0597476a8550
4
- data.tar.gz: 5f689d6a5fb75451d3f8b75ff9f09343f342d80e451b19de39e0a024fdf688dc
3
+ metadata.gz: 53a6367a0ac0f6b8d8698938ad1ddf250ad87b43b2b5ede3f79887024e974ff2
4
+ data.tar.gz: 2f38ecaea5463be1d16711efb0604f883c610323d6751c9b0697292bf082de99
5
5
  SHA512:
6
- metadata.gz: f8e95d8c526f42619d798107a447b103a592005699a06392c61bf05919df0fe090c2066dc427aa6e047d35ec8d19285f11cd6696bf9ff4aa96d810b9bb465a82
7
- data.tar.gz: 6baebd7f5d4c288589d0f1a88b7ed871f0d344529787cc42356ed741c51ca47aa8758c7f25dd4dc9e31ac3804180ea1e23ae14e80642ffb7ee972e7622aed32e
6
+ metadata.gz: ca25187afbccdf0ea27e6ade0ab072977a998a17e79f34f7e512cf328c04345761c6b930beb3a0dbbbf1e9d272208b4fe64f1f7043af21a5c5475f5b2e4d8443
7
+ data.tar.gz: 356146b68b010e2b72c5359b0073332653f2ffb4d1344886881a2c81bd2d46a46218d47369be808320de0eb4cd49f93215a2148ddae6869348ba32a12d81cc24
data/CHANGELOG.md CHANGED
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Added
11
+ - **Escape key support for file/directory creation**: Press `Esc` to cancel file (`a`) or directory (`A`) creation prompts and return to the main view
12
+ - **Interactive input improvements**: Backspace support and better character handling for Japanese input
13
+
14
+ ### Fixed
15
+ - **Module loading order**: Fixed `LoadError` for filter_manager and related dependencies
16
+ - **Required dependencies**: Added proper require statements for all keybind_handler dependencies
17
+
18
+ ### Technical Details
19
+ - New `read_line_with_escape` method for cancelable input handling
20
+ - Comprehensive test suite for escape key functionality
21
+ - Support for multi-byte characters (Japanese, etc.) in filename/directory input
22
+
10
23
  ## [0.6.0] - 2025-01-XX
11
24
 
12
25
  ### Added
@@ -367,10 +367,13 @@ module Beniya
367
367
  def create_file
368
368
  current_path = @directory_listing&.current_path || Dir.pwd
369
369
 
370
- # ファイル名の入力を求める
370
+ # カーソルを画面下部に移動して入力プロンプトを表示
371
+ move_to_input_line
371
372
  print ConfigLoader.message('keybind.input_filename')
372
- filename = STDIN.gets.chomp
373
- return false if filename.empty?
373
+ STDOUT.flush
374
+
375
+ filename = read_line_with_escape
376
+ return false if filename.nil? || filename.empty?
374
377
 
375
378
  # FileOperationsを使用してファイルを作成
376
379
  result = @file_operations.create_file(current_path, filename)
@@ -395,10 +398,13 @@ module Beniya
395
398
  def create_directory
396
399
  current_path = @directory_listing&.current_path || Dir.pwd
397
400
 
398
- # ディレクトリ名の入力を求める
401
+ # カーソルを画面下部に移動して入力プロンプトを表示
402
+ move_to_input_line
399
403
  print ConfigLoader.message('keybind.input_dirname')
400
- dirname = STDIN.gets.chomp
401
- return false if dirname.empty?
404
+ STDOUT.flush
405
+
406
+ dirname = read_line_with_escape
407
+ return false if dirname.nil? || dirname.empty?
402
408
 
403
409
  # FileOperationsを使用してディレクトリを作成
404
410
  result = @file_operations.create_directory(current_path, dirname)
@@ -764,5 +770,51 @@ module Beniya
764
770
  end
765
771
 
766
772
  private
773
+
774
+ # カーソルを画面下部の入力行に移動
775
+ def move_to_input_line
776
+ # 画面の最終行にカーソルを移動
777
+ # terminal_uiから画面の高さを取得できない場合は、24行目(デフォルト)を使用
778
+ screen_height = @terminal_ui&.instance_variable_get(:@screen_height) || 24
779
+ print "\e[#{screen_height};1H" # 最終行の先頭にカーソル移動
780
+ print "\e[2K" # 行全体をクリア
781
+ end
782
+
783
+ # Escキーでキャンセル可能な入力処理
784
+ # 戻り値: 入力された文字列 (Escでキャンセルした場合はnil)
785
+ def read_line_with_escape
786
+ require 'io/console'
787
+ input = []
788
+
789
+ loop do
790
+ char = STDIN.getch
791
+
792
+ case char
793
+ when "\e" # Escape
794
+ # 入力をクリア
795
+ print "\r" + ' ' * (input.length + 50) + "\r"
796
+ return nil
797
+ when "\r", "\n" # Enter
798
+ puts
799
+ return input.join
800
+ when "\u007F", "\b" # Backspace/Delete
801
+ unless input.empty?
802
+ input.pop
803
+ # カーソルを1つ戻して文字を消去
804
+ print "\b \b"
805
+ end
806
+ when "\u0003" # Ctrl+C
807
+ puts
808
+ raise Interrupt
809
+ else
810
+ # 印字可能文字のみ受け付ける
811
+ if char.ord >= ASCII_PRINTABLE_START && char.ord < ASCII_PRINTABLE_END ||
812
+ char.bytesize > MULTIBYTE_THRESHOLD # マルチバイト文字(日本語など)
813
+ input << char
814
+ print char
815
+ end
816
+ end
817
+ end
818
+ end
767
819
  end
768
820
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Beniya
4
- VERSION = '0.6.2'
4
+ VERSION = '0.6.3'
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beniya
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - masisz
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-10-27 00:00:00.000000000 Z
10
+ date: 2025-11-23 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: io-console