summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2013-10-24 12:52:31 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2013-10-24 12:52:31 +0900
commit2bf54a0a5757c47b5b005ab4f3d7bd97f7e392c8 (patch)
tree55cec14a21b1a076f8b4a861779bd8e70ac5f10a
parent0c438111e0e17739a24b9809990318ad63facf6e (diff)
downloadfzf-2bf54a0a5757c47b5b005ab4f3d7bd97f7e392c8.tar.gz
Add 'reading' marker
-rwxr-xr-xfzf20
1 files changed, 16 insertions, 4 deletions
diff --git a/fzf b/fzf
index 448ca3fa..d72e85d5 100755
--- a/fzf
+++ b/fzf
@@ -57,15 +57,16 @@ C = Curses
@cursor_x = 0
@vcursor = 0
@matches = []
+@fan = '-\|/-\|/'.split(//)
@stat = OpenStruct.new(:hit => 0, :partial_hit => 0,
:prefix_hit => 0, :search => 0)
def max_items; C.lines - 2; end
def cursor_y; C.lines - 1; end
-def cprint str, col
- C.attron C.color_pair(col) | C::A_BOLD
+def cprint str, col, flag = C::A_BOLD
+ C.attron C.color_pair(col) | flag
C.addstr str
- C.attroff C.color_pair(col) | C::A_BOLD
+ C.attroff C.color_pair(col) | flag
end
def print_input
@@ -78,7 +79,16 @@ end
def print_info msg = nil
C.setpos cursor_y - 1, 0
C.clrtoeol
- C.addstr " #{@matches.length}/#{@count}#{msg}"
+ prefix =
+ if fan = @fan.shift
+ @fan.push fan
+ cprint fan, 5, 0
+ ' '
+ else
+ ' '
+ end
+ C.addstr "#{prefix}#{@matches.length}/#{@count}"
+ C.addstr msg if msg
end
def refresh
@@ -121,6 +131,7 @@ C.init_pair 1, C::COLOR_BLUE, C::COLOR_BLACK
C.init_pair 2, C::COLOR_WHITE, C::COLOR_BLACK
C.init_pair 3, C::COLOR_YELLOW, C::COLOR_BLACK
C.init_pair 4, C::COLOR_RED, C::COLOR_BLACK
+C.init_pair 5, C::COLOR_CYAN, C::COLOR_BLACK
@read =
if $stdin.tty?
@@ -140,6 +151,7 @@ reader = Thread.new {
@cv.broadcast
end
end
+ @smtx.synchronize { @fan = [] }
}
searcher = Thread.new {