Skip to content

Commit

Permalink
Rename dialog_pointer_* to dialog_highlight_*
Browse files Browse the repository at this point in the history
"Pointer" is not what we usually use to describe a selected item.

"Highlight" is a more common word for the scenario so we should use it instead.
  • Loading branch information
st0012 committed Jul 21, 2022
1 parent b6ffa17 commit b4279d1
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 39 deletions.
20 changes: 10 additions & 10 deletions lib/reline.rb
Expand Up @@ -53,12 +53,12 @@ def match?(other)
:dialog_default_fg_color,
:dialog_default_fg_color_sequence,
:dialog_default_fg_color=,
:dialog_pointer_bg_color,
:dialog_pointer_bg_color_sequence,
:dialog_pointer_bg_color=,
:dialog_pointer_fg_color,
:dialog_pointer_fg_color_sequence,
:dialog_pointer_fg_color=
:dialog_highlight_bg_color,
:dialog_highlight_bg_color_sequence,
:dialog_highlight_bg_color=,
:dialog_highlight_fg_color,
:dialog_highlight_fg_color_sequence,
:dialog_highlight_fg_color=
]

class Core
Expand Down Expand Up @@ -273,9 +273,9 @@ def get_screen_size
scrollbar: true,
height: 15,
bg_color: config.dialog_default_bg_color_sequence,
pointer_bg_color: config.dialog_pointer_bg_color_sequence,
pointer_bg_color: config.dialog_highlight_bg_color_sequence,
fg_color: config.dialog_default_fg_color_sequence,
pointer_fg_color: config.dialog_pointer_fg_color_sequence
pointer_fg_color: config.dialog_highlight_fg_color_sequence
)
}
Reline::DEFAULT_DIALOG_CONTEXT = Array.new
Expand Down Expand Up @@ -586,8 +586,8 @@ def self.core
core.add_dialog_proc(:autocomplete, Reline::DEFAULT_DIALOG_PROC_AUTOCOMPLETE, Reline::DEFAULT_DIALOG_CONTEXT)
core.dialog_default_bg_color = :cyan
core.dialog_default_fg_color = :white
core.dialog_pointer_bg_color = :magenta
core.dialog_pointer_fg_color = :white
core.dialog_highlight_bg_color = :magenta
core.dialog_highlight_fg_color = :white
}
end

Expand Down
32 changes: 16 additions & 16 deletions lib/reline/config.rb
Expand Up @@ -48,8 +48,8 @@ class InvalidInputrc < RuntimeError
attr_accessor :autocompletion
attr_reader :dialog_default_bg_color_sequence,
:dialog_default_fg_color_sequence,
:dialog_pointer_bg_color_sequence,
:dialog_pointer_fg_color_sequence
:dialog_highlight_bg_color_sequence,
:dialog_highlight_fg_color_sequence

def initialize
@additional_key_bindings = {} # from inputrc
Expand All @@ -76,9 +76,9 @@ def initialize
@autocompletion = false
@convert_meta = true if seven_bit_encoding?(Reline::IOGate.encoding)
@dialog_default_bg_color_sequence = nil
@dialog_pointer_bg_color_sequence = nil
@dialog_highlight_bg_color_sequence = nil
@dialog_default_fg_color_sequence = nil
@dialog_pointer_fg_color_sequence = nil
@dialog_highlight_fg_color_sequence = nil
end

def reset
Expand Down Expand Up @@ -112,12 +112,12 @@ def dialog_default_fg_color=(color)
@dialog_default_fg_color_sequence = dialog_color_to_code(:fg, color)
end

def dialog_pointer_bg_color=(color)
@dialog_pointer_bg_color_sequence = dialog_color_to_code(:bg, color)
def dialog_highlight_bg_color=(color)
@dialog_highlight_bg_color_sequence = dialog_color_to_code(:bg, color)
end

def dialog_pointer_fg_color=(color)
@dialog_pointer_fg_color_sequence = dialog_color_to_code(:fg, color)
def dialog_highlight_fg_color=(color)
@dialog_highlight_fg_color_sequence = dialog_color_to_code(:fg, color)
end

