@ -35,8 +35,8 @@ const usage = `usage: fzf [options]
- m , -- multi Enable multi - select with tab / shift - tab
- m , -- multi Enable multi - select with tab / shift - tab
-- ansi Enable processing of ANSI color codes
-- ansi Enable processing of ANSI color codes
-- no - mouse Disable mouse
-- no - mouse Disable mouse
+ c , -- no - color Disable colors
-- color = COL Color scheme [ dark | light | 16 | bw ]
+ 2 , -- no - 256 Disable 256 - color
( default : dark on 256 - color terminal , otherwise 16 )
-- black Use black background
-- black Use black background
-- reverse Reverse orientation
-- reverse Reverse orientation
-- no - hscroll Disable horizontal scroll
-- no - hscroll Disable horizontal scroll
@ -101,8 +101,7 @@ type Options struct {
Multi bool
Multi bool
Ansi bool
Ansi bool
Mouse bool
Mouse bool
Color bool
Theme * curses . ColorTheme
Color256 bool
Black bool
Black bool
Reverse bool
Reverse bool
Hscroll bool
Hscroll bool
@ -119,6 +118,13 @@ type Options struct {
}
}
func defaultOptions ( ) * Options {
func defaultOptions ( ) * Options {
var defaultTheme * curses . ColorTheme
if strings . Contains ( os . Getenv ( "TERM" ) , "256" ) {
defaultTheme = curses . Dark256
} else {
defaultTheme = curses . Default16
}
return & Options {
return & Options {
Mode : ModeFuzzy ,
Mode : ModeFuzzy ,
Case : CaseSmart ,
Case : CaseSmart ,
@ -131,8 +137,7 @@ func defaultOptions() *Options {
Multi : false ,
Multi : false ,
Ansi : false ,
Ansi : false ,
Mouse : true ,
Mouse : true ,
Color : true ,
Theme : defaultTheme ,
Color256 : strings . Contains ( os . Getenv ( "TERM" ) , "256" ) ,
Black : false ,
Black : false ,
Reverse : false ,
Reverse : false ,
Hscroll : true ,
Hscroll : true ,
@ -266,6 +271,22 @@ func parseTiebreak(str string) tiebreak {
return byLength
return byLength
}
}
func parseTheme ( str string ) * curses . ColorTheme {
switch strings . ToLower ( str ) {
case "dark" :
return curses . Dark256
case "light" :
return curses . Light256
case "16" :
return curses . Default16
case "bw" , "off" , "no" , "none" :
return nil
default :
errorExit ( "invalid color scheme: " + str )
}
return nil
}
func checkToggleSort ( str string ) int {
func checkToggleSort ( str string ) int {
keys := parseKeyChords ( str , "key name required" )
keys := parseKeyChords ( str , "key name required" )
if len ( keys ) != 1 {
if len ( keys ) != 1 {
@ -295,6 +316,8 @@ func parseOptions(opts *Options, allArgs []string) {
opts . Expect = parseKeyChords ( nextString ( allArgs , & i , "key names required" ) , "key names required" )
opts . Expect = parseKeyChords ( nextString ( allArgs , & i , "key names required" ) , "key names required" )
case "--tiebreak" :
case "--tiebreak" :
opts . Tiebreak = parseTiebreak ( nextString ( allArgs , & i , "sort criterion required" ) )
opts . Tiebreak = parseTiebreak ( nextString ( allArgs , & i , "sort criterion required" ) )
case "--color" :
opts . Theme = parseTheme ( nextString ( allArgs , & i , "color scheme name required" ) )
case "--toggle-sort" :
case "--toggle-sort" :
opts . ToggleSort = checkToggleSort ( nextString ( allArgs , & i , "key name required" ) )
opts . ToggleSort = checkToggleSort ( nextString ( allArgs , & i , "key name required" ) )
case "-d" , "--delimiter" :
case "-d" , "--delimiter" :
@ -326,9 +349,9 @@ func parseOptions(opts *Options, allArgs []string) {
case "--no-mouse" :
case "--no-mouse" :
opts . Mouse = false
opts . Mouse = false
case "+c" , "--no-color" :
case "+c" , "--no-color" :
opts . Color = false
opts . Theme = nil
case "+2" , "--no-256" :
case "+2" , "--no-256" :
opts . Color256 = false
opts . Theme = curses . Default16
case "--black" :
case "--black" :
opts . Black = true
opts . Black = true
case "--no-black" :
case "--no-black" :
@ -384,6 +407,8 @@ func parseOptions(opts *Options, allArgs []string) {
opts . Expect = parseKeyChords ( value , "key names required" )
opts . Expect = parseKeyChords ( value , "key names required" )
} else if match , value := optString ( arg , "--tiebreak=" ) ; match {
} else if match , value := optString ( arg , "--tiebreak=" ) ; match {
opts . Tiebreak = parseTiebreak ( value )
opts . Tiebreak = parseTiebreak ( value )
} else if match , value := optString ( arg , "--color=" ) ; match {
opts . Theme = parseTheme ( value )
} else {
} else {
errorExit ( "unknown option: " + arg )
errorExit ( "unknown option: " + arg )
}
}