lib/tty/prompt/slider.rb in tty-prompt-0.10.1 vs lib/tty/prompt/slider.rb in tty-prompt-0.11.0
- old
+ new
@@ -1,14 +1,18 @@
# encoding: utf-8
+require_relative 'symbols'
+
module TTY
# A class responsible for shell prompt interactions.
class Prompt
# A class responsible for gathering numeric input from range
#
# @api public
class Slider
+ include Symbols
+
HELP = '(Use arrow keys, press Enter to select)'.freeze
# Initailize a Slider
#
# @api public
@@ -86,11 +90,11 @@
@active -= 1 if @active > 0
end
alias_method :keydown, :keyleft
def keyright(*)
- @active += 1 if (@active + @step) <= range.size
+ @active += 1 if (@active + @step) < range.size
end
alias_method :keyup, :keyright
def keyreturn(*)
@done = true
@@ -157,14 +161,14 @@
# @return [String]
#
# @api private
def render_slider
output = ''
- output << Symbols::SLIDER_END
- output << '-' * @active
- output << @prompt.decorate(Symbols::SLIDER_HANDLE, @active_color)
- output << '-' * (range.size - @active - 1)
- output << Symbols::SLIDER_END
+ output << symbols[:pipe]
+ output << symbols[:line] * @active
+ output << @prompt.decorate(symbols[:handle], @active_color)
+ output << symbols[:line] * (range.size - @active - 1)
+ output << symbols[:pipe]
output << " #{range[@active]}"
output
end
end # Slider
end # Prompt