def dialog_default_bg_color
Expand All @@ -128,12 +128,12 @@ def dialog_default_fg_color
dialog_code_to_color(:fg, @dialog_default_fg_color_sequence)
end

def dialog_pointer_bg_color
dialog_code_to_color(:bg, @dialog_pointer_bg_color_sequence)
def dialog_highlight_bg_color
dialog_code_to_color(:bg, @dialog_highlight_bg_color_sequence)
end

def dialog_pointer_fg_color
dialog_code_to_color(:fg, @dialog_pointer_fg_color_sequence)
def dialog_highlight_fg_color
dialog_code_to_color(:fg, @dialog_highlight_fg_color_sequence)
end

COLORS = [
Expand Down Expand Up @@ -399,10 +399,10 @@ def bind_variable(name, value)
self.dialog_default_bg_color = value
when 'dialog-default-fg-color'
self.dialog_default_fg_color = value
when 'dialog-pointer-bg-color'
self.dialog_pointer_bg_color = value
when 'dialog-pointer-fg-color'
self.dialog_pointer_fg_color = value
when 'dialog-highlight-bg-color'
self.dialog_highlight_bg_color = value
when 'dialog-highlight-fg-color'
self.dialog_highlight_fg_color = value
when *VARIABLE_NAMES then
variable_name = :"@#{name.tr(?-, ?_)}"
instance_variable_set(variable_name, value.nil? || value == '1' || value == 'on')
Expand Down
8 changes: 4 additions & 4 deletions test/reline/test_config.rb
Expand Up @@ -412,15 +412,15 @@ def test_relative_xdg_config_home
def test_dialog_configurations
@config.read_lines(<<~LINES.lines)
set dialog-default-bg-color white
set dialog-pointer-bg-color black
set dialog-highlight-bg-color black
set dialog-default-fg-color cyan
set dialog-pointer-fg-color magenta
set dialog-highlight-fg-color magenta
LINES

assert_equal :white, @config.dialog_default_bg_color
assert_equal :black, @config.dialog_pointer_bg_color
assert_equal :black, @config.dialog_highlight_bg_color
assert_equal :cyan, @config.dialog_default_fg_color
assert_equal :magenta, @config.dialog_pointer_fg_color
assert_equal :magenta, @config.dialog_highlight_fg_color
end
end

18 changes: 9 additions & 9 deletions test/reline/test_reline.rb
Expand Up @@ -50,8 +50,8 @@ def test_dialog_color_configuration
# defaults
assert_equal(:cyan, Reline.dialog_default_bg_color)
assert_equal(:white, Reline.dialog_default_fg_color)
assert_equal(:magenta, Reline.dialog_pointer_bg_color)
assert_equal(:white, Reline.dialog_pointer_fg_color)
assert_equal(:magenta, Reline.dialog_highlight_bg_color)
assert_equal(:white, Reline.dialog_highlight_fg_color)

Reline.dialog_default_bg_color = :black
assert_equal(:black, Reline.dialog_default_bg_color)
Expand All @@ -61,17 +61,17 @@ def test_dialog_color_configuration
assert_equal(:white, Reline.dialog_default_fg_color)
assert_equal(37, Reline.dialog_default_fg_color_sequence)

Reline.dialog_pointer_bg_color = :white
assert_equal(:white, Reline.dialog_pointer_bg_color)
assert_equal(47, Reline.dialog_pointer_bg_color_sequence)
Reline.dialog_highlight_bg_color = :white
assert_equal(:white, Reline.dialog_highlight_bg_color)
assert_equal(47, Reline.dialog_highlight_bg_color_sequence)

Reline.dialog_pointer_fg_color = :black
assert_equal(:black, Reline.dialog_pointer_fg_color)
assert_equal(30, Reline.dialog_pointer_fg_color_sequence)
Reline.dialog_highlight_fg_color = :black
assert_equal(:black, Reline.dialog_highlight_fg_color)
assert_equal(30, Reline.dialog_highlight_fg_color_sequence)

# test value validation
assert_raise(ArgumentError) do
Reline.dialog_pointer_fg_color = :foo
Reline.dialog_highlight_fg_color = :foo
end
end

Expand Down

0 comments on commit b4279d1

Please sign in to comment.