Merge pull request #113 from jeffppfa/master

Press b to go back in preview history II
This commit is contained in:
Mark Badolato 2017-03-28 16:43:20 -07:00 committed by GitHub
commit 89b3f6264f
2 changed files with 11 additions and 2 deletions

View file

@ -1042,7 +1042,8 @@ the linked page, it doesn't run on tmux or screen.
tools/preview.rb schemes/AdventureTime.itermcolors
# Apply the schemes in turn.
# - Press any key to advance; hit CTRL-C or ESC to stop
# - Press (almost) any key to advance; hit CTRL-C or ESC to stop
# - Press the delete key to go back
tools/preview.rb schemes/*
```

View file

@ -21,6 +21,7 @@ if ENV.has_key? 'TMUX'
end
preview = files.length > 1
history = []
until files.empty?
file = files.shift
print "[#{File.basename file, '.*'}] " if preview
@ -59,7 +60,14 @@ until files.empty?
'cursor text' => 'm',
}.fetch(type, '%x' % type.to_i) << rgb << "\e\\"
end
break if files.empty? || [3.chr, "\e"].include?(IO.console.getch)
case IO.console.getch.ord
when 127 # backspace
files.unshift *[history.pop, file].compact
when 3, 27 # ctrl-c, esc
break
else
history << file
end
rescue Exception
print '(X) '
end