redcar-dev 0.13.3dev → 0.13.4dev

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/bin/redcar CHANGED
@@ -9,6 +9,7 @@ file = File.readlink(file) while File.symlink?(file)
9
9
  $LOAD_PATH.unshift File.expand_path('../../lib', file)
10
10
 
11
11
  require "redcar_quick_start"
12
+
12
13
  if ARGV.include? '--silent'
13
14
  # reopen the standard pipes to nothingness if we were forked as part of jruby
14
15
  STDIN.reopen Redcar.null_device
@@ -69,7 +69,7 @@ end
69
69
  #
70
70
  # and so on.
71
71
  module Redcar
72
- VERSION = '0.13.3dev' # also change in the gemspec!
72
+ VERSION = '0.13.4dev' # also change in the gemspec!
73
73
  VERSION_MAJOR = 0
74
74
  VERSION_MINOR = 13
75
75
  VERSION_RELEASE = 0
@@ -9,7 +9,6 @@ module Redcar
9
9
 
10
10
  def version_requested
11
11
  if ARGV.include?("-v")
12
- puts "Redcar #{Redcar::VERSION}"
13
12
  exit
14
13
  end
15
14
  end
@@ -33,7 +33,9 @@ module Redcar
33
33
  end
34
34
 
35
35
  def self.try_to_load_via_drb
36
- return if ARGV.find {|arg| arg == "--multiple-instance" || arg == '--help' || arg == '-h'}
36
+ if ARGV.find {|arg| arg == "--multiple-instance" || arg == '--help' || arg == '-h' || arg == "-v"}
37
+ return false
38
+ end
37
39
  begin
38
40
  begin
39
41
  TCPSocket.new('127.0.0.1', drb_port).close
@@ -18,19 +18,31 @@ module Redcar
18
18
  # either:
19
19
  # the Redcar::Command that is run when the item is selected.
20
20
  # or a block to run when the item is selected
21
- def initialize(text, options={}, &block)
21
+ #
22
+ # Instead of a command, a hash of options may be passed:
23
+ # :command - specify a command class
24
+ # :priority - Integer, higher means lower in menus
25
+ # :value - if passed, the command class with be instantiation like:
26
+ # Command.new(:value => value)
27
+ # :enabled - if set to false, this menu item will be permanently disabled
28
+ # :type - can be set to :check or :radio
29
+ # :checked - if type is check or radio, a block that will be run when
30
+ # the menu is displayed to determine whether this item is checked
31
+ def initialize(text, command_or_options={}, &block)
22
32
  @text = text
23
33
 
24
- if options.respond_to?('[]')
34
+ if command_or_options.respond_to?('[]')
35
+ options = command_or_options
25
36
  @command = options[:command] || block
26
37
  @priority = options[:priority]
27
38
  @value = options[:value]
28
39
  @type = options[:type]
40
+ @enabled = (options.key?(:enabled) ? options[:enabled] : true)
29
41
  if [:check, :radio].include?(@type)
30
42
  @checked = options[:checked]
31
43
  end
32
44
  else
33
- @command = options || block
45
+ @command = command_or_options || block
34
46
  end
35
47
 
36
48
  @priority ||= Menu::DEFAULT_PRIORITY
@@ -41,7 +53,7 @@ module Redcar
41
53
  if @value
42
54
  @command.new.run(:value => @value)
43
55
  else
44
- @command.new.run#(:with_key => with_key)
56
+ @command.new.run
45
57
  end
46
58
  end
47
59
 
@@ -76,6 +88,10 @@ module Redcar
76
88
  false
77
89
  end
78
90
 
91
+ def enabled?
92
+ @enabled
93
+ end
94
+
79
95
  def checked?
80
96
  @checked and (
81
97
  @checked.respond_to?(:call) ?
@@ -132,6 +132,18 @@ module Redcar
132
132
  end
133
133
  index
134
134
  end
135
+
136
+ # Triggers the display of the tab context menu at the current
137
+ # cursor location.
138
+ def right_click_on_tab(tab)
139
+ menu = Menu.new
140
+ Redcar.plugin_manager.objects_implementing(:tab_context_menu).each do |object|
141
+ menu.merge(object.tab_context_menu(tab))
142
+ end
143
+
144
+ Application::Dialog.popup_menu(menu, :pointer)
145
+ end
146
+
135
147
 
136
148
  def inspect
137
149
  "#<Redcar::Notebook #{object_id}>"
@@ -4,7 +4,7 @@ module Redcar
4
4
  module Icon
5
5
  def self.swt_image(icon)
6
6
  case icon
7
- when :directory
7
+ when :directory, :dir
8
8
  dir_image
9
9
  when :file
10
10
  file_image
@@ -16,8 +16,6 @@ module Redcar
16
16
 
17
17
  attr_reader :menu_bar
18
18
 
19
-
20
-
21
19
  def self.menu_types
22
20
  [Swt::SWT::BAR, Swt::SWT::POP_UP]
23
21
  end
@@ -147,7 +145,11 @@ module Redcar
147
145
  else
148
146
  item.text = entry.text
149
147
  end
150
- item.addSelectionListener(ProcSelectionListener.new(entry))
148
+ if entry.enabled?
149
+ item.addSelectionListener(ProcSelectionListener.new(entry))
150
+ else
151
+ item.enabled = false
152
+ end
151
153
  end
152
154
 
153
155
  class SelectionListener
@@ -177,14 +179,18 @@ module Redcar
177
179
  else
178
180
  item.text = entry.text
179
181
  end
180
- item.add_selection_listener(SelectionListener.new(entry))
181
- h = entry.command.add_listener(:active_changed) do |value|
182
- unless item.disposed
183
- item.enabled = value
182
+ if entry.enabled?
183
+ item.add_selection_listener(SelectionListener.new(entry))
184
+ h = entry.command.add_listener(:active_changed) do |value|
185
+ unless item.disposed
186
+ item.enabled = value
187
+ end
184
188
  end
185
- end
186
- @handlers << [entry.command, h]
187
- if not entry.command.active?
189
+ @handlers << [entry.command, h]
190
+ if not entry.command.active?
191
+ item.enabled = false
192
+ end
193
+ else
188
194
  item.enabled = false
189
195
  end
190
196
  end
@@ -104,6 +104,12 @@ module Redcar
104
104
  def attach_view_listeners
105
105
  @tab_folder.add_ctab_folder2_listener(CTabFolder2Listener.new(self))
106
106
  @tab_folder.add_selection_listener(SelectionListener.new(self))
107
+ @tab_folder.add_listener(Swt::SWT::MenuDetect) do |event|
108
+ point = ApplicationSWT.display.map(nil, @tab_folder, Swt::Graphics::Point.new(event.x, event.y))
109
+ if item = @tab_folder.getItem(point)
110
+ @model.right_click_on_tab(tab_item_to_tab_model(item))
111
+ end
112
+ end
107
113
  end
108
114
 
109
115
  # Called by the models when a tab is selected by Redcar.
@@ -139,8 +145,11 @@ module Redcar
139
145
  private
140
146
 
141
147
  def focussed_tab
142
- focussed_tab_item = tab_folder.get_selection
143
- @model.tabs.detect {|tab| tab.controller.item == focussed_tab_item }
148
+ tab_item_to_tab_model(tab_folder.get_selection)
149
+ end
150
+
151
+ def tab_item_to_tab_model(tab_item)
152
+ @model.tabs.detect {|tab| tab.controller.item == tab_item }
144
153
  end
145
154
 
146
155
  end
@@ -4,11 +4,14 @@ module Redcar
4
4
  class FindRecentDialog < FilterListDialog
5
5
  def update_list(filter)
6
6
  recent = Project::Recent.storage['list']
7
- recent = recent.map {|path| path.gsub(/^#{Regexp.escape(Redcar.home_dir)}\/?/, "")}
8
- filter_and_rank_by(recent, filter)
7
+ recent = recent.map do |path|
8
+ {:name => path.gsub(/^#{Regexp.escape(Redcar.home_dir)}\/?/, ""), :icon => :dir}
9
+ end
10
+ filter_and_rank_by(recent, filter) {|h| h[:name] }
9
11
  end
10
12
 
11
- def selected(path, ix)
13
+ def selected(item, ix)
14
+ path = item[:name]
12
15
  unless path[0..0] == "/" or path =~ /^[A-Z]:\//
13
16
  path = Redcar.home_dir + "/" + path
14
17
  end
@@ -421,6 +421,15 @@ module Redcar
421
421
  end
422
422
  end
423
423
 
424
+ def self.tab_context_menu(tab)
425
+ Menu::Builder.build do
426
+ if tab.is_a?(EditTab)
427
+ path = tab.edit_view.document.path
428
+ item("Copy path to clipboard", :enabled => !!path) { Redcar.app.clipboard << path if path }
429
+ end
430
+ end
431
+ end
432
+
424
433
  # Uses our own context menu hook to provide context menu entries
425
434
  # @return [Menu]
426
435
  def self.project_context_menus(tree, node, controller)
@@ -29,7 +29,7 @@ end
29
29
 
30
30
  Gem::Specification.new do |s|
31
31
  s.name = "redcar-dev"
32
- s.version = "0.13.3dev" # also change in lib/redcar.rb
32
+ s.version = "0.13.4dev" # also change in lib/redcar.rb
33
33
  s.platform = "ruby"
34
34
  s.authors = ["Daniel Lucraft"]
35
35
  s.email = ["dan@fluentradical.com"]
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: redcar-dev
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 0.13.3dev
5
+ version: 0.13.4dev
6
6
  platform: ruby
7
7
  authors:
8
8
  - Daniel Lucraft
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-01-11 00:00:00 Z
13
+ date: 2012-01-14 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: git