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
86a66da0
Commit
86a66da0
authored
11 years ago
by
Junegunn Choi
Browse files
Options
Downloads
Patches
Plain Diff
Synchronize getch calls to reduce screen glitches
parent
d66b02b0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fzf
+15
-8
15 additions, 8 deletions
fzf
with
15 additions
and
8 deletions
fzf
+
15
−
8
View file @
86a66da0
...
...
@@ -82,6 +82,7 @@ class FZF
@mouse
=
true
@filter
=
nil
@pending
=
nil
@mutex
=
Mutex
.
new
argv
=
if
opts
=
ENV
[
'FZF_DEFAULT_OPTS'
]
...
...
@@ -721,8 +722,10 @@ class FZF
Thread
.
new
do
begin
while
blk
=
@queue
.
shift
blk
.
call
refresh
@mutex
.
synchronize
do
blk
.
call
refresh
end
end
rescue
Exception
=>
e
@main
.
raise
e
...
...
@@ -766,7 +769,7 @@ class FZF
elsif
(
nch
=
num_unicode_bytes
(
ch
))
>
1
chs
=
[
ch
]
(
nch
-
1
).
times
do
|
i
|
chs
<<
C
.
getch
chs
<<
getch
_nb
end
# UTF-8 TODO Ruby 1.8
ch
=
chs
.
pack
(
'C*'
).
force_encoding
(
'UTF-8'
)
...
...
@@ -776,6 +779,10 @@ class FZF
ch
.
is_a?
(
String
)
&&
ch
=~
/[[:print:]]/
&&
ch
end
def
getch_nb
@mutex
.
synchronize
{
C
.
getch
}
end
def
getch
if
pending
=
@pending
@pending
=
nil
...
...
@@ -784,10 +791,10 @@ class FZF
C
.
stdscr
.
timeout
=
-
1
c
=
C
.
getch
C
.
stdscr
.
timeout
=
0
if
ch
=
to_printable
(
c
)
chs
=
[
ch
]
C
.
stdscr
.
timeout
=
0
if
AFTER_1_9
while
AFTER_1_9
&&
c
=
C
.
getch
while
AFTER_1_9
&&
c
=
getch_nb
if
ch
=
to_printable
(
c
)
chs
<<
ch
else
...
...
@@ -868,7 +875,7 @@ class FZF
case
ch
=
getch
when
C
::
KEY_MOUSE
if
m
=
C
.
getmouse
if
m
=
@mutex
.
synchronize
{
C
.
getmouse
}
st
=
m
.
bstate
if
test_mouse
(
st
,
C
::
BUTTON1_PRESSED
,
C
::
BUTTON1_RELEASED
)
if
m
.
y
==
cursor_y
...
...
@@ -897,9 +904,9 @@ class FZF
when
27
C
.
stdscr
.
timeout
=
0
ch
=
# Typeahead arrow keys
case
ch2
=
C
.
getch
case
ch2
=
getch
_nb
when
'['
,
91
case
ch3
=
C
.
getch
case
ch3
=
getch
_nb
when
'D'
,
68
then
ctrl
(
:b
)
when
'C'
,
67
then
ctrl
(
:f
)
when
'B'
,
66
then
ctrl
(
:j
)
...
...
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