зеркало из https://github.com/github/ruby.git
[ruby/reline] unleash real pasting speed
2700msec -> 410msec read 80 console inputs at once https://github.com/ruby/reline/commit/eb3ef7af98
This commit is contained in:
Родитель
74765a5a36
Коммит
3a2ae5bb19
|
@ -262,23 +262,27 @@ class Reline::Windows
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
next if @@GetNumberOfConsoleInputEvents.(@@hConsoleInputHandle, num_of_events) == 0 or num_of_events.unpack1('L') == 0
|
next if @@GetNumberOfConsoleInputEvents.(@@hConsoleInputHandle, num_of_events) == 0 or num_of_events.unpack1('L') == 0
|
||||||
input_record = 0.chr * 18
|
input_records = 0.chr * 20 * 80
|
||||||
read_event = 0.chr * 4
|
read_event = 0.chr * 4
|
||||||
if @@ReadConsoleInputW.(@@hConsoleInputHandle, input_record, 1, read_event) != 0
|
if @@ReadConsoleInputW.(@@hConsoleInputHandle, input_records, 80, read_event) != 0
|
||||||
event = input_record[0, 2].unpack1('s*')
|
read_events = read_event.unpack1('L')
|
||||||
case event
|
0.upto(read_events) do |idx|
|
||||||
when WINDOW_BUFFER_SIZE_EVENT
|
input_record = input_records[idx * 20, 20]
|
||||||
@@winch_handler.()
|
event = input_record[0, 2].unpack1('s*')
|
||||||
when KEY_EVENT
|
case event
|
||||||
key_down = input_record[4, 4].unpack1('l*')
|
when WINDOW_BUFFER_SIZE_EVENT
|
||||||
repeat_count = input_record[8, 2].unpack1('s*')
|
@@winch_handler.()
|
||||||
virtual_key_code = input_record[10, 2].unpack1('s*')
|
when KEY_EVENT
|
||||||
virtual_scan_code = input_record[12, 2].unpack1('s*')
|
key_down = input_record[4, 4].unpack1('l*')
|
||||||
char_code = input_record[14, 2].unpack1('S*')
|
repeat_count = input_record[8, 2].unpack1('s*')
|
||||||
control_key_state = input_record[16, 2].unpack1('S*')
|
virtual_key_code = input_record[10, 2].unpack1('s*')
|
||||||
is_key_down = key_down.zero? ? false : true
|
virtual_scan_code = input_record[12, 2].unpack1('s*')
|
||||||
if is_key_down
|
char_code = input_record[14, 2].unpack1('S*')
|
||||||
process_key_event(repeat_count, virtual_key_code, virtual_scan_code, char_code, control_key_state)
|
control_key_state = input_record[16, 2].unpack1('S*')
|
||||||
|
is_key_down = key_down.zero? ? false : true
|
||||||
|
if is_key_down
|
||||||
|
process_key_event(repeat_count, virtual_key_code, virtual_scan_code, char_code, control_key_state)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Загрузка…
Ссылка в новой задаче