lib/mireru/command/mireru.rb in mireru-0.2.1 vs lib/mireru/command/mireru.rb in mireru-0.9.0
- old
+ new
@@ -1,15 +1,13 @@
-require "gtk3"
require "mireru/logger"
require "mireru/window"
-require "mireru/container"
require "mireru/version"
module Mireru
module Command
class Mireru
- USAGE = "Usage: mireru [OPTION]... [FILE]..."
+ USAGE = "Usage: mireru [OPTION]... [FILE_OR_DIRECTORY]..."
class << self
def run(*arguments)
new.run(arguments)
end
@@ -29,48 +27,21 @@
end
font = purge_option(arguments, /\A(-f|--font)\z/, true)
files = files_from_arguments(arguments)
- file_container = ::Mireru::Container.new(files)
- if file_container.empty?
- write_empty_message
- exit(false)
- end
-
- window = ::Mireru::Window.new
+ window = ::Mireru::Window.new(files)
window.font = font if font
- window.add_container(file_container)
- Gtk.main
+ window.run
end
private
def files_from_arguments(arguments)
if arguments.empty?
- files = Dir.glob("*")
- elsif purge_option(arguments, /\A(-R|--recursive|-d|--deep)\z/)
- if arguments.empty?
- files = Dir.glob("**/*")
- else
- files = []
- arguments.each do |f|
- if File.directory?(f)
- files << Dir.glob("#{f}/**/*")
- else
- files << f
- end
- end
- files.flatten!
- end
- elsif arguments.all? {|v| File.directory?(v) }
- files = []
- arguments.each do |f|
- files << Dir.glob("#{f}/*")
- end
- files.flatten!
+ files = [Dir.pwd]
else
files = arguments
end
files
end
@@ -87,64 +58,71 @@
end
def write_help_message
message = <<-EOM
#{USAGE}
- If no argument, then search current directory.
+ If no argument, then open the current directory.
+
Options:
- -R, --recursive
- recursive search as "**/*"
+ -h, --help
+ show this help message
+
-f, --font NAME
- set font such as "Monospace 16"
-Keybind:
+ set a font such as "Monospace 16"
+
+Key bindings:
n: next
p: prev
+ e: expand/collpse
r: reload
- e: expand path
q: quit
+ Control key mask:
+ Ctrl+n: 10 tiles next
+ Ctrl+p: 10 tiles prev
+ Ctrl+e: expand all / collpse even if cursor on file
+ Ctrl+h: move position of partition to left
+ Ctrl+l: move position of partition to right
+
scroll:
h: left
j: down
k: up
l: right
+ Shift+h: 100 times left
+ Shift+j: 100 times down
+ Shift+k: 100 times up
+ Shift+l: 100 times right
+
+ Shift+g: down to bottom
+
scale:
+: larger
-: smaller
image:
- f: fits window size
- o: original size
+ f: fit window size
+ o: scale to the original size
text:
f: change font (at random)
video:
space: play/pause
+
+ PDF:
+ j: next page
+ k: prev page
EOM
@logger.info(message)
end
def write_version_message
message = <<-EOM
#{::Mireru::VERSION}
EOM
@logger.info(message)
- end
-
- def write_empty_message
- message = <<-EOM
-Warning: file not found.
-#{USAGE}
- If no argument, then search current directory.
-Options:
- -R, --recursive
- recursive search as "**/*"
- -f, --font NAME
- set font such as "Monospace 16"
- EOM
- @logger.error(message)
end
end
end
end