mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/reline] Bypass cursor down when a char is rendered at eol on Windows
A newline is automatically inserted if a character is rendered at eol on Windows command prompt. https://github.com/ruby/reline/commit/4bfea07e4a
This commit is contained in:
parent
16d4774da1
commit
06c37fa5b4
4 changed files with 23 additions and 3 deletions
|
@ -5,6 +5,10 @@ class Reline::ANSI
|
|||
Encoding.default_external
|
||||
end
|
||||
|
||||
def self.win?
|
||||
false
|
||||
end
|
||||
|
||||
RAW_KEYSTROKE_CONFIG = {
|
||||
[27, 91, 65] => :ed_prev_history, # ↑
|
||||
[27, 91, 66] => :ed_next_history, # ↓
|
||||
|
|
|
@ -5,6 +5,10 @@ class Reline::GeneralIO
|
|||
RUBY_PLATFORM =~ /mswin|mingw/ ? Encoding::UTF_8 : Encoding::default_external
|
||||
end
|
||||
|
||||
def self.win?
|
||||
false
|
||||
end
|
||||
|
||||
RAW_KEYSTROKE_CONFIG = {}
|
||||
|
||||
@@buf = []
|
||||
|
|
|
@ -507,12 +507,20 @@ class Reline::LineEditor
|
|||
Reline::IOGate.move_cursor_column(0)
|
||||
visual_lines.each_with_index do |line, index|
|
||||
if line.nil?
|
||||
Reline::IOGate.erase_after_cursor
|
||||
move_cursor_down(1)
|
||||
Reline::IOGate.move_cursor_column(0)
|
||||
if Reline::IOGate.win? and calculate_width(visual_lines[index - 1], true) == Reline::IOGate.get_screen_size.last
|
||||
# A newline is automatically inserted if a character is rendered at eol on command prompt.
|
||||
else
|
||||
Reline::IOGate.erase_after_cursor
|
||||
move_cursor_down(1)
|
||||
Reline::IOGate.move_cursor_column(0)
|
||||
end
|
||||
next
|
||||
end
|
||||
@output.print line
|
||||
if Reline::IOGate.win? 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
|
||||
|
|
|
@ -5,6 +5,10 @@ class Reline::Windows
|
|||
Encoding::UTF_8
|
||||
end
|
||||
|
||||
def self.win?
|
||||
true
|
||||
end
|
||||
|
||||
RAW_KEYSTROKE_CONFIG = {
|
||||
[224, 72] => :ed_prev_history, # ↑
|
||||
[224, 80] => :ed_next_history, # ↓
|
||||
|
|
Loading…
Add table
Reference in a new issue