hilfer 0.11.7 → 0.11.8

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ === 0.11.8 / 15-Oct-2011
2
+ * do locators for test and lib, whether or not rails is found
3
+ * fix ssc pipe name, so it works again
4
+ * quieten output unless verbose
5
+ * fail gracefully on lack of wmctrl
6
+ * add ssc piping to scite output window
7
+
1
8
  === 0.11.7 / 09-Oct-2011
2
9
  * quieten messages from scite
3
10
 
data/Manifest.txt CHANGED
@@ -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/standard_locator.rb
14
15
  lib/hilfer/rails_locator.rb
15
16
  lib/hilfer/scite_editor.rb
16
17
  lib/hilfer/svn_colours.rb
data/README.txt CHANGED
@@ -16,7 +16,7 @@ I wrote hilfer.
16
16
 
17
17
  === Main UI
18
18
 
19
- - Incremental keyboard search - just start typing in the window
19
+ - Incremental keyboard search - just start typing in the window, then use up and down arrows.
20
20
  - Editable & hideable location bar showing current directory
21
21
  - multiple selections usually do The Right Thing.
22
22
  - Can track which file is currently in front in the editor.
@@ -54,21 +54,38 @@ I wrote hilfer.
54
54
  - left means close level(s)
55
55
  - right means open level(s)
56
56
 
57
+ === Standard shortcuts
58
+
59
+ - Shift-Ctrl-T: go to test/spec
60
+ - Shift-Ctrl-B: go to lib
61
+
57
62
  === Rails shortcuts
58
63
 
59
64
  - Shift-Ctrl-V: go to view, or view dir
60
65
  - Shift-Ctrl-C: go to controller, or controller dir
61
66
  - Shift-Ctrl-M: go to model, or model dir
62
- - Shift-Ctrl-T: go to test/spec
63
67
  - Shift-Ctrl-H: go to helpers dir
64
68
  - Shift-Ctrl-L: go to layouts dir
65
69
  - Shift-Ctrl-I: go to migrations
66
70
  - Shift-Ctrl-S: go to stylesheets
67
71
  - Shift-Ctrl-F: go to fixtures
68
- - Shift-Ctrl-B: go to lib
69
72
  - Shift-Ctrl-O: go to config
70
73
  - Shift-Ctrl-U: go to routes.rb
71
74
 
75
+ === SciTE director commands
76
+
77
+ Use ssc to send commands directly to the instance of scite that was opened by
78
+ hilfer.
79
+
80
+ ssc find:pipe
81
+
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
88
+
72
89
  === Subversion colour highlighting
73
90
 
74
91
  Svn::Wc::STATUS_NONE => '#000', # black
@@ -86,16 +103,13 @@ I wrote hilfer.
86
103
  Svn::Wc::STATUS_EXTERNAL => '#000', # black
87
104
  Svn::Wc::STATUS_UNVERSIONED => '#808', # purple
88
105
 
89
- === SciTE director commands
90
-
91
- Use ssc to send commands directly to the instance of scite that was opened by
92
- hilfer.
93
-
94
106
  == PROBLEMS
95
107
 
96
108
  These may or may not be problems, as you like. No drag-and-drop. No
97
109
  icon themes. Can't create new files. Only opens files in SciTE.
98
110
 
111
+ ssc will send command to the last version of hilfer that had focus.
112
+
99
113
  See TODO file
100
114
 
101
115
  == SYNOPSIS
@@ -113,11 +127,11 @@ See TODO file
113
127
 
114
128
  === Optional packages
115
129
 
130
+ * wmctrl to raise SciTE editor window when files are opened
116
131
  * text-format for ssc to display extended scite director commands
117
132
  * subversion-ruby to display colour highlighted subversion status
118
133
  * gnome-terminal or Xfce Terminal executable
119
134
  * ActiveSupport to enable rails-specific shortcuts
120
- * wmctrl to raise SciTE editor window when files are opened
121
135
 
122
136
  == INSTALL:
123
137
 
data/TODO CHANGED
@@ -1,3 +1,4 @@
1
+ use focus: instead of wmctrl
1
2
  menu
2
3
  working sets, like eclipse
3
4
  option to connect to existing scite, by pid?
@@ -5,6 +6,7 @@ Sort by directories, then files. Needs Options.
5
6
  fix multiple selection editing, ie when several files are selected?
6
7
  shift-* to select all descendants
