hilfer 0.11.8 → 0.13.0

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.
@@ -1,3 +1,9 @@
1
+ === 0.12.0 / 09-Dec-11
2
+ * make ssc use SciteEditor
3
+ * SciteEditor uses Pathname
4
+ * wmctrl dependency removed, so to work this must use a scite which
5
+ support the focus: command
6
+
1
7
  === 0.11.8 / 15-Oct-2011
2
8
  * do locators for test and lib, whether or not rails is found
3
9
  * fix ssc pipe name, so it works again
@@ -1,6 +1,6 @@
1
- History.txt
1
+ History.rdoc
2
2
  Manifest.txt
3
- README.txt
3
+ README.rdoc
4
4
  Rakefile
5
5
  TODO
6
6
  bin/hilfer
@@ -11,6 +11,7 @@ lib/hilfer/hilfer-icon.png
11
11
  lib/hilfer/hilfer_config.rb
12
12
  lib/hilfer/hilfer_item.rb
13
13
  lib/hilfer/hilfer_model.rb
14
+ lib/hilfer/module_extensions.rb
14
15
  lib/hilfer/standard_locator.rb
15
16
  lib/hilfer/rails_locator.rb
16
17
  lib/hilfer/scite_editor.rb
@@ -18,6 +19,5 @@ lib/hilfer/svn_colours.rb
18
19
  lib/hilfer/tree_viewer.rb
19
20
  lib/hilfer/tree_viewer_window.rb
20
21
  lib/hilfer/version.rb
21
- lib/hilfer/window.rb
22
22
  lib/hilfer/xterm.rb
23
23
  lib/hilfer/xfce_terminal.rb
@@ -1,8 +1,8 @@
1
1
  = hilfer
2
2
 
3
- http://www.rubyforge.org/projects/hilfer
3
+ http://rubygems.org/gems/hilfer
4
4
 
5
- == DESCRIPTION:
5
+ == Description:
6
6
 
7
7
  Gtk2 directory browser for SciTE with plenty of keyboard shortcuts for directory
8
8
  and file navigation. It understands some of the Rails directory structure.
