mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-18 08:13:40 -05:00
Add --black for terminals incapable of use_default_colors
See the discussion in #18. Use --black option to use black background regardless of the default background color of the terminal. Also, this option can be used to fix rendering issues on terminals that don't support use_default_colors (man 3 default_colors). Depending on the terminal, use_default_colors may or may not succeed, but the Ruby version of it always returns nil, it's currently not possible to automatically enable this option.
This commit is contained in:
@@ -59,6 +59,7 @@ usage: fzf [options]
|
|||||||
+i Case-sensitive match
|
+i Case-sensitive match
|
||||||
+c, --no-color Disable colors
|
+c, --no-color Disable colors
|
||||||
+2, --no-256 Disable 256-color
|
+2, --no-256 Disable 256-color
|
||||||
|
--black Use black background
|
||||||
--no-mouse Disable mouse
|
--no-mouse Disable mouse
|
||||||
|
|
||||||
Environment variables
|
Environment variables
|
||||||
|
|||||||
10
fzf
10
fzf
@@ -7,7 +7,7 @@
|
|||||||
# / __/ / /_/ __/
|
# / __/ / /_/ __/
|
||||||
# /_/ /___/_/ Fuzzy finder for your shell
|
# /_/ /___/_/ Fuzzy finder for your shell
|
||||||
#
|
#
|
||||||
# Version: 0.8.0 (March 8, 2014)
|
# Version: 0.8.1 (March 9, 2014)
|
||||||
#
|
#
|
||||||
# Author: Junegunn Choi
|
# Author: Junegunn Choi
|
||||||
# URL: https://github.com/junegunn/fzf
|
# URL: https://github.com/junegunn/fzf
|
||||||
@@ -50,7 +50,7 @@ end
|
|||||||
|
|
||||||
class FZF
|
class FZF
|
||||||
C = Curses
|
C = Curses
|
||||||
attr_reader :rxflag, :sort, :color, :ansi256, :mouse, :multi, :query, :filter, :extended
|
attr_reader :rxflag, :sort, :color, :black, :ansi256, :mouse, :multi, :query, :filter, :extended
|
||||||
|
|
||||||
class AtomicVar
|
class AtomicVar
|
||||||
def initialize value
|
def initialize value
|
||||||
@@ -78,6 +78,7 @@ class FZF
|
|||||||
@sort = ENV.fetch('FZF_DEFAULT_SORT', 1000).to_i
|
@sort = ENV.fetch('FZF_DEFAULT_SORT', 1000).to_i
|
||||||
@color = true
|
@color = true
|
||||||
@ansi256 = true
|
@ansi256 = true
|
||||||
|
@black = false
|
||||||
@multi = false
|
@multi = false
|
||||||
@mouse = true
|
@mouse = true
|
||||||
@extended = nil
|
@extended = nil
|
||||||
@@ -104,6 +105,8 @@ class FZF
|
|||||||
when '+c', '--no-color' then @color = false
|
when '+c', '--no-color' then @color = false
|
||||||
when '-2', '--256' then @ansi256 = true
|
when '-2', '--256' then @ansi256 = true
|
||||||
when '+2', '--no-256' then @ansi256 = false
|
when '+2', '--no-256' then @ansi256 = false
|
||||||
|
when '--black' then @black = true
|
||||||
|
when '--no-black' then @black = false
|
||||||
when '--mouse' then @mouse = true
|
when '--mouse' then @mouse = true
|
||||||
when '--no-mouse' then @mouse = false
|
when '--no-mouse' then @mouse = false
|
||||||
when '+s', '--no-sort' then @sort = nil
|
when '+s', '--no-sort' then @sort = nil
|
||||||
@@ -211,6 +214,7 @@ class FZF
|
|||||||
+i Case-sensitive match
|
+i Case-sensitive match
|
||||||
+c, --no-color Disable colors
|
+c, --no-color Disable colors
|
||||||
+2, --no-256 Disable 256-color
|
+2, --no-256 Disable 256-color
|
||||||
|
--black Use black background
|
||||||
--no-mouse Disable mouse
|
--no-mouse Disable mouse
|
||||||
|
|
||||||
Environment variables
|
Environment variables
|
||||||
@@ -517,7 +521,7 @@ class FZF
|
|||||||
C.mousemask C::ALL_MOUSE_EVENTS if @mouse
|
C.mousemask C::ALL_MOUSE_EVENTS if @mouse
|
||||||
C.start_color
|
C.start_color
|
||||||
dbg =
|
dbg =
|
||||||
if C.respond_to?(:use_default_colors)
|
if !@black && C.respond_to?(:use_default_colors)
|
||||||
C.use_default_colors
|
C.use_default_colors
|
||||||
-1
|
-1
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
Gem::Specification.new do |spec|
|
Gem::Specification.new do |spec|
|
||||||
spec.name = 'fzf'
|
spec.name = 'fzf'
|
||||||
spec.version = '0.8.0'
|
spec.version = '0.8.1'
|
||||||
spec.authors = ['Junegunn Choi']
|
spec.authors = ['Junegunn Choi']
|
||||||
spec.email = ['junegunn.c@gmail.com']
|
spec.email = ['junegunn.c@gmail.com']
|
||||||
spec.description = %q{Fuzzy finder for your shell}
|
spec.description = %q{Fuzzy finder for your shell}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class TestFZF < MiniTest::Unit::TestCase
|
|||||||
fzf = FZF.new []
|
fzf = FZF.new []
|
||||||
assert_equal 20000, fzf.sort
|
assert_equal 20000, fzf.sort
|
||||||
|
|
||||||
ENV['FZF_DEFAULT_OPTS'] = '-x -m -s 10000 -q " hello world " +c +2 --no-mouse -f "goodbye world"'
|
ENV['FZF_DEFAULT_OPTS'] = '-x -m -s 10000 -q " hello world " +c +2 --no-mouse -f "goodbye world" --black'
|
||||||
fzf = FZF.new []
|
fzf = FZF.new []
|
||||||
assert_equal 10000, fzf.sort
|
assert_equal 10000, fzf.sort
|
||||||
assert_equal ' hello world ',
|
assert_equal ' hello world ',
|
||||||
@@ -39,6 +39,7 @@ class TestFZF < MiniTest::Unit::TestCase
|
|||||||
assert_equal true, fzf.multi
|
assert_equal true, fzf.multi
|
||||||
assert_equal false, fzf.color
|
assert_equal false, fzf.color
|
||||||
assert_equal false, fzf.ansi256
|
assert_equal false, fzf.ansi256
|
||||||
|
assert_equal true, fzf.black
|
||||||
assert_equal false, fzf.mouse
|
assert_equal false, fzf.mouse
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -50,6 +51,7 @@ class TestFZF < MiniTest::Unit::TestCase
|
|||||||
assert_equal true, fzf.multi
|
assert_equal true, fzf.multi
|
||||||
assert_equal false, fzf.color
|
assert_equal false, fzf.color
|
||||||
assert_equal false, fzf.ansi256
|
assert_equal false, fzf.ansi256
|
||||||
|
assert_equal false, fzf.black
|
||||||
assert_equal false, fzf.mouse
|
assert_equal false, fzf.mouse
|
||||||
assert_equal 0, fzf.rxflag
|
assert_equal 0, fzf.rxflag
|
||||||
assert_equal 'hello', fzf.query.get
|
assert_equal 'hello', fzf.query.get
|
||||||
@@ -57,12 +59,13 @@ class TestFZF < MiniTest::Unit::TestCase
|
|||||||
assert_equal :exact, fzf.extended
|
assert_equal :exact, fzf.extended
|
||||||
|
|
||||||
fzf = FZF.new %w[--sort=2000 --no-color --multi +i --query hello
|
fzf = FZF.new %w[--sort=2000 --no-color --multi +i --query hello
|
||||||
--filter a --filter b --no-256
|
--filter a --filter b --no-256 --black
|
||||||
--no-sort -i --color --no-multi --256]
|
--no-sort -i --color --no-multi --256]
|
||||||
assert_equal nil, fzf.sort
|
assert_equal nil, fzf.sort
|
||||||
assert_equal false, fzf.multi
|
assert_equal false, fzf.multi
|
||||||
assert_equal true, fzf.color
|
assert_equal true, fzf.color
|
||||||
assert_equal true, fzf.ansi256
|
assert_equal true, fzf.ansi256
|
||||||
|
assert_equal true, fzf.black
|
||||||
assert_equal true, fzf.mouse
|
assert_equal true, fzf.mouse
|
||||||
assert_equal 1, fzf.rxflag
|
assert_equal 1, fzf.rxflag
|
||||||
assert_equal 'b', fzf.filter
|
assert_equal 'b', fzf.filter
|
||||||
@@ -82,11 +85,12 @@ class TestFZF < MiniTest::Unit::TestCase
|
|||||||
|
|
||||||
# Left-to-right
|
# Left-to-right
|
||||||
fzf = FZF.new %w[-s 2000 +c -m +i -qhello -x -fgoodbye +2
|
fzf = FZF.new %w[-s 2000 +c -m +i -qhello -x -fgoodbye +2
|
||||||
-s 3000 -c +m -i -q world +x -fworld -2]
|
-s 3000 -c +m -i -q world +x -fworld -2 --black --no-black]
|
||||||
assert_equal 3000, fzf.sort
|
assert_equal 3000, fzf.sort
|
||||||
assert_equal false, fzf.multi
|
assert_equal false, fzf.multi
|
||||||
assert_equal true, fzf.color
|
assert_equal true, fzf.color
|
||||||
assert_equal true, fzf.ansi256
|
assert_equal true, fzf.ansi256
|
||||||
|
assert_equal false, fzf.black
|
||||||
assert_equal 1, fzf.rxflag
|
assert_equal 1, fzf.rxflag
|
||||||
assert_equal 'world', fzf.query.get
|
assert_equal 'world', fzf.query.get
|
||||||
assert_equal 'world', fzf.filter
|
assert_equal 'world', fzf.filter
|
||||||
|
|||||||
Reference in New Issue
Block a user