hilfer 0.10.0 → 0.10.1
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/ChangeLog +32 -0
- data/History.txt +5 -0
- data/lib/hilfer/scite_editor.rb +47 -40
- data/lib/hilfer/tree_viewer.rb +3 -3
- data/lib/hilfer/version.rb +1 -1
- metadata +2 -2
data/ChangeLog
CHANGED
@@ -1,3 +1,35 @@
|
|
1
|
+
2009-08-03 15:52 panic
|
2
|
+
|
3
|
+
* [r4358] History.txt, lib/hilfer/scite_editor.rb,
|
4
|
+
lib/hilfer/tree_viewer.rb:
|
5
|
+
Change pipe names. Add some comments.
|
6
|
+
|
7
|
+
2009-08-03 15:12 panic
|
8
|
+
|
9
|
+
* [r4357] lib/hilfer/scite_editor.rb:
|
10
|
+
Fix the process launching and waiting for scite. Change to
|
11
|
+
debug?. Other debug message tweaks.
|
12
|
+
|
13
|
+
2009-08-03 14:32 panic
|
14
|
+
|
15
|
+
* [r4356] lib/hilfer/tree_viewer.rb:
|
16
|
+
whitespace changes
|
17
|
+
|
18
|
+
2009-08-01 18:53 panic
|
19
|
+
|
20
|
+
* [r4355] lib/hilfer/version.rb:
|
21
|
+
bump version
|
22
|
+
|
23
|
+
2009-08-01 18:52 panic
|
24
|
+
|
25
|
+
* [r4353] Manifest.txt, lib/hilfer/window.rb:
|
26
|
+
Remove debug output. Add files to Manifest.
|
27
|
+
|
28
|
+
2009-08-01 18:40 panic
|
29
|
+
|
30
|
+
* [r4352] History.txt, README.txt:
|
31
|
+
Notes and docs
|
32
|
+
|
1
33
|
2009-08-01 18:28 panic
|
2
34
|
|
3
35
|
* [r4351] bin/hilfer, lib/hilfer/extensions.rb,
|
data/History.txt
CHANGED
data/lib/hilfer/scite_editor.rb
CHANGED
@@ -5,8 +5,9 @@ class SciteEditor
|
|
5
5
|
# options can contain :debug
|
6
6
|
# view is a GtkTreeView
|
7
7
|
def initialize( options = {} )
|
8
|
-
@scite_pipe_name = "/tmp
|
9
|
-
@director_pipe_name = "/tmp
|
8
|
+
@scite_pipe_name = "/tmp/hilfer.#{ENV['USER']}.#{Process.pid}.scite"
|
9
|
+
@director_pipe_name = "/tmp/hilfer.#{ENV['USER']}.#{Process.pid}.director"
|
10
|
+
@pipe_name_file = "/tmp/hilfer.#{ENV['USER']}.scite"
|
10
11
|
|
11
12
|
cleanup
|
12
13
|
|
@@ -18,11 +19,17 @@ class SciteEditor
|
|
18
19
|
|
19
20
|
attr_reader :options
|
20
21
|
attr_reader :scite_pid
|
22
|
+
attr_reader :pipe_name_file
|
23
|
+
|
24
|
+
def debug?
|
25
|
+
@options[:debug]
|
26
|
+
end
|
21
27
|
|
22
28
|
def launched?
|
23
29
|
!@scite_pid.nil?
|
24
30
|
end
|
25
31
|
|
32
|
+
# return a Window object for the editor.
|
26
33
|
def window
|
27
34
|
@window ||= Window.pid( @scite_pid )
|
28
35
|
end
|
@@ -49,20 +56,24 @@ class SciteEditor
|
|
49
56
|
launch
|
50
57
|
File.open( @scite_pipe_name, 'a' ) do |file|
|
51
58
|
file.puts "#{cmd.to_s}:#{arg.to_s}"
|
52
|
-
puts "sending: #{cmd.to_s}:#{arg.to_s}" if
|
59
|
+
puts "sending: #{cmd.to_s}:#{arg.to_s}" if debug?
|
53
60
|
end
|
54
61
|
end
|
55
62
|
|
56
63
|
# bring the SciTE instance to the current
|
57
64
|
# desktop and raise it.
|
58
65
|
def activate
|
59
|
-
|
66
|
+
unless window.nil?
|
67
|
+
puts "activating scite" if debug?
|
68
|
+
window.activate
|
69
|
+
puts "finished activating scite" if debug?
|
70
|
+
end
|
60
71
|
end
|
61
72
|
|
62
73
|
# open files in scite
|
63
74
|
def open_action( files )
|
64
75
|
files.each { |x| send_cmd "open", x.path }
|
65
|
-
send_cmd :identity, 0
|
76
|
+
#~ send_cmd :identity, 0
|
66
77
|
activate
|
67
78
|
end
|
68
79
|
|
@@ -78,6 +89,7 @@ class SciteEditor
|
|
78
89
|
|
79
90
|
# shut down editor, if it's open
|
80
91
|
def quit
|
92
|
+
# check for launched?, otherwise send_cmd will attempt to auto-launch.
|
81
93
|
send_cmd :quit if launched?
|
82
94
|
end
|
83
95
|
|
@@ -97,6 +109,7 @@ class SciteEditor
|
|
97
109
|
@views.each { |v| v.synchronise_editor_path( fs_path ) }
|
98
110
|
end
|
99
111
|
|
112
|
+
# view must respond to synchronise_editor_path( fs_path )
|
100
113
|
def register_view( view )
|
101
114
|
@views << view
|
102
115
|
end
|
@@ -105,10 +118,6 @@ class SciteEditor
|
|
105
118
|
@views.delete( view )
|
106
119
|
end
|
107
120
|
|
108
|
-
def pipe_name_file
|
109
|
-
@pipe_name_file ||= "/tmp/#{ENV['USER']}.hilfer.scite"
|
110
|
-
end
|
111
|
-
|
112
121
|
def write_pipe_name
|
113
122
|
File.open( pipe_name_file, 'w' ) do |f|
|
114
123
|
f.write @scite_pipe_name
|
@@ -116,8 +125,10 @@ class SciteEditor
|
|
116
125
|
end
|
117
126
|
end
|
118
127
|
|
119
|
-
#
|
120
|
-
#
|
128
|
+
# Start up the editor if there isn't already one.
|
129
|
+
# Calling it when the editor is already open does nothing.
|
130
|
+
# Store a Window object for raising, and store the pid for
|
131
|
+
# other things. Will also install a handler for SIGCHLD
|
121
132
|
def launch
|
122
133
|
return if launched?
|
123
134
|
|
@@ -128,9 +139,23 @@ class SciteEditor
|
|
128
139
|
|
129
140
|
scite_cmd = "/usr/bin/scite"
|
130
141
|
|
131
|
-
#
|
132
|
-
@
|
133
|
-
|
142
|
+
# wait for scite shutdown by SIGCHLD, and clean up fifo files.
|
143
|
+
@handler ||= trap( "CHLD" ) do |signal|
|
144
|
+
child_pid = Process.wait( -1, Process::WNOHANG )
|
145
|
+
# copy this now, before something else grabs it
|
146
|
+
process_status = $?
|
147
|
+
if @scite_pid == child_pid
|
148
|
+
puts "process_status: #{process_status.inspect}" if debug?
|
149
|
+
puts "cleaning pipes" if debug?
|
150
|
+
cleanup
|
151
|
+
reset
|
152
|
+
puts "finished cleaning pipes" if debug?
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
# fork and exec scite, so we can get scite's pid
|
157
|
+
if ( @scite_pid = fork() ).nil?
|
158
|
+
puts "in child" if debug?
|
134
159
|
# in child, so exec scite from here, so this pid will become scite's pid
|
135
160
|
# not passing the first arg as a 2 element array doesn't work. So
|
136
161
|
# use the same value for the command and as argv[0]
|
@@ -139,43 +164,25 @@ class SciteEditor
|
|
139
164
|
"-ipc.director.name=#{@director_pipe_name}",
|
140
165
|
"-ipc.scite.name=#{@scite_pipe_name}"
|
141
166
|
)
|
142
|
-
else
|
143
|
-
start_cleanup
|
144
167
|
end
|
145
168
|
|
146
|
-
puts "scite launched with pid #{@scite_pid}" if
|
169
|
+
puts "in parent: scite launched with pid #{@scite_pid}" if debug?
|
147
170
|
|
148
|
-
#
|
171
|
+
# listen for incoming scite events, like file change and open
|
149
172
|
start_listener
|
150
173
|
end
|
151
174
|
|
152
175
|
protected
|
153
|
-
|
154
|
-
def start_cleanup
|
155
|
-
Thread.new do
|
156
|
-
# wait for Scite to end, and cleanup
|
157
|
-
begin
|
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]
|
163
|
-
rescue Exception => e
|
164
|
-
puts "e: #{e.inspect}"
|
165
|
-
puts e.backtrace
|
166
|
-
end
|
167
|
-
end
|
168
|
-
end
|
169
176
|
|
170
177
|
def start_listener
|
171
178
|
|
172
179
|
sleep 0.1 while !File.exists? @scite_pipe_name
|
173
180
|
|
174
|
-
Thread.new
|
181
|
+
Thread.new do
|
175
182
|
begin
|
176
|
-
|
183
|
+
listen
|
177
184
|
rescue Errno::ENOENT
|
178
|
-
|
185
|
+
puts "pipe gone away, so stop listening" if debug?
|
179
186
|
rescue Exception => e
|
180
187
|
print "listener thread ended: ", e.inspect, "\n"
|
181
188
|
puts e.backtrace
|
@@ -189,7 +196,7 @@ protected
|
|
189
196
|
File.open( @director_pipe_name ).each( "\x0" ) do |line|
|
190
197
|
begin
|
191
198
|
line = line.slice(0...-1) if line[-1] = 0
|
192
|
-
print "heard #{line}\n" if
|
199
|
+
print "heard #{line}\n" if debug?
|
193
200
|
case line
|
194
201
|
# scite sends one of these for each file opened
|
195
202
|
when /^opened:(.*)$/
|
@@ -207,13 +214,13 @@ protected
|
|
207
214
|
# TODO could check that it exists and add it if not.
|
208
215
|
when /^saved:(.*)$/
|
209
216
|
|
210
|
-
when /^
|
217
|
+
when /^closing$/
|
211
218
|
puts "SciTE closing"
|
212
219
|
break
|
213
220
|
|
214
221
|
# print it out
|
215
222
|
else
|
216
|
-
print "unknown: ", line, "\n" if
|
223
|
+
print "unknown from scite: ", line, "\n" if debug?
|
217
224
|
end
|
218
225
|
rescue Exception => e
|
219
226
|
print "caught Exception in listen: ", e.inspect, "\n"
|
data/lib/hilfer/tree_viewer.rb
CHANGED
@@ -396,7 +396,7 @@ class TreeViewer
|
|
396
396
|
@editor.insert paths
|
397
397
|
|
398
398
|
# ctrl-c copies current selections as text
|
399
|
-
when event.c? && event.state.control_mask?
|
399
|
+
when event.c? && event.state.control_mask? && !event.state.shift_mask?
|
400
400
|
paths = ""
|
401
401
|
|
402
402
|
# fetch all selected items
|
@@ -438,7 +438,7 @@ class TreeViewer
|
|
438
438
|
when event.r? && event.state.control_mask?
|
439
439
|
refresh
|
440
440
|
|
441
|
-
# ctrl-t opens a terminal window on the given
|
441
|
+
# ctrl-t opens a terminal window on the given directories.
|
442
442
|
# Uses gnome-terminal and opens directories in tabs
|
443
443
|
when event.t? && event.state.control_mask? && !event.state.shift_mask?
|
444
444
|
# collect all unique directories
|
@@ -527,7 +527,7 @@ class TreeViewer
|
|
527
527
|
end
|
528
528
|
break
|
529
529
|
end
|
530
|
-
|
530
|
+
|
531
531
|
# ctrl-down means go to next sibling with children
|
532
532
|
when event.down? && event.state.control_mask?
|
533
533
|
widget.selection.selected_each do |model, path, iter|
|
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.10.
|
4
|
+
version: 0.10.1
|
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: 2009-08-
|
12
|
+
date: 2009-08-03 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|