Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ group :development do
gem "rake"
gem "stackprof" if is_unix && !is_truffleruby
gem "test-unit"
gem "reline", github: "ruby/reline" if ENV["WITH_LATEST_RELINE"] == "true"
gem "reline", github: "ruby/reline"
end
46 changes: 46 additions & 0 deletions lib/irb/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,36 @@ def initialize(irb, workspace = nil, input_method = nil)
if @newline_before_multiline_output.nil?
@newline_before_multiline_output = true
end

if @io.is_a?(ReidlineInputMethod) && Reline.respond_to?(:dialog_default_bg_color)
configure_dialog_colors
end
end

def configure_dialog_colors
@use_bright_theme = IRB.conf[:USE_BRIGHT_THEME]

if @use_bright_theme
@dialog_default_bg_color = :white
@dialog_default_fg_color = :black
@dialog_highlight_bg_color = :black
@dialog_highlight_fg_color = :white
else
@dialog_default_bg_color = :black
@dialog_default_fg_color = :white
@dialog_highlight_bg_color = :white
@dialog_highlight_fg_color = :black
end

@dialog_default_bg_color = IRB.conf[:DIALOG_DEFAULT_BG_COLOR] if IRB.conf[:DIALOG_DEFAULT_BG_COLOR]
@dialog_default_fg_color = IRB.conf[:DIALOG_DEFAULT_FG_COLOR] if IRB.conf[:DIALOG_DEFAULT_FG_COLOR]
@dialog_highlight_bg_color = IRB.conf[:DIALOG_HIGHLIGHT_BG_COLOR] if IRB.conf[:DIALOG_HIGHLIGHT_BG_COLOR]
@dialog_highlight_bg_color = IRB.conf[:DIALOG_HIGHLIGHT_FG_COLOR] if IRB.conf[:DIALOG_HIGHLIGHT_FG_COLOR]

Reline.dialog_default_bg_color = @dialog_default_bg_color if @dialog_default_bg_color
Reline.dialog_default_fg_color = @dialog_default_fg_color if @dialog_default_fg_color
Reline.dialog_highlight_bg_color = @dialog_highlight_bg_color if @dialog_highlight_bg_color
Reline.dialog_highlight_fg_color = @dialog_highlight_fg_color if @dialog_highlight_fg_color
end

# The top-level workspace, see WorkSpace#main
Expand Down Expand Up @@ -179,6 +209,22 @@ def main
# +input_method+ passed to Context.new
attr_accessor :irb_path

# Use bright theme for autocompletion dialog. Default is `false`
attr_reader :use_bright_theme

# Colors for the autocompletion dialog. They will override the colors set by the theme
# Available colors (symbol) are:
# - :black
# - :red
# - :green
# - :yellow
# - :blue
# - :magenta
# - :cyan
# - :white
attr_reader :dialog_default_bg_color, :dialog_default_fg_color,
:dialog_highlight_bg_color, :dialog_highlight_fg_color

# Whether multiline editor mode is enabled or not.
#
# A copy of the default <code>IRB.conf[:USE_MULTILINE]</code>
Expand Down
1 change: 1 addition & 0 deletions lib/irb/init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def IRB.init_config(ap_path)
@CONF[:LC_MESSAGES] = Locale.new

@CONF[:AT_EXIT] = []
@CONF[:USE_BRIGHT_THEME] = false
end

def IRB.set_measure_callback(type = nil, arg = nil, &block)
Expand Down