@@ -12,7 +12,7 @@ Once upon a time there was a directory browser called jaffm (Just a File Manager
12
12
  I liked the idea of an ultra simple file browser, but jaffm went extinct. So
13
13
  I wrote hilfer.
14
14
 
15
- == FEATURES
15
+ == Features
16
16
 
17
17
  === Main UI
18
18
 
@@ -41,9 +41,9 @@ I wrote hilfer.
41
41
  - ctrl-r refreshes from filesystem
42
42
  - ctrl-t opens a terminal window on the given directorties.
43
43
  - alt-l toggles the location bar
44
- - alt-q toggles whether shutdown is automatic or not
44
+ - alt-q toggles whether scite shutdown is automatic or not
45
45
  - ctrl-* on keypad means expand the entire tree
46
- - * on keypad expands subtrees
46
+ - '*' on keypad expands subtrees
47
47
  - shift-/ on keypad means collapse the entire tree
48
48
  - ctrl-left means go to parent
49
49
  - ctrl-right means go to last used path, or first child
@@ -75,16 +75,13 @@ I wrote hilfer.
75
75
  === SciTE director commands
76
76
 
77
77
  Use ssc to send commands directly to the instance of scite that was opened by
78
- hilfer.
78
+ hilfer. For example:
79
79
 
80
- ssc find:pipe
80
+ - to find the string 'pipe' in the current editor window:
81
+ ssc find:pipe
81
82
 
82
- will find the string 'pipe' in the current editor window.
83
-
84
-
85
- find . -name *widge*.rb -exec grep open -Hn | ssc
86
-
87
- will send a F4 traversable list of file search results to scite's output window
83
+ - to send a F4 traversable list of file search results to scite's output window
84
+ find . -name *widge*.rb -exec grep open -Hn | ssc
88
85
 
89
86
  === Subversion colour highlighting
90
87
 
@@ -115,11 +112,11 @@ See TODO file
115
112
  == SYNOPSIS
116
113
 
117
114
  Usage: hilfer [options]
118
- -y, --auto-sync track editor current file changes
119
- -s, --show-hidden Show hidden files
120
- -D, -d, -v, --debug Debug output
121
- -q, --quit-editor close editor on shutdown
122
- -h, -?, --help Show this help
115
+ -y, --auto-sync track editor current file changes
116
+ -s, --show-hidden Show hidden files
117
+ -D, -d, -v, --debug Debug output
118
+ -q, --quit-editor close editor on shutdown
119
+ -h, -?, --help Show this help
123
120
 
124
121
  == REQUIREMENTS:
125
122
 
@@ -127,7 +124,6 @@ See TODO file
127
124
 
128
125
  === Optional packages
129
126
 
130
- * wmctrl to raise SciTE editor window when files are opened
131
127
  * text-format for ssc to display extended scite director commands
132
128
  * subversion-ruby to display colour highlighted subversion status
133
129
  * gnome-terminal or Xfce Terminal executable
@@ -141,7 +137,7 @@ sudo gem install
141
137
 
142
138
  (The MIT License)
143
139
 
144
- Copyright (c) John Anderson 2006 - 2009
140
+ Copyright (c) John Anderson 2006 - 2011
145
141
 
146
142
  Permission is hereby granted, free of charge, to any person obtaining
147
143
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -4,7 +4,8 @@ rescue LoadError
4
4
  abort '### Please install the "bones" gem ###'
5
5
  end
6
6
 
7
- require 'rake/clean'
7
+ require 'rdoc/task'
8
+
8
9
  ensure_in_path 'lib'
9
10
  require 'hilfer/version.rb'
10
11
 
@@ -12,29 +13,24 @@ Bones do
12
13
  name 'hilfer'
13
14
  authors 'John Anderson'
14
15
  email 'panic@semiosix.com'
15
- url 'http://hilfer.rubyforge.org/hilfer'
16
+ url 'http://rubygems.org/gems/hilfer'
16
17
  version Hilfer::VERSION
17
18
  description "Programmers file browser for SciTE"
18
19
 
19
20
  gem.need_tar false
20
21
 
21
- depend_on 'gtk2', '~> 1.0.0'
22
+ depend_on 'gtk2', '>= 1.0.0'
22
23
 
23
24
  # read file list from Manifest.txt
24
25
  gem.files File.new('Manifest.txt').to_a.map( &:chomp )
25
26
 
26
- # List of files to generate rdoc from
27
- # Not the same as the rdoc -i which is list of files
28
- # to search for include directives
29
- rdoc.include %w{README.txt ^lib/clevic/.*\.rb$ models/examples.rb History.txt TODO}
30
-
31
27
  # List of Regexs to exclude from rdoc processing
32
- rdoc.exclude %w{^pkg.*}
28
+ rdoc.exclude %w{^pkg ^model ^test png$}
33
29
 
34
30
  # Include URL for git browser in rdoc output
35
- rdoc.opts %W{-W http://gitweb.semiosix.com/hilfer.cgi?p=clevic;a=blob;f=%s;hb=HEAD} #--template=#{Gem.required_location("allison", "allison.rb")}}
31
+ rdoc.opts %W{-W http://gitweb.semiosix.com/hilfer.cgi?p=hilfer;a=blob;f=%s;hb=HEAD}
36
32
 
37
- rdoc.main 'README.txt'
33
+ rdoc.main 'README.rdoc'
38
34
  end
39
35
 
40
36
  CLEAN.include %w[ChangeLog **/.DS_Store tmp *.log doc website/doc]
data/TODO CHANGED
@@ -1,4 +1,3 @@
1
- use focus: instead of wmctrl
2
1
  menu
3
2
  working sets, like eclipse
4
3
  option to connect to existing scite, by pid?
@@ -31,15 +30,6 @@ Model issues
31
30
  locators don't work unless directories have already been opened.
32
31
  * and / not working properly
33
32
 
34
- Maybe
35
- -----
36
-
37
- multi column view? Like Mac OS X finder?
38
- svn integration, as a second "Mode". CVS?
39
- gnome-vfs integration
40
- vim/gvim integration
41
- other terminal program integration eg xfce-terminal
42
-
43
33
  Done
44
34
  ====
45
35
 
data/bin/hilfer CHANGED
@@ -1,35 +1,49 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
3
  require 'optparse'
4
+ require 'hilfer/module_extensions.rb'
4
5
 
5
6
  # defaults
6
- $options = { :debug => false, :hidden => false, :auto_sync => false, :quit_editor => false }
7
7
 
8
- oparser = OptionParser.new
9
- oparser.on( '-y', '--auto-sync', 'track editor current file changes') { |o| $options[:host] = true }
10
- oparser.on( '-s', '--show-hidden', 'Show hidden files' ) { |o| $options[:user] = true }
11
- oparser.on( '-D', '-d', '--debug' ) { |o| $options[:debug] = $options[:verbose] = true }
12
- oparser.on( '-v', '--verbose' ) { |o| $options[:verbose] = true }
13
- oparser.on( '-q', '--quit-editor', 'close editor on shutdown' ) { |o| $options[:quit_editor] = true }
8
+ $options = OptionParser.new do |oparser|
9
+ class << oparser
10
+ attr_boolean :debug, false
11
+ attr_boolean :hidden, false
12
+ attr_boolean :auto_sync, false
13
+ attr_boolean :verbose, false
14
+ attr_boolean :terminal, false
15
+ attr_boolean :quit_editor, false
14
16
 
15
- oparser.on( '-V', '--version', 'show version' ) do |o|
16
- require 'hilfer/version.rb'
17
- puts <<EOF
17
+ def [](key)
18
+ self.send( "#{key}?" )
19
+ end
20
+ end
21
+
22
+ oparser.on( '-y', '--auto-sync', 'track editor current file changes') { |o| $options.host = true }
23
+ oparser.on( '-s', '--show-hidden', 'Show hidden files' ) { |o| $options.user = true }
24
+ oparser.on( '-D', '-d', '--debug' ) { |o| $options.debug = $options.verbose = true }
25
+ oparser.on( '-v', '--verbose' ) { |o| $options.verbose = true }
26
+ oparser.on( '-q', '--quit-editor', 'close editor on shutdown' ) { |o| $options.quit_editor = true }
27
+
28
+ oparser.on( '-V', '--version', 'show version' ) do |o|
29
+ require 'hilfer/version.rb'
30
+ puts <<EOF
18
31
  Hilfer #{Hilfer::VERSION}
19
32
  EOF
20
- exit(0)
21
- end
33
+ exit(0)
34
+ end
22
35
 
23
- oparser.on( '-h', '-?', '--help' ) do |o|
24
- puts oparser.to_s
25
- exit(1)
36
+ oparser.on( '-h', '-?', '--help' ) do |o|
37
+ puts oparser.to_s
38
+ exit(1)
39
+ end
26
40
  end
27
41
 
28
42
  # parse options, and make sure Gtk doesn't get them
29
- args = oparser.parse( ARGV )
43
+ args = $options.parse( ARGV )
30
44
 
31
45
  # output options on debug
32
- if $options[:debug]
46
+ if $options.debug?
33
47
  require 'pp'
34
48
  pp $options
35
49
  end
@@ -58,7 +72,7 @@ CONFIG_FILE = File.expand_path( '~/.hilfer' )
58
72
 
59
73
  tvw = TreeViewerWindow.new(
60
74
  File.expand_path( args[0] || '.' ),
61
- SciteEditor.new( $options )
75
+ SciteEditor.new( debug: $options.debug? )
62
76
  )
63
77
 
64
78
  # and off we go...
data/bin/ssc CHANGED
@@ -1,6 +1,9 @@
1
1
  #! /usr/bin/ruby
2
2
 
3
3
  require 'optparse'
4
+ require 'pathname'
5
+
6
+ require 'hilfer/scite_editor.rb'
4
7
 
5
8
  begin
6
9
  require 'text/format'
@@ -9,89 +12,144 @@ rescue LoadError
9
12
  HAS_TEXT_FORMAT = false
10
13
  end
11
14
 
12
- $options = {}
13
-
14
15
  # display help and commands
15
- oparser = OptionParser.new
16
- oparser.banner = <<EOF
16
+ $options = OptionParser.new do |oparser|
17
+ class << oparser
18
+ attr_boolean :debug, false
19
+ attr_boolean :pipe_to_output
20
+ attr_accessor :scite_pipe_name
21
+ attr_boolean :file, false
22
+ attr_boolean :line, false
23
+ attr_accessor :goto
24
+ end
25
+
26
+ oparser.banner = <<EOF
17
27
  Usage: ssc [options] | [ cmd] [...]" | STDIN
18
28
 
19
29
  if STDIN is given, pipe to the current scites output window
20
30
 
21
31
  EOF
22
- oparser.on( '-o', '--to-output', "Send stdin to scite's output pane") do |o|
23
- $options[:pipe_to_output] = true
24
- end
25
32
 
26
- oparser.on( '-g', '--goto N[,N]', "go to the given line and column number") do |val|
27
- $options[:goto] = val
28
- end
33
+ oparser.on( '-o', '--to-output', "Send stdin to scite's output pane") do |o|
34
+ oparser.pipe_to_output = true
35
+ end
29
36
 
30
- oparser.on( '-h', '-?', '--help' ) do |o|
31
- puts oparser.to_s
32
- end
37
+ oparser.on( '-p', '--pipe-name [S]', String, "The name of the scite pipe to hook into") do |val|
38
+ oparser.scite_pipe_name = val
39
+ end
40
+
41
+ oparser.on( '-f', '--file', "fetch current file") do |val|
42
+ oparser.file = true
43
+ end
44
+
45
+ oparser.on( '-l', '--line', "fetch current line") do |val|
46
+ oparser.line = true
47
+ end
48
+
49
+ oparser.on( '-g', '--goto N[,N]', "go to the given line and column number") do |val|
50
+ oparser.goto = val
51
+ end
52
+
53
+ oparser.on( '-d', '--debug' ) do |o|
54
+ oparser.debug = true
55
+ end
33
56
 
34
- oparser.on( '--help-commands' ) do |o|
35
- puts "Send one or several commands to the current scite"
36
- if HAS_TEXT_FORMAT
37
- puts
38
- puts "Commands are (http://scintilla.sourceforge.net/SciTEDirector.html):"
39
- puts
40
- st = DATA.read
41
- cmds = st.split(/\n/)
42
- re = /(.*?)\|(.*)/
43
- tf = Text::Format.new( :format_style => :fill, :left_margin => 28, :columns => 90 )
44
- cmds.each do |ln|
45
- cmd, desc = re.match( ln ).to_a[1..-1]
46
- desc = tf.format(desc)
47
- puts( "%-28s%-52s" % [ cmd, desc.strip ] )
57
+ oparser.on( '-h', '-?', '--help' ) do |o|
58
+ puts oparser.to_s
59
+ end
60
+
61
+ oparser.on( '--help-commands' ) do |o|
62
+ puts "Send one or several commands to the current scite"
63
+ if HAS_TEXT_FORMAT
64
+ puts
65
+ puts "Commands are (http://scintilla.sourceforge.net/SciTEDirector.html):"
66
+ puts
67
+ st = DATA.read
68
+ cmds = st.split(/\n/)
69
+ re = /(.*?)\|(.*)/
70
+ tf = Text::Format.new( :format_style => :fill, :left_margin => 28, :columns => 90 )
71
+ cmds.each do |ln|
72
+ cmd, desc = re.match( ln ).to_a[1..-1]
73
+ desc = tf.format(desc)
74
+ puts( "%-28s%-52s" % [ cmd, desc.strip ] )
75
+ end
76
+ else
77
+ puts DATA.read
78
+ puts
79
+ puts "text/format not found. scite director commands uglified"
48
80
  end
49
- else
50
- puts DATA.read
51
- puts
52
- puts "text/format not found. scite director commands uglified"
81
+ exit( 1 )
53
82
  end
54
- exit( 1 )
55
83
  end
56
84
 
57
85
  # parse options
58
- args = oparser.parse( ARGV )
59
-
60
- # which is the pipe file
61
- pipe_name_file_name = "/tmp/hilfer.#{ENV['USER']}.scite"
62
- if !File.exists?( pipe_name_file_name )
63
- puts "#{pipe_name_file_name} does not exist"
64
- exit(1)
65
- end
86
+ @args = $options.parse( ARGV )
66
87
 
67
88
  if ARGV.empty? && STDIN.tty?
68
- puts oparser
89
+ puts $options
69
90
  exit 1
70
91
  end
71
92
 
72
- # open pipe and write commands
73
- pipe_name = IO.read( pipe_name_file_name ).chomp
74
- if File.exists? pipe_name
75
- # responses go to the director pipe
76
- File.open( pipe_name, 'w+' ) do |file|
77
- for cmd in ARGV
78
- cmd += ':' unless cmd.include?(':') || cmd[-1] == ':'
79
- file.puts cmd
80
- end
93
+ def default_scite_pipe_name
94
+ File.read( "/tmp/hilfer.#{ENV['USER']}.scite" ).chomp
95
+ end
81
96
 
82
- if $options[:pipe_to_output] || !STDIN.tty?
83
- text = STDIN.read
84
- # send IDM_CLEAROUTPUT
85
- file.puts "menucommand:420"
86
- file.puts "output:#{text.gsub "\n", '\n'}"
87
- end
97
+ editor = SciteEditor.new(
98
+ debug: $options.debug?,
99
+ scite_pipe_name: $options.scite_pipe_name || default_scite_pipe_name,
100
+ director_pipe_name: "/tmp/ssc.#{Process.pid}",
101
+ launched: true
102
+ )
103
+
104
+ # make sure the director pipe exists to get return values
105
+ editor.director_pipe
106
+
107
+ for cmd in @args
108
+ case cmd
109
+ when /:[0-9]+$/
110
+ # open a file with a line number
111
+ file_name, line_number = cmd.split(':')
112
+ editor.send_cmd :open, Pathname.new( file_name ).realpath.to_s
113
+ editor.send_cmd :goto, line_number
114
+
115
+ when /:/
116
+ # another scite command
117
+ editor.send_cmd *cmd.split(':')
118
+
119
+ else
120
+ # a plain file
121
+ editor.send_cmd :open, Pathname.new( cmd ).realpath.to_s
122
+ end
123
+ puts editor.response
124
+ end
88
125
 
89
- if $options[:goto]
90
- file.puts "goto:#{$options[:goto]}"
91
- end
126
+ if @args.empty? && ( $options.pipe_to_output? || !STDIN.tty? )
127
+ puts "reading stdin" if $options.debug?
128
+ # send IDM_CLEAROUTPUT
129
+ editor.send_cmd :menucommand, 420
130
+ STDIN.each_line do |line|
131
+ editor.send_cmd :output, line
132
+ editor.send_cmd :output, '\n'
133
+ sleep 0.005
92
134
  end
93
135
  end
94
136
 
137
+ if $options.goto
138
+ editor.send_cmd :goto, $options.goto
139
+ end
140
+
141
+ if $options.file?
142
+ editor.synchronize_path
143
+ puts editor.response[/^filename:(.+)$/,1]
144
+ end
145
+
146
+ if $options.line?
147
+ editor.send_cmd :askproperty, :SelectionStartLine
148
+ puts editor.response[/^macro:stringinfo:(\d+)$/,1]
149
+ end
150
+
151
+ editor.director_pipe.unlink
152
+
95
153
  __END__
96
154
  askfilename:|Return the name of the file being edited.
97
155
  askproperty:<key>|Return the value of a property.
@@ -11,18 +11,18 @@ module Gdk
11
11
  @lookup[keyval]
12
12
  end
13
13
  end
14
-
14
+
15
15
  # mainly for testing Gdk::EventKey, cos they're hard to
16
16
  # instantiate
17
17
  module KeyMatcher
18
18
  def key_name
19
19
  self.gdk_symbol[4..-1]
20
20
  end
21
-
21
+
22
22
  def gdk_symbol
23
23
  Gdk::Keyval.symbol( keyval )
24
24
  end
25
-
25
+
26
26
  def match( *args )
27
27
  bools = args.map do |arg|
28
28
  case arg
@@ -36,14 +36,14 @@ module Gdk
36
36
  end
37
37
  return bools.include?( true )
38
38
  end
39
-
39
+
40
40
  def =~( arg )
41
41
  match( arg )
42
42
  end
43
-
43
+
44
44
  def method_missing( meth, *args, &block )
45
45
  if meth.to_s[-1] == "?"[0]
46
- possible_key = meth.to_s[0..-2]
46
+ possible_key = meth.to_s[0..-2]
47
47
  if possible_key.size == 1
48
48
  key_name == possible_key || key_name == possible_key.upcase
49
49
  else
@@ -0,0 +1,19 @@
1
+ class Module
2
+ # define this for the OptionParse singletons
3
+ def attr_boolean( name, default = true )
4
+ # define getter
5
+ define_method( "#{name}?" ) do
6
+ instvar = instance_variable_get( "@#{name}" )
7
+ if instvar.nil?
8
+ instance_variable_set( "@#{name}", default )
9
+ instvar = default
10
+ end
11
+ instvar
12
+ end
13
+
14
+ # define setter
15
+ define_method( "#{name}=" ) do |rhs|
16
+ instance_variable_set( "@#{name}", rhs )
17
+ end
18
+ end
19
+ end
@@ -1,10 +1,12 @@
1
+ require 'pathname'
1
2
  require 'fileutils'
2
- require 'hilfer/window.rb'
3
+ require 'hilfer/module_extensions.rb'
3
4
 
4
5
  # handle director interface to scite
5
6
  class SciteEditor
6
- # options can contain :debug
7
- # view is a GtkTreeView
7
+ # options can contain anything with a setter
8
+ # No options will create a new scite instance
9
+ # specifying scite_pipe_name will hook into an existing instance
8
10
  def initialize( options = {} )
9
11
  # commands to scite are sent here
10
12
  @scite_pipe_name = "/tmp/hilfer.#{ENV['USER']}.#{Process.pid}.scite"
@@ -13,76 +15,97 @@ class SciteEditor
13
15
  @director_pipe_name = "/tmp/hilfer.#{ENV['USER']}.#{Process.pid}.director"
14
16
  @pipe_name_file = "/tmp/hilfer.#{ENV['USER']}.scite"
15
17
 
16
- cleanup
17
-
18
- # this is an array of TreeViewer objects
18
+ # this is an array of objects which respond to synchronise_editor_path
19
19
  @views = []
20
+
20
21
  # the command-line options
21
- @options = options
22
+ puts "options: #{options.inspect}" if options[:debug]
23
+ options.each do |key,value|
24
+ self.send( "#{key}=", value )
25
+ end
22
26
  end
23
27
 
24
- attr_reader :options
28
+ attr_boolean :debug, false
29
+ attr_boolean :launched
25
30
  attr_reader :scite_pid
26
31
  attr_reader :pipe_name_file
32
+ attr_accessor :scite_pipe_name
33
+ attr_accessor :director_pipe_name
27
34
 
28
- def debug?
29
- @options[:debug]
35
+ def scite_pipe
36
+ @scite_pipe ||= Pathname.new( scite_pipe_name )
30
37
  end
31
38
 
32
- def launched?
33
- !@scite_pid.nil?
39
+ def director_pipe
40
+ unless @director_pipe
41
+ puts "set director pipe" if debug?
42
+ @director_pipe = Pathname.new( director_pipe_name )
43
+
44
+ # create the director pipe if it isn't there already
45
+ puts "director pipe #{@director_pipe} exist?" if debug?
46
+ unless @director_pipe.exist?
47
+ puts "creating director pipe" if debug?
48
+ system( "mkfifo #{@director_pipe_name}" )
49
+ end
50
+ end
51
+ @director_pipe
34
52
  end
35
53
 
36
- # return a Window object for the editor.
37
- def window
38
- @window ||= Window.pid( @scite_pid )
54
+ def launched?
55
+ @launched || scite_pid
39
56
  end
40
57
 
41
58
  def reset
42
59
  @scite_pid = nil
43
- @window = nil
44
60
  end
45
61
 
46
62
  def kill
47
- `kill #{@scite_pid}`
63
+ Process.kill 'TERM', scite_pid
48
64
  reset
49
65
  cleanup
50
66
  end
51
67
 
52
68
  def cleanup
53
- FileUtils.rm @scite_pipe_name if File.exist? @scite_pipe_name
54
- FileUtils.rm @director_pipe_name if File.exist? @director_pipe_name
69
+ scite_pipe.unlink if scite_pipe.exist?
70
+ director_pipe.unlink if director_pipe.exist?
55
71
  FileUtils.rm pipe_name_file if File.exist? pipe_name_file
56
72
  end
57
73
 
58
74
  # send a command to SciTE
59
- def send_cmd( cmd, arg = '' )
75
+ def send_cmd( cmd, *args )
76
+ # open scite if necessary
60
77
  launch
61
- File.open( @scite_pipe_name, 'a' ) do |file|
62
- puts "sending: #{cmd.to_s}:#{arg.to_s}" if debug?
63
- file.puts "#{cmd.to_s}:#{arg.to_s}"
78
+
79
+ # make sure the pipe is open for returns
80
+ director_pipe
81
+
82
+ # send the command
83
+ scite_pipe.open('a') do |file|
84
+ args = args.map( &:to_s) * ':'
85
+ puts "args: #{args.inspect}" if debug?
86
+ full = ":#{director_pipe}:#{cmd.to_s}:#{args}"
87
+ puts "sending: #{full} to #{scite_pipe}" if debug?
88
+ file.puts full
89
+ puts "finished sending" if debug?
64
90
  end
65
91
  end
66
92
 
67
93
  # bring the SciTE instance to the current
68
94
  # desktop and raise it.
69
95
  def activate
70
- unless window.nil?
71
- puts "activating scite" if debug?
72
- window.activate
73
- puts "finished activating scite" if debug?
74
- end
96
+ send_cmd :focus
75
97
  end
76
98
 
77
99
  # open files in scite
78
100
  def open_action( files )
79
101
  files.each { |x| send_cmd "open", x.path }
80
- #~ send_cmd :identity, 0
81
102
  activate
82
103
  end
83
104
 
84
105
  def dump
85
- %w{dyn local user base embed}.each {|x| send_cmd 'enumproperties', x}
106
+ %w{dyn local user base embed}.each do |ptype|
107
+ send_cmd 'enumproperties', ptype
108
+ end
86
109
  #~ send_cmd 'askproperty','dyn:CurrentWord'
87
110
  end
88
111
 
@@ -124,22 +147,18 @@ class SciteEditor
124
147
 
125
148
  def write_pipe_name
126
149
  File.open( pipe_name_file, 'w' ) do |f|
127
- f.write @scite_pipe_name
150
+ f.write scite_pipe
128
151
  f.write "\n"
129
152
  end
130
153
  end
131
154
 
132
155
  # Start up the editor if there isn't already one.
133
156
  # Calling it when the editor is already open does nothing.
134
- # Store a Window object for raising, and store the pid for
135
157
  # other things. Will also install a handler for SIGCHLD
136
158
  def launch
137
159
  return if launched?
138
160
 
139
- # create the director pipe if it isn't there already
140
- unless File.exists?( @director_pipe_name )
141
- system( "mkfifo #{@director_pipe_name}" )
142
- end
161
+ cleanup
143
162
 
144
163
  scite_cmd = "/usr/bin/scite"
145
164
 
@@ -148,7 +167,7 @@ class SciteEditor
148
167
  child_pid = Process.wait( -1, Process::WNOHANG )
149
168
  # copy this now, before something else grabs it
150
169
  process_status = $?
151
- if @scite_pid == child_pid
170
+ if scite_pid == child_pid
152
171
  puts "process_status: #{process_status.inspect}" if debug?
153
172
  puts "cleaning pipes" if debug?
154
173
  cleanup
@@ -158,47 +177,72 @@ class SciteEditor
158
177
  end
159
178
 
160
179
  # fork and exec scite, so we can get scite's pid
161
- if ( @scite_pid = fork() ).nil?
180
+ unless @scite_pid = fork
181
+ # these seem to be deactivated by the fork, so
182
+ # so recreate the Pathname instances
183
+ @director_pipe = nil
184
+ @scite_pipe = nil
185
+
162
186
  puts "in child" if debug?
163
187
  # in child, so exec scite from here, so this pid will become scite's pid
164
188
  # not passing the first arg as a 2 element array doesn't work. So
165
189
  # use the same value for the command and as argv[0]
166
190
  exec(
167
191
  [ scite_cmd ] *2,
168
- "-ipc.director.name=#{@director_pipe_name}",
169
- "-ipc.scite.name=#{@scite_pipe_name}"
192
+ "-ipc.director.name=#{director_pipe}",
193
+ "-ipc.scite.name=#{scite_pipe}"
170
194
  )
171
195
  end
172
196
 
173
- puts "in parent: scite launched with pid #{@scite_pid}" if debug?
197
+ puts "in parent: scite launched with pid #{scite_pid}" if debug?
174
198
 
175
199
  # listen for incoming scite events, like file change and open
176
200
  start_listener
177
201
  end
178
202
 
203
+ # works with scite 1.x and 2.x
204
+ def response
205
+ rv = ''
206
+ puts "get response" if debug?
207
+ director_pipe.open do |dpio|
208
+ puts "checking for result" if debug?
209
+ if IO.select( [dpio] )
210
+ puts "reading line" if debug?
211
+ line = dpio.read_nonblock( 4096 )
212
+ puts "got line: #{line}" if debug?
213
+ rv << line.gsub( /[\0\n]+$/, '' )
214
+ end
215
+ end
216
+ rv
217
+ rescue EOFError
218
+ puts "eof error" if debug?
219
+ # just return empty
220
+ ''
221
+ end
222
+
179
223
  protected
180
224
 
181
225
  def start_listener
182
226
  # wait for scite pipe otherwise scite sometimes hangs and
183
227
  # doesn't receive open requests
184
- sleep 0.1 while !File.exists? @scite_pipe_name
185
- puts "#{@scite_pipe_name} exists" if debug?
228
+ sleep 0.1 while !scite_pipe.exist?
229
+ puts "scite_pipe #{scite_pipe} exists" if debug?
186
230
 
187
231
  # wait for director pipe as well
188
- sleep 0.1 while !File.exists? @director_pipe_name
189
- puts "#{@director_pipe_name} exists" if debug?
232
+ puts "director_pipe.exist?: #{director_pipe.exist?.inspect}" if debug?
233
+ sleep 0.1 while !director_pipe.exist?
234
+ puts "director_pipe #{director_pipe} exists" if debug?
190
235
 
191
236
  Thread.new do
192
237
  begin
193
238
  listen
194
239
  rescue Errno::ENOENT
195
- puts "pipe gone away, so stop listening" if debug?
240
+ puts "pipe gone away, so stop listening"
196
241
  rescue Exception => e
197
242
  puts "listener thread ended: #{e.message}"
198
243
  puts e.backtrace
199
244
  end
200
245
  end
201
-
202
246
  end
203
247
 
204
248
  def react( line )
@@ -235,12 +279,13 @@ protected
235
279
  def listen
236
280
  select_listen do |line|
237
281
  puts "read line: #{line.inspect}" if debug?
238
- line.gsub!( /[\0\n]+$/, '' )
239
- next if line.empty?
240
- react( line )
282
+ unless line.nil? || line.empty?
283
+ react line
284
+ end
241
285
  end
242
286
  rescue EOFError
243
287
  # just exit quietly, because scite has closed down
288
+ puts "EOFError in listen. Maybe scite closed down?" if debug?
244
289
  rescue Exception => e
245
290
  puts "caught Exception in listen: #{e.inspect}"
246
291
  puts e.backtrace
@@ -248,17 +293,17 @@ protected
248
293
 
249
294
  # doesn't work with scite 2.x
250
295
  def block_listen
251
- File.open( @director_pipe_name ).each( "\x0" ) do |line|
296
+ director_pipe.each_line( "\x0" ) do |line|
252
297
  yield line
253
298
  end
254
299
  end
255
300
 
256
301
  # works with scite 1.x and 2.x
257
302
  def select_listen
258
- File.open( @director_pipe_name ) do |director_pipe|
259
- while IO.select( [director_pipe] )
260
- line = director_pipe.read_nonblock( 4096 )
261
- yield line
303
+ director_pipe.open do |dpio|
304
+ while IO.select( [dpio] )
305
+ line = dpio.read_nonblock( 4096 )
306
+ yield line.gsub( /[\0\n]+$/, '' )
262
307
  end
263
308
  end
264
309
  end
@@ -472,7 +472,7 @@ class TreeViewer
472
472
 
473
473
  # alt-q toggles whether shutdown is automatic or not
474
474
  when event.q? && event.state.mod1_mask?
475
- $options[:quit_editor] = !$options[:quit_editor]
475
+ $options.quit_editor = !$options.quit_editor?
476
476
 
477
477
  # ctrl-* on keypad means expand the entire tree
478
478
  when event =~ 'KP_Multiply' && event.state.control_mask?
@@ -1,3 +1,3 @@
1
1
  module Hilfer
2
- VERSION = '0.11.8'
2
+ VERSION = '0.13.0'
3
3
  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.11.8
4
+ version: 0.13.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,30 +9,30 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-15 00:00:00.000000000 Z
12
+ date: 2012-04-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gtk2
16
- requirement: &78167250 !ruby/object:Gem::Requirement
16
+ requirement: &76124550 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: 1.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *78167250
24
+ version_requirements: *76124550
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bones
27
- requirement: &78166110 !ruby/object:Gem::Requirement
27
+ requirement: &76124210 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
- version: 3.7.1
32
+ version: 3.7.3
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *78166110
35
+ version_requirements: *76124210
36
36
  description: Programmers file browser for SciTE
37
37
  email: panic@semiosix.com
38
38
  executables:
@@ -40,13 +40,15 @@ executables:
40
40
  - ssc
41
41
  extensions: []
42
42
  extra_rdoc_files:
43
- - History.txt
44
- - README.txt
45
- - TODO
43
+ - History.rdoc
44
+ - Manifest.txt
45
+ - README.rdoc
46
+ - bin/hilfer
47
+ - bin/ssc
46
48
  files:
47
- - History.txt
49
+ - History.rdoc
48
50
  - Manifest.txt
49
- - README.txt
51
+ - README.rdoc
50
52
  - Rakefile
51
53
  - TODO
52
54
  - bin/hilfer
@@ -57,6 +59,7 @@ files:
57
59
  - lib/hilfer/hilfer_config.rb
58
60
  - lib/hilfer/hilfer_item.rb
59
61
  - lib/hilfer/hilfer_model.rb
62
+ - lib/hilfer/module_extensions.rb
60
63
  - lib/hilfer/standard_locator.rb
61
64
  - lib/hilfer/rails_locator.rb
62
65
  - lib/hilfer/scite_editor.rb
@@ -64,18 +67,17 @@ files:
64
67
  - lib/hilfer/tree_viewer.rb
65
68
  - lib/hilfer/tree_viewer_window.rb
66
69
  - lib/hilfer/version.rb
67
- - lib/hilfer/window.rb
68
70
  - lib/hilfer/xterm.rb
69
71
  - lib/hilfer/xfce_terminal.rb
70
72
  - test/test_key_matcher.rb
71
- homepage: http://hilfer.rubyforge.org/hilfer
73
+ homepage: http://rubygems.org/gems/hilfer
72
74
  licenses: []
73
75
  post_install_message:
74
76
  rdoc_options:
75
77
  - -W
76
- - http://gitweb.semiosix.com/hilfer.cgi?p=clevic;a=blob;f=%s;hb=HEAD
78
+ - http://gitweb.semiosix.com/hilfer.cgi?p=hilfer;a=blob;f=%s;hb=HEAD
77
79
  - --main
78
- - README.txt
80
+ - README.rdoc
79
81
  require_paths:
80
82
  - lib
81
83
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -92,9 +94,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
94
  version: '0'
93
95
  requirements: []
94
96
  rubyforge_project: hilfer
95
- rubygems_version: 1.8.10
97
+ rubygems_version: 1.8.11
96
98
  signing_key:
97
99
  specification_version: 3
98
- summary: http://www.
100
+ summary: http://rubygems.
99
101
  test_files:
100
102
  - test/test_key_matcher.rb
@@ -1,40 +0,0 @@
1
- # Currently only offers activate, which raises the window and give it focus
2
- class Window
3
- attr_accessor :window_id, :desktop, :pid, :title
4
-
5
- def initialize( window_id, desktop, pid, title )
6
- @window_id, @desktop, @pid, @title = window_id, desktop, pid, title
7
- end
8
-
9
- # create a new Window instance from the pid
10
- def self.pid( pid )
11
- list.find {|x| x.pid == pid.to_s }
12
- end
13
-
14
- def self.wmctrl( *args )
15
- unless `which wmctrl` == ''
16
- `wmctrl #{args * ' '}`
17
- else
18
- ''
19
- end
20
- rescue
21
- ''
22
- end
23
-
24
- def wmctrl( *args )
25
- self.class.wmctrl( *args )
26
- end
27
-
28
- # window is the Window ID
29
- def activate
30
- wmctrl "-i -R 0x#{window_id}"
31
- $?
32
- end
33
-
34
- def self.list
35
- wmctrl( '-lp' ).split("\n").map do |line|
36
- line =~ /^(0x[[:xdigit:]]+)\s+(-?\d+)\s+(\d+)\s+(.*)/i
37
- Window.new( $1, $2, $3, $4 )
38
- end
39
- end
40
- end