redcar 0.8.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (210) hide show
  1. data/CHANGES +41 -1
  2. data/README.md +1 -1
  3. data/Rakefile +5 -6
  4. data/lib/plugin_manager/lib/plugin_manager.rb +1 -2
  5. data/lib/redcar.rb +19 -14
  6. data/lib/redcar/installer.rb +21 -17
  7. data/lib/redcar/runner.rb +10 -7
  8. data/lib/redcar/usage.rb +1 -0
  9. data/lib/redcar_quick_start.rb +8 -12
  10. data/lib/regex_replace.rb +3 -3
  11. data/plugins/application/features/step_definitions/menu_steps.rb +10 -0
  12. data/plugins/application/features/step_definitions/speedbar_steps.rb +8 -2
  13. data/plugins/application/features/step_definitions/tree_steps.rb +48 -6
  14. data/plugins/application/features/step_definitions/window_steps.rb +9 -4
  15. data/plugins/application/features/support/env.rb +20 -1
  16. data/plugins/application/features/support/fake_event.rb +14 -0
  17. data/plugins/application/lib/application.rb +29 -12
  18. data/plugins/application/lib/application/dialogs/filter_list_dialog.rb +19 -0
  19. data/plugins/application/lib/application/speedbar.rb +23 -17
  20. data/plugins/application/lib/application/tab.rb +20 -15
  21. data/plugins/application/lib/application/treebook.rb +10 -7
  22. data/plugins/application/lib/application/window.rb +1 -1
  23. data/plugins/application/plugin.rb +1 -1
  24. data/plugins/application_swt/lib/application_swt/dialog_adapter.rb +4 -4
  25. data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +15 -4
  26. data/plugins/application_swt/lib/application_swt/icon.rb +3 -5
  27. data/plugins/application_swt/lib/application_swt/notebook/tab_drag_and_drop_listener.rb +4 -4
  28. data/plugins/application_swt/lib/application_swt/notebook/tab_transfer.rb +5 -5
  29. data/plugins/application_swt/lib/application_swt/speedbar.rb +34 -120
  30. data/plugins/application_swt/lib/application_swt/speedbar/button_item.rb +20 -0
  31. data/plugins/application_swt/lib/application_swt/speedbar/combo_item.rb +38 -0
  32. data/plugins/application_swt/lib/application_swt/speedbar/label_item.rb +15 -0
  33. data/plugins/application_swt/lib/application_swt/speedbar/slider_item.rb +32 -0
  34. data/plugins/application_swt/lib/application_swt/speedbar/text_box_item.rb +36 -0
  35. data/plugins/application_swt/lib/application_swt/speedbar/toggle_item.rb +29 -0
  36. data/plugins/application_swt/lib/application_swt/tab.rb +1 -3
  37. data/plugins/application_swt/lib/application_swt/toolbar.rb +19 -20
  38. data/plugins/application_swt/lib/application_swt/treebook.rb +24 -9
  39. data/plugins/application_swt/lib/application_swt/window.rb +110 -98
  40. data/plugins/application_swt/lib/swt/vtab_folder.rb +77 -32
  41. data/plugins/application_swt/lib/swt/vtab_item.rb +9 -0
  42. data/plugins/application_swt/lib/swt/vtab_label.rb +63 -23
  43. data/plugins/application_swt/plugin.rb +1 -1
  44. data/plugins/clipboard-viewer/lib/clipboard_viewer/clipboard_bar.rb +2 -2
  45. data/plugins/comment/features/line_comment.feature +116 -4
  46. data/plugins/comment/lib/comment.rb +18 -16
  47. data/plugins/connection_manager/lib/connection_manager/commands.rb +1 -1
  48. data/plugins/connection_manager/lib/connection_manager/private_key_store.rb +5 -3
  49. data/plugins/declarations/lib/declarations.rb +1 -1
  50. data/plugins/declarations/lib/declarations/parser.rb +68 -20
  51. data/plugins/document_search/features/replace.feature +18 -0
  52. data/plugins/document_search/lib/document_search.rb +37 -54
  53. data/plugins/document_search/lib/document_search/replace_all_command.rb +27 -0
  54. data/plugins/document_search/lib/document_search/replace_command.rb +38 -0
  55. data/plugins/document_search/lib/document_search/replace_next_command.rb +27 -0
  56. data/plugins/document_search/lib/document_search/search_and_replace.rb +17 -24
  57. data/plugins/edit_view/features/step_definitions/editing_steps.rb +4 -4
  58. data/plugins/edit_view/features/step_definitions/tab_steps.rb +9 -0
  59. data/plugins/edit_view/features/step_definitions/window_steps.rb +0 -12
  60. data/plugins/edit_view/lib/edit_view/document.rb +2 -0
  61. data/plugins/edit_view/lib/edit_view/document/command.rb +8 -8
  62. data/plugins/edit_view/lib/edit_view/edit_tab.rb +21 -7
  63. data/plugins/edit_view/lib/edit_view/select_font_dialog.rb +6 -0
  64. data/plugins/edit_view/lib/edit_view/select_theme_dialog.rb +6 -0
  65. data/plugins/edit_view_swt/lib/edit_view_swt.rb +92 -43
  66. data/plugins/edit_view_swt/lib/edit_view_swt/document.rb +17 -4
  67. data/plugins/find-in-project/lib/find_in_project.rb +1 -4
  68. data/plugins/find-in-project/lib/find_in_project/commands.rb +0 -14
  69. data/plugins/find-in-project/lib/find_in_project/controllers.rb +12 -0
  70. data/plugins/find-in-project/lib/find_in_project/views/index.html.erb +5 -0
  71. data/plugins/groovy/features/fixtures/test.groovy +0 -0
  72. data/plugins/groovy/features/step_definitions/groovy_steps.rb +27 -0
  73. data/plugins/groovy/features/support/env.rb +27 -0
  74. data/plugins/groovy/features/syntax_check_groovy.feature +72 -0
  75. data/plugins/groovy/lib/syntax_check/groovy.rb +76 -0
  76. data/plugins/groovy/plugin.rb +7 -0
  77. data/plugins/help/lib/help.rb +28 -4
  78. data/plugins/help/lib/help/help_tab.rb +11 -0
  79. data/plugins/help/lib/help/view_controller.rb +25 -0
  80. data/plugins/help/plugin.rb +2 -1
  81. data/plugins/{view_shortcuts → help}/views/default.css +0 -0
  82. data/plugins/{view_shortcuts → help}/views/index.html.erb +1 -1
  83. data/plugins/{view_shortcuts → help}/views/redcar_small_icon.png +0 -0
  84. data/plugins/html_view/features/browser_bar.feature +47 -0
  85. data/plugins/html_view/features/fixtures/other.html +1 -0
  86. data/plugins/html_view/features/fixtures/sample.html +1 -0
  87. data/plugins/html_view/features/step_definitions/html_view_steps.rb +45 -5
  88. data/plugins/html_view/features/support/env.rb +26 -0
  89. data/plugins/html_view/features/web_preview.feature +21 -0
  90. data/plugins/html_view/lib/html_controller.rb +5 -5
  91. data/plugins/html_view/lib/html_view.rb +62 -10
  92. data/plugins/{web_bookmarks/lib/web_bookmarks → html_view/lib/html_view}/browser_bar.rb +32 -20
  93. data/plugins/html_view/lib/html_view/commands.rb +64 -0
  94. data/plugins/{web_bookmarks/lib/web_bookmarks/view_controller.rb → html_view/lib/html_view/default_controller.rb} +7 -6
  95. data/plugins/html_view/lib/html_view/html_tab.rb +17 -6
  96. data/plugins/html_view/plugin.rb +3 -3
  97. data/plugins/{web_bookmarks → html_view}/views/index.html.erb +0 -0
  98. data/plugins/javascript/features/fixtures/test.js +0 -0
  99. data/plugins/javascript/features/support/env.rb +4 -0
  100. data/plugins/javascript/features/syntax_check_javascript.feature +27 -0
  101. data/plugins/javascript/lib/syntax_check/javascript.rb +52 -0
  102. data/plugins/javascript/plugin.rb +7 -0
  103. data/plugins/javascript/vendor/jslint.js +539 -0
  104. data/plugins/macros/lib/macros/commands.rb +3 -3
  105. data/plugins/open_default_app/lib/open_default_app.rb +29 -3
  106. data/plugins/open_default_app/plugin.rb +1 -1
  107. data/plugins/outline_view/features/outline_view.feature +79 -0
  108. data/plugins/outline_view/features/step_definitions/outline_steps.rb +45 -0
  109. data/plugins/outline_view/lib/outline_view.rb +1 -1
  110. data/plugins/outline_view/spec/fixtures/some_project/javascript.js +10 -0
  111. data/plugins/outline_view/spec/fixtures/some_project/nothing_to_see.rb +0 -0
  112. data/plugins/outline_view/spec/fixtures/some_project/one_lonely_class.rb +2 -0
  113. data/plugins/outline_view/spec/fixtures/some_project/similar_names.rb +18 -0
  114. data/plugins/outline_view/spec/fixtures/some_project/something_fancy.rb +736 -0
  115. data/plugins/outline_view/spec/fixtures/some_project/trailing_space.rb +5 -0
  116. data/plugins/outline_view_swt/lib/outline_view_swt.rb +17 -19
  117. data/plugins/pair_highlighter/lib/pair_highlighter/document_controller.rb +1 -4
  118. data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +12 -3
  119. data/plugins/project/features/close_directory_tree.feature +27 -0
  120. data/plugins/project/features/highlight_focussed_tab.feature +45 -1
  121. data/plugins/project/features/open_and_save_files.feature +33 -0
  122. data/plugins/project/features/open_directory_tree.feature +37 -11
  123. data/plugins/project/features/step_definitions/directory_steps.rb +1 -1
  124. data/plugins/project/features/step_definitions/drb_steps.rb +40 -0
  125. data/plugins/project/features/support/env.rb +17 -0
  126. data/plugins/project/lib/project.rb +12 -2
  127. data/plugins/project/lib/project/commands.rb +101 -99
  128. data/plugins/project/lib/project/drb_service.rb +55 -65
  129. data/plugins/project/lib/project/manager.rb +29 -4
  130. data/plugins/project/lib/project/project_tree_controller.rb +24 -0
  131. data/plugins/project/lib/project/support/trash.rb +1 -0
  132. data/plugins/redcar/redcar.rb +100 -37
  133. data/plugins/redcar_debug/lib/redcar_debug.rb +3 -3
  134. data/plugins/repl/features/step_definitions/repl_steps.rb +3 -0
  135. data/plugins/repl/lib/repl.rb +4 -11
  136. data/plugins/repl/lib/repl/repl_tab.rb +26 -0
  137. data/plugins/ruby/features/fixtures/test.rb +0 -0
  138. data/plugins/ruby/features/support/env.rb +4 -0
  139. data/plugins/ruby/features/syntax_check_ruby.feature +25 -0
  140. data/plugins/runnables/features/command_tree.feature +28 -0
  141. data/plugins/runnables/lib/runnables.rb +1 -0
  142. data/plugins/runnables/lib/runnables/commands.rb +4 -4
  143. data/plugins/runnables/lib/runnables/output_processor.rb +5 -5
  144. data/plugins/runnables/lib/runnables/tree_mirror/tree_controller.rb +2 -7
  145. data/plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb +13 -8
  146. data/plugins/scm_git/lib/scm_git/change.rb +5 -5
  147. data/plugins/strip_trailing_spaces/features/fixtures/test.txt +3 -0
  148. data/plugins/strip_trailing_spaces/features/strip_trailing_spaces.feature +34 -0
  149. data/plugins/strip_trailing_spaces/lib/strip_trailing_spaces.rb +3 -38
  150. data/plugins/swt/lib/swt.rb +5 -13
  151. data/plugins/swt/lib/swt/full_swt.rb +15 -13
  152. data/plugins/syntax_check/features/step_definitions/syntax_check_steps.rb +7 -0
  153. data/plugins/syntax_check/lib/syntax_check.rb +21 -3
  154. data/plugins/syntax_check/lib/syntax_check/error.rb +4 -3
  155. data/plugins/task_manager/lib/task_manager.rb +1 -1
  156. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ant.tmbundle/Preferences/Autocompletions.tmPreferences +345 -0
  157. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ant.tmbundle/Preferences/Symbol List Target.tmPreferences +22 -0
  158. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ant.tmbundle/Snippets/Doc Banner.tmSnippet +20 -0
  159. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ant.tmbundle/Syntaxes/Ant.tmLanguage +247 -0
  160. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ant.tmbundle/info.plist +55 -0
  161. data/plugins/textmate/vendor/redcar-bundles/Bundles/RedcarRepl.tmbundle/Syntaxes/GroovyRepl.plist +40 -0
  162. data/plugins/textmate/vendor/redcar-bundles/Bundles/RedcarRepl.tmbundle/info.plist +1 -1
  163. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ruby Haml.tmbundle/Syntaxes/Ruby_Haml.tmLanguage +0 -1
  164. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ruby Sass.tmbundle/Syntaxes/Ruby Sass.tmLanguage +626 -0
  165. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ruby Sass.tmbundle/info.plist +16 -0
  166. data/plugins/todo_list/features/support/env.rb +8 -0
  167. data/plugins/todo_list/features/todo_list.feature +26 -0
  168. data/plugins/todo_list/lib/todo_list.rb +1 -0
  169. data/plugins/todo_list/lib/todo_list/file_parser.rb +23 -19
  170. data/plugins/todo_list/lib/todo_list/todo_controller.rb +60 -100
  171. data/plugins/todo_list/spec/fixtures/project/FIXME.file +3 -0
  172. data/plugins/todo_list/spec/fixtures/project/NOTE.ignored.file +1 -0
  173. data/plugins/todo_list/spec/fixtures/project/OPTIMIZE_colon.file +1 -0
  174. data/plugins/todo_list/spec/fixtures/project/XXX.ignored +1 -0
  175. data/plugins/todo_list/spec/fixtures/project/ignored_directory/TODO.file +2 -0
  176. data/plugins/todo_list/spec/fixtures/settings.rb +11 -0
  177. data/plugins/todo_list/spec/spec_helper.rb +6 -0
  178. data/plugins/todo_list/spec/todo_list/file_parser_spec.rb +35 -0
  179. data/plugins/tree/lib/tree.rb +1 -0
  180. data/plugins/tree/lib/tree/command.rb +5 -0
  181. data/plugins/web_bookmarks/features/bookmark.feature +37 -0
  182. data/plugins/web_bookmarks/features/fixtures/other.html +1 -0
  183. data/plugins/web_bookmarks/features/fixtures/sample.html +1 -0
  184. data/plugins/web_bookmarks/features/step_definitions/web_steps.rb +4 -0
  185. data/plugins/web_bookmarks/features/support/env.rb +26 -0
  186. data/plugins/web_bookmarks/lib/web_bookmarks.rb +0 -10
  187. data/plugins/web_bookmarks/lib/web_bookmarks/bookmark.rb +10 -1
  188. data/plugins/web_bookmarks/lib/web_bookmarks/commands.rb +1 -47
  189. data/plugins/web_bookmarks/lib/web_bookmarks/tree.rb +21 -14
  190. data/{plugins/application → share}/icons/close.png +0 -0
  191. data/{plugins/application → share}/icons/darwin-file.png +0 -0
  192. data/{plugins/application → share}/icons/darwin-folder.png +0 -0
  193. data/share/icons/open-source-flipped.png +0 -0
  194. data/{plugins/application/icons/redcar_icon_beta_dev.png → share/icons/redcar-icon-beta-dev.png} +0 -0
  195. data/{plugins/application/icons/redcar_icon_beta.png → share/icons/redcar-icon-beta.png} +0 -0
  196. data/{plugins/application → share}/icons/redcar-splash.png +0 -0
  197. metadata +90 -30
  198. data/lib/redcar/jvm_options_probe.rb +0 -33
  199. data/plugins/document_search/lib/document_search/replace.rb +0 -113
  200. data/plugins/document_search/lib/document_search/search.rb +0 -45
  201. data/plugins/outline_view_swt/lib/icons/alias.png +0 -0
  202. data/plugins/outline_view_swt/lib/icons/assignment.png +0 -0
  203. data/plugins/outline_view_swt/lib/icons/attribute.png +0 -0
  204. data/plugins/outline_view_swt/lib/icons/class.png +0 -0
  205. data/plugins/outline_view_swt/lib/icons/interface.png +0 -0
  206. data/plugins/outline_view_swt/lib/icons/method.png +0 -0
  207. data/plugins/strip_trailing_spaces/CHANGELOG +0 -12
  208. data/plugins/strip_trailing_spaces/README.md +0 -32
  209. data/plugins/view_shortcuts/lib/view_shortcuts.rb +0 -52
  210. data/plugins/view_shortcuts/plugin.rb +0 -11
@@ -4,7 +4,8 @@ module Swt
4
4
  attr_accessor :tab_area, :content_area
5
5
  attr_reader :selection_color_options, :font, :items
6
6
 
7
- SelectionEvent = Struct.new("Event", :item, :doit)
7
+ SelectionEvent = Struct.new("Event", :item, :doit)
8
+ CTabFolderEvent = SelectionEvent
8
9
 
9
10
  def initialize(parent, style)
10
11
  super(parent, style | Swt::SWT::BORDER)
@@ -17,6 +18,7 @@ module Swt
17
18
 
18
19
  @items = []
19
20
  @selection_listeners = []
21
+ @ctab_folder2_listeners = []
20
22
  @font = Swt::Widgets::Display.current.system_font
21
23
 
22
24
  @tab_area = Swt::Widgets::Composite.new(self, Swt::SWT::NONE).tap do |t|
@@ -43,15 +45,16 @@ module Swt
43
45
  @items << tab
44
46
  tab.draw_label(@tab_area)
45
47
  tab.font = @font
46
- tab.active = true if @items.size == 1
48
+ selection = tab if @items.size == 1
47
49
  layout
48
50
  end
49
51
 
50
52
  def remove_item(tab)
51
- @items.delete(tab)
52
- tab.dispose
53
- selection = @items.first if tab.active?
54
- layout
53
+ return unless tab = ensure_tab(tab)
54
+
55
+ evt = create_ctab_folder_event(tab)
56
+ call_listeners(@ctab_folder2_listeners, evt, :method => :close, :run_blocks => true)
57
+ do_remove_item(tab) if evt.doit
55
58
  end
