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.
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
|
Encoding.default_external
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.win?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
RAW_KEYSTROKE_CONFIG = {
|
RAW_KEYSTROKE_CONFIG = {
|
||||||
[27, 91, 65] => :ed_prev_history, # ↑
|
[27, 91, 65] => :ed_prev_history, # ↑
|
||||||
[27, 91, 66] => :ed_next_history, # ↓
|
[27, 91, 66] => :ed_next_history, # ↓
|
||||||
|
|
|
@ -5,6 +5,10 @@ class Reline::GeneralIO
|
||||||
RUBY_PLATFORM =~ /mswin|mingw/ ? Encoding::UTF_8 : Encoding::default_external
|
RUBY_PLATFORM =~ /mswin|mingw/ ? Encoding::UTF_8 : Encoding::default_external
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.win?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
RAW_KEYSTROKE_CONFIG = {}
|
RAW_KEYSTROKE_CONFIG = {}
|
||||||
|
|
||||||
@@buf = []
|
@@buf = []
|
||||||
|
|
|
@ -507,12 +507,20 @@ class Reline::LineEditor
|
||||||
Reline::IOGate.move_cursor_column(0)
|
Reline::IOGate.move_cursor_column(0)
|
||||||
visual_lines.each_with_index do |line, index|
|
visual_lines.each_with_index do |line, index|
|
||||||
if line.nil?
|
if line.nil?
|
||||||
Reline::IOGate.erase_after_cursor
|
if Reline::IOGate.win? and calculate_width(visual_lines[index - 1], true) == Reline::IOGate.get_screen_size.last
|
||||||
move_cursor_down(1)
|
# A newline is automatically inserted if a character is rendered at eol on command prompt.
|
||||||
Reline::IOGate.move_cursor_column(0)
|
else
|
||||||
|
Reline::IOGate.erase_after_cursor
|
||||||
|
move_cursor_down(1)
|
||||||
|
Reline::IOGate.move_cursor_column(0)
|
||||||
|
end
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
@output.print line
|
@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
|
@output.flush
|
||||||
if @first_prompt
|
if @first_prompt
|
||||||
@first_prompt = false
|
@first_prompt = false
|
||||||
|
|
|
@ -5,6 +5,10 @@ class Reline::Windows
|
||||||
Encoding::UTF_8
|
Encoding::UTF_8
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.win?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
RAW_KEYSTROKE_CONFIG = {
|
RAW_KEYSTROKE_CONFIG = {
|
||||||
[224, 72] => :ed_prev_history, # ↑
|
[224, 72] => :ed_prev_history, # ↑
|
||||||
[224, 80] => :ed_next_history, # ↓
|
[224, 80] => :ed_next_history, # ↓
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue