[前][次][番号順一覧][スレッド一覧]

ruby-changes:68305

From: aycabta <ko1@a...>
Date: Fri, 8 Oct 2021 10:33:54 +0900 (JST)
Subject: [ruby-changes:68305] 5c02df8296 (master): [ruby/irb] Display doc dialog in gaps on narrow screen

https://git.ruby-lang.org/ruby.git/commit/?id=5c02df8296

From 5c02df829665ea2063c674fba93d3025817718cf Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Fri, 8 Oct 2021 03:43:21 +0900
Subject: [ruby/irb] Display doc dialog in gaps on narrow screen

https://github.com/ruby/irb/commit/4d7cefcaa4
---
 lib/irb/input-method.rb | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb
index d65c0308c6..f005ed7474 100644
--- a/lib/irb/input-method.rb
+++ b/lib/irb/input-method.rb
@@ -366,14 +366,35 @@ module IRB https://github.com/ruby/ruby/blob/trunk/lib/irb/input-method.rb#L366
       end
       return nil if doc.nil?
       width = 40
+
+      x = cursor_pos_to_render.x + autocomplete_dialog.width
+      if x + width > screen_width
+        old_width = screen_width - (x + 0)
+        new_x = autocomplete_dialog.column - width
+        new_x = 0 if new_x < 0
+        new_width = width > autocomplete_dialog.column ? autocomplete_dialog.column : width
+        if old_width.positive? and new_width.positive?
+          if old_width >= new_width
+            width = old_width
+          else
+            width = new_width
+            x = new_x
+          end
+        elsif old_width.positive? and new_width.negative?
+          width = old_width
+        elsif old_width.negative? and new_width.positive?
+          width = new_width
+          x = new_x
+        else # Both are negative width.
+          return nil
+        end
+      end
       formatter = RDoc::Markup::ToAnsi.new
       formatter.width = width
       dialog.trap_key = alt_d
       message = 'Press Alt+d to read the full document'
       contents = [message] + doc.accept(formatter).split("\n")
 
-      x = cursor_pos_to_render.x + autocomplete_dialog.width
-      x = autocomplete_dialog.column - width if x + width >= screen_width
       y = cursor_pos_to_render.y
       DialogRenderInfo.new(pos: Reline::CursorPos.new(x, y), contents: contents, width: width, bg_color: '49')
     }
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]