56
59
 
57
60
  def get_item(selector)
@@ -69,33 +72,12 @@ module Swt
69
72
  end
70
73
 
71
74
  def selection=(tab)
72
- return if tab.nil?
73
- evt = SelectionEvent.new.tap do |e|
74
- e.item = tab
75
- e.doit = true
76
- end
77
- @selection_listeners.each do |l|
78
- if l.respond_to? :call
79
- l[evt]
80
- else
81
- l.widgetSelected(evt)
82
- end
83
- end
84
- if evt.doit
85
- silent_selection(tab)
86
- end
87
- end
75
+ tab = ensure_tab(tab)
76
+ return if tab.nil? or tab.active?
88
77
 
89
- def silent_selection(tab)
90
- return if tab.nil?
91
- selection.active = false if selection
92
- if tab.respond_to? :to_int
93
- @items[tab].active = true
94
- else
95
- tab.active = true
96
- end
97
- layout
98
- @tab_area.layout
78
+ evt = create_selection_event(tab)
79
+ call_listeners(@selection_listeners, evt, :method => :widgetSelected, :run_blocks => true)
80
+ do_selection(tab) if evt.doit
99
81
  end
100
82
 
101
83
  def selection_index
@@ -110,16 +92,79 @@ module Swt
110
92
  selection = tab
