about summary refs log tree commit diff stats
path: root/ranger.rb
blob: 33af212f5e652febb4ff4fc7228808506612d785 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/ruby -Ku
version = '0.2.4'

require 'pathname'
$: << MYDIR = File.dirname(Pathname(__FILE__).realpath)

EVIL = false

if ARGV.size > 0
	case ARGV.first
	when '-k'
		exec "killall -9 #{File.basename($0)}"
	end
	pwd = ARGV.first
	if pwd =~ /^file:\/\//
		pwd = $'
	end

	unless File.exists?(pwd)
		pwd = nil
	end

else
	pwd = nil
end

for file in Dir.glob "#{MYDIR}/code/**/*.rb"
	require file [MYDIR.size + 1 ... -3]
end

## default options
opt = {
	:show_hidden => false,
	:sort => :name,
	:dir_first => true,
	:sort_reverse => false,
	:colorscheme => true,
	:wide_bar => true,
	:file_preview => true,
	:preview => true,
	:colorscheme => 'default'
}

Option = Struct.new(*opt.keys).new(*opt.values)
opt = nil

load 'ranger.conf'
load 'data/colorscheme/' + Option.colorscheme + '.rb'
load 'data/screensaver/clock.rb'

include Debug

Debug.setup( :name   => 'nyuron',
             :file   => '/tmp/errorlog',
             :level  => 3 )

if pwd and !ARGV.empty? and !File.directory?(pwd)
	file = Directory::Entry.new(pwd)
	file.get_data
	Action.run(RunContext.new(file, 0, 'c'))
	exit
end

include CLI

Signal.trap(Scheduler::UPDATE_SIGNAL) do
	Fm.refresh
end

begin
	Fm.initialize( pwd )
	Fm.main_loop
ensure
	log "exiting!"
	log ""
	closei if CLI.running?
	Fm.dump

	# Kill all other threads
	for thr in Thread.list
		unless thr == Thread.current
			thr.kill
		end
	end
end