hilfer 0.9.1 → 0.9.2
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 +48 -0
- data/Manifest.txt +7 -0
- data/README.txt +9 -2
- data/Rakefile +4 -5
- data/TODO +6 -2
- data/bin/hilfer +12 -222
- data/bin/ssc +24 -13
- data/lib/hilfer/gnome_terminal.rb +22 -0
- data/lib/hilfer/hilfer_config.rb +35 -0
- data/lib/hilfer/hilfer_item.rb +50 -0
- data/lib/hilfer/hilfer_model.rb +12 -0
- data/lib/hilfer/rails_locator.rb +1 -0
- data/lib/hilfer/svn_colours.rb +1 -0
- data/lib/hilfer/tree_viewer.rb +64 -23
- data/lib/hilfer/tree_viewer_window.rb +87 -0
- data/lib/hilfer/version.rb +3 -0
- data/lib/hilfer/xterm.rb +15 -0
- metadata +10 -3
data/History.txt
CHANGED
@@ -1,3 +1,51 @@
|
|
1
|
+
2008-04-10 12:27 panic
|
2
|
+
|
3
|
+
* [r3475] trunk/History.txt, trunk/Manifest.txt, trunk/README.txt,
|
4
|
+
trunk/Rakefile, trunk/TODO, trunk/bin/hilfer, trunk/bin/ssc,
|
5
|
+
trunk/lib/hilfer/gnome_terminal.rb,
|
6
|
+
trunk/lib/hilfer/hilfer_config.rb,
|
7
|
+
trunk/lib/hilfer/hilfer_item.rb,
|
8
|
+
trunk/lib/hilfer/hilfer_model.rb,
|
9
|
+
trunk/lib/hilfer/rails_locator.rb,
|
10
|
+
trunk/lib/hilfer/svn_colours.rb,
|
11
|
+
trunk/lib/hilfer/tree_viewer.rb,
|
12
|
+
trunk/lib/hilfer/tree_viewer_window.rb,
|
13
|
+
trunk/lib/hilfer/version.rb, trunk/lib/hilfer/xterm.rb:
|
14
|
+
Implement graceful failure for optional dependencies. Move
|
15
|
+
classes to separate files.
|
16
|
+
|
17
|
+
2008-04-02 08:21 panic
|
18
|
+
|
19
|
+
* [r3457] trunk/lib/hilfer/tree_viewer.rb:
|
20
|
+
alt-q toggles editor shutdown
|
21
|
+
|
22
|
+
2008-04-01 21:28 panic
|
23
|
+
|
24
|
+
* [r3456] trunk/Rakefile, trunk/bin/hilfer,
|
25
|
+
trunk/lib/hilfer/svn_colours.rb,
|
26
|
+
trunk/lib/hilfer/tree_viewer.rb:
|
27
|
+
allow loading of svn/client to fail gracefully. output modifier
|
28
|
+
mask in debug. Don't use -w, because of all the activerecord
|
29
|
+
verbiage.
|
30
|
+
|
31
|
+
2008-04-01 20:21 panic
|
32
|
+
|
33
|
+
* [r3455] trunk/README.txt:
|
34
|
+
link to RubyForge project from docs pages
|
35
|
+
|
36
|
+
2008-04-01 18:37 panic
|
37
|
+
|
38
|
+
* [r3454] trunk/History.txt, trunk/Rakefile:
|
39
|
+
dependencies were the wrong way round
|
40
|
+
|
41
|
+
2008-04-01 18:18 panic
|
42
|
+
|
43
|
+
* [r3453] trunk/Rakefile:
|
44
|
+
bump version
|
45
|
+
* [r3452] trunk/Rakefile, trunk/bin/hilfer,
|
46
|
+
trunk/lib/hilfer/tree_viewer.rb:
|
47
|
+
ruby-gtk is not a gem. find icon properly. fix enter key.
|
48
|
+
|
1
49
|
2008-04-01 15:31 panic
|
2
50
|
|
3
51
|
* [r3451] trunk, trunk/History.txt, trunk/Manifest.txt,
|
data/Manifest.txt
CHANGED
@@ -5,8 +5,15 @@ Rakefile
|
|
5
5
|
TODO
|
6
6
|
bin/hilfer
|
7
7
|
bin/ssc
|
8
|
+
lib/hilfer/gnome_terminal.rb
|
8
9
|
lib/hilfer/hilfer-icon.png
|
10
|
+
lib/hilfer/hilfer_config.rb
|
11
|
+
lib/hilfer/hilfer_item.rb
|
12
|
+
lib/hilfer/hilfer_model.rb
|
9
13
|
lib/hilfer/rails_locator.rb
|
10
14
|
lib/hilfer/scite_editor.rb
|
11
15
|
lib/hilfer/svn_colours.rb
|
12
16
|
lib/hilfer/tree_viewer.rb
|
17
|
+
lib/hilfer/tree_viewer_window.rb
|
18
|
+
lib/hilfer/version.rb
|
19
|
+
lib/hilfer/xterm.rb
|
data/README.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= hilfer
|
2
2
|
|
3
|
-
|
3
|
+
Download from RubyForge: http://www.rubyforge.org/projects/hilfer
|
4
4
|
|
5
5
|
== DESCRIPTION:
|
6
6
|
|
@@ -95,7 +95,14 @@ See TODO file
|
|
95
95
|
|
96
96
|
== REQUIREMENTS:
|
97
97
|
|
98
|
-
ruby-gtk2
|
98
|
+
* ruby-gtk2
|
99
|
+
|
100
|
+
=== Optional packages
|
101
|
+
|
102
|
+
* text-format for ssc to display extended scite director commands
|
103
|
+
* subversion-ruby to display colour highlighted subversion status
|
104
|
+
* gnome-terminal executable
|
105
|
+
* ActiveSupport to enable rails-specific shortcuts
|
99
106
|
|
100
107
|
== INSTALL:
|
101
108
|
|
data/Rakefile
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake/clean'
|
3
3
|
require 'hoe'
|
4
|
+
require 'lib/hilfer/version.rb'
|
4
5
|
|
5
|
-
Hoe.new('hilfer',
|
6
|
+
Hoe.new('hilfer', Hilfer::VERSION) do |s|
|
6
7
|
s.author = "John Anderson"
|
7
8
|
s.email = "john at semiosix dot com"
|
8
9
|
s.extra_deps = [ 'text-format' ]
|
@@ -11,7 +12,7 @@ end
|
|
11
12
|
desc "Runs Hilfer"
|
12
13
|
task :run do |t|
|
13
14
|
ARGV.shift()
|
14
|
-
exec "ruby -
|
15
|
+
exec "ruby -Ilib bin/hilfer -dq #{ARGV.join(' ')}"
|
15
16
|
end
|
16
17
|
|
17
18
|
desc 'Runs irb in this project\'s context'
|
@@ -21,8 +22,6 @@ task :irb do |t|
|
|
21
22
|
exec "irb -Ilib"
|
22
23
|
end
|
23
24
|
|
24
|
-
task :svn2cl do |t|
|
25
|
+
task :svn2cl => :docs do |t|
|
25
26
|
`svn2cl -i --break-before-msg -o History.txt`
|
26
27
|
end
|
27
|
-
|
28
|
-
task :docs => :svn2cl
|
data/TODO
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
switch focus to editor when opening files
|
2
|
-
check for svn ruby requires
|
3
|
-
* and / not working properly - wait for HilferModel in c. Might never happen.
|
4
2
|
working sets, like eclipse
|
5
3
|
option to connect to existing scite
|
6
4
|
Sort by directories, then files. Needs Options.
|
@@ -14,6 +12,7 @@ HilferWindow < Gtk::Window?
|
|
14
12
|
Separate HilferFileItem and HilferDirItem?
|
15
13
|
Auto Refresh from filesystem - FileWatcher
|
16
14
|
flatten view
|
15
|
+
filter view
|
17
16
|
Handle Ctrl-C to save status and options
|
18
17
|
move files (drag & drop)
|
19
18
|
filters for file types (TreeModelFilter)
|
@@ -25,6 +24,11 @@ Options dialog
|
|
25
24
|
consolidate model in HilferModel? Not sure if it's worth it.
|
26
25
|
use Pathname for HilferItem
|
27
26
|
|
27
|
+
Model issues
|
28
|
+
------------
|
29
|
+
locators don't work unless directories have already been opened.
|
30
|
+
* and / not working properly
|
31
|
+
|
28
32
|
Maybe
|
29
33
|
-----
|
30
34
|
|
data/bin/hilfer
CHANGED
@@ -1,10 +1,5 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
|
3
|
-
require 'yaml'
|
4
|
-
require 'pathname'
|
5
|
-
|
6
|
-
require 'hilfer/tree_viewer.rb'
|
7
|
-
|
8
3
|
require 'optparse'
|
9
4
|
|
10
5
|
# defaults
|
@@ -31,229 +26,24 @@ if $options[:debug]
|
|
31
26
|
end
|
32
27
|
|
33
28
|
# this must come after options parsing or it tries to eat the options
|
34
|
-
|
29
|
+
begin
|
30
|
+
require 'gtk2'
|
31
|
+
rescue LoadError
|
32
|
+
puts <<EOF
|
33
|
+
ruby-gtk2 not available.
|
34
|
+
The official site is http://ruby-gnome2.sourceforge.jp
|
35
|
+
EOF
|
36
|
+
exit( 1 )
|
37
|
+
end
|
38
|
+
|
39
|
+
require 'hilfer/tree_viewer_window.rb'
|
40
|
+
require 'hilfer/scite_editor.rb'
|
35
41
|
|
36
42
|
# NOTE no space after comma, trailing comma is so
|
37
43
|
# that bold, italic etc and font size can be specified
|
38
44
|
FIXED_FONT = "Lucida Console,Courier New,"
|
39
45
|
CONFIG_FILE = File.expand_path( '~/.hilfer' )
|
40
46
|
|
41
|
-
=begin rdoc
|
42
|
-
HilferItems are stored in the TreeModel
|
43
|
-
- item is the display name (ie filename and extension)
|
44
|
-
- path is the full pathname, expanded, unqualified etc etc
|
45
|
-
- last_child_used is the GtkTreeView path of the last child of a directory
|
46
|
-
node that had selection
|
47
|
-
- status is either :expanded or :collapsed
|
48
|
-
- populated is whether or not this directory node has been populated
|
49
|
-
from the filesystem. To aid in recursively populating the tree
|
50
|
-
=end
|
51
|
-
class HilferItem
|
52
|
-
attr_accessor :item, :path, :last_child_used, :status, :svn_status, :colour
|
53
|
-
attr_writer :populated
|
54
|
-
|
55
|
-
def initialize( item, path )
|
56
|
-
@item = item
|
57
|
-
@path = path
|
58
|
-
@dir = File.directory? path
|
59
|
-
@populated = false
|
60
|
-
@status = :collapsed
|
61
|
-
@colour = '#000'
|
62
|
-
end
|
63
|
-
|
64
|
-
def dir?
|
65
|
-
@dir
|
66
|
-
end
|
67
|
-
|
68
|
-
def to_s
|
69
|
-
@item
|
70
|
-
end
|
71
|
-
|
72
|
-
# always return true for file nodes
|
73
|
-
def populated?
|
74
|
-
if !dir?
|
75
|
-
true
|
76
|
-
else
|
77
|
-
@populated
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
# always return false for file nodes
|
82
|
-
def expanded?
|
83
|
-
if !dir?
|
84
|
-
false
|
85
|
-
else
|
86
|
-
@status == :expanded
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
end
|
91
|
-
|
92
|
-
=begin rdoc
|
93
|
-
Knows how to lauch gnome-terminal with mutiple tabs,
|
94
|
-
each opened on a different directory
|
95
|
-
=end
|
96
|
-
class GnomeTerminal
|
97
|
-
def launch( dirs )
|
98
|
-
# construct arguments and launch
|
99
|
-
args = [ "gnome-terminal" ]
|
100
|
-
dirs.uniq.each do |x|
|
101
|
-
# first one will be a window, subsequent ones are tabs
|
102
|
-
args << ( args.size == 1 ? '--window' : '--tab' )
|
103
|
-
args << "--working-directory=#{x}"
|
104
|
-
end
|
105
|
-
system( *args )
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
=begin rdoc
|
110
|
-
Just launches xterm. I couldn't figure out how to open it in different
|
111
|
-
directories.
|
112
|
-
|
113
|
-
use it by saying
|
114
|
-
|
115
|
-
$options[:terminal] = Xterm.new
|
116
|
-
|
117
|
-
before the call to TreeViewer.new
|
118
|
-
=end
|
119
|
-
class Xterm
|
120
|
-
def launch( dirs )
|
121
|
-
system( 'xterm &' )
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
# yes, this actually does catch method calls polymorphically
|
126
|
-
# but you can't change the TreePath or TreeIter that are returned
|
127
|
-
class HilferModel < Gtk::TreeStore
|
128
|
-
def initialize( *args )
|
129
|
-
super
|
130
|
-
end
|
131
|
-
|
132
|
-
def ancestor?( iter, descendant )
|
133
|
-
print "testing #{iter[0]} against #{descendant}\n" if $options[:debug]
|
134
|
-
super
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
=begin rdoc
|
139
|
-
Read and write configuration to ~/.hilfer in yaml.
|
140
|
-
Currently only writes window position
|
141
|
-
=end
|
142
|
-
class HilferConfig
|
143
|
-
|
144
|
-
def initialize( file, window, count )
|
145
|
-
@file, @window = file, window
|
146
|
-
|
147
|
-
if File.file? CONFIG_FILE
|
148
|
-
config = YAML.load_file CONFIG_FILE
|
149
|
-
@window.set_default_size( *config[:size] )
|
150
|
-
@window.show_all
|
151
|
-
# move must be after show_all otherwise it
|
152
|
-
# gets overridden
|
153
|
-
@window.move( *config[:position] ) if count == 1
|
154
|
-
else
|
155
|
-
@window.set_default_size( 300,700 ).show_all
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
# save config
|
160
|
-
def save
|
161
|
-
config = {
|
162
|
-
:path => @window.title,
|
163
|
-
:position => @window.position,
|
164
|
-
:size => @window.size
|
165
|
-
}
|
166
|
-
File.open( CONFIG_FILE, 'w' ) { |file| file.print config.to_yaml }
|
167
|
-
end
|
168
|
-
|
169
|
-
end
|
170
|
-
|
171
|
-
=begin rdoc
|
172
|
-
Layout of the Tree Viewer Window.
|
173
|
-
=end
|
174
|
-
class TreeViewerWindow
|
175
|
-
@@window_count = 0
|
176
|
-
|
177
|
-
def initialize( root_fs_path, editor )
|
178
|
-
@window = Gtk::Window.new
|
179
|
-
|
180
|
-
# initialize viewer with a path
|
181
|
-
@editor = editor
|
182
|
-
|
183
|
-
# location bar
|
184
|
-
@location = Gtk::Entry.new
|
185
|
-
|
186
|
-
@tv = TreeViewer.new( root_fs_path, editor, @window, @location )
|
187
|
-
|
188
|
-
# add scrollbars
|
189
|
-
@scroll = Gtk::ScrolledWindow.new( nil, nil )
|
190
|
-
@scroll.set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC )
|
191
|
-
@scroll.add( @tv.view )
|
192
|
-
|
193
|
-
# expand and fill
|
194
|
-
@vbox = Gtk::VBox.new( false )
|
195
|
-
@vbox.pack_start( @location, false, false )
|
196
|
-
@vbox.pack_start( @scroll, true, true )
|
197
|
-
@vbox.focus_chain = [@scroll, @location]
|
198
|
-
|
199
|
-
icon_path = find_icon_path
|
200
|
-
if icon_path != nil
|
201
|
-
@window.icon = Gdk::Pixbuf.new( icon_path )
|
202
|
-
end
|
203
|
-
@window.title = 'Hilfer ' + @tv.root_item.path
|
204
|
-
@window.add( @vbox )
|
205
|
-
|
206
|
-
# read config. OK, the last parameter is a hack
|
207
|
-
# but we need it so that new windows aren't show in
|
208
|
-
# exactly the same position and it looks like nothing
|
209
|
-
# has happened
|
210
|
-
@@window_count += 1
|
211
|
-
@hc = HilferConfig.new( CONFIG_FILE, @window, @@window_count )
|
212
|
-
|
213
|
-
# set first line selected
|
214
|
-
@tv.select_first
|
215
|
-
|
216
|
-
# The program will directly end upon 'delete_event', ie window close
|
217
|
-
@window.signal_connect( 'delete_event' ) do
|
218
|
-
# unregister view from editor
|
219
|
-
@editor.unregister_view( @tv )
|
220
|
-
# finish
|
221
|
-
@@window_count -= 1
|
222
|
-
if @@window_count == 0
|
223
|
-
@hc.save
|
224
|
-
# this MUST come before cleanup, otherwise
|
225
|
-
# there will be no pipes to write the command to
|
226
|
-
@editor.quit if $options[:quit_editor]
|
227
|
-
# delete command pipe files
|
228
|
-
@editor.cleanup
|
229
|
-
Gtk.main_quit
|
230
|
-
false
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
# to allow the sd command to find the correct editor instance
|
235
|
-
@window.signal_connect 'focus-in-event' do |widget,event|
|
236
|
-
@editor.write_pipe_name
|
237
|
-
false
|
238
|
-
end
|
239
|
-
|
240
|
-
# to allow the sd command to find the correct editor instance
|
241
|
-
@window.signal_connect 'focus-out-event' do |widget,event|
|
242
|
-
@editor.write_pipe_name
|
243
|
-
false
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
def find_icon_path
|
248
|
-
$LOAD_PATH.each do |path|
|
249
|
-
png_file = Pathname.new( path ) + 'hilfer/hilfer-icon.png'
|
250
|
-
return png_file.to_s if png_file.exist?
|
251
|
-
end
|
252
|
-
nil
|
253
|
-
end
|
254
|
-
end
|
255
|
-
|
256
|
-
|
257
47
|
################
|
258
48
|
# Main script
|
259
49
|
|
data/bin/ssc
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
#! /usr/bin/ruby
|
2
2
|
|
3
3
|
require 'optparse'
|
4
|
-
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'text/format'
|
7
|
+
HAS_TEXT_FORMAT = true
|
8
|
+
rescue LoadError
|
9
|
+
HAS_TEXT_FORMAT = false
|
10
|
+
end
|
5
11
|
|
6
12
|
# display help and commands
|
7
13
|
oparser = OptionParser.new
|
@@ -10,10 +16,11 @@ oparser.on( '-h', '-?', '--help' ) do |o|
|
|
10
16
|
puts oparser.to_s
|
11
17
|
puts
|
12
18
|
puts "Send one or several commands to the current scite"
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
19
|
+
if HAS_TEXT_FORMAT
|
20
|
+
puts
|
21
|
+
puts "Commands are (http://scintilla.sourceforge.net/SciTEDirector.html):"
|
22
|
+
puts
|
23
|
+
st = <<EOF
|
17
24
|
askfilename:|Return the name of the file being edited.
|
18
25
|
askproperty:<key>|Return the value of a property.
|
19
26
|
close:|Close the current file.
|
@@ -46,15 +53,19 @@ replaceall:<srch>\\000<rep>|Replace all instances of he search string in the doc
|
|
46
53
|
saveas:<path>|Save the document as the indicated file.
|
47
54
|
savesession:<path>|Save a session as given by the indicated file.
|
48
55
|
EOF
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
+
cmds = st.split(/\n/)
|
57
|
+
re = /(.*?)\|(.*)/
|
58
|
+
tf = Text::Format.new( :format_style => :fill, :left_margin => 28, :columns => 90 )
|
59
|
+
cmds.each do |ln|
|
60
|
+
cmd, desc = re.match( ln ).to_a[1..-1]
|
61
|
+
desc = tf.format(desc)
|
62
|
+
puts( "%-28s%-52s" % [ cmd, desc.strip ] )
|
63
|
+
end
|
64
|
+
else
|
65
|
+
puts
|
66
|
+
puts "text/format not found. scite director commands not displayed."
|
56
67
|
end
|
57
|
-
exit(
|
68
|
+
exit( 1 )
|
58
69
|
end
|
59
70
|
|
60
71
|
# parse options
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# check for existence of gnome-terminal
|
2
|
+
unless File.exist?( '/usr/bin/gnome-terminal' )
|
3
|
+
raise 'gnome-terminal not available at /usr/bin/gnome-terminal'
|
4
|
+
end
|
5
|
+
|
6
|
+
=begin rdoc
|
7
|
+
Knows how to lauch gnome-terminal with mutiple tabs,
|
8
|
+
each opened on a different directory
|
9
|
+
=end
|
10
|
+
class GnomeTerminal
|
11
|
+
def launch( dirs )
|
12
|
+
# construct arguments and launch
|
13
|
+
args = [ "gnome-terminal" ]
|
14
|
+
dirs.uniq.each do |x|
|
15
|
+
# first one will be a window, subsequent ones are tabs
|
16
|
+
args << ( args.size == 1 ? '--window' : '--tab' )
|
17
|
+
args << "--working-directory=#{x}"
|
18
|
+
end
|
19
|
+
system( *args )
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
=begin rdoc
|
5
|
+
Read and write configuration to ~/.hilfer in yaml.
|
6
|
+
Currently only writes window position
|
7
|
+
=end
|
8
|
+
class HilferConfig
|
9
|
+
|
10
|
+
def initialize( file, window, count )
|
11
|
+
@file, @window = file, window
|
12
|
+
|
13
|
+
if File.file? CONFIG_FILE
|
14
|
+
config = YAML.load_file CONFIG_FILE
|
15
|
+
@window.set_default_size( *config[:size] )
|
16
|
+
@window.show_all
|
17
|
+
# move must be after show_all otherwise it
|
18
|
+
# gets overridden
|
19
|
+
@window.move( *config[:position] ) if count == 1
|
20
|
+
else
|
21
|
+
@window.set_default_size( 300,700 ).show_all
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# save config
|
26
|
+
def save
|
27
|
+
config = {
|
28
|
+
:path => @window.title,
|
29
|
+
:position => @window.position,
|
30
|
+
:size => @window.size
|
31
|
+
}
|
32
|
+
File.open( CONFIG_FILE, 'w' ) { |file| file.print config.to_yaml }
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
=begin rdoc
|
2
|
+
HilferItems are stored in the TreeModel
|
3
|
+
- item is the display name (ie filename and extension)
|
4
|
+
- path is the full pathname, expanded, unqualified etc etc
|
5
|
+
- last_child_used is the GtkTreeView path of the last child of a directory
|
6
|
+
node that had selection
|
7
|
+
- status is either :expanded or :collapsed
|
8
|
+
- populated is whether or not this directory node has been populated
|
9
|
+
from the filesystem. To aid in recursively populating the tree
|
10
|
+
=end
|
11
|
+
class HilferItem
|
12
|
+
attr_accessor :item, :path, :last_child_used, :status, :svn_status, :colour
|
13
|
+
attr_writer :populated
|
14
|
+
|
15
|
+
def initialize( item, path )
|
16
|
+
@item = item
|
17
|
+
@path = path
|
18
|
+
@dir = File.directory? path
|
19
|
+
@populated = false
|
20
|
+
@status = :collapsed
|
21
|
+
@colour = '#000'
|
22
|
+
end
|
23
|
+
|
24
|
+
def dir?
|
25
|
+
@dir
|
26
|
+
end
|
27
|
+
|
28
|
+
def to_s
|
29
|
+
@item
|
30
|
+
end
|
31
|
+
|
32
|
+
# always return true for file nodes
|
33
|
+
def populated?
|
34
|
+
if !dir?
|
35
|
+
true
|
36
|
+
else
|
37
|
+
@populated
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# always return false for file nodes
|
42
|
+
def expanded?
|
43
|
+
if !dir?
|
44
|
+
false
|
45
|
+
else
|
46
|
+
@status == :expanded
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# yes, this actually does catch method calls polymorphically
|
2
|
+
# but you can't change the TreePath or TreeIter that are returned
|
3
|
+
class HilferModel < Gtk::TreeStore
|
4
|
+
def initialize( *args )
|
5
|
+
super
|
6
|
+
end
|
7
|
+
|
8
|
+
def ancestor?( iter, descendant )
|
9
|
+
print "testing #{iter[0]} against #{descendant}\n" if $options[:debug]
|
10
|
+
super
|
11
|
+
end
|
12
|
+
end
|
data/lib/hilfer/rails_locator.rb
CHANGED
data/lib/hilfer/svn_colours.rb
CHANGED
data/lib/hilfer/tree_viewer.rb
CHANGED
@@ -1,9 +1,45 @@
|
|
1
1
|
# local files
|
2
|
-
# local files
|
3
|
-
require 'hilfer/scite_editor.rb'
|
4
|
-
require 'hilfer/rails_locator.rb'
|
5
|
-
require 'hilfer/svn_colours.rb'
|
6
2
|
require 'pathname'
|
3
|
+
require 'hilfer/hilfer_item.rb'
|
4
|
+
require 'hilfer/scite_editor.rb'
|
5
|
+
require 'hilfer/hilfer_model.rb'
|
6
|
+
|
7
|
+
# try to load Gnome terminal
|
8
|
+
begin
|
9
|
+
require 'hilfer/gnome_terminal.rb'
|
10
|
+
HAS_GNOME_TERMINAL = true
|
11
|
+
rescue
|
12
|
+
puts "gnome-terminal not available. Defaulting to xterm."
|
13
|
+
HAS_GNOME_TERMINAL = false
|
14
|
+
end
|
15
|
+
require 'hilfer/xterm.rb'
|
16
|
+
|
17
|
+
# try to load rails locator
|
18
|
+
begin
|
19
|
+
require 'hilfer/rails_locator.rb'
|
20
|
+
HAS_RAILS_LOCATOR = true
|
21
|
+
rescue
|
22
|
+
puts "ActiveSupport not loaded. No rails-specific keystrokes"
|
23
|
+
HAS_RAILS_LOCATOR = false
|
24
|
+
end
|
25
|
+
|
26
|
+
# try to load subversion bindings
|
27
|
+
begin
|
28
|
+
require 'hilfer/svn_colours.rb'
|
29
|
+
HAS_SUBVERSION = true
|
30
|
+
rescue
|
31
|
+
puts "svn/client not loaded. Coloured SVN status will not be displayed."
|
32
|
+
HAS_SUBVERSION = false
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
module Gdk
|
37
|
+
class EventKey
|
38
|
+
def inspect
|
39
|
+
"#<Gdk::EventKey keycode=#{hardware_keycode} state=#{state.inspect}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
7
43
|
|
8
44
|
=begin
|
9
45
|
This is the tree viewer object. It contains a GtkTreeView
|
@@ -11,7 +47,7 @@ and references an editor object. It also contains a HilferItem
|
|
11
47
|
which is the root node of the tree, but it's never displayed
|
12
48
|
=end
|
13
49
|
class TreeViewer
|
14
|
-
include SvnColours
|
50
|
+
include SvnColours if HAS_SUBVERSION
|
15
51
|
|
16
52
|
attr_reader :view, :editor, :root_item
|
17
53
|
|
@@ -37,7 +73,7 @@ class TreeViewer
|
|
37
73
|
# locators are things that provide a set of shortcut keys
|
38
74
|
# to jump to specific directories, files, or related locations
|
39
75
|
@locators = []
|
40
|
-
@locators << RailsLocator.new( self )
|
76
|
+
@locators << RailsLocator.new( self ) if HAS_RAILS_LOCATOR
|
41
77
|
|
42
78
|
# pre-populate model from filesystem, only 1 level deep
|
43
79
|
#model = Gtk::TreeStore.new( HilferItem )
|
@@ -142,10 +178,6 @@ class TreeViewer
|
|
142
178
|
|
143
179
|
def refresh
|
144
180
|
go_into( @root_item.path )
|
145
|
-
if $options[:debug]
|
146
|
-
load 'rails_locator.rb'
|
147
|
-
load 'tree_viewer.rb'
|
148
|
-
end
|
149
181
|
end
|
150
182
|
|
151
183
|
def init_renderers
|
@@ -288,7 +320,7 @@ class TreeViewer
|
|
288
320
|
def init_keys
|
289
321
|
@view.signal_connect( 'key-press-event' ) do
|
290
322
|
|widget,event|
|
291
|
-
|
323
|
+
puts event.inspect if $options[:debug]
|
292
324
|
retval = true
|
293
325
|
case
|
294
326
|
# enter - go into directory
|
@@ -421,18 +453,22 @@ class TreeViewer
|
|
421
453
|
end
|
422
454
|
end
|
423
455
|
terminal.launch( dirs )
|
424
|
-
|
456
|
+
|
425
457
|
# alt-l toggles the location bar
|
426
458
|
when event.hardware_keycode == 46 && event.state.mod1_mask?
|
427
459
|
@location.no_show_all = true
|
428
460
|
@location.visible = !@location.visible?
|
429
|
-
|
461
|
+
|
462
|
+
# alt-q toggles whether shutdown is automatic or not
|
463
|
+
when event.hardware_keycode == 24 && event.state.mod1_mask?
|
464
|
+
$options[:quit_editor] = !$options[:quit_editor]
|
465
|
+
|
430
466
|
# ctrl-* on keypad means expand the entire tree
|
431
467
|
when event.hardware_keycode == 63 && event.state.control_mask?
|
432
468
|
# 100 levels of directories should be enough...
|
433
469
|
populate( @view.model, @root_item, nil, 100 )
|
434
470
|
@view.expand_all
|
435
|
-
|
471
|
+
|
436
472
|
# * on keypad means expand subtree
|
437
473
|
when event.hardware_keycode == 63 && event.state.empty?
|
438
474
|
widget.selection.selected_rows.each do |path|
|
@@ -441,11 +477,11 @@ class TreeViewer
|
|
441
477
|
expand_dir( widget, path, iter )
|
442
478
|
end
|
443
479
|
end
|
444
|
-
|
480
|
+
|
445
481
|
# shift-/ on keypad means collapse the entire tree
|
446
482
|
when event.hardware_keycode == 112 && event.state.shift_mask?
|
447
483
|
@view.collapse_all
|
448
|
-
|
484
|
+
|
449
485
|
# ctrl-left means go to parent
|
450
486
|
when event.hardware_keycode == 100 && event.state.control_mask?
|
451
487
|
widget.selection.selected_each do |model, path, iter|
|
@@ -453,11 +489,11 @@ class TreeViewer
|
|
453
489
|
iter.parent[0].last_child_used = path
|
454
490
|
select_iter( iter.parent )
|
455
491
|
end
|
456
|
-
|
492
|
+
|
457
493
|
# only do the first one
|
458
494
|
break
|
459
495
|
end
|
460
|
-
|
496
|
+
|
461
497
|
# ctrl-right means go to last used path, or first child
|
462
498
|
when event.hardware_keycode == 102 && event.state.control_mask?
|
463
499
|
widget.selection.selected_each do |model, path, iter|
|
@@ -469,11 +505,11 @@ class TreeViewer
|
|
469
505
|
select_iter( iter.first_child )
|
470
506
|
end
|
471
507
|
end
|
472
|
-
|
508
|
+
|
473
509
|
# only do the first one
|
474
510
|
break
|
475
511
|
end
|
476
|
-
|
512
|
+
|
477
513
|
# ctrl-up means go to previous sibling with children
|
478
514
|
when event.hardware_keycode == 98 && event.state.control_mask?
|
479
515
|
widget.selection.selected_each do |model, path, iter|
|
@@ -544,9 +580,10 @@ class TreeViewer
|
|
544
580
|
end
|
545
581
|
|
546
582
|
else
|
547
|
-
# pass keypress to all locators
|
548
|
-
@locators.each {|x| retval &&= x.handle_keypress( widget, event ) }
|
549
583
|
# indicate signal not handled
|
584
|
+
retval = false
|
585
|
+
# pass keypress to all locators
|
586
|
+
@locators.each {|x| retval = x.handle_keypress( widget, event ) and retval }
|
550
587
|
if $options[:debug] && !retval
|
551
588
|
print "hardware_keycode: #{event.hardware_keycode}\n"
|
552
589
|
end
|
@@ -685,7 +722,11 @@ class TreeViewer
|
|
685
722
|
end
|
686
723
|
|
687
724
|
def terminal
|
688
|
-
|
725
|
+
if HAS_GNOME_TERMINAL
|
726
|
+
@terminal ||= GnomeTerminal.new
|
727
|
+
else
|
728
|
+
@terminal ||= Xterm.new
|
729
|
+
end
|
689
730
|
end
|
690
731
|
|
691
732
|
# Move the displayed tree to the given directory
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'hilfer/tree_viewer.rb'
|
2
|
+
require 'hilfer/hilfer_config.rb'
|
3
|
+
|
4
|
+
=begin rdoc
|
5
|
+
Layout of the Tree Viewer Window.
|
6
|
+
=end
|
7
|
+
class TreeViewerWindow
|
8
|
+
@@window_count = 0
|
9
|
+
|
10
|
+
def initialize( root_fs_path, editor )
|
11
|
+
@window = Gtk::Window.new
|
12
|
+
|
13
|
+
# initialize viewer with a path
|
14
|
+
@editor = editor
|
15
|
+
|
16
|
+
# location bar
|
17
|
+
@location = Gtk::Entry.new
|
18
|
+
|
19
|
+
@tv = TreeViewer.new( root_fs_path, editor, @window, @location )
|
20
|
+
|
21
|
+
# add scrollbars
|
22
|
+
@scroll = Gtk::ScrolledWindow.new( nil, nil )
|
23
|
+
@scroll.set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC )
|
24
|
+
@scroll.add( @tv.view )
|
25
|
+
|
26
|
+
# expand and fill
|
27
|
+
@vbox = Gtk::VBox.new( false )
|
28
|
+
@vbox.pack_start( @location, false, false )
|
29
|
+
@vbox.pack_start( @scroll, true, true )
|
30
|
+
@vbox.focus_chain = [@scroll, @location]
|
31
|
+
|
32
|
+
icon_path = find_icon_path
|
33
|
+
if icon_path != nil
|
34
|
+
@window.icon = Gdk::Pixbuf.new( icon_path )
|
35
|
+
end
|
36
|
+
@window.title = 'Hilfer ' + @tv.root_item.path
|
37
|
+
@window.add( @vbox )
|
38
|
+
|
39
|
+
# read config. OK, the last parameter is a hack
|
40
|
+
# but we need it so that new windows aren't show in
|
41
|
+
# exactly the same position and it looks like nothing
|
42
|
+
# has happened
|
43
|
+
@@window_count += 1
|
44
|
+
@hc = HilferConfig.new( CONFIG_FILE, @window, @@window_count )
|
45
|
+
|
46
|
+
# set first line selected
|
47
|
+
@tv.select_first
|
48
|
+
|
49
|
+
# The program will directly end upon 'delete_event', ie window close
|
50
|
+
@window.signal_connect( 'delete_event' ) do
|
51
|
+
# unregister view from editor
|
52
|
+
@editor.unregister_view( @tv )
|
53
|
+
# finish
|
54
|
+
@@window_count -= 1
|
55
|
+
if @@window_count == 0
|
56
|
+
@hc.save
|
57
|
+
# this MUST come before cleanup, otherwise
|
58
|
+
# there will be no pipes to write the command to
|
59
|
+
@editor.quit if $options[:quit_editor]
|
60
|
+
# delete command pipe files
|
61
|
+
@editor.cleanup
|
62
|
+
Gtk.main_quit
|
63
|
+
false
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# to allow the sd command to find the correct editor instance
|
68
|
+
@window.signal_connect 'focus-in-event' do |widget,event|
|
69
|
+
@editor.write_pipe_name
|
70
|
+
false
|
71
|
+
end
|
72
|
+
|
73
|
+
# to allow the sd command to find the correct editor instance
|
74
|
+
@window.signal_connect 'focus-out-event' do |widget,event|
|
75
|
+
@editor.write_pipe_name
|
76
|
+
false
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def find_icon_path
|
81
|
+
$LOAD_PATH.each do |path|
|
82
|
+
png_file = Pathname.new( path ) + 'hilfer/hilfer-icon.png'
|
83
|
+
return png_file.to_s if png_file.exist?
|
84
|
+
end
|
85
|
+
nil
|
86
|
+
end
|
87
|
+
end
|
data/lib/hilfer/xterm.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
=begin rdoc
|
2
|
+
Just launches xterm. I couldn't figure out how to open it in different
|
3
|
+
directories.
|
4
|
+
|
5
|
+
use it by saying
|
6
|
+
|
7
|
+
$options[:terminal] = Xterm.new
|
8
|
+
|
9
|
+
before the call to TreeViewer.new
|
10
|
+
=end
|
11
|
+
class Xterm
|
12
|
+
def launch( dirs )
|
13
|
+
system( 'xterm &' )
|
14
|
+
end
|
15
|
+
end
|
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.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Anderson
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-04-
|
12
|
+
date: 2008-04-10 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -49,13 +49,20 @@ files:
|
|
49
49
|
- TODO
|
50
50
|
- bin/hilfer
|
51
51
|
- bin/ssc
|
52
|
+
- lib/hilfer/gnome_terminal.rb
|
52
53
|
- lib/hilfer/hilfer-icon.png
|
54
|
+
- lib/hilfer/hilfer_config.rb
|
55
|
+
- lib/hilfer/hilfer_item.rb
|
56
|
+
- lib/hilfer/hilfer_model.rb
|
53
57
|
- lib/hilfer/rails_locator.rb
|
54
58
|
- lib/hilfer/scite_editor.rb
|
55
59
|
- lib/hilfer/svn_colours.rb
|
56
60
|
- lib/hilfer/tree_viewer.rb
|
61
|
+
- lib/hilfer/tree_viewer_window.rb
|
62
|
+
- lib/hilfer/version.rb
|
63
|
+
- lib/hilfer/xterm.rb
|
57
64
|
has_rdoc: true
|
58
|
-
homepage: http://
|
65
|
+
homepage: "Download from RubyForge: http://www.rubyforge.org/projects/hilfer"
|
59
66
|
post_install_message:
|
60
67
|
rdoc_options:
|
61
68
|
- --main
|