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
2ccdf21a
Commit
2ccdf21a
authored
9 years ago
by
Junegunn Choi
Browse files
Options
Downloads
Patches
Plain Diff
Add --hscroll-off=COL option
Close #513
parent
cf8afc52
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
man/man1/fzf.1
+6
-1
6 additions, 1 deletion
man/man1/fzf.1
src/options.go
+12
-0
12 additions, 0 deletions
src/options.go
src/terminal.go
+5
-4
5 additions, 4 deletions
src/terminal.go
src/util/util.go
+8
-0
8 additions, 0 deletions
src/util/util.go
test/test_go.rb
+12
-0
12 additions, 0 deletions
test/test_go.rb
with
43 additions
and
5 deletions
man/man1/fzf.1
+
6
−
1
View file @
2ccdf21a
...
@@ -21,7 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
...
@@ -21,7 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.
..
..
.TH fzf 1 "
Feb
2016" "fzf 0.11.
3
" "fzf - a command-line fuzzy finder"
.TH fzf 1 "
Mar
2016" "fzf 0.11.
4
" "fzf - a command-line fuzzy finder"
.SH NAME
.SH NAME
fzf - a command-line fuzzy finder
fzf - a command-line fuzzy finder
...
@@ -175,6 +175,11 @@ Enable cyclic scroll
...
@@ -175,6 +175,11 @@ Enable cyclic scroll
.B "--no-hscroll"
.B "--no-hscroll"
Disable horizontal scroll
Disable horizontal scroll
.TP
.TP
.BI "--hscroll-off=" "COL"
Number of screen columns to keep to the right of the highlighted substring
(default: 10). Setting it to a large value will cause the text to be positioned
on the center of the screen.
.TP
.B "--inline-info"
.B "--inline-info"
Display finder info inline with the query
Display finder info inline with the query
.TP
.TP
...
...
This diff is collapsed.
Click to expand it.
src/options.go
+
12
−
0
View file @
2ccdf21a
...
@@ -42,6 +42,8 @@ const usage = `usage: fzf [options]
...
@@ -42,6 +42,8 @@ const usage = `usage: fzf [options]
--tabstop=SPACES Number of spaces for a tab character (default: 8)
--tabstop=SPACES Number of spaces for a tab character (default: 8)
--cycle Enable cyclic scroll
--cycle Enable cyclic scroll
--no-hscroll Disable horizontal scroll
--no-hscroll Disable horizontal scroll
--hscroll-off=COL Number of screen columns to keep to the right of the
highlighted substring (default: 10)
--inline-info Display finder info inline with the query
--inline-info Display finder info inline with the query
--prompt=STR Input prompt (default: '> ')
--prompt=STR Input prompt (default: '> ')
--bind=KEYBINDS Custom key bindings. Refer to the man page.
--bind=KEYBINDS Custom key bindings. Refer to the man page.
...
@@ -108,6 +110,7 @@ type Options struct {
...
@@ -108,6 +110,7 @@ type Options struct {
Reverse
bool
Reverse
bool
Cycle
bool
Cycle
bool
Hscroll
bool
Hscroll
bool
HscrollOff
int
InlineInfo
bool
InlineInfo
bool
Prompt
string
Prompt
string
Query
string
Query
string
...
@@ -155,6 +158,7 @@ func defaultOptions() *Options {
...
@@ -155,6 +158,7 @@ func defaultOptions() *Options {
Reverse
:
false
,
Reverse
:
false
,
Cycle
:
false
,
Cycle
:
false
,
Hscroll
:
true
,
Hscroll
:
true
,
HscrollOff
:
10
,
InlineInfo
:
false
,
InlineInfo
:
false
,
Prompt
:
"> "
,
Prompt
:
"> "
,
Query
:
""
,
Query
:
""
,
...
@@ -795,6 +799,8 @@ func parseOptions(opts *Options, allArgs []string) {
...
@@ -795,6 +799,8 @@ func parseOptions(opts *Options, allArgs []string) {
opts
.
Hscroll
=
true
opts
.
Hscroll
=
true
case
"--no-hscroll"
:
case
"--no-hscroll"
:
opts
.
Hscroll
=
false
opts
.
Hscroll
=
false
case
"--hscroll-off"
:
opts
.
HscrollOff
=
nextInt
(
allArgs
,
&
i
,
"hscroll offset required"
)
case
"--inline-info"
:
case
"--inline-info"
:
opts
.
InlineInfo
=
true
opts
.
InlineInfo
=
true
case
"--no-inline-info"
:
case
"--no-inline-info"
:
...
@@ -884,6 +890,8 @@ func parseOptions(opts *Options, allArgs []string) {
...
@@ -884,6 +890,8 @@ func parseOptions(opts *Options, allArgs []string) {
opts
.
Margin
=
parseMargin
(
value
)
opts
.
Margin
=
parseMargin
(
value
)
}
else
if
match
,
value
:=
optString
(
arg
,
"--tabstop="
);
match
{
}
else
if
match
,
value
:=
optString
(
arg
,
"--tabstop="
);
match
{
opts
.
Tabstop
=
atoi
(
value
)
opts
.
Tabstop
=
atoi
(
value
)
}
else
if
match
,
value
:=
optString
(
arg
,
"--hscroll-off="
);
match
{
opts
.
HscrollOff
=
atoi
(
value
)
}
else
{
}
else
{
errorExit
(
"unknown option: "
+
arg
)
errorExit
(
"unknown option: "
+
arg
)
}
}
...
@@ -894,6 +902,10 @@ func parseOptions(opts *Options, allArgs []string) {
...
@@ -894,6 +902,10 @@ func parseOptions(opts *Options, allArgs []string) {
errorExit
(
"header lines must be a non-negative integer"
)
errorExit
(
"header lines must be a non-negative integer"
)
}
}
if
opts
.
HscrollOff
<
0
{
errorExit
(
"hscroll offset must be a non-negative integer"
)
}
if
opts
.
Tabstop
<
1
{
if
opts
.
Tabstop
<
1
{
errorExit
(
"tab stop must be a positive integer"
)
errorExit
(
"tab stop must be a positive integer"
)
}
}
...
...
This diff is collapsed.
Click to expand it.
src/terminal.go
+
5
−
4
View file @
2ccdf21a
...
@@ -26,6 +26,7 @@ type Terminal struct {
...
@@ -26,6 +26,7 @@ type Terminal struct {
prompt
string
prompt
string
reverse
bool
reverse
bool
hscroll
bool
hscroll
bool
hscrollOff
int
cx
int
cx
int
cy
int
cy
int
offset
int
offset
int
...
@@ -210,6 +211,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
...
@@ -210,6 +211,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
prompt
:
opts
.
Prompt
,
prompt
:
opts
.
Prompt
,
reverse
:
opts
.
Reverse
,
reverse
:
opts
.
Reverse
,
hscroll
:
opts
.
Hscroll
,
hscroll
:
opts
.
Hscroll
,
hscrollOff
:
opts
.
HscrollOff
,
cx
:
len
(
input
),
cx
:
len
(
input
),
cy
:
0
,
cy
:
0
,
offset
:
0
,
offset
:
0
,
...
@@ -556,11 +558,9 @@ func trimLeft(runes []rune, width int) ([]rune, int32) {
...
@@ -556,11 +558,9 @@ func trimLeft(runes []rune, width int) ([]rune, int32) {
}
}
func
(
t
*
Terminal
)
printHighlighted
(
item
*
Item
,
bold
bool
,
col1
int
,
col2
int
,
current
bool
)
{
func
(
t
*
Terminal
)
printHighlighted
(
item
*
Item
,
bold
bool
,
col1
int
,
col2
int
,
current
bool
)
{
var
maxe
int
32
var
maxe
int
for
_
,
offset
:=
range
item
.
offsets
{
for
_
,
offset
:=
range
item
.
offsets
{
if
offset
[
1
]
>
maxe
{
maxe
=
util
.
Max
(
maxe
,
int
(
offset
[
1
]))
maxe
=
offset
[
1
]
}
}
}
// Overflow
// Overflow
...
@@ -568,6 +568,7 @@ func (t *Terminal) printHighlighted(item *Item, bold bool, col1 int, col2 int, c
...
@@ -568,6 +568,7 @@ func (t *Terminal) printHighlighted(item *Item, bold bool, col1 int, col2 int, c
copy
(
text
,
item
.
text
)
copy
(
text
,
item
.
text
)
offsets
:=
item
.
colorOffsets
(
col2
,
bold
,
current
)
offsets
:=
item
.
colorOffsets
(
col2
,
bold
,
current
)
maxWidth
:=
C
.
MaxX
()
-
3
-
t
.
marginInt
[
1
]
-
t
.
marginInt
[
3
]
maxWidth
:=
C
.
MaxX
()
-
3
-
t
.
marginInt
[
1
]
-
t
.
marginInt
[
3
]
maxe
=
util
.
Constrain
(
maxe
+
util
.
Min
(
maxWidth
/
2
-
2
,
t
.
hscrollOff
),
0
,
len
(
text
))
fullWidth
:=
displayWidth
(
text
)
fullWidth
:=
displayWidth
(
text
)
if
fullWidth
>
maxWidth
{
if
fullWidth
>
maxWidth
{
if
t
.
hscroll
{
if
t
.
hscroll
{
...
...
This diff is collapsed.
Click to expand it.
src/util/util.go
+
8
−
0
View file @
2ccdf21a
...
@@ -21,6 +21,14 @@ func Max(first int, items ...int) int {
...
@@ -21,6 +21,14 @@ func Max(first int, items ...int) int {
return
max
return
max
}
}
// Min returns the smallest integer
func
Min
(
first
int
,
second
int
)
int
{
if
first
<=
second
{
return
first
}
return
second
}
// Min32 returns the smallest 32-bit integer
// Min32 returns the smallest 32-bit integer
func
Min32
(
first
int32
,
second
int32
)
int32
{
func
Min32
(
first
int32
,
second
int32
)
int32
{
if
first
<=
second
{
if
first
<=
second
{
...
...
This diff is collapsed.
Click to expand it.
test/test_go.rb
+
12
−
0
View file @
2ccdf21a
...
@@ -1137,6 +1137,18 @@ class TestGoFZF < TestBase
...
@@ -1137,6 +1137,18 @@ class TestGoFZF < TestBase
`seq 10 |
#{
FZF
}
-f '1 | !1'`
.
lines
.
map
(
&
:chomp
)
`seq 10 |
#{
FZF
}
-f '1 | !1'`
.
lines
.
map
(
&
:chomp
)
end
end
def
test_hscroll_off
writelines
tempname
,
[
'='
*
10000
+
'0123456789'
]
[
0
,
3
,
6
].
each
do
|
off
|
tmux
.
prepare
tmux
.
send_keys
"
#{
FZF
}
--hscroll-off=
#{
off
}
-q 0 <
#{
tempname
}
"
,
:Enter
tmux
.
until
{
|
lines
|
lines
[
-
3
].
end_with?
((
0
..
off
).
to_a
.
join
+
'..'
)
}
tmux
.
send_keys
'9'
tmux
.
until
{
|
lines
|
lines
[
-
3
].
end_with?
'789'
}
tmux
.
send_keys
:Enter
end
end
private
private
def
writelines
path
,
lines
def
writelines
path
,
lines
File
.
unlink
path
while
File
.
exists?
path
File
.
unlink
path
while
File
.
exists?
path
...
...
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