hilfer 0.9.5 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +154 -100
- data/History.txt +6 -1
- data/Manifest.txt +2 -0
- data/README.txt +11 -4
- data/TODO +6 -2
- data/bin/hilfer +1 -1
- data/lib/hilfer/extensions.rb +64 -0
- data/lib/hilfer/scite_editor.rb +166 -131
- data/lib/hilfer/tree_viewer.rb +37 -45
- data/lib/hilfer/tree_viewer_window.rb +4 -4
- data/lib/hilfer/version.rb +1 -1
- data/lib/hilfer/window.rb +26 -0
- data/lib/hilfer/xfce_terminal.rb +1 -1
- data/test/test_key_matcher.rb +25 -0
- metadata +20 -8
data/lib/hilfer/scite_editor.rb
CHANGED
@@ -1,61 +1,84 @@
|
|
1
|
+
require 'hilfer/window.rb'
|
2
|
+
|
1
3
|
# handle director interface to scite
|
2
4
|
class SciteEditor
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
5
|
+
# options can contain :debug
|
6
|
+
# view is a GtkTreeView
|
7
|
+
def initialize( options = {} )
|
8
|
+
@scite_pipe_name = "/tmp/#{ENV['USER']}.#{Process.pid}.scite"
|
9
|
+
@director_pipe_name = "/tmp/#{ENV['USER']}.#{Process.pid}.director"
|
10
|
+
|
11
|
+
cleanup
|
12
|
+
|
13
|
+
# this is an array of TreeViewer objects
|
14
|
+
@views = []
|
15
|
+
# the command-line options
|
16
|
+
@options = options
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_reader :options
|
20
|
+
attr_reader :scite_pid
|
20
21
|
|
21
22
|
def launched?
|
22
|
-
|
23
|
+
!@scite_pid.nil?
|
24
|
+
end
|
25
|
+
|
26
|
+
def window
|
27
|
+
@window ||= Window.pid( @scite_pid )
|
28
|
+
end
|
29
|
+
|
30
|
+
def reset
|
31
|
+
@scite_pid = nil
|
32
|
+
@window = nil
|
33
|
+
end
|
34
|
+
|
35
|
+
def kill
|
36
|
+
`kill #{@scite_pid}`
|
37
|
+
reset
|
38
|
+
cleanup
|
23
39
|
end
|
24
40
|
|
25
41
|
def cleanup
|
26
42
|
FileUtils.rm @scite_pipe_name if File.exist? @scite_pipe_name
|
27
|
-
|
43
|
+
FileUtils.rm @director_pipe_name if File.exist? @director_pipe_name
|
28
44
|
FileUtils.rm pipe_name_file if File.exist? pipe_name_file
|
29
45
|
end
|
30
46
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
puts "sending: #{cmd}:#{arg.to_s}" if
|
37
|
-
|
38
|
-
|
47
|
+
# send a command to SciTE
|
48
|
+
def send_cmd( cmd, arg = '' )
|
49
|
+
launch
|
50
|
+
File.open( @scite_pipe_name, 'a' ) do |file|
|
51
|
+
file.puts "#{cmd.to_s}:#{arg.to_s}"
|
52
|
+
puts "sending: #{cmd.to_s}:#{arg.to_s}" if @options[:debug]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# bring the SciTE instance to the current
|
57
|
+
# desktop and raise it.
|
58
|
+
def activate
|
59
|
+
window.activate unless window.nil?
|
60
|
+
end
|
39
61
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
62
|
+
# open files in scite
|
63
|
+
def open_action( files )
|
64
|
+
files.each { |x| send_cmd "open", x.path }
|
65
|
+
send_cmd :identity, 0
|
66
|
+
activate
|
67
|
+
end
|
45
68
|
|
46
69
|
def dump
|
47
|
-
%w{dyn local user base embed}.each {|x|
|
48
|
-
#~
|
70
|
+
%w{dyn local user base embed}.each {|x| send_cmd 'enumproperties', x}
|
71
|
+
#~ send_cmd 'askproperty','dyn:CurrentWord'
|
49
72
|
end
|
50
73
|
|
51
74
|
# fetch the current file in scite
|
52
|
-
|
53
|
-
|
54
|
-
|
75
|
+
def synchronize_path
|
76
|
+
send_cmd :askfilename
|
77
|
+
end
|
55
78
|
|
56
79
|
# shut down editor, if it's open
|
57
80
|
def quit
|
58
|
-
|
81
|
+
send_cmd :quit if launched?
|
59
82
|
end
|
60
83
|
|
61
84
|
# insert text to editor, at current caret, or overwriting the current selection
|
@@ -66,21 +89,21 @@ class SciteEditor
|
|
66
89
|
when arg.respond_to?( :join ); arg.join( '\\n' ) + '\\n'
|
67
90
|
else; arg.to_s
|
68
91
|
end
|
69
|
-
|
92
|
+
send_cmd :insert, value
|
70
93
|
end
|
71
94
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
95
|
+
# send selection to all registered views
|
96
|
+
def set_selection ( fs_path )
|
97
|
+
@views.each { |v| v.synchronise_editor_path( fs_path ) }
|
98
|
+
end
|
76
99
|
|
77
|
-
|
78
|
-
|
79
|
-
|
100
|
+
def register_view( view )
|
101
|
+
@views << view
|
102
|
+
end
|
80
103
|
|
81
|
-
|
82
|
-
|
83
|
-
|
104
|
+
def unregister_view( view )
|
105
|
+
@views.delete( view )
|
106
|
+
end
|
84
107
|
|
85
108
|
def pipe_name_file
|
86
109
|
@pipe_name_file ||= "/tmp/#{ENV['USER']}.hilfer.scite"
|
@@ -93,98 +116,110 @@ class SciteEditor
|
|
93
116
|
end
|
94
117
|
end
|
95
118
|
|
119
|
+
# start up the editor if there isn't already one
|
120
|
+
# calling it when the editor is already open does nothing
|
121
|
+
def launch
|
122
|
+
return if launched?
|
123
|
+
|
124
|
+
# create the director pipe if it isn't there already
|
125
|
+
unless File.exists?( @director_pipe_name )
|
126
|
+
system( "mkfifo #{@director_pipe_name}" )
|
127
|
+
end
|
128
|
+
|
129
|
+
scite_cmd = "/usr/bin/scite"
|
130
|
+
|
131
|
+
# start a process to clean up when scite exits
|
132
|
+
@scite_pid = fork()
|
133
|
+
if @scite_pid.nil?
|
134
|
+
# in child, so exec scite from here, so this pid will become scite's pid
|
135
|
+
# not passing the first arg as a 2 element array doesn't work. So
|
136
|
+
# use the same value for the command and as argv[0]
|
137
|
+
exec(
|
138
|
+
[ scite_cmd ] *2,
|
139
|
+
"-ipc.director.name=#{@director_pipe_name}",
|
140
|
+
"-ipc.scite.name=#{@scite_pipe_name}"
|
141
|
+
)
|
142
|
+
else
|
143
|
+
start_cleanup
|
144
|
+
end
|
145
|
+
|
146
|
+
puts "scite launched with pid #{@scite_pid}" if @options[:debug]
|
147
|
+
|
148
|
+
# start the listener thread
|
149
|
+
start_listener
|
150
|
+
end
|
151
|
+
|
96
152
|
protected
|
97
153
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
# create the director pipe if it isn't there already
|
102
|
-
if !File.exists?( @director_pipe_name )
|
103
|
-
system( "mkfifo #{@director_pipe_name}" )
|
104
|
-
end
|
105
|
-
|
106
|
-
# scite already open, so don't launch another instance
|
107
|
-
return if File.exists? @scite_pipe_name
|
108
|
-
|
109
|
-
cmd = <<EOF
|
110
|
-
/usr/bin/scite
|
111
|
-
-ipc.director.name=#{@director_pipe_name}
|
112
|
-
-ipc.scite.name=#{@scite_pipe_name}
|
113
|
-
EOF
|
114
|
-
oneline = cmd.gsub( "\n", " ")
|
115
|
-
child_pid = fork
|
116
|
-
if child_pid.nil?
|
117
|
-
# start the editor and wait for it to end
|
118
|
-
system( oneline )
|
119
|
-
|
120
|
-
# scite ended, so delete the pipes
|
154
|
+
def start_cleanup
|
155
|
+
Thread.new do
|
156
|
+
# wait for Scite to end, and cleanup
|
121
157
|
begin
|
122
|
-
|
123
|
-
|
158
|
+
puts "waiting for scite(#{@scite_pid})" if @options[:debug]
|
159
|
+
Process.wait( @scite_pid )
|
160
|
+
cleanup
|
161
|
+
reset
|
162
|
+
puts "cleaned up scite pipes" if @options[:debug]
|
124
163
|
rescue Exception => e
|
125
|
-
puts e.
|
164
|
+
puts "e: #{e.inspect}"
|
165
|
+
puts e.backtrace
|
126
166
|
end
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
print "listener thread ended: ", e.inspect, "\n"
|
147
|
-
e.backtrace.each { |x| print x, "\n" }
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def start_listener
|
171
|
+
|
172
|
+
sleep 0.1 while !File.exists? @scite_pipe_name
|
173
|
+
|
174
|
+
Thread.new( self ) do |arg|
|
175
|
+
begin
|
176
|
+
arg.listen
|
177
|
+
rescue Errno::ENOENT
|
178
|
+
break
|
179
|
+
rescue Exception => e
|
180
|
+
print "listener thread ended: ", e.inspect, "\n"
|
181
|
+
puts e.backtrace
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
end
|
152
186
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
187
|
+
# respond to strings from scite
|
188
|
+
def listen
|
189
|
+
File.open( @director_pipe_name ).each( "\x0" ) do |line|
|
190
|
+
begin
|
191
|
+
line = line.slice(0...-1) if line[-1] = 0
|
192
|
+
print "heard #{line}\n" if @options[:debug]
|
193
|
+
case line
|
194
|
+
# scite sends one of these for each file opened
|
195
|
+
when /^opened:(.*)$/
|
196
|
+
set_selection( $1 )
|
163
197
|
|
164
|
-
|
165
|
-
|
166
|
-
|
198
|
+
# scite sends one of these each time the buffer is switched
|
199
|
+
when /^switched:(.*)$/
|
200
|
+
set_selection( $1 )
|
167
201
|
|
168
|
-
|
169
|
-
|
170
|
-
|
202
|
+
# response to askfilename, as sent by synchronize_path
|
203
|
+
when /^filename:(.*)$/
|
204
|
+
set_selection( $1 )
|
171
205
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
206
|
+
# the specified file has just been saved. Do nothing.
|
207
|
+
# TODO could check that it exists and add it if not.
|
208
|
+
when /^saved:(.*)$/
|
209
|
+
|
210
|
+
when /^closed$/
|
177
211
|
puts "SciTE closing"
|
178
|
-
|
212
|
+
break
|
179
213
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
214
|
+
# print it out
|
215
|
+
else
|
216
|
+
print "unknown: ", line, "\n" if @options[:debug]
|
217
|
+
end
|
218
|
+
rescue Exception => e
|
219
|
+
print "caught Exception in listen: ", e.inspect, "\n"
|
220
|
+
puts e.backtrace
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
189
224
|
|
190
225
|
end
|
data/lib/hilfer/tree_viewer.rb
CHANGED
@@ -3,6 +3,7 @@ require 'pathname'
|
|
3
3
|
require 'hilfer/hilfer_item.rb'
|
4
4
|
require 'hilfer/scite_editor.rb'
|
5
5
|
require 'hilfer/hilfer_model.rb'
|
6
|
+
require 'hilfer/extensions.rb'
|
6
7
|
|
7
8
|
# try to load Gnome terminal
|
8
9
|
begin
|
@@ -42,15 +43,6 @@ rescue
|
|
42
43
|
HAS_SUBVERSION = false
|
43
44
|
end
|
44
45
|
|
45
|
-
|
46
|
-
module Gdk
|
47
|
-
class EventKey
|
48
|
-
def inspect
|
49
|
-
"#<Gdk::EventKey keycode=#{hardware_keycode} state=#{state.inspect}"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
46
|
=begin
|
55
47
|
This is the tree viewer object. It contains a GtkTreeView
|
56
48
|
and references an editor object. It also contains a HilferItem
|
@@ -148,11 +140,11 @@ class TreeViewer
|
|
148
140
|
|
149
141
|
@view.signal_connect( 'row-expanded' ) do
|
150
142
|
|view, iter, path|
|
151
|
-
|
143
|
+
puts "expanding row: #{iter[0].path}, #{iter[0].populated?}" if $options[:debug]
|
152
144
|
iter[0].status = :expanded
|
153
145
|
child = iter.first_child
|
154
146
|
loop do
|
155
|
-
|
147
|
+
puts "expanded child: #{child[0].path}, #{child[0].populated?}" if $options[:debug]
|
156
148
|
populate( @view.model, child[0], child ) unless child[0].populated?
|
157
149
|
break if !child.next!
|
158
150
|
end
|
@@ -328,14 +320,14 @@ class TreeViewer
|
|
328
320
|
|
329
321
|
# handle keypresses
|
330
322
|
def init_keys
|
331
|
-
@view.signal_connect( 'key-press-event' ) do
|
332
|
-
|
333
|
-
|
323
|
+
@view.signal_connect( 'key-press-event' ) do |widget,event|
|
324
|
+
puts "event: #{event.inspect}" if $options[:debug]
|
325
|
+
|
334
326
|
retval = true
|
335
327
|
case
|
336
328
|
# enter - go into directory
|
337
329
|
# or open all selected files
|
338
|
-
when event.
|
330
|
+
when event.match( /return/i, /enter/i ) && !event.state.control_mask?
|
339
331
|
items = []
|
340
332
|
|
341
333
|
# fetch all selected items
|
@@ -347,7 +339,7 @@ class TreeViewer
|
|
347
339
|
open_action( items )
|
348
340
|
|
349
341
|
# ctrl-enter opens new window with the selected root(s)
|
350
|
-
when event.
|
342
|
+
when event.match( /return/i, /enter/i ) && event.state.control_mask?
|
351
343
|
widget.selection.selected_each do |model, path, iter|
|
352
344
|
new_path =
|
353
345
|
if !iter[0].dir?
|
@@ -362,14 +354,14 @@ class TreeViewer
|
|
362
354
|
end
|
363
355
|
|
364
356
|
# backspace - go up to parent directory
|
365
|
-
when event
|
357
|
+
when event =~ 'BackSpace'
|
366
358
|
# go up one directory
|
367
359
|
temp = Pathname.new( @root_item.path )
|
368
360
|
@root_item.path = temp.parent.realpath.to_s
|
369
361
|
go_into( @root_item.path )
|
370
362
|
|
371
363
|
# del on main keyboard or keypad deletes a file
|
372
|
-
when
|
364
|
+
when event =~ /Delete/
|
373
365
|
iters = []
|
374
366
|
widget.selection.selected_each do |model, path, iter|
|
375
367
|
iters << iter
|
@@ -377,7 +369,7 @@ class TreeViewer
|
|
377
369
|
confirm_delete_files( iters )
|
378
370
|
|
379
371
|
# ctrl-e and F2 edits the file name
|
380
|
-
when
|
372
|
+
when event.match( :e, :f2 ) && event.state.control_mask?
|
381
373
|
# make sure all the files are selected
|
382
374
|
rows = widget.selection.selected_rows
|
383
375
|
rows.each do |path|
|
@@ -391,11 +383,11 @@ class TreeViewer
|
|
391
383
|
end
|
392
384
|
|
393
385
|
# ctrl-d sends some debug/info commands to scite
|
394
|
-
when event.
|
386
|
+
when event.d? && event.state.control_mask? && !event.state.shift_mask?
|
395
387
|
@editor.dump
|
396
388
|
|
397
389
|
# ctrl-b sends the current selection to the editor
|
398
|
-
when event.
|
390
|
+
when event.b? && event.state.control_mask? && !event.state.shift_mask?
|
399
391
|
paths = []
|
400
392
|
widget.selection.selected_each do |model, path, iter|
|
401
393
|
# note use of single quotes
|
@@ -404,7 +396,7 @@ class TreeViewer
|
|
404
396
|
@editor.insert paths
|
405
397
|
|
406
398
|
# ctrl-c copies current selections as text
|
407
|
-
when event.
|
399
|
+
when event.c? && event.state.control_mask? && !event.state.shift_mask?
|
408
400
|
paths = ""
|
409
401
|
|
410
402
|
# fetch all selected items
|
@@ -416,7 +408,7 @@ class TreeViewer
|
|
416
408
|
Gtk::Clipboard.get( Gdk::Selection::CLIPBOARD ).text = paths
|
417
409
|
|
418
410
|
# ctrl-v selects the files in the clipboard
|
419
|
-
when event.
|
411
|
+
when event.v? && event.state.control_mask? && !event.state.shift_mask?
|
420
412
|
text = Gtk::Clipboard.get( Gdk::Selection::CLIPBOARD ).wait_for_text
|
421
413
|
paths = text.strip.split( /\s*\n\s*/ )
|
422
414
|
location_path = Pathname.new( @root_item.path )
|
@@ -428,27 +420,27 @@ class TreeViewer
|
|
428
420
|
select_fs_paths( paths )
|
429
421
|
|
430
422
|
# ctrl-n opens new window with same root
|
431
|
-
when event.
|
423
|
+
when event.n? && event.state.control_mask?
|
432
424
|
TreeViewerWindow.new( @root_item.path, @editor )
|
433
425
|
|
434
426
|
# ctrl-y synchronizes with current editor file
|
435
|
-
when event.
|
427
|
+
when event.y? && event.state.control_mask?
|
436
428
|
# make sure other windows don't synchronize
|
437
429
|
@expecting_synchronize_path = true
|
438
430
|
# ask editor for current file and sync
|
439
431
|
@editor.synchronize_path
|
440
432
|
|
441
433
|
# alt-y toggles automatic synchronization
|
442
|
-
when event.
|
434
|
+
when event.y? && event.state.mod1_mask?
|
443
435
|
@auto_synchronize_path = !@auto_synchronize_path
|
444
436
|
|
445
437
|
# ctrl-r refreshes from filesystem
|
446
|
-
when event.
|
438
|
+
when event.r? && event.state.control_mask?
|
447
439
|
refresh
|
448
440
|
|
449
441
|
# ctrl-t opens a terminal window on the given directorties.
|
450
442
|
# Uses gnome-terminal and opens directories in tabs
|
451
|
-
when event.
|
443
|
+
when event.t? && event.state.control_mask? && !event.state.shift_mask?
|
452
444
|
# collect all unique directories
|
453
445
|
dirs = []
|
454
446
|
widget.selection.selected_each do |model, path, iter|
|
@@ -465,22 +457,22 @@ class TreeViewer
|
|
465
457
|
terminal.launch( dirs )
|
466
458
|
|
467
459
|
# alt-l toggles the location bar
|
468
|
-
when event.
|
460
|
+
when event.l? && event.state.mod1_mask?
|
469
461
|
@location.no_show_all = true
|
470
462
|
@location.visible = !@location.visible?
|
471
463
|
|
472
464
|
# alt-q toggles whether shutdown is automatic or not
|
473
|
-
when event.
|
465
|
+
when event.q? && event.state.mod1_mask?
|
474
466
|
$options[:quit_editor] = !$options[:quit_editor]
|
475
467
|
|
476
468
|
# ctrl-* on keypad means expand the entire tree
|
477
|
-
when event
|
469
|
+
when event =~ 'KP_Multiply' && event.state.control_mask?
|
478
470
|
# 100 levels of directories should be enough...
|
479
471
|
populate( @view.model, @root_item, nil, 100 )
|
480
472
|
@view.expand_all
|
481
473
|
|
482
474
|
# * on keypad means expand subtree
|
483
|
-
when event
|
475
|
+
when event =~ 'KP_Multiply' && event.state.empty?
|
484
476
|
widget.selection.selected_rows.each do |path|
|
485
477
|
iter = @view.model.get_iter( path )
|
486
478
|
if iter[0].dir?
|
@@ -489,11 +481,11 @@ class TreeViewer
|
|
489
481
|
end
|
490
482
|
|
491
483
|
# shift-/ on keypad means collapse the entire tree
|
492
|
-
when event
|
484
|
+
when event =~ 'KP_Divide' && event.state.shift_mask?
|
493
485
|
@view.collapse_all
|
494
486
|
|
495
487
|
# ctrl-left means go to parent
|
496
|
-
when event
|
488
|
+
when event =~ /left$/i && event.state.control_mask?
|
497
489
|
widget.selection.selected_each do |model, path, iter|
|
498
490
|
if iter.parent != nil
|
499
491
|
iter.parent[0].last_child_used = path
|
@@ -505,7 +497,7 @@ class TreeViewer
|
|
505
497
|
end
|
506
498
|
|
507
499
|
# ctrl-right means go to last used path, or first child
|
508
|
-
when event.
|
500
|
+
when event.right? && event.state.control_mask?
|
509
501
|
widget.selection.selected_each do |model, path, iter|
|
510
502
|
if iter[0].dir?
|
511
503
|
widget.expand_row( iter.path, false )
|
@@ -521,7 +513,7 @@ class TreeViewer
|
|
521
513
|
end
|
522
514
|
|
523
515
|
# ctrl-up means go to previous sibling with children
|
524
|
-
when event.
|
516
|
+
when event.up? && event.state.control_mask?
|
525
517
|
widget.selection.selected_each do |model, path, iter|
|
526
518
|
if iter[0].dir?
|
527
519
|
while path.prev!
|
@@ -537,7 +529,7 @@ class TreeViewer
|
|
537
529
|
end
|
538
530
|
|
539
531
|
# ctrl-down means go to next sibling with children
|
540
|
-
when event.
|
532
|
+
when event.down? && event.state.control_mask?
|
541
533
|
widget.selection.selected_each do |model, path, iter|
|
542
534
|
if iter[0].dir?
|
543
535
|
while iter.next!
|
@@ -560,7 +552,7 @@ class TreeViewer
|
|
560
552
|
end
|
561
553
|
|
562
554
|
# shift-left means select parent
|
563
|
-
when event.
|
555
|
+
when event.left? && event.state.shift_mask?
|
564
556
|
widget.selection.selected_each do |model, path, iter|
|
565
557
|
if iter.parent != nil
|
566
558
|
select_children( widget, iter.parent )
|
@@ -568,7 +560,7 @@ class TreeViewer
|
|
568
560
|
end
|
569
561
|
|
570
562
|
# shift-right means select children
|
571
|
-
when event.
|
563
|
+
when event.right? && event.state.shift_mask?
|
572
564
|
widget.selection.selected_each do |model, path, iter|
|
573
565
|
if iter[0].dir?
|
574
566
|
select_children( widget, iter )
|
@@ -576,13 +568,13 @@ class TreeViewer
|
|
576
568
|
end
|
577
569
|
|
578
570
|
# left means close level(s)
|
579
|
-
when event.
|
571
|
+
when event.left? && event.state.empty?
|
580
572
|
widget.selection.selected_each do |model, path, iter|
|
581
573
|
widget.collapse_row( path ) if iter[0].dir?
|
582
574
|
end
|
583
575
|
|
584
576
|
# right means open level(s)
|
585
|
-
when event.
|
577
|
+
when event.right?
|
586
578
|
widget.selection.selected_each do
|
587
579
|
|model, path, iter|
|
588
580
|
# false means don't expand children
|
@@ -595,7 +587,7 @@ class TreeViewer
|
|
595
587
|
# pass keypress to all locators
|
596
588
|
@locators.each {|x| retval = x.handle_keypress( widget, event ) and retval }
|
597
589
|
if $options[:debug] && !retval
|
598
|
-
|
590
|
+
puts "not handled"
|
599
591
|
end
|
600
592
|
end
|
601
593
|
retval
|
@@ -825,7 +817,7 @@ class TreeViewer
|
|
825
817
|
# recursively populate files, so the TreeView
|
826
818
|
# knows to draw the expanders
|
827
819
|
if ( ( File.directory?( next_item_path ) && level < levels_to_populate ) || iter[0].expanded? )
|
828
|
-
|
820
|
+
puts "populating level #{level} #{iter[0].path}" if $options[:debug]
|
829
821
|
# populate children
|
830
822
|
populate( model, iter[0], iter, levels_to_populate, level + 1 )
|
831
823
|
end
|
@@ -833,8 +825,8 @@ class TreeViewer
|
|
833
825
|
rescue Errno::EACCES
|
834
826
|
# mostly to protect against permissions errors
|
835
827
|
rescue Exception => ex
|
836
|
-
|
837
|
-
ex.backtrace
|
828
|
+
puts "caught exception: #{ex} #{ex.class}"
|
829
|
+
puts ex.backtrace
|
838
830
|
end
|
839
831
|
|
840
832
|
end
|
@@ -9,15 +9,15 @@ class TreeViewerWindow
|
|
9
9
|
|
10
10
|
def initialize( root_fs_path, editor )
|
11
11
|
@window = Gtk::Window.new
|
12
|
-
|
12
|
+
|
13
13
|
# initialize viewer with a path
|
14
14
|
@editor = editor
|
15
|
-
|
15
|
+
|
16
16
|
# location bar
|
17
17
|
@location = Gtk::Entry.new
|
18
|
-
|
18
|
+
|
19
19
|
@tv = TreeViewer.new( root_fs_path, editor, @window, @location )
|
20
|
-
|
20
|
+
|
21
21
|
# add scrollbars
|
22
22
|
@scroll = Gtk::ScrolledWindow.new( nil, nil )
|
23
23
|
@scroll.set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC )
|
data/lib/hilfer/version.rb
CHANGED