7
8
  alt-d to toggle deletion confirmation. Status icon to show warning?
9
+ alt-n for new empty file, with similarity to current file
8
10
  Ctrl-H to Hide/unhide certain files. Right-click to hide, or Alt-H to hide
9
11
 
10
12
  autosize?
data/bin/hilfer CHANGED
@@ -8,7 +8,8 @@ $options = { :debug => false, :hidden => false, :auto_sync => false, :quit_edito
8
8
  oparser = OptionParser.new
9
9
  oparser.on( '-y', '--auto-sync', 'track editor current file changes') { |o| $options[:host] = true }
10
10
  oparser.on( '-s', '--show-hidden', 'Show hidden files' ) { |o| $options[:user] = true }
11
- oparser.on( '-D', '-d', '-v', '--debug' ) { |o| puts "debug on"; $options[:debug] = true }
11
+ oparser.on( '-D', '-d', '--debug' ) { |o| $options[:debug] = $options[:verbose] = true }
12
+ oparser.on( '-v', '--verbose' ) { |o| $options[:verbose] = true }
12
13
  oparser.on( '-q', '--quit-editor', 'close editor on shutdown' ) { |o| $options[:quit_editor] = true }
13
14
 
14
15
  oparser.on( '-V', '--version', 'show version' ) do |o|
data/bin/ssc CHANGED
@@ -9,50 +9,35 @@ rescue LoadError
9
9
  HAS_TEXT_FORMAT = false
10
10
  end
11
11
 
12
+ $options = {}
13
+
12
14
  # display help and commands
13
15
  oparser = OptionParser.new
14
- oparser.banner = "Usage: ssc [-h] | cmd[ cmd][...]"
16
+ oparser.banner = <<EOF
17
+ Usage: ssc [options] | [ cmd] [...]" | STDIN
18
+
19
+ if STDIN is given, pipe to the current scites output window
20
+
21
+ 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
+
26
+ oparser.on( '-g', '--goto N[,N]', "go to the given line and column number") do |val|
27
+ $options[:goto] = val
28
+ end
29
+
15
30
  oparser.on( '-h', '-?', '--help' ) do |o|
16
31
  puts oparser.to_s
17
- puts
32
+ end
33
+
34
+ oparser.on( '--help-commands' ) do |o|
18
35
  puts "Send one or several commands to the current scite"
19
36
  if HAS_TEXT_FORMAT
20
37
  puts
21
38
  puts "Commands are (http://scintilla.sourceforge.net/SciTEDirector.html):"
22
39
  puts
23
- st = <<EOF
24
- askfilename:|Return the name of the file being edited.
25
- askproperty:<key>|Return the value of a property.
26
- close:|Close the current file.
27
- closing:|Director is closing - SciTE closes if it was started by the director.
28
- currentmacro:<string>|Set the current macro to name.
29
- cwd:|Change the working directory.
30
- enumproperties:dyn|local|user|base|embed|Enumerate all the properties in the argument set.
31
- exportashtml:<path>|Save the document in HTML format as the indicated file.
32
- exportasrtf:<path>|Save the document in RTF format as the indicated file.
33
- exportaspdf:<path>|Save the document in PDF format as the indicated file.
34
- exportaslatex:<path>|Save the document in LaTeX format as the indicated file.
35
- exportasxml:<path>|Save the document in XML format as the indicated file.
36
- extender:<command>|Call the extension interface with the given command.
37
- find:<string>|Search for a string, select and show it.
38
- focus:<timeStamp>|On GTK+ bring this SciTE window to the front. The timeStamp is from the window manager and ensures that windows are only activated because of a user command. Has no effect on Windows as applications on Windows can only donate focus, not take focus.
39
- goto:<line>[,<col>]|Move caret to a particular line and make it visible. If there is a column number then select the word at that column number or move the caret there if no word is present.
40
- identity:<hwndDirector>|Sets the director window handle to which SciTE sends messages. The argument is in decimal.
41
- insert:<value>|Display the value in the editor pane replacing the selection.
42
- loadsession:<path>|Load a session as given by the indicated file.
43
- macrocommand:<command>|Execute a macro command. See the SciTE source code for the syntax of the command argument.
44
- macroenable:<enable>|If enable, display menu commands in SciTE for recording and playing macros.
45
- macrolist:<list>|Display a list for the user to choose from.
46
- menucommand:<cmd>|Execute a menu command based on numeric ID.
47
- open:<path>|Open the indicated file.
48
- output:<value>|Display the value in the output pane replacing the selection.
49
- property:<key>=<value>|Set a property to a value.
50
- quit:|Shut down SciTE.
51
- reloadproperties:|Reload properties from files.
52
- replaceall:<srch>\\000<rep>|Replace all instances of he search string in the document with the replace string.
53
- saveas:<path>|Save the document as the indicated file.
54
- savesession:<path>|Save a session as given by the indicated file.
55
- EOF
40
+ st = DATA.read
56
41
  cmds = st.split(/\n/)
57
42
  re = /(.*?)\|(.*)/
58
43
  tf = Text::Format.new( :format_style => :fill, :left_margin => 28, :columns => 90 )
@@ -62,8 +47,9 @@ EOF
62
47
  puts( "%-28s%-52s" % [ cmd, desc.strip ] )
63
48
  end
64
49
  else
50
+ puts DATA.read
65
51
  puts
66
- puts "text/format not found. scite director commands not displayed."
52
+ puts "text/format not found. scite director commands uglified"
67
53
  end
68
54
  exit( 1 )
69
55
  end
@@ -72,18 +58,69 @@ end
72
58
  args = oparser.parse( ARGV )
73
59
 
74
60
  # which is the pipe file
75
- pipe_name_file_name = "/tmp/#{ENV['USER']}.hilfer.scite"
61
+ pipe_name_file_name = "/tmp/hilfer.#{ENV['USER']}.scite"
76
62
  if !File.exists?( pipe_name_file_name )
77
63
  puts "#{pipe_name_file_name} does not exist"
78
64
  exit(1)
79
65
  end
80
66
 
67
+ if ARGV.empty? && STDIN.tty?
68
+ puts oparser
69
+ exit 1
70
+ end
71
+
81
72
  # open pipe and write commands
82
73
  pipe_name = IO.read( pipe_name_file_name ).chomp
83
74
  if File.exists? pipe_name
75
+ # responses go to the director pipe
84
76
  File.open( pipe_name, 'w+' ) do |file|
85
77
  for cmd in ARGV
78
+ cmd += ':' unless cmd.include?(':') || cmd[-1] == ':'
86
79
  file.puts cmd
87
80
  end
81
+
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
88
+
89
+ if $options[:goto]
90
+ file.puts "goto:#{$options[:goto]}"
91
+ end
88
92
  end
89
93
  end
94
+
95
+ __END__
96
+ askfilename:|Return the name of the file being edited.
97
+ askproperty:<key>|Return the value of a property.
98
+ close:|Close the current file.
99
+ closing:|Director is closing - SciTE closes if it was started by the director.
100
+ currentmacro:<string>|Set the current macro to name.
101
+ cwd:|Change the working directory.
102
+ enumproperties:dyn|local|user|base|embed|Enumerate all the properties in the argument set.
103
+ exportashtml:<path>|Save the document in HTML format as the indicated file.
104
+ exportasrtf:<path>|Save the document in RTF format as the indicated file.
105
+ exportaspdf:<path>|Save the document in PDF format as the indicated file.
106
+ exportaslatex:<path>|Save the document in LaTeX format as the indicated file.
107
+ exportasxml:<path>|Save the document in XML format as the indicated file.
108
+ extender:<command>|Call the extension interface with the given command.
109
+ find:<string>|Search for a string, select and show it.
110
+ focus:<timeStamp>|On GTK+ bring this SciTE window to the front. The timeStamp is from the window manager and ensures that windows are only activated because of a user command. Has no effect on Windows as applications on Windows can only donate focus, not take focus.
111
+ goto:<line>[,<col>]|Move caret to a particular line and make it visible. If there is a column number then select the word at that column number or move the caret there if no word is present.
112
+ identity:<hwndDirector>|Sets the director window handle to which SciTE sends messages. The argument is in decimal.
113
+ insert:<value>|Display the value in the editor pane replacing the selection.
114
+ loadsession:<path>|Load a session as given by the indicated file.
115
+ macrocommand:<command>|Execute a macro command. See the SciTE source code for the syntax of the command argument.
116
+ macroenable:<enable>|If enable, display menu commands in SciTE for recording and playing macros.
117
+ macrolist:<list>|Display a list for the user to choose from.
118
+ menucommand:<cmd>|Execute a menu command based on numeric ID.
119
+ open:<path>|Open the indicated file.
120
+ output:<value>|Display the value in the output pane replacing the selection.
121
+ property:<key>=<value>|Set a property to a value.
122
+ quit:|Shut down SciTE.
123
+ reloadproperties:|Reload properties from files.
124
+ replaceall:<srch>\\000<rep>|Replace all instances of he search string in the document with the replace string.
125
+ saveas:<path>|Save the document as the indicated file.
126
+ savesession:<path>|Save a session as given by the indicated file.
@@ -0,0 +1,85 @@
1
+ require 'pathname'
2
+
3
+ =begin
4
+ This handles various keypresses that jump to specific
5
+ locations in a project. If a specific file isn't
6
+ selected, the jump will go to the directory. Otherwise
7
+ it will go to a specific file.
8
+ =end
9
+ class StandardLocator
10
+ attr_accessor :treeviewer
11
+
12
+ def initialize( treeviewer )
13
+ @treeviewer = treeviewer
14
+
15
+ @controller_re = %r|^(.*?)/app/controllers/(.*?)/?(.*?)_controller.rb$|
16
+ @view_re = %r|^(.*?)/app/views/(.*?)/?([^/.]*?\..*?)?$|
17
+ @model_re = %r|^(.*?)/app/models/(.*?/?)([^/.]*?).rb$|
18
+ @unit_test_re = %r|^(.*?)/test/unit/(.*?/?)(.*?)_test.rb$|
19
+ @functional_test_re = %r|^(.*?)/test/functional/(.*?/?)(.*?)_controller_test.rb$|
20
+ @fixture_re = %r|^(.*?)/test/fixtures/(.*?/?)(.*?).yml$|
21
+ end
22
+
23
+ def viewer_root
24
+ treeviewer.root_item.path
25
+ end
26
+
27
+ def goto_path( fs_path )
28
+ treeviewer.select_fs_path( viewer_root + fs_path, true )
29
+ end
30
+
31
+ def select_related_paths( widget, event, &block )
32
+ items = []
33
+ paths_to_select = []
34
+ widget.selection.selected_each do
35
+ |model, path, iter|
36
+ item = model.get_value( iter, 0 )
37
+ puts "item: #{item.path}" if $options[:debug]
38
+ new_path = yield( item )
39
+ puts "new_path #{new_path}" if $options[:debug]
40
+ paths_to_select << viewer_root + new_path
41
+ end
42
+
43
+ treeviewer.select_fs_paths( paths_to_select, true )
44
+ end
45
+
46
+ def handle_keypress( widget, event )
47
+ retval = true
48
+ case
49
+ # Shift-Ctrl-T - go to test, or test dir
50
+ when event.hardware_keycode == 28 && event.state.control_mask? && event.state.shift_mask?
51
+ select_related_paths( widget, event ) do |item|
52
+ case
53
+ when md = @model_re.match( item.path )
54
+ '/test/unit/' + $2 + $3 + '_test.rb'
55
+ when md = @view_re.match( item.path )
56
+ '/test/functional/' + $2 + '_controller_test.rb'
57
+ when md = @controller_re.match( item.path )
58
+ '/test/functional/' + $2 + $3 + '_controller_test.rb'
59
+ when md = @fixture_re.match( item.path )
60
+ '/test/unit/' + $2 + $3.singularize + '_test.rb'
61
+ else
62
+ rp = Pathname.new( viewer_root )
63
+ if ( rp + 'test' ).exist?
64
+ '/test'
65
+ elsif (rp + 'spec').exist?
66
+ '/spec'
67
+ end
68
+ end
69
+ end
70
+
71
+ # Shift-Ctrl-B - go to lib dir
72
+ when event.hardware_keycode == 56 && event.state.control_mask? && event.state.shift_mask?
73
+ goto_path '/lib'
74
+
75
+ # Shift-Ctrl-O - go to config
76
+ when event.hardware_keycode == 32 && event.state.control_mask? && event.state.shift_mask?
77
+ goto_path '/config'
78
+
79
+ else
80
+ retval = false
81
+ end
82
+ retval
83
+ end
84
+
85
+ end
@@ -7,10 +7,10 @@ require 'hilfer/extensions.rb'
7
7
 
8
8
  # try to load Gnome terminal
9
9
  begin
10
- require 'hilfer/gnome_terminal.rb'
10
+ require 'hilfer/gnome_terminal.rb' if $options[:verbose]
11
11
  HAS_GNOME_TERMINAL = true
12
12
  rescue
13
- puts "gnome-terminal not available."
13
+ puts "gnome-terminal not available." if $options[:verbose]
14
14
  HAS_GNOME_TERMINAL = false
15
15
  end
16
16
 
@@ -25,12 +25,15 @@ end
25
25
 
26
26
  require 'hilfer/xterm.rb'
27
27
 
28
+ # standard locator
29
+ require 'hilfer/standard_locator.rb'
30
+
28
31
  # try to load rails locator
29
32
  begin
30
33
  require 'hilfer/rails_locator.rb'
31
34
  HAS_RAILS_LOCATOR = true
32
35
  rescue LoadError
33
- puts "ActiveSupport not loaded. No rails-specific keystrokes"
36
+ puts "ActiveSupport not loaded. No rails-specific keystrokes" if $options[:verbose]
34
37
  HAS_RAILS_LOCATOR = false
35
38
  end
36
39
 
@@ -39,7 +42,7 @@ begin
39
42
  require 'hilfer/svn_colours.rb'
40
43
  HAS_SUBVERSION = true
41
44
  rescue LoadError
42
- puts "svn/client not loaded. Coloured SVN status will not be displayed."
45
+ puts "svn/client not loaded. Coloured SVN status will not be displayed." if $options[:verbose]
43
46
  HAS_SUBVERSION = false
44
47
  end
45
48
 
@@ -79,6 +82,7 @@ class TreeViewer
79
82
  # locators are things that provide a set of shortcut keys
80
83
  # to jump to specific directories, files, or related locations
81
84
  @locators = []
85
+ @locators << StandardLocator.new( self )
82
86
  @locators << RailsLocator.new( self ) if HAS_RAILS_LOCATOR
83
87
 
84
88
  # pre-populate model from filesystem, only 1 level deep
@@ -1,3 +1,3 @@
1
1
  module Hilfer
2
- VERSION = '0.11.7'
2
+ VERSION = '0.11.8'
3
3
  end
data/lib/hilfer/window.rb CHANGED
@@ -1,24 +1,38 @@
1
1
  # Currently only offers activate, which raises the window and give it focus
2
2
  class Window
3
3
  attr_accessor :window_id, :desktop, :pid, :title
4
-
4
+
5
5
  def initialize( window_id, desktop, pid, title )
6
6
  @window_id, @desktop, @pid, @title = window_id, desktop, pid, title
7
7
  end
8
-
8
+
9
9
  # create a new Window instance from the pid
10
10
  def self.pid( pid )
11
11
  list.find {|x| x.pid == pid.to_s }
12
12
  end
13
-
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
+
14
28
  # window is the Window ID
15
29
  def activate
16
- `wmctrl -i -R 0x#{window_id}`
30
+ wmctrl "-i -R 0x#{window_id}"
17
31
  $?
18
32
  end
19
-
33
+
20
34
  def self.list
21
- `wmctrl -lp`.split("\n").map do |line|
35
+ wmctrl( '-lp' ).split("\n").map do |line|
22
36
  line =~ /^(0x[[:xdigit:]]+)\s+(-?\d+)\s+(\d+)\s+(.*)/i
23
37
  Window.new( $1, $2, $3, $4 )
24
38
  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.7
4
+ version: 0.11.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-09 00:00:00.000000000Z
12
+ date: 2011-10-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gtk2
16
- requirement: &82581120 !ruby/object:Gem::Requirement
16
+ requirement: &78167250 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,18 +21,18 @@ dependencies:
21
21
  version: 1.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *82581120
24
+ version_requirements: *78167250
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bones
27
- requirement: &82580360 !ruby/object:Gem::Requirement
27
+ requirement: &78166110 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
- version: 3.7.0
32
+ version: 3.7.1
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *82580360
35
+ version_requirements: *78166110
36
36
  description: Programmers file browser for SciTE
37
37
  email: panic@semiosix.com
38
38
  executables:
@@ -57,6 +57,7 @@ files:
57
57
  - lib/hilfer/hilfer_config.rb
58
58
  - lib/hilfer/hilfer_item.rb
59
59
  - lib/hilfer/hilfer_model.rb
60
+ - lib/hilfer/standard_locator.rb
60
61
  - lib/hilfer/rails_locator.rb
61
62
  - lib/hilfer/scite_editor.rb
62
63
  - lib/hilfer/svn_colours.rb