betters3tui 0.2.6 → 0.2.8

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 (4) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/lib/betters3tui.rb +84 -11
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab931099fefd059f96432438693cbdcdeeb8f787ddf0b747b0803381f2633e46
4
- data.tar.gz: 50f83a05203e7f4fb2b1c70948c0c57be51263616b515b74baff606b89f92283
3
+ metadata.gz: f163b7db0b942399b20d4282c2f1f211a3f29b22d91c3e96d8cec144aa974725
4
+ data.tar.gz: 0d32d3a731580847b1a2cc36430c564876c90dc62f59957018f5c211ae965b9c
5
5
  SHA512:
6
- metadata.gz: a3ec6adc6791f0c8de899381721af78cbb6c42886345f25c0957cbde1fee4bf6bd8bbcc87caee4ccf5952ba006d61116bf3373a8c9fad9d1698b6d3bd6e4f2c2
7
- data.tar.gz: 9dafee1ec69e01d8bf5862a5291a85c50b1a2dff499477b7497949c5e96d58ba806375b852d4a2e7110065efa91cc53c8db49b395df067761ceb3114345e0403
6
+ metadata.gz: 2c1f146b0ac1cb24726186f5dc9627d1bbf473181bc786a4690b7a82e8ee670926eb91ac9bb2e813e0ac48c25ef360b2030574eb0549521d636f58950ccad7e5
7
+ data.tar.gz: 5de653abe8d434b5379320142c0b5c148b23ed470cd50ee6960edd911dde7a7d2d1a10bc3001d9b0b57354603a89219f1e056f419c21d610c0dac552cf2abf99
data/CHANGELOG.md CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.2.8] - 2026-02-28
6
+
7
+ ### Fixed
8
+ - **Windows navigation support** - Fixed keyboard navigation not working on Windows by implementing Windows Console API support
9
+ - Added cross-platform terminal setup/cleanup (`setup_terminal`/`cleanup_terminal`)
10
+ - Implemented Windows-specific `read_char` method for proper key input handling
11
+ - Console mode is now properly saved and restored on Windows platforms
12
+
13
+ ## [0.2.7] - 2026-02-28
14
+
15
+ ### Fixed
16
+ - **Auto-create profiles.json** - App now automatically creates the config directory and empty profiles.json file on first run instead of exiting with an error
17
+
5
18
  ## [0.2.6] - 2026-02-27
6
19
 
7
20
  ### Added
@@ -34,6 +47,8 @@ All notable changes to this project will be documented in this file.
34
47
  - File download capability
35
48
  - Interactive keyboard navigation
36
49
 
50
+ [0.2.8]: https://github.com/adiprnm/betters3tui/compare/v0.2.7...v0.2.8
51
+ [0.2.7]: https://github.com/adiprnm/betters3tui/compare/v0.2.6...v0.2.7
37
52
  [0.2.6]: https://github.com/adiprnm/betters3tui/compare/v0.2.5...v0.2.6
38
53
  [0.1.1]: https://github.com/adiprnm/betters3tui/compare/v0.1.0...v0.1.1
39
54
  [0.1.0]: https://github.com/adiprnm/betters3tui/releases/tag/v0.1.0
data/lib/betters3tui.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- VERSION = "0.2.6"
4
+ VERSION = "0.2.8"
5
5
 
6
6
  require "json"
7
7
  require "aws-sdk-s3"
@@ -69,12 +69,7 @@ class S3Browser
69
69
  end
70
70
 
71
71
  def run
72
- if @profiles.empty?
73
- puts "No profiles found at #{PROFILES_PATH}"
74
- puts "Please create a profiles.json file with your S3 credentials."
75
- exit 1
76
- end
77
-
72
+ ensure_profiles_file_exists
78
73
  setup_terminal
79
74
 
80
75
  loop do
@@ -97,9 +92,49 @@ class S3Browser
97
92
  []
98
93
  end
99
94
 
95
+ def ensure_profiles_file_exists
96
+ require 'fileutils'
97
+ config_dir = File.dirname(PROFILES_PATH)
98
+ FileUtils.mkdir_p(config_dir) unless File.exist?(config_dir)
99
+
100
+ unless File.exist?(PROFILES_PATH)
101
+ File.write(PROFILES_PATH, JSON.pretty_generate([]))
102
+ end
103
+ end
104
+
100
105
  def setup_terminal
