Press b to go back in preview history II
This commit is contained in:
parent
24adb7fff6
commit
85aea69235
2 changed files with 11 additions and 2 deletions
|
|
@ -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/*
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue