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

ruby-changes:67324

From: aycabta <ko1@a...>
Date: Sun, 29 Aug 2021 20:31:12 +0900 (JST)
Subject: [ruby-changes:67324] acd15a39d2 (master): [ruby/reline] Support custom bg color

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

From acd15a39d23e59b7f6434de462010d137a442a36 Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Sat, 28 Aug 2021 02:10:51 +0900
Subject: [ruby/reline] Support custom bg color

https://github.com/ruby/reline/commit/cd0cbf53d5
---
 lib/reline.rb             | 4 ++--
 lib/reline/line_editor.rb | 8 ++++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/reline.rb b/lib/reline.rb
index fea0498..b32d07b 100644
--- a/lib/reline.rb
+++ b/lib/reline.rb
@@ -211,7 +211,7 @@ module Reline https://github.com/ruby/ruby/blob/trunk/lib/reline.rb#L211
       cursor_pos_to_render = Reline::CursorPos.new(x, y)
       context.clear
       context.push(cursor_pos_to_render, result, pointer)
-      [cursor_pos_to_render, result, pointer]
+      [cursor_pos_to_render, result, pointer, nil]
     }
 
     require 'rdoc'
@@ -247,7 +247,7 @@ module Reline https://github.com/ruby/ruby/blob/trunk/lib/reline.rb#L247
       formatter.width = 40
       str = doc.accept(formatter)
 
-      [Reline::CursorPos.new(cursor_pos_to_render.x + 40, cursor_pos_to_render.y + pointer), str.split("\n"), nil]
+      [Reline::CursorPos.new(cursor_pos_to_render.x + 40, cursor_pos_to_render.y + pointer), str.split("\n"), nil, '40']
     }
 
     def readmultiline(prompt = '', add_hist = false, &confirm_multiline_termination)
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index 6783ff9..3eb6133 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -560,7 +560,7 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L560
       return
     end
     dialog.set_cursor_pos(cursor_column, @first_line_started_from + @started_from)
-    pos, result, pointer = dialog.call
+    pos, result, pointer, bg = dialog.call
     old_dialog_contents = dialog.contents
     old_dialog_column = dialog.column
     old_dialog_vertical_offset = dialog.vertical_offset
@@ -605,7 +605,11 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L605
       if i == pointer
         bg_color = '45'
       else
-        bg_color = '46'
+        if bg
+          bg_color = bg
+        else
+          bg_color = '46'
+        end
       end
       @output.write "\e[#{bg_color}m%-#{DIALOG_WIDTH}s\e[49m" % item.slice(0, DIALOG_WIDTH)
       Reline::IOGate.move_cursor_column(dialog.column)
-- 
cgit v1.1


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

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