lib/cli/ui/frame.rb in cli-ui-2.2.3 vs lib/cli/ui/frame.rb in cli-ui-2.3.0
- old
+ new
@@ -1,8 +1,7 @@
-# coding: utf-8
-
# typed: true
+# frozen_string_literal: true
require 'cli/ui'
require 'cli/ui/frame/frame_stack'
require 'cli/ui/frame/frame_style'
@@ -248,22 +247,24 @@
#
# * +:color+ - The color of the prefix. Defaults to +Thread.current[:cliui_frame_color_override]+
#
sig { params(color: T.nilable(Colorable)).returns(String) }
def prefix(color: Thread.current[:cliui_frame_color_override])
- +''.tap do |output|
+ (+'').tap do |output|
items = FrameStack.items
items[0..-2].to_a.each do |item|
- output << item.color.code << item.frame_style.prefix
+ output << item.color.code if CLI::UI.enable_color?
+ output << item.frame_style.prefix
+ output << CLI::UI::Color::RESET.code if CLI::UI.enable_color?
end
if (item = items.last)
final_color = color || item.color
- output << CLI::UI.resolve_color(final_color).code \
- << item.frame_style.prefix \
- << ' ' \
- << CLI::UI::Color::RESET.code
+ output << CLI::UI.resolve_color(final_color).code if CLI::UI.enable_color?
+ output << item.frame_style.prefix
+ output << CLI::UI::Color::RESET.code if CLI::UI.enable_color?
+ output << ' '
end
end
end
# The width of a prefix given the number of Frames in the stack