diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/irb/cmd/info.rb | 1 | ||||
-rw-r--r-- | lib/irb/ext/loader.rb | 4 | ||||
-rw-r--r-- | lib/irb/version.rb | 4 | ||||
-rw-r--r-- | lib/irb/workspace.rb | 2 | ||||
-rw-r--r-- | lib/reline/line_editor.rb | 28 | ||||
-rw-r--r-- | lib/reline/unicode.rb | 1 | ||||
-rw-r--r-- | lib/reline/version.rb | 2 | ||||
-rw-r--r-- | lib/reline/windows.rb | 24 |
8 files changed, 51 insertions, 15 deletions
diff --git a/lib/irb/cmd/info.rb b/lib/irb/cmd/info.rb index 53ec71d754..d122c88b77 100644 --- a/lib/irb/cmd/info.rb +++ b/lib/irb/cmd/info.rb @@ -13,6 +13,7 @@ module IRB str += "IRB version: #{IRB.version}\n" str += "InputMethod: #{IRB.CurrentContext.io.inspect}\n" str += ".irbrc path: #{IRB.rc_file}\n" if File.exist?(IRB.rc_file) + str += "RUBY_PLATFORM: #{RUBY_PLATFORM}\n" str end alias_method :to_s, :inspect diff --git a/lib/irb/ext/loader.rb b/lib/irb/ext/loader.rb index 90dcd70bd0..af028996e7 100644 --- a/lib/irb/ext/loader.rb +++ b/lib/irb/ext/loader.rb @@ -38,9 +38,9 @@ module IRB # :nodoc: else separator = if File::ALT_SEPARATOR - File::SEPARATOR - else "[#{Regexp.quote(File::SEPARATOR + File::ALT_SEPARATOR)}]" + else + File::SEPARATOR end ABSOLUTE_PATH_PATTERN = # :nodoc: case Dir.pwd diff --git a/lib/irb/version.rb b/lib/irb/version.rb index a715293b34..0a4a1bb922 100644 --- a/lib/irb/version.rb +++ b/lib/irb/version.rb @@ -11,7 +11,7 @@ # module IRB # :nodoc: - VERSION = "1.3.3" + VERSION = "1.3.4" @RELEASE_VERSION = VERSION - @LAST_UPDATE_DATE = "2021-02-07" + @LAST_UPDATE_DATE = "2021-02-25" end diff --git a/lib/irb/workspace.rb b/lib/irb/workspace.rb index c6c328e7b5..78d434d106 100644 --- a/lib/irb/workspace.rb +++ b/lib/irb/workspace.rb @@ -175,7 +175,7 @@ EOF body = (start_pos..end_pos).map do |current_pos| sprintf(fmt, pos == current_pos ? '=>' : '', current_pos + 1, lines[current_pos]) end.join("") - "\nFrom: #{file} @ line #{pos + 1} :\n\n#{body}#{Color.clear}\n" + "\nFrom: #{file} @ line #{pos + 1} :\n\n#{body}#{Color.clear if use_colorize}\n" end def IRB.delete_caller diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 557b5aa737..12a2bde234 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -124,6 +124,7 @@ class Reline::LineEditor @prompt_cache_time = Time.now.to_f end prompt_list.map!{ prompt } if @vi_arg or @searching_prompt + prompt_list = [prompt] if prompt_list.empty? mode_string = check_mode_string prompt_list = prompt_list.map{ |pr| mode_string + pr } if mode_string prompt = prompt_list[@line_index] @@ -343,8 +344,9 @@ class Reline::LineEditor else end_of_line_cursor = new_cursor_max end - line_to_calc.encode(Encoding::UTF_8).grapheme_clusters.each do |gc| - mbchar_width = Reline::Unicode.get_mbchar_width(gc) + line_to_calc.grapheme_clusters.each do |gc| + mbchar = gc.encode(Encoding::UTF_8) + mbchar_width = Reline::Unicode.get_mbchar_width(mbchar) now = new_cursor + mbchar_width if now > end_of_line_cursor or now > cursor break @@ -724,13 +726,17 @@ class Reline::LineEditor Reline::IOGate.move_cursor_column(0) if line.nil? if calculate_width(visual_lines[index - 1], true) == Reline::IOGate.get_screen_size.last - # Reaches the end of line. - # - # When the cursor is at the end of the line and erases characters - # after the cursor, some terminals delete the character at the - # cursor position. - move_cursor_down(1) - Reline::IOGate.move_cursor_column(0) + # reaches the end of line + if Reline::IOGate.win? and Reline::IOGate.win_legacy_console? + # A newline is automatically inserted if a character is rendered at + # eol on command prompt. + else + # When the cursor is at the end of the line and erases characters + # after the cursor, some terminals delete the character at the + # cursor position. + move_cursor_down(1) + Reline::IOGate.move_cursor_column(0) + end else Reline::IOGate.erase_after_cursor move_cursor_down(1) @@ -739,6 +745,10 @@ class Reline::LineEditor next end @output.write line + if Reline::IOGate.win? and Reline::IOGate.win_legacy_console? and calculate_width(line, true) == Reline::IOGate.get_screen_size.last + # A newline is automatically inserted if a character is rendered at eol on command prompt. + @rest_height -= 1 if @rest_height > 0 + end @output.flush if @first_prompt @first_prompt = false diff --git a/lib/reline/unicode.rb b/lib/reline/unicode.rb index 9b5ddc4622..7dbe8a12a5 100644 --- a/lib/reline/unicode.rb +++ b/lib/reline/unicode.rb @@ -108,6 +108,7 @@ class Reline::Unicode end m = mbchar.encode(Encoding::UTF_8).match(MBCharWidthRE) case + when m.nil? then 1 # TODO should be U+FFFD � REPLACEMENT CHARACTER when m[:width_2_1], m[:width_2_2] then 2 when m[:width_3] then 3 when m[:width_0] then 0 diff --git a/lib/reline/version.rb b/lib/reline/version.rb index 5b20f6f3e7..11e8145c7f 100644 --- a/lib/reline/version.rb +++ b/lib/reline/version.rb @@ -1,3 +1,3 @@ module Reline - VERSION = '0.2.3' + VERSION = '0.2.4' end diff --git a/lib/reline/windows.rb b/lib/reline/windows.rb index 4f5fcb74bc..6edc68e780 100644 --- a/lib/reline/windows.rb +++ b/lib/reline/windows.rb @@ -9,6 +9,10 @@ class Reline::Windows true end + def self.win_legacy_console? + @@legacy_console + end + RAW_KEYSTROKE_CONFIG = { [224, 72] => :ed_prev_history, # ↑ [224, 80] => :ed_next_history, # ↓ @@ -94,6 +98,26 @@ class Reline::Windows @@GetFileInformationByHandleEx = Win32API.new('kernel32', 'GetFileInformationByHandleEx', ['L', 'I', 'P', 'L'], 'I') @@FillConsoleOutputAttribute = Win32API.new('kernel32', 'FillConsoleOutputAttribute', ['L', 'L', 'L', 'L', 'P'], 'L') + @@GetConsoleMode = Win32API.new('kernel32', 'GetConsoleMode', ['L', 'P'], 'L') + @@SetConsoleMode = Win32API.new('kernel32', 'SetConsoleMode', ['L', 'L'], 'L') + ENABLE_VIRTUAL_TERMINAL_PROCESSING = 4 + + private_class_method def self.getconsolemode + mode = "\000\000\000\000" + @@GetConsoleMode.call(@@hConsoleHandle, mode) + mode.unpack1('L') + end + + private_class_method def self.setconsolemode(mode) + @@SetConsoleMode.call(@@hConsoleHandle, mode) + end + + @@legacy_console = (getconsolemode() & ENABLE_VIRTUAL_TERMINAL_PROCESSING == 0) + #if @@legacy_console + # setconsolemode(getconsolemode() | ENABLE_VIRTUAL_TERMINAL_PROCESSING) + # @@legacy_console = (getconsolemode() & ENABLE_VIRTUAL_TERMINAL_PROCESSING == 0) + #end + @@input_buf = [] @@output_buf = [] |