hilfer 0.11.3 → 0.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/lib/hilfer/tree_viewer.rb +58 -54
- data/lib/hilfer/version.rb +1 -1
- metadata +7 -7
data/History.txt
CHANGED
data/lib/hilfer/tree_viewer.rb
CHANGED
@@ -50,7 +50,7 @@ which is the root node of the tree, but it's never displayed
|
|
50
50
|
=end
|
51
51
|
class TreeViewer
|
52
52
|
include SvnColours if HAS_SUBVERSION
|
53
|
-
|
53
|
+
|
54
54
|
attr_reader :view, :editor, :root_item
|
55
55
|
|
56
56
|
# Can pass in $options[:terminal] => some_terminal
|
@@ -65,13 +65,17 @@ class TreeViewer
|
|
65
65
|
# these need to be window-local
|
66
66
|
@expecting_synchronize_path = false
|
67
67
|
@auto_synchronize_path = $options[:auto_sync]
|
68
|
-
|
68
|
+
|
69
|
+
path = Pathname.new( path )
|
70
|
+
path = path.parent while !path.directory?
|
71
|
+
|
72
|
+
@root_item = HilferItem.new( '', path.to_s )
|
69
73
|
# TODO this shuold be in set_root or something like that
|
70
74
|
@location.text = @root_item.path
|
71
75
|
@location.select_region(0,0)
|
72
76
|
@location.position = -1
|
73
77
|
@hilfer_items = {}
|
74
|
-
|
78
|
+
|
75
79
|
# locators are things that provide a set of shortcut keys
|
76
80
|
# to jump to specific directories, files, or related locations
|
77
81
|
@locators = []
|
@@ -227,10 +231,10 @@ class TreeViewer
|
|
227
231
|
editable && editable.signal_connect("editing-done") do |widget|
|
228
232
|
# Fetch the HilferItem
|
229
233
|
item = @view.model.get_iter(path)[0]
|
230
|
-
|
234
|
+
|
231
235
|
# make the new file name, in full
|
232
236
|
new_path = ( Pathname.new( item.path ).parent + editable.text )
|
233
|
-
|
237
|
+
|
234
238
|
# rename the file if it's renameable
|
235
239
|
if editable.text != item.item && !File.exists?( new_path.to_s )
|
236
240
|
# rename the file
|
@@ -246,10 +250,10 @@ class TreeViewer
|
|
246
250
|
end
|
247
251
|
true
|
248
252
|
end
|
249
|
-
|
253
|
+
|
250
254
|
true
|
251
255
|
end
|
252
|
-
|
256
|
+
|
253
257
|
@view.append_column( column )
|
254
258
|
end
|
255
259
|
|
@@ -279,7 +283,7 @@ class TreeViewer
|
|
279
283
|
def confirm_delete_files( iters )
|
280
284
|
msg = "Are you sure you want to delete\n"
|
281
285
|
iters.each { |it| msg += it[0].path + "\n" }
|
282
|
-
|
286
|
+
|
283
287
|
confirm = Gtk::MessageDialog.new(
|
284
288
|
@window,
|
285
289
|
Gtk::Dialog::Flags::MODAL,
|
@@ -299,7 +303,7 @@ class TreeViewer
|
|
299
303
|
true
|
300
304
|
end
|
301
305
|
end
|
302
|
-
|
306
|
+
|
303
307
|
# actually delete the files
|
304
308
|
confirm.run do |response|
|
305
309
|
delete_files( iters ) if response == Gtk::Dialog::RESPONSE_YES
|
@@ -317,32 +321,32 @@ class TreeViewer
|
|
317
321
|
end
|
318
322
|
end
|
319
323
|
end
|
320
|
-
|
324
|
+
|
321
325
|
# handle keypresses
|
322
326
|
# TODO use HandlerDefn
|
323
327
|
def init_keys
|
324
328
|
@view.signal_connect( 'key-press-event' ) do |widget,event|
|
325
329
|
puts "event: #{event.inspect}" if $options[:debug]
|
326
|
-
|
330
|
+
|
327
331
|
retval = true
|
328
332
|
case
|
329
333
|
# enter - go into directory
|
330
334
|
# or open all selected files
|
331
335
|
when event.match( /return/i, /enter/i ) && !event.state.control_mask?
|
332
336
|
items = []
|
333
|
-
|
337
|
+
|
334
338
|
# fetch all selected items
|
335
339
|
widget.selection.selected_each do |model, path, iter|
|
336
340
|
items << model.get_value( iter, 0 )
|
337
341
|
end
|
338
|
-
|
342
|
+
|
339
343
|
# go into if the first item is a directory
|
340
344
|
open_action( items )
|
341
|
-
|
345
|
+
|
342
346
|
# ctrl-enter opens new window with the selected root(s)
|
343
347
|
when event.match( /return/i, /enter/i ) && event.state.control_mask?
|
344
348
|
widget.selection.selected_each do |model, path, iter|
|
345
|
-
new_path =
|
349
|
+
new_path =
|
346
350
|
if !iter[0].dir?
|
347
351
|
# open the directory this file lives in
|
348
352
|
# unless we're already in that directory
|
@@ -353,14 +357,14 @@ class TreeViewer
|
|
353
357
|
end
|
354
358
|
TreeViewerWindow.new( new_path, @editor ) unless new_path.nil?
|
355
359
|
end
|
356
|
-
|
360
|
+
|
357
361
|
# backspace - go up to parent directory
|
358
362
|
when event =~ 'BackSpace'
|
359
363
|
# go up one directory
|
360
364
|
temp = Pathname.new( @root_item.path )
|
361
365
|
@root_item.path = temp.parent.realpath.to_s
|
362
366
|
go_into( @root_item.path )
|
363
|
-
|
367
|
+
|
364
368
|
# del on main keyboard or keypad deletes a file
|
365
369
|
when event =~ /Delete/
|
366
370
|
iters = []
|
@@ -368,7 +372,7 @@ class TreeViewer
|
|
368
372
|
iters << iter
|
369
373
|
end
|
370
374
|
confirm_delete_files( iters )
|
371
|
-
|
375
|
+
|
372
376
|
# ctrl-e and F2 edits the file name
|
373
377
|
when ( event.e? && event.state.control_mask? ) || event.f2?
|
374
378
|
# make sure all the files are selected
|
@@ -382,11 +386,11 @@ class TreeViewer
|
|
382
386
|
# the rest of the work is done in the renderer's handler.
|
383
387
|
@text_renderer.editable = false
|
384
388
|
end
|
385
|
-
|
389
|
+
|
386
390
|
# ctrl-d sends some debug/info commands to scite
|
387
391
|
when event.d? && event.state.control_mask? && !event.state.shift_mask?
|
388
392
|
@editor.dump
|
389
|
-
|
393
|
+
|
390
394
|
# ctrl-b sends the current selection to the editor
|
391
395
|
when event.b? && event.state.control_mask? && !event.state.shift_mask?
|
392
396
|
paths = []
|
@@ -395,20 +399,20 @@ class TreeViewer
|
|
395
399
|
paths << model.get_value( iter, 0 ).path
|
396
400
|
end
|
397
401
|
@editor.insert paths
|
398
|
-
|
402
|
+
|
399
403
|
# ctrl-c copies current selections as text
|
400
404
|
when event.c? && event.state.control_mask? && !event.state.shift_mask?
|
401
405
|
paths = []
|
402
|
-
|
406
|
+
|
403
407
|
# fetch all selected items
|
404
408
|
# don't use a join here so we get a trailing newline
|
405
409
|
widget.selection.selected_each do |model, path, iter|
|
406
410
|
paths << model.get_value( iter, 0 ).path
|
407
411
|
end
|
408
|
-
|
412
|
+
|
409
413
|
Gtk::Clipboard.get( Gdk::Selection::CLIPBOARD ).text = paths.join("\n")
|
410
|
-
|
411
|
-
# ctrl-v selects the files in the clipboard
|
414
|
+
|
415
|
+
# ctrl-v selects the files in the clipboard
|
412
416
|
when event.v? && event.state.control_mask? && !event.state.shift_mask?
|
413
417
|
text = Gtk::Clipboard.get( Gdk::Selection::CLIPBOARD ).wait_for_text
|
414
418
|
paths = text.strip.split( /\s*\n\s*/ )
|
@@ -419,18 +423,18 @@ class TreeViewer
|
|
419
423
|
( fullpath.exist? ? fullpath : x ).to_s
|
420
424
|
end
|
421
425
|
select_fs_paths( paths )
|
422
|
-
|
426
|
+
|
423
427
|
# ctrl-n opens new window with same root
|
424
428
|
when event.n? && event.state.control_mask?
|
425
429
|
TreeViewerWindow.new( @root_item.path, @editor )
|
426
|
-
|
430
|
+
|
427
431
|
# ctrl-y synchronizes with current editor file
|
428
432
|
when event.y? && event.state.control_mask?
|
429
433
|
# make sure other windows don't synchronize
|
430
434
|
@expecting_synchronize_path = true
|
431
435
|
# ask editor for current file and sync
|
432
436
|
@editor.synchronize_path
|
433
|
-
|
437
|
+
|
434
438
|
# alt-y toggles automatic synchronization
|
435
439
|
when event.y? && event.state.mod1_mask?
|
436
440
|
@auto_synchronize_path = !@auto_synchronize_path
|
@@ -438,7 +442,7 @@ class TreeViewer
|
|
438
442
|
# ctrl-r refreshes from filesystem
|
439
443
|
when event.r? && event.state.control_mask?
|
440
444
|
refresh
|
441
|
-
|
445
|
+
|
442
446
|
# ctrl-t opens a terminal window on the given directories.
|
443
447
|
# Uses gnome-terminal and opens directories in tabs
|
444
448
|
when event.t? && event.state.control_mask? && !event.state.shift_mask?
|
@@ -456,22 +460,22 @@ class TreeViewer
|
|
456
460
|
end
|
457
461
|
end
|
458
462
|
terminal.launch( dirs )
|
459
|
-
|
463
|
+
|
460
464
|
# alt-l toggles the location bar
|
461
465
|
when event.l? && event.state.mod1_mask?
|
462
466
|
@location.no_show_all = true
|
463
467
|
@location.visible = !@location.visible?
|
464
|
-
|
468
|
+
|
465
469
|
# alt-q toggles whether shutdown is automatic or not
|
466
470
|
when event.q? && event.state.mod1_mask?
|
467
471
|
$options[:quit_editor] = !$options[:quit_editor]
|
468
|
-
|
472
|
+
|
469
473
|
# ctrl-* on keypad means expand the entire tree
|
470
474
|
when event =~ 'KP_Multiply' && event.state.control_mask?
|
471
475
|
# 100 levels of directories should be enough...
|
472
476
|
populate( @view.model, @root_item, nil, 100 )
|
473
477
|
@view.expand_all
|
474
|
-
|
478
|
+
|
475
479
|
# * on keypad means expand subtree
|
476
480
|
when event =~ 'KP_Multiply' && event.state.empty?
|
477
481
|
widget.selection.selected_rows.each do |path|
|
@@ -480,11 +484,11 @@ class TreeViewer
|
|
480
484
|
expand_dir( widget, path, iter )
|
481
485
|
end
|
482
486
|
end
|
483
|
-
|
487
|
+
|
484
488
|
# shift-/ on keypad means collapse the entire tree
|
485
489
|
when event =~ 'KP_Divide' && event.state.shift_mask?
|
486
490
|
@view.collapse_all
|
487
|
-
|
491
|
+
|
488
492
|
# ctrl-left means go to parent
|
489
493
|
when event =~ /left$/i && event.state.control_mask?
|
490
494
|
widget.selection.selected_each do |model, path, iter|
|
@@ -492,11 +496,11 @@ class TreeViewer
|
|
492
496
|
iter.parent[0].last_child_used = path
|
493
497
|
select_iter( iter.parent )
|
494
498
|
end
|
495
|
-
|
499
|
+
|
496
500
|
# only do the first one
|
497
501
|
break
|
498
502
|
end
|
499
|
-
|
503
|
+
|
500
504
|
# ctrl-right means go to last used path, or first child
|
501
505
|
when event.right? && event.state.control_mask?
|
502
506
|
widget.selection.selected_each do |model, path, iter|
|
@@ -508,11 +512,11 @@ class TreeViewer
|
|
508
512
|
select_iter( iter.first_child )
|
509
513
|
end
|
510
514
|
end
|
511
|
-
|
515
|
+
|
512
516
|
# only do the first one
|
513
517
|
break
|
514
518
|
end
|
515
|
-
|
519
|
+
|
516
520
|
# ctrl-up means go to previous sibling with children
|
517
521
|
when event.up? && event.state.control_mask?
|
518
522
|
widget.selection.selected_each do |model, path, iter|
|
@@ -528,7 +532,7 @@ class TreeViewer
|
|
528
532
|
end
|
529
533
|
break
|
530
534
|
end
|
531
|
-
|
535
|
+
|
532
536
|
# ctrl-down means go to next sibling with children
|
533
537
|
when event.down? && event.state.control_mask?
|
534
538
|
widget.selection.selected_each do |model, path, iter|
|
@@ -581,7 +585,7 @@ class TreeViewer
|
|
581
585
|
# false means don't expand children
|
582
586
|
widget.expand_row( path, false )
|
583
587
|
end
|
584
|
-
|
588
|
+
|
585
589
|
else
|
586
590
|
# indicate signal not handled
|
587
591
|
retval = false
|
@@ -594,7 +598,7 @@ class TreeViewer
|
|
594
598
|
retval
|
595
599
|
end
|
596
600
|
end
|
597
|
-
|
601
|
+
|
598
602
|
def expand_dir( widget, path, iter )
|
599
603
|
# make sure all directories in subtree are populated
|
600
604
|
populate( @view.model, iter[0], iter, 100 )
|
@@ -611,7 +615,7 @@ class TreeViewer
|
|
611
615
|
paths << cur.clone
|
612
616
|
cur.up!
|
613
617
|
end
|
614
|
-
|
618
|
+
|
615
619
|
# now open the necessary paths from the top down
|
616
620
|
# false is don't open all children
|
617
621
|
paths.reverse.each do |x|
|
@@ -619,18 +623,18 @@ class TreeViewer
|
|
619
623
|
@view.selection.unselect_path( x )
|
620
624
|
end
|
621
625
|
end
|
622
|
-
|
626
|
+
|
623
627
|
def unselect_all
|
624
628
|
@view.selection.unselect_all
|
625
629
|
end
|
626
|
-
|
630
|
+
|
627
631
|
def select_children( widget, iter )
|
628
632
|
widget.expand_row( iter.path, false )
|
629
633
|
(0...iter.n_children).each do |index|
|
630
634
|
select_iter( iter.nth_child( index ), false, false )
|
631
635
|
end
|
632
636
|
end
|
633
|
-
|
637
|
+
|
634
638
|
# set selection and cursor to the given GtkTreeModel path
|
635
639
|
def select_path( path, unselect = true, set_cursor = true )
|
636
640
|
unselect_all if unselect
|
@@ -650,7 +654,7 @@ class TreeViewer
|
|
650
654
|
# path, column, use_align, row_align, col_align
|
651
655
|
@view.scroll_to_cell( iter.path, nil, true, 0.5, 0.0 )
|
652
656
|
end
|
653
|
-
|
657
|
+
|
654
658
|
# Set selection to the given filesystem path.
|
655
659
|
# TODO could optimise this to select faster if we
|
656
660
|
# use directory names. Possibly also use select_iter if it's faster
|
@@ -678,13 +682,13 @@ class TreeViewer
|
|
678
682
|
@view.set_cursor( iter.path, nil, false )
|
679
683
|
cursor_set = true
|
680
684
|
end
|
681
|
-
|
685
|
+
|
682
686
|
select_iter( iter, false, false )
|
683
687
|
end
|
684
688
|
end
|
685
|
-
|
689
|
+
|
686
690
|
end
|
687
|
-
|
691
|
+
|
688
692
|
def select_first
|
689
693
|
# set first item as selected
|
690
694
|
@view.selection.select_path Gtk::TreePath.new( '0' )
|
@@ -700,7 +704,7 @@ class TreeViewer
|
|
700
704
|
@expecting_synchronize_path = false
|
701
705
|
end
|
702
706
|
end
|
703
|
-
|
707
|
+
|
704
708
|
# called from open_action when we don't want the auto-centering
|
705
709
|
# to do its thing.
|
706
710
|
def no_synchronize
|
@@ -709,7 +713,7 @@ class TreeViewer
|
|
709
713
|
yield @editor
|
710
714
|
@auto_synchronize_path = save
|
711
715
|
end
|
712
|
-
|
716
|
+
|
713
717
|
# called from the keyboard handler on enter
|
714
718
|
# and the double-click handler to
|
715
719
|
# open files or go into a directory
|
@@ -777,13 +781,13 @@ class TreeViewer
|
|
777
781
|
{}
|
778
782
|
end
|
779
783
|
end
|
780
|
-
|
784
|
+
|
781
785
|
# populate the model from the filesystem
|
782
786
|
# by default populate only 1 level down
|
783
787
|
def populate( model, item, parent_iter, levels_to_populate = 1, level = 0 )
|
784
788
|
iter = nil
|
785
789
|
path_colours = do_compute_colours( item )
|
786
|
-
|
790
|
+
|
787
791
|
Dir.new( item.path ).entries.sort.each do |x|
|
788
792
|
begin
|
789
793
|
# ignore directory entries
|
data/lib/hilfer/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hilfer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,23 +9,23 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-08-16 00:00:00.000000000 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: gtk2
|
17
|
-
requirement: &
|
17
|
+
requirement: &79176550 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.
|
22
|
+
version: 1.0.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *79176550
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: bones
|
28
|
-
requirement: &
|
28
|
+
requirement: &79176270 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: 3.7.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *79176270
|
37
37
|
description: Programmers file browser for SciTE
|
38
38
|
email: panic@semiosix.com
|
39
39
|
executables:
|