111
93
  end
112
94
 
95
+ # Mirrors the selection-listener behaviour of CTabFolder.
96
+ # Additionally accepts a block as listener. If a block is passed,
97
+ # only widgetSelected events will be passed, not widgetDefaultSelected.
113
98
  def add_selection_listener(listener = nil)
114
99
  return @selection_listeners << listener if listener
115
100
  raise ArgumentError, "Expected a listener or a block" unless block_given?
116
101
  @selection_listeners << Proc.new
117
102
  end
118
103
 
104
+ # Mirrors the CTabFolder2Listener behaviour of CTabFolder.
105
+ # You can also pass a a block as listener. Note that when you pass a
106
+ # block, only close events will be passed to it, not the minimize, maximize,
107
+ # restore or showList events.
108
+ def add_ctab_folder2_listener(listener = nil)
109
+ return @ctab_folder2_listeners << listener if listener
110
+ raise ArgumentError, "Expected a listener or a block" unless block_given?
111
+ @ctab_folder2_listeners << Proc.new
112
+ end
113
+
119
114
  def font= swt_font
120
115
  @font = swt_font
121
116
  @items.each { |tab| tab.font = swt_font }
122
117
  end
118
+
119
+ private
120
+
121
+ def ensure_tab(tab)
122
+ tab = @items[tab] if tab.respond_to? :to_int
123
+ tab
124
+ end
125
+
126
+ def do_selection(tab)
127
+ selection.active = false if selection
128
+ tab.active = true
129
+ relayout!
130
+ end
131
+
132
+ def do_remove_item(tab)
133
+ @items.delete(tab)
134
+ tab.dispose
135
+ selection = @items.first if tab.active?
136
+ relayout!
137
+ end
138
+
139
+ def relayout!
140
+ layout
141
+ @tab_area.layout
142
+ end
143
+
144
+ def create_selection_event(tab)
145
+ create_event(tab, SelectionEvent)
146
+ end
147
+
148
+ def create_ctab_folder_event(tab)
149
+ create_event(tab, CTabFolderEvent)
150
+ end
151
+
152
+ def create_event(tab, clazz)
153
+ clazz.new.tap do |e|
154
+ e.item = tab
155
+ e.doit = true
156
+ end
157
+ end
158
+
159
+ def call_listeners(list, evt, hash)
160
+ list.each do |l|
161
+ if hash[:run_blocks] and l.respond_to? :call
162
+ l[evt]
163
+ else
164
+ l.send(hash[:method], evt)
165
+ end
166
+ end
167
+ end
123
168
  end
124
169
  end
125
170
  end
@@ -4,6 +4,7 @@ module Swt
4
4
  module Widgets
5
5
  class VTabItem
6
6
  attr_accessor :text, :control
7
+ attr_reader :parent
7
8
 
8
9
  def initialize(parent, style)
9
10
  @parent = parent
@@ -60,6 +61,14 @@ module Swt
60
61
  @label.font
61
62
  end
62
63
 
64
+ def show_close= bool
65
+ @label.show_close = bool
66
+ end
67
+
68
+ def show_close
69
+ @label.show_close
70
+ end
71
+
63
72
  def dispose
64
73
  @control.dispose
65
74
  @label.dispose
@@ -3,10 +3,14 @@ require File.expand_path("../graphics_utils", __FILE__)
3
3
  module Swt
4
4
  module Widgets
5
5
  class VTabLabel
6
- attr_reader :active, :title
6
+ attr_reader :active, :title, :show_close
7
7
  attr_accessor :font
8
8
 
9
9
  include Swt::Events::MouseListener
10
+ include Swt::Events::MouseTrackListener
11
+
12
+ CLOSE_ICON = Redcar::ApplicationSWT::Icon.swt_image(:close)
13
+ ICON_PADDING = 3
10
14
 
11
15
  def initialize(tab, parent, style)
12
16
  @label = Swt::Widgets::Label.new(parent, style)
@@ -14,41 +18,56 @@ module Swt
14
18
  @tab = tab
15
19
  @parent = parent
16
20
  @title = ""
21
+ @icon = nil
22
+ @show_close = false
17
23
 
18
24
  @label.image = label_image
19
25
  @label.add_paint_listener { |event| event.gc.draw_image(label_image, 0, 0) }
20
26
  @label.add_mouse_listener(self)
27
+ self.show_close = true
21
28
  end
22
29
 
23
30
  def label_image
24
31
  display = Swt::Widgets::Display.current
25
- @img = nil if @dirty
26
- @img ||= GraphicsUtils.create_rotated_text(@title, @font, @parent.foreground, @parent.background, Swt::SWT::UP) do |gc, extent|
27
- fg, bg = gc.foreground, gc.background
28
- if @active
29
- options = @tab.selection_color_options
30
- options[:percents].each_with_index do |p, idx|
31
- gc.foreground = options[:colors][idx]
32
- gc.background = options[:colors][idx + 1]
33
- if options[:vertical]
34
- h = idx > 0 ? extent.height * options[:percents][idx - 1] : 0
35
- gc.fill_gradient_rectangle(0, h, extent.width, extent.height * p, true)
36
- else
37
- h = idx > 0 ? extent.width * options[:percents][idx - 1] : 0
38
- gc.fill_gradient_rectangle(w, 0, extent.width * p, extent.height, false)
32
+ unless @img
33
+ @img = GraphicsUtils.create_rotated_text(@title, @font, @parent.foreground, @parent.background, Swt::SWT::UP) do |gc, extent|
34
+ fg, bg = gc.foreground, gc.background
35
+ if @active
36
+ options = @tab.selection_color_options
37
+ options[:percents].each_with_index do |p, idx|
38
+ gc.foreground = options[:colors][idx]
39
+ gc.background = options[:colors][idx + 1]
40
+ if options[:vertical]
41
+ h = idx > 0 ? extent.height * options[:percents][idx - 1] : 0
42
+ gc.fill_gradient_rectangle(0, h, extent.width, extent.height * p, true)
43
+ else
44
+ h = idx > 0 ? extent.width * options[:percents][idx - 1] : 0
45
+ gc.fill_gradient_rectangle(w, 0, extent.width * p, extent.height, false)
46
+ end
39
47
  end
48
+ else
49
+ gc.fill_rectangle(0, 0, extent.width, extent.height)
40
50
  end
41
- else
42
- gc.fill_rectangle(0, 0, extent.width, extent.height)
51
+ gc.foreground = display.get_system_color(Swt::SWT::COLOR_WIDGET_NORMAL_SHADOW)
52
+ gc.draw_rectangle(0, 0, extent.width - 1, extent.height - 1)
53
+ gc.foreground, gc.background = fg, bg
43
54
  end
44
- gc.foreground = display.get_system_color(Swt::SWT::COLOR_WIDGET_NORMAL_SHADOW)
45
- gc.draw_rectangle(0, 0, extent.width - 1, extent.height - 1)
46
- gc.foreground, gc.background = fg, bg
55
+ overlay_icon(@icon, @img)
47
56
  end
48
- @dirty = false
49
57
  @img
50
58
  end
51
59
 
60
+ def overlay_icon(icon, image)
61
+ return unless icon
62
+ gc = GraphicsUtils::GC.new(image)
63
+ gc.draw_image(@icon, ICON_PADDING, ICON_PADDING)
64
+ gc.dispose
65
+ end
66
+
67
+ def dirty!
68
+ @img = nil
69
+ end
70
+
52
71
  def activate
53
72
  @tab.activate
54
73
  end
@@ -64,7 +83,7 @@ module Swt
64
83
  end
65
84
 
66
85
  def redraw
67
- @dirty = true
86
+ dirty!
68
87
  @label.image = label_image
69
88
  end
70
89
 
@@ -72,13 +91,34 @@ module Swt
72
91
  @label.dispose
73
92
  end
74
93
 
94
+ def show_close= boolean
95
+ return if @show_close == boolean
96
+ @show_close = boolean
97
+ @show_close ? @label.add_mouse_track_listener(self) : @label.remove_mouse_track_listener(self)
98
+ end
99
+
75
100
  def mouseUp(e)
76
- activate
101
+ if show_close and CLOSE_ICON.bounds.contains(e.x - ICON_PADDING, e.y - ICON_PADDING)
102
+ @tab.parent.remove_item(@tab)
103
+ else
104
+ activate if e.button == 1
105
+ end
106
+ end
107
+
108
+ def mouseEnter(e)
109
+ @icon = CLOSE_ICON
110
+ redraw
111
+ end
112
+
113
+ def mouseExit(e)
114
+ @icon = nil
115
+ redraw
77
116
  end
78
117
 
79
118
  # Unused
80
119
  def mouseDown(e); end
81
120
  def mouseDoubleClick(e); end
121
+ def mouseHover(e); end
82
122
  end
83
123
  end
84
124
  end
@@ -1,7 +1,7 @@
1
1
 
2
2
  Plugin.define do
3
3
  name "application_swt"
4
- version "1.0"
4
+ version "1.1"
5
5
  file "lib", "application_swt"
6
6
  object "Redcar::ApplicationSWT"
7
7
  dependencies "application", ">0",
@@ -48,8 +48,8 @@ module Redcar
48
48
  value = ""
49
49
  r=0
50
50
  l.to_s.each_line do |line|
51
- value += line if r <= @line_limit - 1
52
- value += "..." if r == @line_limit
51
+ value << line if r <= @line_limit - 1
52
+ value << "..." if r == @line_limit
53
53
  r+=1
54
54
  break if r > @line_limit - 1
55
55
  end
@@ -60,6 +60,15 @@ Feature: Commenting lines by prefixing a comment string
60
60
  When I toggle comment lines
61
61
  Then the contents should be "# foo\n# bar\nbaz"
62
62
 
63
+ Scenario: Commenting when not all the lines begin with the comment symbol, reversed
64
+ When I replace the contents with "# foo\n# bar\nbaz"
65
+ And I switch the language to "Ruby"
66
+ And I select from 15 to 0
67
+ And I toggle comment lines
68
+ Then the contents should be "<c># # foo\n# # bar\n# baz<s>"
69
+ When I toggle comment lines
70
+ Then the contents should be "# foo\n# bar\nbaz"
71
+
63
72
  Scenario: Commenting a single line with the cursor on the next line
64
73
  When I replace the contents with "Two pieces\nof code"
65
74
  And I switch the language to "Ruby"
@@ -69,6 +78,15 @@ Feature: Commenting lines by prefixing a comment string
69
78
  When I toggle comment lines
70
79
  Then the contents should be "<s>Two pieces\n<c>of code"
71
80
 
81
+ Scenario: Commenting a single line with the cursor on the next line, reversed
82
+ When I replace the contents with "Two pieces\nof code"
83
+ And I switch the language to "Ruby"
84
+ And I select from 11 to 0
85
+ And I toggle comment lines
86
+ Then the contents should be "<c># Two pieces\n<s>of code"
87
+ When I toggle comment lines
88
+ Then the contents should be "<c>Two pieces\n<s>of code"
89
+
72
90
  Scenario: Commenting a single line with the cursor and selection point on the same line