101
- @original_stty = `stty -g 2>/dev/null`.chomp
102
- system("stty -echo -icanon raw 2>/dev/null")
106
+ if windows?
107
+ require 'io/console'
108
+ @console_mode = nil
109
+ begin
110
+ # Get the Windows console handle and save current mode
111
+ kernel32 = Win32API.new('kernel32', 'GetStdHandle', ['L'], 'L')
112
+ @stdout_handle = kernel32.call(-11) # STD_OUTPUT_HANDLE = -11
113
+ @stdin_handle = kernel32.call(-10) # STD_INPUT_HANDLE = -10
114
+
115
+ # Save and set console input mode
116
+ get_mode = Win32API.new('kernel32', 'GetConsoleMode', ['L', 'P'], 'I')
117
+ set_mode = Win32API.new('kernel32', 'SetConsoleMode', ['L', 'L'], 'I')
118
+
119
+ mode_buf = [0].pack('L')
120
+ get_mode.call(@stdin_handle, mode_buf)
121
+ @original_console_mode = mode_buf.unpack1('L')
122
+
123
+ # Enable window input, disable line input and echo
124
+ new_mode = 0x0080 | 0x0008 # ENABLE_WINDOW_INPUT | ENABLE_PROCESSED_INPUT
125
+ set_mode.call(@stdin_handle, new_mode)
126
+
127
+ # Set output mode for virtual terminal processing
128
+ get_mode.call(@stdout_handle, mode_buf)
129
+ @original_stdout_mode = mode_buf.unpack1('L')
130
+ set_mode.call(@stdout_handle, @original_stdout_mode | 0x0004) # ENABLE_VIRTUAL_TERMINAL_PROCESSING
131
+ rescue LoadError
132
+ # Fall back to basic mode
133
+ end
134
+ else
135
+ @original_stty = `stty -g 2>/dev/null`.chomp
136
+ system("stty -echo -icanon raw 2>/dev/null")
137
+ end
103
138
  print Tui::ANSI::ALT_SCREEN_ON
104
139
  print Tui::ANSI::HIDE
105
140
  $stdout.flush
@@ -109,10 +144,29 @@ class S3Browser
109
144
  print Tui::ANSI::ALT_SCREEN_OFF
110
145
  print Tui::ANSI::SHOW
111
146
  print Tui::ANSI::RESET
112
- system("stty #{@original_stty} 2>/dev/null") if @original_stty && !@original_stty.empty?
147
+ if windows?
148
+ begin
149
+ if @stdin_handle && @original_console_mode
150
+ set_mode = Win32API.new('kernel32', 'SetConsoleMode', ['L', 'L'], 'I')
151
+ set_mode.call(@stdin_handle, @original_console_mode)
152
+ end
153
+ if @stdout_handle && @original_stdout_mode
154
+ set_mode = Win32API.new('kernel32', 'SetConsoleMode', ['L', 'L'], 'I')
155
+ set_mode.call(@stdout_handle, @original_stdout_mode)
156
+ end
157
+ rescue
158
+ # Ignore errors during cleanup
159
+ end
160
+ else
161
+ system("stty #{@original_stty} 2>/dev/null") if @original_stty && !@original_stty.empty?
162
+ end
113
163
  $stdout.flush
114
164
  end
115
165
 
166
+ def windows?
167
+ RUBY_PLATFORM =~ /mswin|mingw|cygwin/
168
+ end
169
+
116
170
  def render
117
171
  screen = Tui::Screen.new
118
172
 
@@ -503,7 +557,7 @@ class S3Browser
503
557
  end
504
558
 
505
559
  def handle_input
506
- char = $stdin.getc
560
+ char = read_char
507
561
  return unless char
508
562
 
509
563
  if @delete_confirm_mode
@@ -518,6 +572,25 @@ class S3Browser
518
572
  end
519
573
  end
520
574
 
575
+ def read_char
576
+ if windows?
577
+ require 'io/console'
578
+ # On Windows, use console API for proper key reading
579
+ # Try to get a single character without echo
580
+ begin
581
+ # Use IO#raw if available (Ruby 2.4+)
582
+ $stdin.raw do
583
+ return $stdin.getch
584
+ end
585
+ rescue
586
+ # Fallback for older Ruby versions
587
+ return $stdin.getch
588
+ end
589
+ else
590
+ $stdin.getc
591
+ end
592
+ end
593
+
521
594
  def handle_search_input(char)
522
595
  case char
523
596
  when "\e"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: betters3tui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adi Purnama