mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/irb] Specify whether to show the doc dialog on the left or right side by using variable names
a23a88b8c9
This commit is contained in:
parent
5c02df8296
commit
374efa8e30
1 changed files with 20 additions and 16 deletions
|
@ -367,27 +367,31 @@ module IRB
|
||||||
return nil if doc.nil?
|
return nil if doc.nil?
|
||||||
width = 40
|
width = 40
|
||||||
|
|
||||||
x = cursor_pos_to_render.x + autocomplete_dialog.width
|
right_x = cursor_pos_to_render.x + autocomplete_dialog.width
|
||||||
if x + width > screen_width
|
if right_x + width > screen_width
|
||||||
old_width = screen_width - (x + 0)
|
right_width = screen_width - (right_x + 0)
|
||||||
new_x = autocomplete_dialog.column - width
|
left_x = autocomplete_dialog.column - width
|
||||||
new_x = 0 if new_x < 0
|
left_x = 0 if left_x < 0
|
||||||
new_width = width > autocomplete_dialog.column ? autocomplete_dialog.column : width
|
left_width = width > autocomplete_dialog.column ? autocomplete_dialog.column : width
|
||||||
if old_width.positive? and new_width.positive?
|
if right_width.positive? and left_width.positive?
|
||||||
if old_width >= new_width
|
if right_width >= left_width
|
||||||
width = old_width
|
width = right_width
|
||||||
|
x = right_x
|
||||||
else
|
else
|
||||||
width = new_width
|
width = left_width
|
||||||
x = new_x
|
x = left_x
|
||||||
end
|
end
|
||||||
elsif old_width.positive? and new_width.negative?
|
elsif right_width.positive? and left_width.negative?
|
||||||
width = old_width
|
width = right_width
|
||||||
elsif old_width.negative? and new_width.positive?
|
x = right_x
|
||||||
width = new_width
|
elsif right_width.negative? and left_width.positive?
|
||||||
x = new_x
|
width = left_width
|
||||||
|
x = left_x
|
||||||
else # Both are negative width.
|
else # Both are negative width.
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
x = right_x
|
||||||
end
|
end
|
||||||
formatter = RDoc::Markup::ToAnsi.new
|
formatter = RDoc::Markup::ToAnsi.new
|
||||||
formatter.width = width
|
formatter.width = width
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue