vimmate 0.8.1 → 0.9.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.
data/README CHANGED
@@ -51,11 +51,10 @@ To install:
51
51
  {VimMate's homepage}[http://vimmate.rubyforge.org/].
52
52
  - You now have 3 choices to install VimMate: manually, with Ruby Gems or with
53
53
  <tt>setup.rb</tt>:
54
- - With Ruby Gems
55
- - Simply run <tt>gem install VimMate</tt> .
56
- - With <tt>setup.rb</tt>
57
- - Simply run <tt>ruby setup.rb</tt> . Run <tt>ruby setup.rb --help</tt> for
58
- more information.
54
+ - With Ruby Gems from GemCutter
55
+ - Simply run <tt>gem install vimmate --source http://gemcutter.org</tt> .
56
+ - Build the gem by yourself
57
+ - Simply run <tt>rake install</tt>
59
58
  - Manually
60
59
  - Copy the file <tt>bin/vimmate</tt> and the directory
61
60
  <tt>lib/vimmatelib</tt> to a directory somewhere in your path.
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.9.0
data/bin/vimmate CHANGED
@@ -18,6 +18,10 @@ OptionParser.new do |opts|
18
18
  excludes = list
19
19
  end
20
20
 
21
+ opts.on_tail('-w', '--no-detach', 'Do not return to the terminal') do
22
+ @do_not_detach = true
23
+ end
24
+
21
25
  opts.on_tail("-h", "--help", "Show this help screen") do |string|
22
26
  puts opts
23
27
  exit
@@ -36,65 +40,14 @@ if File.exists?(local_ignore_file)
36
40
  end
37
41
  end
38
42
 
39
- # We fork to give back the shell to the user, like Vim
40
- fork do
43
+ starting = lambda do
41
44
  require File.expand_path( File.join( File.dirname(__FILE__), '..', 'config', 'environment' ) )
42
45
  Thread.abort_on_exception = true
43
46
 
44
- class VimMateApp < ActiveWindow::Application
45
- def initialize(opts={})
46
- @excludes = opts.delete(:excludes)
47
- super
48
- end
49
- def file_tree
50
- files.file_tree
51
- end
52
- def files
53
- controller[:file_filter]
54
- end
55
- def vim
56
- controller[:vim].vim
57
- end
58
- def add_path(path)
59
- file_tree.initial_adding do
60
- file_tree.add_path(path)
61
- end
62
- end
63
-
64
- def post_setup
65
- super
66
-
67
- @excludes.each do |rule|
68
- file_tree.exclude! rule
69
- end unless @excludes.blank?
70
-
71
- # If there are no files given, add the current directory to the file list.
72
- # If files are specified on the command line, use them
73
- if ARGV.empty?
74
- add_path(File.expand_path('.'))
75
- files.expand_first_row
76
- else
77
- ARGV.each do |file|
78
- path = File.expand_path(file)
79
- add_path(path)
80
- #window.vim.open(path, :tab)
81
- end
82
- end
83
- end
84
-
85
- def run
86
- GLib::Timeout.add(23) do
87
- vim.start
88
- false
89
- end
90
- super
91
- end
92
- end
93
-
94
47
  icon_path = File.join( File.dirname(__FILE__), '..', 'images', 'vimmate48.png' )
95
48
  Gtk::Window.set_default_icon(icon_path)
96
49
 
97
- app = VimMateApp.new(:title => 'VimMate', :main_window => 'VimMate', :excludes => excludes)
50
+ app = VimMate::App.new(:title => 'VimMate', :main_window => 'VimMate', :excludes => excludes)
98
51
  app.start
99
52
 
100
53
 
@@ -103,3 +56,8 @@ fork do
103
56
 
104
57
  end
105
58
 
59
+ if @do_not_detach
60
+ starting.call
61
+ else
62
+ fork { starting.call }
63
+ end
@@ -1,25 +1,26 @@
1
1
  require 'rubygems'
2
- require 'activesupport'
3
-
4
2
 
5
3
  APP_ROOT = File.expand_path( File.join( File.dirname(__FILE__), '..' ) )
6
4
  PROGRAM_NAME = 'vim_mate'
7
5
 
8
- #ActiveSupport::Dependencies::logger = Logger.new( File.expand_path('log/dependencies.log') )
9
- #ActiveSupport::Dependencies::log_activity = true
10
- ActiveSupport::Dependencies::load_paths << File.join(APP_ROOT, "lib")
11
- ActiveSupport::Dependencies::load_paths << File.join(APP_ROOT, "controllers")
12
- ActiveSupport::Dependencies::load_paths << File.join(APP_ROOT, "lib/vim_mate")
6
+ require 'gtk2'
7
+ require 'i18n' # activesupport needs this
8
+ require 'active_support'
9
+ require 'active_support/core_ext/object'
10
+ require 'yaml'# for DotFile
13
11
 
14
- VimMate::Requirer.require_exit('gtk2')
15
- VimMate::Requirer.require_exit('libglade2')
12
+ $:.unshift APP_ROOT
16
13
 
14
+ require 'lib/active_window'
15
+ require 'lib/listed_file'
16
+ require 'lib/listed_directory'
17
+ require 'lib/file_tree_store.rb'
18
+ require 'lib/filtered_file_tree_store.rb'
19
+ require 'lib/vim'
20
+ require 'lib/vim_mate'
17
21
 
18
- #require 'vimmatelib/file_tree_view'
19
- require_dependency 'gtk_thread_helper'
20
- require_dependency 'plugins'
21
22
 
22
- require_dependency 'active_window'
23
+ require 'gtk_thread_helper'
23
24
 
24
25
  %w(
25
26
  file_created file_modified file_deleted file_opened
@@ -31,5 +32,5 @@ require_dependency 'active_window'
31
32
  end
32
33
 
33
34
  Dir[File.join(APP_ROOT, 'controllers', '*_controller.rb' )].each do |controller_path|
34
- require_dependency File.basename(controller_path)
35
+ require controller_path
35
36
  end
@@ -0,0 +1,91 @@
1
+ class ConfigController < ActiveWindow::Controller
2
+
3
+ attr_reader :boxes, :fields
4
+
5
+ def setup
6
+ @fields = {}
7
+ @boxes = []
8
+ with_options(:pack => general_config) do |general|
9
+ general.create_field(:files_use_search, :label => 'Use Search')
10
+ general.create_field(:files_use_ellipsis, :label => 'Shorten Filenames')
11
+ end
12
+ end
13
+
14
+ def save_settings
15
+ VimMate::Config::DEFAULT_CONFIG.keys.each do |key|
16
+ unless (new_val = val_of(key)).nil?
17
+ VimMate::Config.config[key] = new_val
18
+ end
19
+ end
20
+ VimMate::Config.write_config
21
+ close_window
22
+ end
23
+
24
+ def reset_settings
25
+ boxes.each(&:destroy)
26
+ setup
27
+ config_window.show_all
28
+ end
29
+
30
+ def open_window
31
+ config_window.show_all
32
+ end
33
+
34
+ def close_window
35
+ config_window.hide
36
+ end
37
+
38
+ private
39
+
40
+ def create_field(key, options = {})
41
+ val = VimMate::Config[key]
42
+
43
+ box = Gtk::HBox.new(true, 10)
44
+ label = Gtk::Label.new options.delete(:label) || key.to_s.humanize
45
+ label.xalign = 1
46
+ box.pack_start label, true, true
47
+ field = field_for val
48
+ fields[key] = field
49
+ box.pack_start field, true, false
50
+
51
+ boxes << box
52
+
53
+ container = options.delete(:pack) || general_config
54
+ container.pack_start box, false, false
55
+ end
56
+
57
+ def val_of(key)
58
+ return unless field = fields[key]
59
+ case VimMate::Config::DEFAULT_CONFIG[key]
60
+ when String
61
+ field.text
62
+ when Fixnum
63
+ field.value.to_i
64
+ when Float
65
+ field.value.to_f
66
+ when FalseClass, TrueClass
67
+ field.active?
68
+ end
69
+ end
70
+
71
+ def field_for(val)
72
+ case val
73
+ when String
74
+ # TODO make "textarea" for more than 42 chars
75
+ e = Gtk::Entry.new
76
+ e.editable = true
77
+ e.text = val
78
+ e
79
+ when Fixnum, Float
80
+ Gtk::SpinButton.new(
81
+ Gtk::Adjustment.new(val,0,10000,1,10,1),
82
+ 1,0)
83
+ when FalseClass, TrueClass
84
+ e = Gtk::CheckButton.new
85
+ e.active = val
86
+ e
87
+ else
88
+ Gtk::Label.new(val.to_s)
89
+ end
90
+ end
91
+ end
@@ -71,8 +71,7 @@ class FileFilterController < ActiveWindow::Controller
71
71
  file_tree_view.expand_row(Gtk::TreePath.new("0"), false)
72
72
  end
73
73
 
74
- def button_pressed(given)
75
- event = given[:event]
74
+ def button_pressed(given, event)
76
75
  if event.kind_of? Gdk::EventButton and event.button == 3
77
76
  path = file_tree_view.get_path_at_pos(event.x, event.y)
78
77
  file_tree_view.selection.select_path(path[0]) if path
@@ -28,8 +28,7 @@ class VimMateController < ActiveWindow::Controller
28
28
  #end
29
29
  end
30
30
 
31
- def pressed_key(given)
32
- return unless event = given[:event]
31
+ def pressed_key(given, event)
33
32
  if event.state & Gdk::Window::ModifierType::CONTROL_MASK != 0
34
33
  if event.state & Gdk::Window::ModifierType::SHIFT_MASK != 0
35
34
  case event.keyval
@@ -2,19 +2,29 @@ class ActiveWindow::Application
2
2
  include ActiveSupport::Callbacks
3
3
  define_callbacks :after_initialize
4
4
 
5
- attr_accessor :controller, :database, :glade, :window
5
+ attr_accessor :controller, :database, :window
6
+ attr_reader :builder
7
+
8
+ def self.widget(*widgets)
9
+ widgets.each do |widget|
10
+ name = widget.to_s.camelize
11
+ define_method widget do
12
+ builder[name]
13
+ end
14
+ end
15
+ end
6
16
 
7
17
  def widget(name)
8
- glade[name]
18
+ builder[name]
9
19
  end
10
20
 
11
21
  def initialize(options = {})
12
- @glade = GladeXML.new(find_glade, nil, options[:title] || 'application' )
22
+ @builder = Gtk::Builder.new
23
+ @builder.add_from_file(find_view)
13
24
  @window = widget(options[:main_window] || 'main_window')
14
25
  @window.signal_connect("destroy") { Gtk.main_quit }
15
- @dot_file_prefs = DotFile.read
26
+ @dot_file_prefs = ActiveWindow::DotFile.read
16
27
  @database = options[:database]
17
- define_widget_readers
18
28
  run_callbacks :after_initialize
19
29
  end
20
30
 
@@ -49,18 +59,11 @@ class ActiveWindow::Application
49
59
  name = klass.to_s.sub('Controller','').underscore.to_sym # eg MyFirstController -> :my_first
50
60
  controller[name] = ctrl
51
61
  end
52
-
53
- glade.signal_autoconnect_full do |source, target, signal, handler, data|
54
- # for example:
55
- # source : instance of Gtk::ImageMenuItem
56
- # target : nil
57
- # signal : activate, clicked, pressed, etc.
58
- # handler : window.close, which would call WindowController.close()
59
- # data : nil
60
- #puts [source, target, signal, handler, data].inspect
61
- source.signal_connect(signal) { |widget,event| self.dispatch(handler, :source => source, :target => target, :signal => signal, :handler => handler, :data => data, :widget => widget, :event => event) }
62
- #source.signal_connect(signal) { self.(handler, data) }
62
+
63
+ builder.connect_signals do |handler_name|
64
+ dispatch(handler_name)
63
65
  end
66
+
64
67
  post_setup
65
68
  end
66
69
 
@@ -71,10 +74,10 @@ class ActiveWindow::Application
71
74
  end
72
75
  end
73
76
 
77
+ ## gets a handler like "config.reset_settings"
78
+ ## returns the method (reset_settings) of the controller (ConfigController) to use as a callback
74
79
  ##
75
- ## dispatch a signal to the correct controller
76
- ##
77
- def dispatch(handler, event)
80
+ def dispatch(handler)
78
81
  controller_name,action = handler.to_s.split('.')
79
82
  unless controller_name and action
80
83
  return(error "cannot parse handler '%s'" % handler)
@@ -92,12 +95,6 @@ class ActiveWindow::Application
92
95
  end
93
96
 
94
97
  method = ctrl.method(action)
95
- #puts "calling %s.%s" % [controller_name.camelize, action]
96
- if method.arity == 0
97
- method.call
98
- else
99
- method.call(event)
100
- end
101
98
  end
102
99
 
103
100
 
@@ -111,27 +108,16 @@ class ActiveWindow::Application
111
108
  puts msg
112
109
  end
113
110
 
114
- def find_glade
115
- Dir.glob("#{views_directory}/*.glade") do |f|
111
+ # TODO find the *.ui file according to app name or whatever
112
+ def find_view
113
+ Dir.glob("#{views_directory}/*.ui") do |f|
116
114
  return f
117
115
  end
118
- raise "could not find a .glade file in #{views_directory}"
116
+ raise "could not find a .ui file in #{views_directory}"
119
117
  end
120
118
 
121
119
  def views_directory
122
120
  File.join(APP_ROOT, 'views')
123
121
  end
124
122
 
125
- def define_widget_readers
126
- glade.widget_names.each do |widget|
127
- meth = widget.underscore
128
- instance_eval <<-EOEVAL
129
- @#{meth} = glade['#{widget}']
130
- def #{meth}
131
- @#{meth}
132
- end
133
- EOEVAL
134
- end
135
- end
136
-
137
123
  end
@@ -1,5 +1,4 @@
1
- # require 'libglade2'
2
- # require 'gtk2'
1
+ require 'singleton'
3
2
 
4
3
  class ActiveWindow::Controller
5
4
  include Singleton
@@ -12,6 +12,16 @@ module ActiveWindow
12
12
  define_callbacks :before_filter_applied, :after_filter_applied
13
13
  define_callbacks :before_clear_filter, :after_clear_filter
14
14
 
15
+ # BETTER:
16
+ #
17
+ # class FilteredFileStore < ActiveTreeStore.filter
18
+ # returns new anonymous class which inherits from Gtk::TreeModelFilter
19
+ # we can inherit from -- like Struct.new
20
+ # .filter is a class method the ActiveTreeStore got extended with
21
+ # end
22
+ # the #add stuff down there we could replace with GTK's signals
23
+ # =>
24
+
15
25
  def self.inherited(child_class)
16
26
  unfiltered_class_name = child_class.name.sub(/^Filtered/,'')
17
27
  unfiltered_class = unfiltered_class_name.constantize
@@ -53,6 +63,7 @@ module ActiveWindow
53
63
  def clear_filter
54
64
  run_callbacks :before_clear_filter
55
65
  @filter_string = ''
66
+ @filtering = false
56
67
  @found_count = -1
57
68
  refilter
58
69
  run_callbacks :after_clear_filter
@@ -65,8 +76,11 @@ module ActiveWindow
65
76
 
66
77
  # Iterate over child model and set visible column according to #iter_visible?
67
78
  def apply_filter
79
+ @filtering = true
68
80
  run_callbacks :before_filter_applied
69
81
  @found_count = 0
82
+ # we could traverse the tree for ourself with #first_iter and TreeIter#next! and #parent,
83
+ # setting visid to true/false accordingly => less method calls, better control
70
84
  child_model.each do |model,path,iter|
71
85
  set_visibility_for(iter)
72
86
  end
@@ -75,35 +89,41 @@ module ActiveWindow
75
89
  end
76
90
 
77
91
  def filtered?
78
- !filter_string.blank?
92
+ @filtering
79
93
  end
80
94
  alias_method :filter, :filter_string
81
95
  alias_method :filter=, :filter_string=
82
96
  alias_method :filtering?, :filtered?
83
97
 
84
98
  def set_visibility_for(iter)
85
- visid = self.class.column_id[:visible]
86
- unless filtering?
87
- iter[ visid ] = true
88
- else
99
+ visid = visibility_column
100
+ vis = true
101
+ if filtering?
89
102
  if iter_visible?(iter) # iter matches - mark it and all parents as visible
90
103
  @found_count += 1
91
- iter[ visid ] = true
104
+ vis = true
92
105
  i = iter
93
106
  while i = i.parent
94
107
  i[ visid ] = true
95
108
  end
96
109
  else
97
- iter[ visid ] = false
110
+ vis = false
98
111
  end
99
112
  end
113
+ iter[ visid ] = vis
114
+ iter
115
+ end
116
+
117
+ def visibility_column
118
+ self.class.column_id[:visible]
100
119
  end
101
120
 
102
121
  private
103
122
 
104
123
  def setup_filter
124
+ visid = visibility_column
105
125
  set_visible_func do |model, iter|
106
- !filtered? || iter[ self.class.column_id[:visible] ]
126
+ !filtering? || iter[ visid ]
107
127
  end
108
128
  child_model.filtered_model = self
109
129
  clear_filter
data/lib/active_window.rb CHANGED
@@ -1,8 +1,16 @@
1
1
  module ActiveWindow
2
-
3
2
  end
4
- require_dependency 'active_window/signal'
5
- require_dependency 'active_window/active_tree_store/columns'
6
- require_dependency 'active_window/active_tree_store/index'
7
- require_dependency 'active_window/active_tree_store/extentions'
8
- require_dependency 'active_window/filtered_active_tree_store'
3
+
4
+ $:.unshift File.dirname(__FILE__)
5
+
6
+ require 'active_window/signal'
7
+ require 'active_window/listed_item'
8
+ require 'active_window/controller'
9
+ require 'active_window/dot_file'
10
+ require 'active_window/active_column'
11
+ require 'active_window/active_tree_store/index'
12
+ require 'active_window/active_tree_store/columns'
13
+ require 'active_window/active_tree_store/extentions' # must be _extensions
14
+ require 'active_window/active_tree_store'
15
+ require 'active_window/filtered_active_tree_store'
16
+ require 'active_window/application'
data/lib/vim.rb ADDED
@@ -0,0 +1,9 @@
1
+ module Vim
2
+ end
3
+
4
+ require 'vim/buffers.rb'
5
+ require 'vim/netbeans.rb'
6
+ require 'vim/integration.rb'
7
+
8
+
9
+
@@ -0,0 +1,56 @@
1
+ module VimMate
2
+ class App < ActiveWindow::Application
3
+ def initialize(opts={})
4
+ @excludes = opts.delete(:excludes)
5
+ super
6
+ end
7
+ def file_tree
8
+ files.file_tree
9
+ end
10
+ def files
11
+ controller[:file_filter]
12
+ end
13
+ def vim
14
+ controller[:vim].vim
15
+ end
16
+
17
+ widget :file_tree_view
18
+ widget :tree_scroller
19
+ widget :main_pane
20
+ widget :general_config
21
+ widget :files_filter_button
22
+ widget :files_pane
23
+ widget :file_popup
24
+ widget :files_filter_term
25
+
26
+ def add_path(path)
27
+ file_tree.initial_adding do
28
+ file_tree.add_path(path)
29
+ end
30
+ end
31
+
32
+ def post_setup
33
+ super
34
+
35
+ @excludes.each do |rule|
36
+ file_tree.exclude! rule
37
+ end unless @excludes.blank?
38
+
39
+ # If there are no files given, open an empty window
40
+ # If files are specified on the command line, use them
41
+ ARGV.each do |file|
42
+ path = File.expand_path(file)
43
+ add_path(path)
44
+ #window.vim.open(path, :tab)
45
+ end
46
+ end
47
+
48
+ def run
49
+ GLib::Timeout.add(23) do
50
+ vim.start
51
+ false
52
+ end
53
+ super
54
+ end
55
+ end
56
+ end
@@ -1,4 +1,4 @@
1
- require_dependency 'lib/INotify'
2
- require_dependency 'lib/directory'
1
+ require 'lib/INotify'
2
+ require 'lib/directory'
3
3
  ListedDirectory.class_eval { include VimMate::Plugin::INotifyDirectory }
4
4
 
@@ -1,6 +1,6 @@
1
1
  plugin_dir = File.expand_path File.dirname(__FILE__) + '/plugins'
2
2
 
3
3
  Dir["#{plugin_dir}/*/init.rb"].each do |plugin_init|
4
- ActiveSupport::Dependencies::load_paths << File.dirname(plugin_init)
5
- require_dependency plugin_init
4
+ $: << File.dirname(plugin_init)
5
+ require plugin_init
6
6
  end
@@ -97,13 +97,15 @@ module VimMate
97
97
 
98
98
  # Start Vim's window. This must be called after the window which
99
99
  # will contain Vim is visible.
100
+ # FIXME disabled netbeans, crashes to often
100
101
  def start
101
102
  return if @vim_started
102
103
  return unless @gtk_socket
103
104
  @vim_started = true
104
105
  listen
105
106
  fork do
106
- exec %Q[#{Executable} --servername #{@vim_server_name} --socketid #{@gtk_socket.id} -nb:localhost:#{port}:#{Password} -S #{extras_source_path}]
107
+ #exec %Q[#{Executable} --servername #{@vim_server_name} --socketid #{@gtk_socket.id} -nb:localhost:#{port}:#{Password} -S #{extras_source_path}]
108
+ exec %Q[#{Executable} --servername #{@vim_server_name} --socketid #{@gtk_socket.id} -S #{extras_source_path}]
107
109
  end
108
110
  self
109
111
  end
data/lib/vim_mate.rb ADDED
@@ -0,0 +1,12 @@
1
+ module VimMate
2
+ end
3
+
4
+ $:.unshift File.dirname(__FILE__)
5
+
6
+ require 'vim_mate/requirer'
7
+ require 'vim_mate/nice_singleton'
8
+ require 'vim_mate/vim_widget'
9
+ require 'vim_mate/config'
10
+ require 'vim_mate/icons'
11
+ require 'vim_mate/plugins'
12
+ require 'vim_mate/app'
data/tasks/gem.rake ADDED
@@ -0,0 +1,31 @@
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |gemspec|
4
+ gemspec.name = %q{vimmate}
5
+ gemspec.summary = %q{VimMate is a graphical add-on to Vim with IDE-like features.}
6
+ gemspec.description = %q{
7
+ VimMate is a graphical add-on to Vim with IDE-like features: it does more
8
+ than the plain Vim while still being lightweight. Even with the additional
9
+ features, it stays out of the way for it's main task: editing files with Vim.
10
+ VimMate adds functionality to Vim by embedding Vim GTK GUI (gVim) within
11
+ VimMate.
12
+ }
13
+ gemspec.email = %q{niklas+vimmate@lanpartei.de}
14
+ gemspec.homepage = %q{http://github.com/niklas/vimmate/}
15
+ gemspec.authors = ["Guillaume Benny", "Niklas Hofer", "Stefan Bethge"]
16
+ gemspec.executables = %w{vimmate}
17
+ gemspec.require_paths = ["lib"]
18
+
19
+
20
+ # TODO docs would be nice, indeed
21
+ gemspec.has_rdoc = false
22
+
23
+ gemspec.add_dependency 'gtk2', '>= 0.90.5'
24
+ gemspec.add_dependency 'i18n', '>= 0.5.0'
25
+ gemspec.add_dependency 'activesupport', '>= 3.0.3'
26
+
27
+ end
28
+ Jeweler::GemcutterTasks.new
29
+ rescue LoadError
30
+ puts "Jeweler not available. Install it with: sudo gem install jeweler"
31
+ end