73
91
  When I replace the contents with "Two pieces\nof code"
74
92
  And I switch the language to "Ruby"
@@ -104,6 +122,15 @@ Feature: Commenting lines by prefixing a comment string
104
122
  When I toggle comment lines
105
123
  Then the contents should be "Tw<s>o pieces\nof<c> code"
106
124
 
125
+ Scenario: Commenting several lines, not from the start of one of them, reversed
126
+ When I replace the contents with "Two pieces\nof code"
127
+ And I switch the language to "Ruby"
128
+ And I select from 13 to 2
129
+ And I toggle comment lines
130
+ Then the contents should be "Tw<c># o pieces\n# of<s> code"
131
+ When I toggle comment lines
132
+ Then the contents should be "Tw<c>o pieces\nof<s> code"
133
+
107
134
  Scenario: Commenting several lines, not from the start of one of them
108
135
  When I replace the contents with " foo\n bar"
109
136
  And I switch the language to "Ruby"
@@ -121,12 +148,97 @@ Feature: Commenting lines by prefixing a comment string
121
148
  Then the contents should be "<s># def foo\n# dfo\n# sdfj\n# asdf\n# as<c>df"
122
149
 
123
150
  Scenario: Commenting several indented lines, beginning before the text starts
124
- When I replace the contents with " def foo\n dfo"
151
+ Given the content is:
152
+ """
153
+ <s> def foo
154
+ dfo<c>
155
+ """
125
156
  And I switch the language to "Ruby"
126
- And I select from 2 to 25
127
157
  And I toggle comment lines
128
- Then the contents should be " <s> # def foo\n # dfo<c>"
129
-
158
+ Then the content should be:
159
+ """
160
+ <s> # def foo
161
+ # dfo<c>
162
+ """
163
+
164
+ Scenario: Commenting several indented lines, beginning before the text starts, reversed
165
+ Given the content is:
166
+ """
167
+ <c> def foo
168
+ dfo<s>
169
+ """
170
+ And I switch the language to "Ruby"
171
+ And I toggle comment lines
172
+ Then the content should be:
173
+ """
174
+ <c> # def foo
175
+ # dfo<s>
176
+ """
177
+
178
+ Scenario: Commenting several indented lines, beginning where the text starts
179
+ Given the content is:
180
+ """
181
+ <s>def foo
182
+ dfo<c>
183
+ """
184
+ And I switch the language to "Ruby"
185
+ And I toggle comment lines
186
+ Then the content should be:
187
+ """
188
+ <s># def foo
189
+ # dfo<c>
190
+ """
191
+ And I toggle comment lines
192
+ Then the content should be:
193
+ """
194
+ <s>def foo
195
+ dfo<c>
196
+ """
197
+
198
+ Scenario: Commenting several indented lines, with a whitespace only line in between
199
+ Given the content is:
200
+ """
201
+ <s>doc.compound do
202
+ all_lines_are_already_commented = true
203
+ start_line_comment_offset = nil
204
+ insertion_column = 1000
205
+
206
+ <c>(start_line..end_line).each do |line|
207
+ """
208
+ And I switch the language to "Ruby"
209
+ And I toggle comment lines
210
+ Then the content should be:
211
+ """
212
+ <s># doc.compound do
213
+ # all_lines_are_already_commented = true
214
+ # start_line_comment_offset = nil
215
+ # insertion_column = 1000
216
+ #
217
+ # <c>(start_line..end_line).each do |line|
218
+ """
219
+
220
+ Scenario: Commenting several indented lines, with a blank line in between
221
+ Given the content is:
222
+ """
223
+ <s>doc.compound do
224
+ all_lines_are_already_commented = true
225
+ start_line_comment_offset = nil
226
+ insertion_column = 1000
227
+
228
+ <c>(start_line..end_line).each do |line|
229
+ """
230
+ And I switch the language to "Ruby"
231
+ And I toggle comment lines
232
+ Then the content should be:
233
+ """
234
+ <s># doc.compound do
235
+ # all_lines_are_already_commented = true
236
+ # start_line_comment_offset = nil
237
+ # insertion_column = 1000
238
+ #
239
+ # <c>(start_line..end_line).each do |line|
240
+ """
241
+
130
242
  # This is pretty damn marginal, and I'm tired...
131
243
  #Scenario: Commenting several lines, with mismatched indentation, beginning in the middle
132
244
  # When I replace the contents with " def foo\n dfo\n sdfj\n asdf\nasdf"