diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2014-03-09 04:06:12 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2014-03-09 04:09:09 +0900 |
commit | 9904f5354e94407dad0b33b1fdd93ed4c5cfb357 (patch) | |
tree | f54e488f9fc2371f131725de6bbd93402d932714 | |
parent | f345bf7983656473c4fbe4b71130189765fa4da7 (diff) |
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.
-rw-r--r-- | README.md | 1 | ||||
-rwxr-xr-x | fzf | 10 | ||||
-rw-r--r-- | fzf.gemspec | 2 | ||||
-rw-r--r-- | test/test_fzf.rb | 10 |
4 files changed, 16 insertions, 7 deletions
@@ -59,6 +59,7 @@ usage: fzf [options] +i Case-sensitive match +c, --no-color Disable colors +2, --no-256 Disable 256-color + --black Use black background --no-mouse Disable mouse Environment variables @@ -7,7 +7,7 @@ # / __/ / /_/ __/ # /_/ /___/_/ Fuzzy finder for your shell # -# Version: 0.8.0 (March 8, 2014) +# Version: 0.8.1 (March 9, 2014) # # Author: Junegunn Choi # URL: https://github.com/junegunn/fzf @@ -50,7 +50,7 @@ end class FZF 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 def initialize value @@ -78,6 +78,7 @@ class FZF @sort = ENV.fetch('FZF_DEFAULT_SORT', 1000).to_i @color = true @ansi256 = true + @black = false @multi = false @mouse = true @extended = nil @@ -104,6 +105,8 @@ class FZF when '+c', '--no-color' then @color = false when '-2', '--256' then @ansi256 = true when '+2', '--no-256' then @ansi256 = false + when '--black' then @black = true + when '--no-black' then @black = false when '--mouse' then @mouse = true when '--no-mouse' then @mouse = false when '+s', '--no-sort' then @sort = nil @@ -211,6 +214,7 @@ class FZF +i Case-sensitive match +c, --no-color Disable colors +2, --no-256 Disable 256-color + --black Use black background --no-mouse Disable mouse Environment variables @@ -517,7 +521,7 @@ class FZF C.mousemask C::ALL_MOUSE_EVENTS if @mouse C.start_color dbg = - if C.respond_to?(:use_default_colors) + if !@black && C.respond_to?(:use_default_colors) C.use_default_colors -1 else diff --git a/fzf.gemspec b/fzf.gemspec index ab28611d..9556c0d6 100644 --- a/fzf.gemspec +++ b/fzf.gemspec @@ -1,7 +1,7 @@ # coding: utf-8 Gem::Specification.new do |spec| spec.name = 'fzf' - spec.version = '0.8.0' + spec.version = '0.8.1' spec.authors = ['Junegunn Choi'] spec.email = ['junegunn.c@gmail.com'] spec.description = %q{Fuzzy finder for your shell} diff --git a/test/test_fzf.rb b/test/test_fzf.rb index df825928..b236d6ea 100644 --- a/test/test_fzf.rb +++ b/test/test_fzf.rb @@ -28,7 +28,7 @@ class TestFZF < MiniTest::Unit::TestCase fzf = FZF.new [] 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 [] assert_equal 10000, fzf.sort assert_equal ' hello world ', @@ -39,6 +39,7 @@ class TestFZF < MiniTest::Unit::TestCase assert_equal true, fzf.multi assert_equal false, fzf.color assert_equal false, fzf.ansi256 + assert_equal true, fzf.black assert_equal false, fzf.mouse end @@ -50,6 +51,7 @@ class TestFZF < MiniTest::Unit::TestCase assert_equal true, fzf.multi assert_equal false, fzf.color assert_equal false, fzf.ansi256 + assert_equal false, fzf.black assert_equal false, fzf.mouse assert_equal 0, fzf.rxflag assert_equal 'hello', fzf.query.get @@ -57,12 +59,13 @@ class TestFZF < MiniTest::Unit::TestCase assert_equal :exact, fzf.extended 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] assert_equal nil, fzf.sort assert_equal false, fzf.multi assert_equal true, fzf.color assert_equal true, fzf.ansi256 + assert_equal true, fzf.black assert_equal true, fzf.mouse assert_equal 1, fzf.rxflag assert_equal 'b', fzf.filter @@ -82,11 +85,12 @@ class TestFZF < MiniTest::Unit::TestCase # Left-to-right 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 false, fzf.multi assert_equal true, fzf.color assert_equal true, fzf.ansi256 + assert_equal false, fzf.black assert_equal 1, fzf.rxflag assert_equal 'world', fzf.query.get assert_equal 'world', fzf.filter |