diff options
author | pocari <caffelattenonsugar@gmail.com> | 2022-06-27 22:28:34 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2022-06-27 22:28:49 +0900 |
commit | 8c6c3e30f3a86ba0b697a0d99efe8ff4585c4a42 (patch) | |
tree | 2073fde89b3c57858cb5909b2e036bebd18ca5ea /lib/reline.rb | |
parent | b6b9a6190def53aa53ac816a51034fa1c96ed70b (diff) | |
download | ruby-8c6c3e30f3a86ba0b697a0d99efe8ff4585c4a42.tar.gz |
[ruby/reline] Enable to change the background color of dialogs. (https://github.com/ruby/reline/pull/413)
https://github.com/ruby/reline/commit/bd49537964
Diffstat (limited to 'lib/reline.rb')
-rw-r--r-- | lib/reline.rb | 53 |
1 files changed, 43 insertions, 10 deletions
diff --git a/lib/reline.rb b/lib/reline.rb index a57b570544..21e2dbf095 100644 --- a/lib/reline.rb +++ b/lib/reline.rb @@ -33,7 +33,18 @@ module Reline alias_method :==, :match? end CursorPos = Struct.new(:x, :y) - DialogRenderInfo = Struct.new(:pos, :contents, :bg_color, :width, :height, :scrollbar, keyword_init: true) + DialogRenderInfo = Struct.new( + :pos, + :contents, + :bg_color, + :pointer_bg_color, + :fg_color, + :pointer_fg_color, + :width, + :height, + :scrollbar, + keyword_init: true + ) class Core ATTR_READER_NAMES = %i( @@ -58,6 +69,19 @@ module Reline attr_accessor :last_incremental_search attr_reader :output + extend Forwardable + def_delegators :config, + :autocompletion, + :autocompletion=, + :dialog_default_bg_color, + :dialog_default_bg_color=, + :dialog_default_fg_color, + :dialog_default_fg_color=, + :dialog_pointer_bg_color, + :dialog_pointer_bg_color=, + :dialog_pointer_fg_color, + :dialog_pointer_fg_color= + def initialize self.output = STDOUT @dialog_proc_list = {} @@ -123,14 +147,6 @@ module Reline @completion_proc = p end - def autocompletion - @config.autocompletion - end - - def autocompletion=(val) - @config.autocompletion = val - end - def output_modifier_proc=(p) raise ArgumentError unless p.respond_to?(:call) or p.nil? @output_modifier_proc = p @@ -243,7 +259,16 @@ module Reline context.push(cursor_pos_to_render, result, pointer, dialog) end dialog.pointer = pointer - DialogRenderInfo.new(pos: cursor_pos_to_render, contents: result, scrollbar: true, height: 15) + DialogRenderInfo.new( + pos: cursor_pos_to_render, + contents: result, + scrollbar: true, + height: 15, + bg_color: config.dialog_default_bg_color, + pointer_bg_color: config.dialog_pointer_bg_color, + fg_color: config.dialog_default_fg_color, + pointer_fg_color: config.dialog_pointer_fg_color + ) } Reline::DEFAULT_DIALOG_CONTEXT = Array.new @@ -528,6 +553,10 @@ module Reline def_single_delegators :core, :add_dialog_proc def_single_delegators :core, :dialog_proc def_single_delegators :core, :autocompletion, :autocompletion= + def_single_delegators :core, :dialog_default_bg_color, :dialog_default_bg_color= + def_single_delegators :core, :dialog_pointer_bg_color, :dialog_pointer_bg_color= + def_single_delegators :core, :dialog_default_fg_color, :dialog_default_fg_color= + def_single_delegators :core, :dialog_pointer_fg_color, :dialog_pointer_fg_color= def_single_delegators :core, :readmultiline def_instance_delegators self, :readmultiline @@ -550,6 +579,10 @@ module Reline core.filename_quote_characters = "" core.special_prefixes = "" core.add_dialog_proc(:autocomplete, Reline::DEFAULT_DIALOG_PROC_AUTOCOMPLETE, Reline::DEFAULT_DIALOG_CONTEXT) + core.dialog_default_bg_color = 46 # Cyan + core.dialog_default_fg_color = 37 # White + core.dialog_pointer_bg_color = 45 # Magenta + core.dialog_pointer_fg_color = 37 # White } end |