Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
fzf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
fzf
Commits
ae274158
Unverified
Commit
ae274158
authored
8 years ago
by
Junegunn Choi
Browse files
Options
Downloads
Patches
Plain Diff
Add experimental support for 24-bit colors
parent
340af463
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
man/man1/fzf.1
+3
-1
3 additions, 1 deletion
man/man1/fzf.1
src/options.go
+11
-4
11 additions, 4 deletions
src/options.go
src/tui/tui.go
+8
-0
8 additions, 0 deletions
src/tui/tui.go
src/tui/tui_test.go
+20
-0
20 additions, 0 deletions
src/tui/tui_test.go
with
42 additions
and
5 deletions
man/man1/fzf.1
+
3
−
1
View file @
ae274158
...
...
@@ -197,7 +197,9 @@ Number of spaces for a tab character (default: 8)
.BI "--color=" "[BASE_SCHEME][,COLOR:ANSI]"
Color configuration. The name of the base color scheme is followed by custom
color mappings. Ansi color code of -1 denotes terminal default
foreground/background color.
foreground/background color. You can also specify 24-bit color in \fB#rrggbb\fR
format, but the support for 24-bit colors is experimental and only works when
\fB--height\fR option is used.
.RS
e.g. \fBfzf --color=bg+:24\fR
...
...
This diff is collapsed.
Click to expand it.
src/options.go
+
11
−
4
View file @
ae274158
...
...
@@ -493,6 +493,7 @@ func dupeTheme(theme *tui.ColorTheme) *tui.ColorTheme {
func
parseTheme
(
defaultTheme
*
tui
.
ColorTheme
,
str
string
)
*
tui
.
ColorTheme
{
theme
:=
dupeTheme
(
defaultTheme
)
rrggbb
:=
regexp
.
MustCompile
(
"^#[0-9a-fA-F]{6}$"
)
for
_
,
str
:=
range
strings
.
Split
(
strings
.
ToLower
(
str
),
","
)
{
switch
str
{
case
"dark"
:
...
...
@@ -516,11 +517,17 @@ func parseTheme(defaultTheme *tui.ColorTheme, str string) *tui.ColorTheme {
if
len
(
pair
)
!=
2
{
fail
()
}
ansi32
,
err
:=
strconv
.
Atoi
(
pair
[
1
])
if
err
!=
nil
||
ansi32
<
-
1
||
ansi32
>
255
{
fail
()
var
ansi
tui
.
Color
if
rrggbb
.
MatchString
(
pair
[
1
])
{
ansi
=
tui
.
HexToColor
(
pair
[
1
])
}
else
{
ansi32
,
err
:=
strconv
.
Atoi
(
pair
[
1
])
if
err
!=
nil
||
ansi32
<
-
1
||
ansi32
>
255
{
fail
()
}
ansi
=
tui
.
Color
(
ansi32
)
}
ansi
:=
tui
.
Color
(
ansi32
)
switch
pair
[
0
]
{
case
"fg"
:
theme
.
Fg
=
ansi
...
...
This diff is collapsed.
Click to expand it.
src/tui/tui.go
+
8
−
0
View file @
ae274158
package
tui
import
(
"strconv"
"time"
)
...
...
@@ -121,6 +122,13 @@ type ColorPair struct {
id
int16
}
func
HexToColor
(
rrggbb
string
)
Color
{
r
,
_
:=
strconv
.
ParseInt
(
rrggbb
[
1
:
3
],
16
,
0
)
g
,
_
:=
strconv
.
ParseInt
(
rrggbb
[
3
:
5
],
16
,
0
)
b
,
_
:=
strconv
.
ParseInt
(
rrggbb
[
5
:
7
],
16
,
0
)
return
Color
((
1
<<
24
)
+
(
r
<<
16
)
+
(
g
<<
8
)
+
b
)
}
func
NewColorPair
(
fg
Color
,
bg
Color
)
ColorPair
{
return
ColorPair
{
fg
,
bg
,
-
1
}
}
...
...
This diff is collapsed.
Click to expand it.
src/tui/tui_test.go
0 → 100644
+
20
−
0
View file @
ae274158
package
tui
import
"testing"
func
TestHexToColor
(
t
*
testing
.
T
)
{
assert
:=
func
(
expr
string
,
r
,
g
,
b
int
)
{
color
:=
HexToColor
(
expr
)
if
!
color
.
is24
()
||
int
((
color
>>
16
)
&
0xff
)
!=
r
||
int
((
color
>>
8
)
&
0xff
)
!=
g
||
int
((
color
)
&
0xff
)
!=
b
{
t
.
Fail
()
}
}
assert
(
"#ff0000"
,
255
,
0
,
0
)
assert
(
"#010203"
,
1
,
2
,
3
)
assert
(
"#102030"
,
16
,
32
,
48
)
assert
(
"#ffffff"
,
255
,
255
,
255
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment