Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
os: [ubuntu-latest]
ruby-version:
- head
- '3.4'
- '3.3'
- '3.2'
- '3.1'
Expand All @@ -23,7 +24,7 @@ jobs:
- os: windows-latest
ruby-version: head
- os: windows-latest
ruby-version: '3.3'
ruby-version: '3.4'
- os: windows-latest
ruby-version: mingw
- os: windows-latest
Expand All @@ -33,7 +34,7 @@ jobs:
- os: macos-latest
ruby-version: 'head'
- os: macos-latest
ruby-version: '3.3'
ruby-version: '3.4'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# https://github.com/bbatsov/rubocop/tree/master/config

AllCops:
TargetRubyVersion: 3.3
TargetRubyVersion: 3.4
NewCops: enable

# General
Expand Down
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Below is a complete listing of changes for each revision of HighLine.

### 3.1.2 / 2025-01-05
* PR #279 - Upgrades and adjustments for Ruby 3.4 release (@abinoam)
* PR #278 - Prevent ArgumentError for #col_count_calculate when items exceed 80 chars (@davidjkling, @justintsteele)

### 3.1.1 / 2024-08-18
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ group :code_quality do
# gem "pronto-poper", require: false, platform: :ruby
gem "pronto-reek", require: false, platform: :ruby
gem "pronto-rubocop", require: false, platform: :ruby
gem "base64", require: false
end
29 changes: 17 additions & 12 deletions lib/highline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -555,21 +555,26 @@ def get_line_raw_no_echo_mode(question)
terminal.raw_no_echo_mode_exec do
loop do
character = terminal.get_character
raise Interrupt if character == "\u0003"
break unless character
break if ["\n", "\r"].include? character

# honor backspace and delete
if character == "\b" || character == "\u007F"
chopped = line.chop!
output_erase_char if chopped && question.echo
elsif character == "\cU"

case character
when "\u0003" # Ctrl+C (Interrupt)
raise Interrupt
when nil # No character received
break
when "\n", "\r" # Newline or carriage return
break
when "\b", "\u007F" # Backspace and delete
unless line.empty?
line = line.chop
output_erase_char if question.echo
end
when "\cU" # Clear line
line.size.times { output_erase_char } if question.echo
line = ""
elsif character == "\e"
when "\e" # Escape key
ignore_arrow_key
else
line << character
else # Any other character
line += character
say_last_char_or_echo_char(line, question)
end

Expand Down
12 changes: 7 additions & 5 deletions lib/highline/menu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,14 @@ def options
end

def map_items_by_index
if [:letter, :capital_letter].include?(@index)
# @ and ` are the previous ASCII characters to A and a respectively
prev_char = (@index == :capital_letter ? '@' : '`')
all_items.map { prev_char.succ!.dup }
size = all_items.size
case @index
when :letter
("a".."z").first(size)
when :capital_letter
("A".."Z").first(size)
else
(1..all_items.size).map(&:to_s)
(1..size).map(&:to_s)
end
end

Expand Down
10 changes: 6 additions & 4 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
require "highline/io_console_compatible"

require "highline"
debug_message = "Tests will be run under:\n"
debug_message << " - #{HighLine.new.terminal.class}\n"
debug_message << " - HighLine::VERSION #{HighLine::VERSION}\n"

debug_message << " - #{RUBY_DESCRIPTION}\n" if defined? RUBY_DESCRIPTION
debug_message = <<~DEBUG_MESSAGE
Tests will be run under:
- #{HighLine.new.terminal.class}
- HighLine::VERSION #{HighLine::VERSION}
DEBUG_MESSAGE

debug_message += " - #{RUBY_DESCRIPTION}\n" if defined? RUBY_DESCRIPTION
puts debug_message

require "minitest/autorun"
Loading