Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ExeBy/exe_root.../opt/alt/ruby32/share/ruby
File: reline.rb
require 'io/console'
[0] Fix | Delete
require 'timeout'
[1] Fix | Delete
require 'forwardable'
[2] Fix | Delete
require 'reline/version'
[3] Fix | Delete
require 'reline/config'
[4] Fix | Delete
require 'reline/key_actor'
[5] Fix | Delete
require 'reline/key_stroke'
[6] Fix | Delete
require 'reline/line_editor'
[7] Fix | Delete
require 'reline/history'
[8] Fix | Delete
require 'reline/terminfo'
[9] Fix | Delete
require 'rbconfig'
[10] Fix | Delete
[11] Fix | Delete
module Reline
[12] Fix | Delete
FILENAME_COMPLETION_PROC = nil
[13] Fix | Delete
USERNAME_COMPLETION_PROC = nil
[14] Fix | Delete
[15] Fix | Delete
class ConfigEncodingConversionError < StandardError; end
[16] Fix | Delete
[17] Fix | Delete
Key = Struct.new('Key', :char, :combined_char, :with_meta) do
[18] Fix | Delete
def match?(other)
[19] Fix | Delete
case other
[20] Fix | Delete
when Reline::Key
[21] Fix | Delete
(other.char.nil? or char.nil? or char == other.char) and
[22] Fix | Delete
(other.combined_char.nil? or combined_char.nil? or combined_char == other.combined_char) and
[23] Fix | Delete
(other.with_meta.nil? or with_meta.nil? or with_meta == other.with_meta)
[24] Fix | Delete
when Integer, Symbol
[25] Fix | Delete
(combined_char and combined_char == other) or
[26] Fix | Delete
(combined_char.nil? and char and char == other)
[27] Fix | Delete
else
[28] Fix | Delete
false
[29] Fix | Delete
end
[30] Fix | Delete
end
[31] Fix | Delete
alias_method :==, :match?
[32] Fix | Delete
end
[33] Fix | Delete
CursorPos = Struct.new(:x, :y)
[34] Fix | Delete
DialogRenderInfo = Struct.new(
[35] Fix | Delete
:pos,
[36] Fix | Delete
:contents,
[37] Fix | Delete
:bg_color,
[38] Fix | Delete
:pointer_bg_color,
[39] Fix | Delete
:fg_color,
[40] Fix | Delete
:pointer_fg_color,
[41] Fix | Delete
:width,
[42] Fix | Delete
:height,
[43] Fix | Delete
:scrollbar,
[44] Fix | Delete
keyword_init: true
[45] Fix | Delete
)
[46] Fix | Delete
[47] Fix | Delete
class Core
[48] Fix | Delete
ATTR_READER_NAMES = %i(
[49] Fix | Delete
completion_append_character
[50] Fix | Delete
basic_word_break_characters
[51] Fix | Delete
completer_word_break_characters
[52] Fix | Delete
basic_quote_characters
[53] Fix | Delete
completer_quote_characters
[54] Fix | Delete
filename_quote_characters
[55] Fix | Delete
special_prefixes
[56] Fix | Delete
completion_proc
[57] Fix | Delete
output_modifier_proc
[58] Fix | Delete
prompt_proc
[59] Fix | Delete
auto_indent_proc
[60] Fix | Delete
pre_input_hook
[61] Fix | Delete
dig_perfect_match_proc
[62] Fix | Delete
).each(&method(:attr_reader))
[63] Fix | Delete
[64] Fix | Delete
attr_accessor :config
[65] Fix | Delete
attr_accessor :key_stroke
[66] Fix | Delete
attr_accessor :line_editor
[67] Fix | Delete
attr_accessor :last_incremental_search
[68] Fix | Delete
attr_reader :output
[69] Fix | Delete
[70] Fix | Delete
extend Forwardable
[71] Fix | Delete
def_delegators :config,
[72] Fix | Delete
:autocompletion,
[73] Fix | Delete
:autocompletion=
[74] Fix | Delete
[75] Fix | Delete
def initialize
[76] Fix | Delete
self.output = STDOUT
[77] Fix | Delete
@dialog_proc_list = {}
[78] Fix | Delete
yield self
[79] Fix | Delete
@completion_quote_character = nil
[80] Fix | Delete
@bracketed_paste_finished = false
[81] Fix | Delete
end
[82] Fix | Delete
[83] Fix | Delete
def encoding
[84] Fix | Delete
Reline::IOGate.encoding
[85] Fix | Delete
end
[86] Fix | Delete
[87] Fix | Delete
def completion_append_character=(val)
[88] Fix | Delete
if val.nil?
[89] Fix | Delete
@completion_append_character = nil
[90] Fix | Delete
elsif val.size == 1
[91] Fix | Delete
@completion_append_character = val.encode(Reline::IOGate.encoding)
[92] Fix | Delete
elsif val.size > 1
[93] Fix | Delete
@completion_append_character = val[0].encode(Reline::IOGate.encoding)
[94] Fix | Delete
else
[95] Fix | Delete
@completion_append_character = nil
[96] Fix | Delete
end
[97] Fix | Delete
end
[98] Fix | Delete
[99] Fix | Delete
def basic_word_break_characters=(v)
[100] Fix | Delete
@basic_word_break_characters = v.encode(Reline::IOGate.encoding)
[101] Fix | Delete
end
[102] Fix | Delete
[103] Fix | Delete
def completer_word_break_characters=(v)
[104] Fix | Delete
@completer_word_break_characters = v.encode(Reline::IOGate.encoding)
[105] Fix | Delete
end
[106] Fix | Delete
[107] Fix | Delete
def basic_quote_characters=(v)
[108] Fix | Delete
@basic_quote_characters = v.encode(Reline::IOGate.encoding)
[109] Fix | Delete
end
[110] Fix | Delete
[111] Fix | Delete
def completer_quote_characters=(v)
[112] Fix | Delete
@completer_quote_characters = v.encode(Reline::IOGate.encoding)
[113] Fix | Delete
end
[114] Fix | Delete
[115] Fix | Delete
def filename_quote_characters=(v)
[116] Fix | Delete
@filename_quote_characters = v.encode(Reline::IOGate.encoding)
[117] Fix | Delete
end
[118] Fix | Delete
[119] Fix | Delete
def special_prefixes=(v)
[120] Fix | Delete
@special_prefixes = v.encode(Reline::IOGate.encoding)
[121] Fix | Delete
end
[122] Fix | Delete
[123] Fix | Delete
def completion_case_fold=(v)
[124] Fix | Delete
@config.completion_ignore_case = v
[125] Fix | Delete
end
[126] Fix | Delete
[127] Fix | Delete
def completion_case_fold
[128] Fix | Delete
@config.completion_ignore_case
[129] Fix | Delete
end
[130] Fix | Delete
[131] Fix | Delete
def completion_quote_character
[132] Fix | Delete
@completion_quote_character
[133] Fix | Delete
end
[134] Fix | Delete
[135] Fix | Delete
def completion_proc=(p)
[136] Fix | Delete
raise ArgumentError unless p.respond_to?(:call) or p.nil?
[137] Fix | Delete
@completion_proc = p
[138] Fix | Delete
end
[139] Fix | Delete
[140] Fix | Delete
def output_modifier_proc=(p)
[141] Fix | Delete
raise ArgumentError unless p.respond_to?(:call) or p.nil?
[142] Fix | Delete
@output_modifier_proc = p
[143] Fix | Delete
end
[144] Fix | Delete
[145] Fix | Delete
def prompt_proc=(p)
[146] Fix | Delete
raise ArgumentError unless p.respond_to?(:call) or p.nil?
[147] Fix | Delete
@prompt_proc = p
[148] Fix | Delete
end
[149] Fix | Delete
[150] Fix | Delete
def auto_indent_proc=(p)
[151] Fix | Delete
raise ArgumentError unless p.respond_to?(:call) or p.nil?
[152] Fix | Delete
@auto_indent_proc = p
[153] Fix | Delete
end
[154] Fix | Delete
[155] Fix | Delete
def pre_input_hook=(p)
[156] Fix | Delete
@pre_input_hook = p
[157] Fix | Delete
end
[158] Fix | Delete
[159] Fix | Delete
def dig_perfect_match_proc=(p)
[160] Fix | Delete
raise ArgumentError unless p.respond_to?(:call) or p.nil?
[161] Fix | Delete
@dig_perfect_match_proc = p
[162] Fix | Delete
end
[163] Fix | Delete
[164] Fix | Delete
DialogProc = Struct.new(:dialog_proc, :context)
[165] Fix | Delete
def add_dialog_proc(name_sym, p, context = nil)
[166] Fix | Delete
raise ArgumentError unless p.respond_to?(:call) or p.nil?
[167] Fix | Delete
raise ArgumentError unless name_sym.instance_of?(Symbol)
[168] Fix | Delete
@dialog_proc_list[name_sym] = DialogProc.new(p, context)
[169] Fix | Delete
end
[170] Fix | Delete
[171] Fix | Delete
def dialog_proc(name_sym)
[172] Fix | Delete
@dialog_proc_list[name_sym]
[173] Fix | Delete
end
[174] Fix | Delete
[175] Fix | Delete
def input=(val)
[176] Fix | Delete
raise TypeError unless val.respond_to?(:getc) or val.nil?
[177] Fix | Delete
if val.respond_to?(:getc)
[178] Fix | Delete
if defined?(Reline::ANSI) and Reline::IOGate == Reline::ANSI
[179] Fix | Delete
Reline::ANSI.input = val
[180] Fix | Delete
elsif Reline::IOGate == Reline::GeneralIO
[181] Fix | Delete
Reline::GeneralIO.input = val
[182] Fix | Delete
end
[183] Fix | Delete
end
[184] Fix | Delete
end
[185] Fix | Delete
[186] Fix | Delete
def output=(val)
[187] Fix | Delete
raise TypeError unless val.respond_to?(:write) or val.nil?
[188] Fix | Delete
@output = val
[189] Fix | Delete
if defined?(Reline::ANSI) and Reline::IOGate == Reline::ANSI
[190] Fix | Delete
Reline::ANSI.output = val
[191] Fix | Delete
end
[192] Fix | Delete
end
[193] Fix | Delete
[194] Fix | Delete
def vi_editing_mode
[195] Fix | Delete
config.editing_mode = :vi_insert
[196] Fix | Delete
nil
[197] Fix | Delete
end
[198] Fix | Delete
[199] Fix | Delete
def emacs_editing_mode
[200] Fix | Delete
config.editing_mode = :emacs
[201] Fix | Delete
nil
[202] Fix | Delete
end
[203] Fix | Delete
[204] Fix | Delete
def vi_editing_mode?
[205] Fix | Delete
config.editing_mode_is?(:vi_insert, :vi_command)
[206] Fix | Delete
end
[207] Fix | Delete
[208] Fix | Delete
def emacs_editing_mode?
[209] Fix | Delete
config.editing_mode_is?(:emacs)
[210] Fix | Delete
end
[211] Fix | Delete
[212] Fix | Delete
def get_screen_size
[213] Fix | Delete
Reline::IOGate.get_screen_size
[214] Fix | Delete
end
[215] Fix | Delete
[216] Fix | Delete
Reline::DEFAULT_DIALOG_PROC_AUTOCOMPLETE = ->() {
[217] Fix | Delete
# autocomplete
[218] Fix | Delete
return nil unless config.autocompletion
[219] Fix | Delete
if just_cursor_moving and completion_journey_data.nil?
[220] Fix | Delete
# Auto complete starts only when edited
[221] Fix | Delete
return nil
[222] Fix | Delete
end
[223] Fix | Delete
pre, target, post = retrieve_completion_block(true)
[224] Fix | Delete
if target.nil? or target.empty? or (completion_journey_data&.pointer == -1 and target.size <= 3)
[225] Fix | Delete
return nil
[226] Fix | Delete
end
[227] Fix | Delete
if completion_journey_data and completion_journey_data.list
[228] Fix | Delete
result = completion_journey_data.list.dup
[229] Fix | Delete
result.shift
[230] Fix | Delete
pointer = completion_journey_data.pointer - 1
[231] Fix | Delete
else
[232] Fix | Delete
result = call_completion_proc_with_checking_args(pre, target, post)
[233] Fix | Delete
pointer = nil
[234] Fix | Delete
end
[235] Fix | Delete
if result and result.size == 1 and result[0] == target and pointer != 0
[236] Fix | Delete
result = nil
[237] Fix | Delete
end
[238] Fix | Delete
target_width = Reline::Unicode.calculate_width(target)
[239] Fix | Delete
x = cursor_pos.x - target_width
[240] Fix | Delete
if x < 0
[241] Fix | Delete
x = screen_width + x
[242] Fix | Delete
y = -1
[243] Fix | Delete
else
[244] Fix | Delete
y = 0
[245] Fix | Delete
end
[246] Fix | Delete
cursor_pos_to_render = Reline::CursorPos.new(x, y)
[247] Fix | Delete
if context and context.is_a?(Array)
[248] Fix | Delete
context.clear
[249] Fix | Delete
context.push(cursor_pos_to_render, result, pointer, dialog)
[250] Fix | Delete
end
[251] Fix | Delete
dialog.pointer = pointer
[252] Fix | Delete
DialogRenderInfo.new(
[253] Fix | Delete
pos: cursor_pos_to_render,
[254] Fix | Delete
contents: result,
[255] Fix | Delete
scrollbar: true,
[256] Fix | Delete
height: 15,
[257] Fix | Delete
bg_color: 46,
[258] Fix | Delete
pointer_bg_color: 45,
[259] Fix | Delete
fg_color: 37,
[260] Fix | Delete
pointer_fg_color: 37
[261] Fix | Delete
)
[262] Fix | Delete
}
[263] Fix | Delete
Reline::DEFAULT_DIALOG_CONTEXT = Array.new
[264] Fix | Delete
[265] Fix | Delete
def readmultiline(prompt = '', add_hist = false, &confirm_multiline_termination)
[266] Fix | Delete
unless confirm_multiline_termination
[267] Fix | Delete
raise ArgumentError.new('#readmultiline needs block to confirm multiline termination')
[268] Fix | Delete
end
[269] Fix | Delete
inner_readline(prompt, add_hist, true, &confirm_multiline_termination)
[270] Fix | Delete
[271] Fix | Delete
whole_buffer = line_editor.whole_buffer.dup
[272] Fix | Delete
whole_buffer.taint if RUBY_VERSION < '2.7'
[273] Fix | Delete
if add_hist and whole_buffer and whole_buffer.chomp("\n").size > 0
[274] Fix | Delete
Reline::HISTORY << whole_buffer
[275] Fix | Delete
end
[276] Fix | Delete
[277] Fix | Delete
line_editor.reset_line if line_editor.whole_buffer.nil?
[278] Fix | Delete
whole_buffer
[279] Fix | Delete
end
[280] Fix | Delete
[281] Fix | Delete
def readline(prompt = '', add_hist = false)
[282] Fix | Delete
inner_readline(prompt, add_hist, false)
[283] Fix | Delete
[284] Fix | Delete
line = line_editor.line.dup
[285] Fix | Delete
line.taint if RUBY_VERSION < '2.7'
[286] Fix | Delete
if add_hist and line and line.chomp("\n").size > 0
[287] Fix | Delete
Reline::HISTORY << line.chomp("\n")
[288] Fix | Delete
end
[289] Fix | Delete
[290] Fix | Delete
line_editor.reset_line if line_editor.line.nil?
[291] Fix | Delete
line
[292] Fix | Delete
end
[293] Fix | Delete
[294] Fix | Delete
private def inner_readline(prompt, add_hist, multiline, &confirm_multiline_termination)
[295] Fix | Delete
if ENV['RELINE_STDERR_TTY']
[296] Fix | Delete
if Reline::IOGate.win?
[297] Fix | Delete
$stderr = File.open(ENV['RELINE_STDERR_TTY'], 'a')
[298] Fix | Delete
else
[299] Fix | Delete
$stderr.reopen(ENV['RELINE_STDERR_TTY'], 'w')
[300] Fix | Delete
end
[301] Fix | Delete
$stderr.sync = true
[302] Fix | Delete
$stderr.puts "Reline is used by #{Process.pid}"
[303] Fix | Delete
end
[304] Fix | Delete
otio = Reline::IOGate.prep
[305] Fix | Delete
[306] Fix | Delete
may_req_ambiguous_char_width
[307] Fix | Delete
line_editor.reset(prompt, encoding: Reline::IOGate.encoding)
[308] Fix | Delete
if multiline
[309] Fix | Delete
line_editor.multiline_on
[310] Fix | Delete
if block_given?
[311] Fix | Delete
line_editor.confirm_multiline_termination_proc = confirm_multiline_termination
[312] Fix | Delete
end
[313] Fix | Delete
else
[314] Fix | Delete
line_editor.multiline_off
[315] Fix | Delete
end
[316] Fix | Delete
line_editor.output = output
[317] Fix | Delete
line_editor.completion_proc = completion_proc
[318] Fix | Delete
line_editor.completion_append_character = completion_append_character
[319] Fix | Delete
line_editor.output_modifier_proc = output_modifier_proc
[320] Fix | Delete
line_editor.prompt_proc = prompt_proc
[321] Fix | Delete
line_editor.auto_indent_proc = auto_indent_proc
[322] Fix | Delete
line_editor.dig_perfect_match_proc = dig_perfect_match_proc
[323] Fix | Delete
line_editor.pre_input_hook = pre_input_hook
[324] Fix | Delete
@dialog_proc_list.each_pair do |name_sym, d|
[325] Fix | Delete
line_editor.add_dialog_proc(name_sym, d.dialog_proc, d.context)
[326] Fix | Delete
end
[327] Fix | Delete
[328] Fix | Delete
unless config.test_mode
[329] Fix | Delete
config.read
[330] Fix | Delete
config.reset_default_key_bindings
[331] Fix | Delete
Reline::IOGate.set_default_key_bindings(config)
[332] Fix | Delete
end
[333] Fix | Delete
[334] Fix | Delete
line_editor.rerender
[335] Fix | Delete
[336] Fix | Delete
begin
[337] Fix | Delete
line_editor.set_signal_handlers
[338] Fix | Delete
prev_pasting_state = false
[339] Fix | Delete
loop do
[340] Fix | Delete
prev_pasting_state = Reline::IOGate.in_pasting?
[341] Fix | Delete
read_io(config.keyseq_timeout) { |inputs|
[342] Fix | Delete
line_editor.set_pasting_state(Reline::IOGate.in_pasting?)
[343] Fix | Delete
inputs.each { |c|
[344] Fix | Delete
line_editor.input_key(c)
[345] Fix | Delete
line_editor.rerender
[346] Fix | Delete
}
[347] Fix | Delete
if @bracketed_paste_finished
[348] Fix | Delete
line_editor.rerender_all
[349] Fix | Delete
@bracketed_paste_finished = false
[350] Fix | Delete
end
[351] Fix | Delete
}
[352] Fix | Delete
if prev_pasting_state == true and not Reline::IOGate.in_pasting? and not line_editor.finished?
[353] Fix | Delete
line_editor.set_pasting_state(false)
[354] Fix | Delete
prev_pasting_state = false
[355] Fix | Delete
line_editor.rerender_all
[356] Fix | Delete
end
[357] Fix | Delete
break if line_editor.finished?
[358] Fix | Delete
end
[359] Fix | Delete
Reline::IOGate.move_cursor_column(0)
[360] Fix | Delete
rescue Errno::EIO
[361] Fix | Delete
# Maybe the I/O has been closed.
[362] Fix | Delete
rescue StandardError => e
[363] Fix | Delete
line_editor.finalize
[364] Fix | Delete
Reline::IOGate.deprep(otio)
[365] Fix | Delete
raise e
[366] Fix | Delete
rescue Exception
[367] Fix | Delete
# Including Interrupt
[368] Fix | Delete
line_editor.finalize
[369] Fix | Delete
Reline::IOGate.deprep(otio)
[370] Fix | Delete
raise
[371] Fix | Delete
end
[372] Fix | Delete
[373] Fix | Delete
line_editor.finalize
[374] Fix | Delete
Reline::IOGate.deprep(otio)
[375] Fix | Delete
end
[376] Fix | Delete
[377] Fix | Delete
# GNU Readline waits for "keyseq-timeout" milliseconds to see if the ESC
[378] Fix | Delete
# is followed by a character, and times out and treats it as a standalone
[379] Fix | Delete
# ESC if the second character does not arrive. If the second character
[380] Fix | Delete
# comes before timed out, it is treated as a modifier key with the
[381] Fix | Delete
# meta-property of meta-key, so that it can be distinguished from
[382] Fix | Delete
# multibyte characters with the 8th bit turned on.
[383] Fix | Delete
#
[384] Fix | Delete
# GNU Readline will wait for the 2nd character with "keyseq-timeout"
[385] Fix | Delete
# milli-seconds but wait forever after 3rd characters.
[386] Fix | Delete
private def read_io(keyseq_timeout, &block)
[387] Fix | Delete
buffer = []
[388] Fix | Delete
loop do
[389] Fix | Delete
c = Reline::IOGate.getc
[390] Fix | Delete
if c == -1
[391] Fix | Delete
result = :unmatched
[392] Fix | Delete
@bracketed_paste_finished = true
[393] Fix | Delete
else
[394] Fix | Delete
buffer << c
[395] Fix | Delete
result = key_stroke.match_status(buffer)
[396] Fix | Delete
end
[397] Fix | Delete
case result
[398] Fix | Delete
when :matched
[399] Fix | Delete
expanded = key_stroke.expand(buffer).map{ |expanded_c|
[400] Fix | Delete
Reline::Key.new(expanded_c, expanded_c, false)
[401] Fix | Delete
}
[402] Fix | Delete
block.(expanded)
[403] Fix | Delete
break
[404] Fix | Delete
when :matching
[405] Fix | Delete
if buffer.size == 1
[406] Fix | Delete
case read_2nd_character_of_key_sequence(keyseq_timeout, buffer, c, block)
[407] Fix | Delete
when :break then break
[408] Fix | Delete
when :next then next
[409] Fix | Delete
end
[410] Fix | Delete
end
[411] Fix | Delete
when :unmatched
[412] Fix | Delete
if buffer.size == 1 and c == "\e".ord
[413] Fix | Delete
read_escaped_key(keyseq_timeout, c, block)
[414] Fix | Delete
else
[415] Fix | Delete
expanded = buffer.map{ |expanded_c|
[416] Fix | Delete
Reline::Key.new(expanded_c, expanded_c, false)
[417] Fix | Delete
}
[418] Fix | Delete
block.(expanded)
[419] Fix | Delete
end
[420] Fix | Delete
break
[421] Fix | Delete
end
[422] Fix | Delete
end
[423] Fix | Delete
end
[424] Fix | Delete
[425] Fix | Delete
private def read_2nd_character_of_key_sequence(keyseq_timeout, buffer, c, block)
[426] Fix | Delete
begin
[427] Fix | Delete
succ_c = nil
[428] Fix | Delete
Timeout.timeout(keyseq_timeout / 1000.0) {
[429] Fix | Delete
succ_c = Reline::IOGate.getc
[430] Fix | Delete
}
[431] Fix | Delete
rescue Timeout::Error # cancel matching only when first byte
[432] Fix | Delete
block.([Reline::Key.new(c, c, false)])
[433] Fix | Delete
return :break
[434] Fix | Delete
else
[435] Fix | Delete
case key_stroke.match_status(buffer.dup.push(succ_c))
[436] Fix | Delete
when :unmatched
[437] Fix | Delete
if c == "\e".ord
[438] Fix | Delete
block.([Reline::Key.new(succ_c, succ_c | 0b10000000, true)])
[439] Fix | Delete
else
[440] Fix | Delete
block.([Reline::Key.new(c, c, false), Reline::Key.new(succ_c, succ_c, false)])
[441] Fix | Delete
end
[442] Fix | Delete
return :break
[443] Fix | Delete
when :matching
[444] Fix | Delete
Reline::IOGate.ungetc(succ_c)
[445] Fix | Delete
return :next
[446] Fix | Delete
when :matched
[447] Fix | Delete
buffer << succ_c
[448] Fix | Delete
expanded = key_stroke.expand(buffer).map{ |expanded_c|
[449] Fix | Delete
Reline::Key.new(expanded_c, expanded_c, false)
[450] Fix | Delete
}
[451] Fix | Delete
block.(expanded)
[452] Fix | Delete
return :break
[453] Fix | Delete
end
[454] Fix | Delete
end
[455] Fix | Delete
end
[456] Fix | Delete
[457] Fix | Delete
private def read_escaped_key(keyseq_timeout, c, block)
[458] Fix | Delete
begin
[459] Fix | Delete
escaped_c = nil
[460] Fix | Delete
Timeout.timeout(keyseq_timeout / 1000.0) {
[461] Fix | Delete
escaped_c = Reline::IOGate.getc
[462] Fix | Delete
}
[463] Fix | Delete
rescue Timeout::Error # independent ESC
[464] Fix | Delete
block.([Reline::Key.new(c, c, false)])
[465] Fix | Delete
else
[466] Fix | Delete
if escaped_c.nil?
[467] Fix | Delete
block.([Reline::Key.new(c, c, false)])
[468] Fix | Delete
elsif escaped_c >= 128 # maybe, first byte of multi byte
[469] Fix | Delete
block.([Reline::Key.new(c, c, false), Reline::Key.new(escaped_c, escaped_c, false)])
[470] Fix | Delete
elsif escaped_c == "\e".ord # escape twice
[471] Fix | Delete
block.([Reline::Key.new(c, c, false), Reline::Key.new(c, c, false)])
[472] Fix | Delete
else
[473] Fix | Delete
block.([Reline::Key.new(escaped_c, escaped_c | 0b10000000, true)])
[474] Fix | Delete
end
[475] Fix | Delete
end
[476] Fix | Delete
end
[477] Fix | Delete
[478] Fix | Delete
def ambiguous_width
[479] Fix | Delete
may_req_ambiguous_char_width unless defined? @ambiguous_width
[480] Fix | Delete
@ambiguous_width
[481] Fix | Delete
end
[482] Fix | Delete
[483] Fix | Delete
private def may_req_ambiguous_char_width
[484] Fix | Delete
@ambiguous_width = 2 if Reline::IOGate == Reline::GeneralIO or !STDOUT.tty?
[485] Fix | Delete
return if defined? @ambiguous_width
[486] Fix | Delete
Reline::IOGate.move_cursor_column(0)
[487] Fix | Delete
begin
[488] Fix | Delete
output.write "\u{25bd}"
[489] Fix | Delete
rescue Encoding::UndefinedConversionError
[490] Fix | Delete
# LANG=C
[491] Fix | Delete
@ambiguous_width = 1
[492] Fix | Delete
else
[493] Fix | Delete
@ambiguous_width = Reline::IOGate.cursor_pos.x
[494] Fix | Delete
end
[495] Fix | Delete
Reline::IOGate.move_cursor_column(0)
[496] Fix | Delete
Reline::IOGate.erase_after_cursor
[497] Fix | Delete
end
[498] Fix | Delete
end
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function