def rl_complete_internal(what_to_do)
rl_setstate(RL_STATE_COMPLETING)
set_completion_defaults(what_to_do)
saved_line_buffer = @rl_line_buffer ? @rl_line_buffer.delete(0.chr) : nil
our_func = @rl_completion_entry_function ?
@rl_completion_entry_function : :rl_filename_completion_function
_end = @rl_point
found_quote = false
delimiter = 0.chr
quote_char = 0.chr
if (@rl_point!=0)
quote_char,found_quote,delimiter = _rl_find_completion_word()
end
start = @rl_point
@rl_point = _end
text = rl_copy_text(start, _end)
matches = gen_completion_matches(text, start, _end, our_func, found_quote, quote_char)
nontrivial_lcd = !!(matches && text != matches[0])
text = nil
if matches.nil?
rl_ding()
saved_line_buffer = nil
@completion_changed_buffer = false
rl_unsetstate(RL_STATE_COMPLETING)
return 0
end
i = @rl_filename_completion_desired
if (postprocess_matches(matches, i) == 0)
rl_ding()
saved_line_buffer = nil
@completion_changed_buffer = false
rl_unsetstate(RL_STATE_COMPLETING)
return 0
end
case (what_to_do)
when TAB,'!','@'
if (matches[0])
insert_match(matches[0], start, matches[1] ? MULT_MATCH : SINGLE_MATCH, quote_char)
end
if (matches[1])
if (what_to_do == '!')
display_matches(matches)
elsif (what_to_do == '@')
if (!nontrivial_lcd)
display_matches(matches)
end
elsif (@rl_editing_mode != @vi_mode)
rl_ding()
end
else
append_to_match(matches[0], delimiter, quote_char, nontrivial_lcd)
end
when '*'
insert_all_matches(matches, start, quote_char)
when '?'
display_matches(matches)
else
$stderr.write("\r\nreadline: bad value #{what_to_do} for what_to_do in rl_complete\n")
rl_ding()
saved_line_buffer = nil
rl_unsetstate(RL_STATE_COMPLETING)
return 1
end
matches = nil
if (saved_line_buffer)
@completion_changed_buffer = @rl_line_buffer.delete(0.chr) != saved_line_buffer
saved_line_buffer = nil
end
rl_unsetstate(RL_STATE_COMPLETING)
0
end