m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-17 15:53:39 -05:00

Different color for selection-marker

This commit is contained in:
Junegunn Choi
2013-11-16 16:23:59 +09:00
parent f0b2b98c5d
commit f0a5757244

52
fzf
View File

@@ -92,7 +92,7 @@ class FZF
@matches = AtomicVar.new([]) @matches = AtomicVar.new([])
@count = AtomicVar.new(0) @count = AtomicVar.new(0)
@vcursor = AtomicVar.new(0) @vcursor = AtomicVar.new(0)
@fan = AtomicVar.new('-\|/-\|/'.split(//)) @spinner = AtomicVar.new('-\|/-\|/'.split(//))
@selects = AtomicVar.new({}) # ordered >= 1.9 @selects = AtomicVar.new({}) # ordered >= 1.9
end end
@@ -246,7 +246,7 @@ class FZF
def print_input def print_input
C.setpos cursor_y, 0 C.setpos cursor_y, 0
C.clrtoeol C.clrtoeol
cprint '> ', color(:blue, true) cprint '> ', color(:prompt, true)
C.attron(C::A_BOLD) do C.attron(C::A_BOLD) do
C.addstr @query.get C.addstr @query.get
end end
@@ -256,9 +256,9 @@ class FZF
C.setpos cursor_y - 1, 0 C.setpos cursor_y - 1, 0
C.clrtoeol C.clrtoeol
prefix = prefix =
if fan = @fan.shift if spinner = @spinner.shift
@fan.push fan @spinner.push spinner
cprint fan, color(:fan, true) cprint spinner, color(:spinner, true)
' ' ' '
else else
' ' ' '
@@ -325,9 +325,9 @@ class FZF
# Cursor # Cursor
C.setpos row, 0 C.setpos row, 0
C.clrtoeol C.clrtoeol
cprint chosen ? '>' : ' ', color(:red, true) cprint chosen ? '>' : ' ', color(:cursor, true)
cprint selected ? '>' : ' ', cprint selected ? '>' : ' ',
chosen ? color(:chosen) : (selected ? color(:red, true) : 0) chosen ? color(:chosen) : (selected ? color(:selected, true) : 0)
# Highlighted item # Highlighted item
C.attron color(:chosen, true) if chosen C.attron color(:chosen, true) if chosen
@@ -417,28 +417,28 @@ class FZF
if @color if @color
if C.can_change_color? if C.can_change_color?
fg = ENV.fetch('FZF_FG', 252).to_i C.init_pair 1, 110, dbg
bg = ENV.fetch('FZF_BG', 236).to_i C.init_pair 2, 108, dbg
C.init_pair 1, 110, dbg C.init_pair 3, 254, 236
C.init_pair 2, 108, dbg C.init_pair 4, 151, 236
C.init_pair 3, fg + 2, bg C.init_pair 5, 148, dbg
C.init_pair 4, 151, bg C.init_pair 6, 144, dbg
C.init_pair 5, 148, dbg C.init_pair 7, 161, 236
C.init_pair 6, 144, dbg C.init_pair 8, 168, 236
C.init_pair 7, 161, bg
else else
C.init_pair 1, C::COLOR_BLUE, dbg C.init_pair 1, C::COLOR_BLUE, dbg
C.init_pair 2, C::COLOR_GREEN, dbg C.init_pair 2, C::COLOR_GREEN, dbg
C.init_pair 3, C::COLOR_YELLOW, C::COLOR_BLACK C.init_pair 3, C::COLOR_YELLOW, C::COLOR_BLACK
C.init_pair 4, C::COLOR_GREEN, C::COLOR_BLACK C.init_pair 4, C::COLOR_GREEN, C::COLOR_BLACK
C.init_pair 5, C::COLOR_GREEN, dbg C.init_pair 5, C::COLOR_GREEN, dbg
C.init_pair 6, C::COLOR_WHITE, dbg C.init_pair 6, C::COLOR_WHITE, dbg
C.init_pair 7, C::COLOR_RED, C::COLOR_BLACK C.init_pair 7, C::COLOR_RED, C::COLOR_BLACK
C.init_pair 8, C::COLOR_MAGENTA, C::COLOR_BLACK
end end
def self.color sym, bold = false def self.color sym, bold = false
C.color_pair([:blue, :match, :chosen, C.color_pair([:prompt, :match, :chosen, :match!,
:match!, :fan, :info, :red].index(sym) + 1) | :spinner, :info, :cursor, :selected].index(sym) + 1) |
(bold ? C::A_BOLD : 0) (bold ? C::A_BOLD : 0)
end end
else else
@@ -476,7 +476,7 @@ class FZF
emit(:new) { @new << line.chomp } emit(:new) { @new << line.chomp }
end end
emit(:loaded) { true } emit(:loaded) { true }
@fan.clear @spinner.clear
end end
end end