def correct_indentation(full_line, overhang=0)
if Readline.respond_to?(:get_screen_size)
_, cols = Readline.get_screen_size
lines = full_line.length / cols + 1
elsif ENV['COLUMNS'] && ENV['COLUMNS'] != ''
cols = ENV['COLUMNS'].to_i
lines = full_line.length / cols + 1
else
lines = 1
end
if defined?(Win32::Console)
move_up = "\e[#{lines}F"
move_down = "\e[#{lines}E"
else
move_up = "\e[#{lines}A\e[0G"
move_down = "\e[#{lines}B\e[0G"
end
whitespace = ' ' * overhang
"#{move_up}#{full_line}#{whitespace}#{move_down}"
end