redcar-dev 0.12.17dev → 0.12.18dev

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. data/CHANGES +4 -2
  2. data/README.md +5 -41
  3. data/Rakefile +3 -35
  4. data/lib/redcar.rb +19 -17
  5. data/lib/redcar/runner.rb +1 -7
  6. data/lib/redcar_quick_start.rb +5 -5
  7. data/plugins/application/features/main_menu.feature +1 -1
  8. data/plugins/application/features/step_definitions/command_steps.rb +8 -7
  9. data/plugins/application/features/step_definitions/filter_list_dialog_steps.rb +25 -10
  10. data/plugins/application/features/step_definitions/key_steps.rb +6 -4
  11. data/plugins/application/features/step_definitions/menu_steps.rb +27 -26
  12. data/plugins/application/features/step_definitions/speedbar_steps.rb +28 -16
  13. data/plugins/application/features/step_definitions/tree_steps.rb +88 -64
  14. data/plugins/application/features/step_definitions/window_steps.rb +14 -10
  15. data/plugins/application/features/support/env.rb +85 -83
  16. data/plugins/application/spec/application/application_spec.rb +1 -1
  17. data/plugins/application/spec/application/clipboard_spec.rb +1 -1
  18. data/plugins/application/spec/application/command/executor_spec.rb +1 -1
  19. data/plugins/application/spec/application/command/history_spec.rb +1 -1
  20. data/plugins/application/spec/application/command_spec.rb +1 -1
  21. data/plugins/application/spec/application/keymap/builder_spec.rb +1 -1
  22. data/plugins/application/spec/application/menu/builder_spec.rb +1 -1
  23. data/plugins/application/spec/application/menu/menu_item_spec.rb +1 -1
  24. data/plugins/application/spec/application/menu_spec.rb +1 -1
  25. data/plugins/application/spec/application/navigation_history_spec.rb +2 -0
  26. data/plugins/application/spec/application/notebook_spec.rb +1 -1
  27. data/plugins/application/spec/application/sensitive_spec.rb +1 -1
  28. data/plugins/application/spec/application/speedbar_spec.rb +1 -1
  29. data/plugins/application/spec/application/treebook_spec.rb +1 -1
  30. data/plugins/application/spec/application/window_spec.rb +1 -1
  31. data/plugins/application/spec/spec_helper.rb +4 -6
  32. data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +1 -1
  33. data/plugins/application_swt/lib/application_swt/gradient.rb +15 -5
  34. data/plugins/application_swt/lib/application_swt/window.rb +1 -1
  35. data/plugins/application_swt/spec/application_swt/gradient_spec.rb +13 -14
  36. data/plugins/application_swt/spec/application_swt/menu/binding_translator_spec.rb +1 -1
  37. data/plugins/application_swt/spec/application_swt/menu_spec.rb +1 -1
  38. data/plugins/application_swt/spec/spec_helper.rb +1 -19
  39. data/plugins/auto_completer/features/auto_complete.feature +7 -7
  40. data/plugins/auto_completer/features/step_definitions/auto_complete_steps.rb +3 -1
  41. data/plugins/auto_completer/features/step_definitions/dependency_steps.rb +0 -0
  42. data/plugins/auto_indenter/features/java_style_indentation.feature +5 -3
  43. data/plugins/auto_indenter/features/ruby_style_indentation.feature +13 -13
  44. data/plugins/auto_indenter/features/step_definitions/indentation_steps.rb +3 -1
  45. data/plugins/auto_indenter/spec/auto_indenter/analyzer_spec.rb +1 -1
  46. data/plugins/auto_indenter/spec/spec_helper.rb +1 -5
  47. data/plugins/auto_pairer/features/auto_pairer.feature +1 -1
  48. data/plugins/comment/features/line_comment.feature +31 -26
  49. data/plugins/comment/features/selection_comment.feature +1 -1
  50. data/plugins/comment/features/step_definitions/comment_steps.rb +6 -2
  51. data/plugins/comment/vendor/comment_lib.json +2 -0
  52. data/plugins/core/lib/core.rb +26 -0
  53. data/plugins/core/spec/core/base_storage_spec.rb +1 -1
  54. data/plugins/core/spec/core/gui_spec.rb +1 -1
  55. data/plugins/core/spec/core/observable_spec.rb +2 -1
  56. data/plugins/core/spec/core/persistent_cache_spec.rb +1 -1
  57. data/plugins/core/spec/core/shared_storage_spec.rb +1 -1
  58. data/plugins/core/spec/core/storage_spec.rb +1 -1
  59. data/plugins/core/spec/core/task_queue_spec.rb +1 -3
  60. data/plugins/core/spec/spec_helper.rb +1 -4
  61. data/plugins/declarations/spec/declarations/file_spec.rb +1 -1
  62. data/plugins/declarations/spec/spec_helper.rb +1 -5
  63. data/plugins/document_search/features/find.feature +39 -39
  64. data/plugins/document_search/features/step_definitions/find_steps.rb +6 -2
  65. data/plugins/edit_view/features/align_assignment.feature +6 -82
  66. data/plugins/edit_view/features/case_change.feature +22 -22
  67. data/plugins/edit_view/features/cursor_navigation.feature +2 -2
  68. data/plugins/edit_view/features/cut_and_paste.feature +9 -9
  69. data/plugins/edit_view/features/indentation_commands.feature +8 -8
  70. data/plugins/edit_view/features/line_delimiter.feature +7 -7
  71. data/plugins/edit_view/features/multiple_windows.feature +48 -48
  72. data/plugins/edit_view/features/step_definitions/dependency_steps.rb +0 -0
  73. data/plugins/edit_view/features/step_definitions/editing_steps.rb +237 -127
  74. data/plugins/edit_view/features/step_definitions/grammar_steps.rb +5 -1
  75. data/plugins/edit_view/features/step_definitions/notebook_steps.rb +38 -24
  76. data/plugins/edit_view/features/step_definitions/tab_steps.rb +83 -45
  77. data/plugins/edit_view/features/step_definitions/window_steps.rb +75 -54
  78. data/plugins/edit_view/features/support/env.rb +4 -23
  79. data/plugins/edit_view/lib/edit_view/commands/align_assignment_command.rb +29 -30
  80. data/plugins/edit_view/lib/edit_view/document.rb +23 -0
  81. data/plugins/edit_view/spec/edit_view/commands/align_assignment_command_spec.rb +83 -0
  82. data/plugins/edit_view/spec/edit_view/document/indentation_spec.rb +1 -1
  83. data/plugins/edit_view/spec/edit_view/document_spec.rb +1 -1
  84. data/plugins/edit_view/spec/spec_helper.rb +1 -4
  85. data/plugins/edit_view_swt/spec/edit_view_swt/word_movement_spec.rb +1 -1
  86. data/plugins/edit_view_swt/spec/spec_helper.rb +1 -4
  87. data/plugins/html_view/features/fixtures/sample.html +1 -1
  88. data/plugins/html_view/features/step_definitions/html_view_steps.rb +40 -39
  89. data/plugins/java/features/syntax_check_java.feature +18 -16
  90. data/plugins/line_tools/features/step_definitions/line_tools_steps.rb +18 -6
  91. data/plugins/macros/features/block_selection_in_macros.feature +47 -47
  92. data/plugins/macros/features/step_definitions/macro_steps.rb +9 -3
  93. data/plugins/macros/features/step_definitions/prediction_steps.rb +6 -2
  94. data/plugins/macros/plugin.rb +2 -1
  95. data/plugins/macros/spec/macros/predictive/sequence_finder_spec.rb +1 -1
  96. data/plugins/macros/spec/spec_helper.rb +1 -6
  97. data/plugins/outline_view/features/outline_view.feature +5 -5
  98. data/plugins/outline_view/features/step_definitions/outline_steps.rb +29 -17
  99. data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +1 -1
  100. data/plugins/project/features/close_directory_tree.feature +0 -12
  101. data/plugins/project/features/open_directory_tree.feature +1 -2
  102. data/plugins/project/features/step_definitions/directory_steps.rb +13 -5
  103. data/plugins/project/features/step_definitions/file_steps.rb +23 -9
  104. data/plugins/project/features/step_definitions/find_file_steps.rb +6 -2
  105. data/plugins/project/features/step_definitions/project_tree_steps.rb +6 -2
  106. data/plugins/project/features/watch_for_modified_files.feature +1 -1
  107. data/plugins/project/spec/project/adapters/remote_protocols/ftp_spec.rb +1 -1
  108. data/plugins/project/spec/project/adapters/remote_protocols/sftp_spec.rb +1 -1
  109. data/plugins/project/spec/project/adapters/remote_spec.rb +1 -1
  110. data/plugins/project/spec/project/dir_mirror_spec.rb +1 -1
  111. data/plugins/project/spec/project/file_list_spec.rb +1 -1
  112. data/plugins/project/spec/project/file_mirror_spec.rb +2 -1
  113. data/plugins/project/spec/spec_helper.rb +1 -4
  114. data/plugins/project_search/spec/project_search/binary_data_detector_spec.rb +1 -1
  115. data/plugins/project_search/spec/project_search/word_search_spec.rb +1 -1
  116. data/plugins/project_search/spec/spec_helper.rb +1 -4
  117. data/plugins/{application → redcar}/features/navigation_history.feature +8 -8
  118. data/plugins/redcar/features/step_definitions/font_steps.rb +9 -5
  119. data/plugins/redcar/redcar.rb +0 -26
  120. data/plugins/repl/features/step_definitions/repl_steps.rb +15 -5
  121. data/plugins/repl/plugin.rb +1 -1
  122. data/plugins/repl/spec/repl/repl_mirror_spec.rb +1 -1
  123. data/plugins/repl/spec/spec_helper.rb +1 -4
  124. data/plugins/ruby/spec/ruby/repl_mirror_spec.rb +1 -1
  125. data/plugins/ruby/spec/spec_helper.rb +1 -5
  126. data/plugins/runnables/features/parameter_input.feature +43 -43
  127. data/plugins/runnables/features/step_definitions/runnable_steps.rb +9 -3
  128. data/plugins/runnables/plugin.rb +2 -2
  129. data/plugins/runnables/spec/runnables/output_processor_spec.rb +1 -1
  130. data/plugins/runnables/spec/spec_helper.rb +1 -5
  131. data/plugins/scm_svn/features/add_and_commit.feature +1 -0
  132. data/plugins/scm_svn/features/checkout.feature +1 -0
  133. data/plugins/scm_svn/features/edit_and_index.feature +1 -0
  134. data/plugins/scm_svn/features/ignore_files.feature +1 -0
  135. data/plugins/scm_svn/features/merge.feature +1 -0
  136. data/plugins/scm_svn/features/resolve_conflict.feature +1 -0
  137. data/plugins/scm_svn/features/revert_and_delete.feature +1 -0
  138. data/plugins/scm_svn/features/step_definitions/branch_and_merge_steps.rb +14 -9
  139. data/plugins/scm_svn/features/support/env.rb +4 -4
  140. data/plugins/scm_svn/features/switch_branches.feature +1 -0
  141. data/plugins/scm_svn/features/update.feature +1 -0
  142. data/plugins/strip_trailing_spaces/features/strip_trailing_spaces.feature +4 -4
  143. data/plugins/test_runner/plugin.rb +3 -1
  144. data/plugins/test_runner/spec/run_test_command_spec.rb +58 -50
  145. data/plugins/test_runner/spec/spec_helper.rb +1 -5
  146. data/plugins/textmate/features/step_definitions/tree_steps.rb +2 -0
  147. data/plugins/todo_list/features/todo_list.feature +1 -1
  148. data/plugins/todo_list/spec/spec_helper.rb +1 -4
  149. data/plugins/todo_list/spec/todo_list/file_parser_spec.rb +1 -1
  150. data/plugins/tree_view_swt/lib/tree_view_swt.rb +2 -1
  151. data/plugins/web_bookmarks/features/step_definitions/web_steps.rb +1 -1
  152. metadata +48 -48
  153. data/lib/redcar/installer.rb +0 -178
  154. data/plugins/key_bindings/spec/spec_helper.rb +0 -5
  155. data/plugins/scm/spec/spec_helper.rb +0 -5
@@ -8,237 +8,339 @@ def escape_text(text)
8
8
  end
9
9
 
10
10
  When /^I undo$/ do
11
- Redcar::Top::UndoCommand.new.run(:env => {:edit_view => implicit_edit_view})
11
+ Swt.sync_exec do
12
+ Redcar::Top::UndoCommand.new.run(:env => {:edit_view => implicit_edit_view})
13
+ end
12
14
  end
13
15
 
14
16
  When /^I redo$/ do
15
- Redcar::Top::RedoCommand.new.run(:env => {:edit_view => implicit_edit_view})
17
+ Swt.sync_exec do
18
+ Redcar::Top::RedoCommand.new.run(:env => {:edit_view => implicit_edit_view})
19
+ end
20
+ end
21
+
22
+ When /^I select (-?)(\d+) from \((\d+), ?(\d+)\)$/ do |minus, length, start_line, start_line_offset|
23
+ length = length.to_i
24
+ length = length * -1 if minus == "-"
25
+ Swt.bot.styled_text.select_range(start_line.to_i, start_line_offset.to_i, length)
26
+ end
27
+
28
+ When /^I select from \((\d+), ?(\d+)\) to \((\d+), ?(\d+)\)$/ do |start_line, start_line_offset, end_line, end_line_offset|
29
+ length = nil
30
+ Swt.sync_exec do
31
+ doc = implicit_edit_view.document
32
+ start_of_end_line = doc.offset_at_line(end_line.to_i)
33
+ end_offset = start_of_end_line + end_line_offset.to_i
34
+
35
+ start_of_start_line = doc.offset_at_line(start_line.to_i)
36
+ start_offset = start_of_start_line + start_line_offset.to_i
37
+ length = end_offset - start_offset
38
+ end
39
+ Swt.bot.styled_text.select_range(start_line.to_i, start_line_offset.to_i, length)
16
40
  end
17
41
 
18
42
  When /^I select from (\d+) to (\d+)$/ do |start_offset, end_offset|
19
- doc = implicit_edit_view.document
20
- doc.set_selection_range(end_offset.to_i, start_offset.to_i)
43
+ Swt.sync_exec do
44
+ doc = implicit_edit_view.document
45
+ doc.set_selection_range(start_offset.to_i, end_offset.to_i)
46
+ end
21
47
  end
22
48
 
23
49
  When /^I copy text$/ do
24
- Redcar::Top::CopyCommand.new.run(:env => {:edit_view => implicit_edit_view})
50
+ # Redcar::Top::CopyCommand.new.run(:env => {:edit_view => implicit_edit_view})
51
+ When "I select menu item \"Edit|Copy\""
25
52
  end
26
53
 
27
54
  When /^I cut text$/ do
28
- Redcar::Top::CutCommand.new.run(:env => {:edit_view => implicit_edit_view})
55
+ # Redcar::Top::CutCommand.new.run(:env => {:edit_view => implicit_edit_view})
56
+ When "I select menu item \"Edit|Cut\""
29
57
  end
30
58
 
31
59
  When /^I paste text$/ do
32
- Redcar::Top::PasteCommand.new.run(:env => {:edit_view => implicit_edit_view})
60
+ # Redcar::Top::PasteCommand.new.run(:env => {:edit_view => implicit_edit_view})
61
+ When "I select menu item \"Edit|Paste\""
33
62
  end
34
63
 
35
64
  When /^I move the cursor to (\d+)$/ do |offset|
36
- doc = implicit_edit_view.document
37
- doc.cursor_offset = offset.to_i
65
+ Swt.sync_exec do
66
+ implicit_edit_view.document.cursor_offset = offset.to_i
67
+ end
68
+ end
69
+
70
+ When /^I move the cursor to \((\d+),(\d+)\)$/ do |line, line_offset|
71
+ Swt.bot.styled_text.navigate_to(line.to_i, line_offset.to_i)
38
72
  end
39
73
 
40
74
  When /^I move the cursor to the end of the document$/ do
41
- doc = implicit_edit_view.document
42
- doc.cursor_offset = doc.length
75
+ Swt.sync_exec do
76
+ doc = implicit_edit_view.document
77
+ doc.cursor_offset = doc.length
78
+ end
79
+ end
80
+
81
+ Then /^the cursor should be at \((\d+),(\d+)\)$/ do |line, line_offset|
82
+ position = Swt.bot.styled_text.cursor_position
83
+ position.line.should == line.to_i
84
+ position.column.should == line_offset.to_i
43
85
  end
44
86
 
45
87
  Then /^the cursor should be at (\d+)$/ do |offset|
46
- doc = implicit_edit_view.document
47
- doc.cursor_offset.should == offset.to_i
88
+ Swt.sync_exec do
89
+ doc = implicit_edit_view.document
90
+ doc.cursor_offset.should == offset.to_i
91
+ end
48
92
  end
49
93
 
50
94
  When /^tabs are hard$/ do
51
- implicit_edit_view.soft_tabs = false
95
+ Swt.sync_exec do
96
+ implicit_edit_view.soft_tabs = false
97
+ end
52
98
  end
53
99
 
54
100
  When /^tabs are soft, (\d+) spaces$/ do |int|
55
- implicit_edit_view.soft_tabs = true
56
- implicit_edit_view.tab_width = int.to_i
101
+ Swt.sync_exec do
102
+ implicit_edit_view.soft_tabs = true
103
+ implicit_edit_view.tab_width = int.to_i
104
+ end
57
105
  end
58
106
 
59
107
  When /^I insert "(.*)" at the cursor$/ do |text|
60
- implicit_edit_view.document.insert_at_cursor(unescape_text(text))
108
+ Swt.sync_exec do
109
+ implicit_edit_view.document.insert_at_cursor(unescape_text(text))
110
+ end
61
111
  end
62
112
 
63
113
  When /^I insert "(.*)" at (\d+)$/ do |text, offset_s|
64
- implicit_edit_view.document.insert(offset_s.to_i, unescape_text(text))
114
+ Swt.sync_exec do
115
+ implicit_edit_view.document.insert(offset_s.to_i, unescape_text(text))
116
+ end
65
117
  end
66
118
 
67
119
  When /^I replace (\d+) to (\d+) with "(.*)"$/ do |from, to, text|
68
- implicit_edit_view.document.replace(from.to_i, to.to_i - from.to_i, unescape_text(text))
120
+ Swt.sync_exec do
121
+ implicit_edit_view.document.replace(from.to_i, to.to_i - from.to_i, unescape_text(text))
122
+ end
69
123
  end
70
124
 
71
125
  When /^I press the Tab key in the edit tab$/ do
72
- implicit_edit_view.tab_pressed([])
126
+ Swt.sync_exec do
127
+ implicit_edit_view.tab_pressed([])
128
+ end
73
129
  end
74
130
 
75
131
  When /^I press Shift\+Tab in the edit tab$/ do
76
- implicit_edit_view.tab_pressed(["Shift"])
132
+ Swt.sync_exec do
133
+ implicit_edit_view.tab_pressed(["Shift"])
134
+ end
77
135
  end
78
136
 
79
137
  When /^I press the Left key in the edit tab$/ do
80
- implicit_edit_view.left_pressed([])
138
+ Swt.sync_exec do
139
+ implicit_edit_view.left_pressed([])
140
+ end
81
141
  end
82
142
 
83
143
  When /^I press the Right key in the edit tab$/ do
84
- implicit_edit_view.right_pressed([])
144
+ Swt.sync_exec do
145
+ implicit_edit_view.right_pressed([])
146
+ end
85
147
  end
86
148
 
87
149
  When /^I press Shift\+Left key in the edit tab$/ do
88
- implicit_edit_view.left_pressed(["Shift"])
150
+ Swt.sync_exec do
151
+ implicit_edit_view.left_pressed(["Shift"])
152
+ end
89
153
  end
90
154
 
91
155
  When /^I press Shift\+Right key in the edit tab$/ do
92
- implicit_edit_view.right_pressed(["Shift"])
156
+ Swt.sync_exec do
157
+ implicit_edit_view.right_pressed(["Shift"])
158
+ end
93
159
  end
94
160
 
95
161
  When /^I press the Delete key in the edit tab$/ do
96
- implicit_edit_view.delete_pressed([])
162
+ Swt.sync_exec do
163
+ implicit_edit_view.delete_pressed([])
164
+ end
97
165
  end
98
166
 
99
167
  When /^I press the Backspace key in the edit tab$/ do
100
- edit_view = implicit_edit_view
101
- edit_view.backspace_pressed([])
168
+ Swt.bot.styled_text.type_text("\b")
102
169
  end
103
170
 
104
171
  Then /^the contents should (not )?be "(.*)"$/ do |negative,text|
105
- expected = unescape_text(text)
106
- doc = implicit_edit_view.document
107
- actual = doc.to_s
108
- if expected.include?("<c>")
109
- char_curoff = doc.cursor_offset
110
- actual = actual.insert(actual.char_offset_to_byte_offset(char_curoff), "<c>")
111
- char_seloff = doc.selection_offset
112
- if char_seloff > char_curoff
113
- char_seloff += 3
172
+ Swt.sync_exec do
173
+ expected = unescape_text(text)
174
+ doc = implicit_edit_view.document
175
+ actual = doc.to_s
176
+ if expected.include?("<c>")
177
+ char_curoff = doc.cursor_offset
178
+ actual = actual.insert(actual.char_offset_to_byte_offset(char_curoff), "<c>")
179
+ char_seloff = doc.selection_offset
180
+ if char_seloff > char_curoff
181
+ char_seloff += 3
182
+ end
183
+ actual = actual.insert(actual.char_offset_to_byte_offset(char_seloff), "<s>") unless char_curoff == char_seloff
184
+ end
185
+ if negative
186
+ actual.should_not == expected
187
+ else
188
+ actual.should == expected
114
189
  end
115
- actual = actual.insert(actual.char_offset_to_byte_offset(char_seloff), "<s>") unless char_curoff == char_seloff
116
- end
117
- if negative
118
- actual.should_not == expected
119
- else
120
- actual.should == expected
121
190
  end
122
191
  end
123
192
 
124
193
  Then /^the contents of the edit tab should be "(.*)"$/ do |text|
125
- implicit_edit_view.document.to_s.should == unescape_text(text)
194
+ Swt.sync_exec do
195
+ implicit_edit_view.document.to_s.should == unescape_text(text)
196
+ end
126
197
  end
127
198
 
128
199
  When /^I block select from (\d+) to (\d+)$/ do |from_str, to_str|
129
- doc = implicit_edit_view.document
130
- doc.block_selection_mode = true
131
- doc.set_selection_range(from_str.to_i, to_str.to_i)
200
+ Swt.sync_exec do
201
+ doc = implicit_edit_view.document
202
+ doc.block_selection_mode = true
203
+ doc.set_selection_range(from_str.to_i, to_str.to_i)
204
+ end
132
205
  end
133
206
 
134
207
  Then /^the selection range should be from (\d+) to (\d+)$/ do |from_str, to_str|
135
- doc = implicit_edit_view.document
136
- r = doc.selection_range
137
- r.begin.should == from_str.to_i
138
- r.end.should == to_str.to_i
208
+ Swt.sync_exec do
209
+ doc = implicit_edit_view.document
210
+ r = doc.selection_range
211
+ r.begin.should == from_str.to_i
212
+ r.end.should == to_str.to_i
213
+ end
139
214
  end
140
215
 
141
216
  Then /^the selection should be on line (.*)$/ do |line_num|
142
- line_num = line_num.to_i
143
- doc = implicit_edit_view.document
144
- r = doc.selection_range
145
- doc.line_at_offset(r.begin).should == line_num
146
- doc.line_at_offset(r.end).should == line_num
217
+ Swt.sync_exec do
218
+ line_num = line_num.to_i
219
+ doc = implicit_edit_view.document
220
+ r = doc.selection_range
221
+ doc.line_at_offset(r.begin).should == line_num
222
+ doc.line_at_offset(r.end).should == line_num
223
+ end
147
224
  end
148
225
 
149
226
  Then /^there should not be any text selected$/ do
150
- doc = implicit_edit_view.document
151
- doc.selected_text.should == ""
227
+ Swt.sync_exec do
228
+ doc = implicit_edit_view.document
229
+ doc.selected_text.should == ""
230
+ end
152
231
  end
153
232
 
154
233
  Then /^the selected text should be "([^"]*)"$/ do |selected_text|
155
- doc = implicit_edit_view.document
156
- doc.selected_text.should == unescape_text(selected_text)
234
+ Swt.bot.styled_text.selection.should == unescape_text(selected_text)
157
235
  end
158
236
 
159
237
  Then /the line delimiter should be "(.*)"/ do |delim|
160
- doc = implicit_edit_view.document
161
- doc.delim.should == unescape_text(delim)
238
+ Swt.sync_exec do
239
+ doc = implicit_edit_view.document
240
+ doc.delim.should == unescape_text(delim)
241
+ end
162
242
  end
163
243
 
164
244
  When /^I move to line (\d+)$/ do |num|
165
- doc = implicit_edit_view.document
166
- doc.cursor_offset = doc.offset_at_line(num.to_i)
245
+ Swt.sync_exec do
246
+ doc = implicit_edit_view.document
247
+ doc.cursor_offset = doc.offset_at_line(num.to_i)
248
+ end
167
249
  end
168
250
 
169
251
  Then /^the cursor should be on line (\d+)$/ do |num|
170
- doc = implicit_edit_view.document
171
- doc.cursor_line.should == num.to_i
252
+ Swt.sync_exec do
253
+ doc = implicit_edit_view.document
254
+ doc.cursor_line.should == num.to_i
255
+ end
172
256
  end
173
257
 
174
258
  When /^I replace the contents with "((?:[^\"]|\\")*)"$/ do |contents|
175
- contents = unescape_text(contents)
176
- doc = implicit_edit_view.document
177
- cursor_offset = (contents =~ /<c>/)
178
- doc.text = contents.gsub("<c>", "")
179
- doc.cursor_offset = cursor_offset if cursor_offset
259
+ Swt.sync_exec do
260
+ contents = unescape_text(contents)
261
+ doc = implicit_edit_view.document
262
+ cursor_offset = (contents =~ /<c>/)
263
+ doc.text = contents.gsub("<c>", "")
264
+ doc.cursor_offset = cursor_offset if cursor_offset
265
+ end
180
266
  end
181
267
 
182
268
  When /^I replace the contents with 100 lines of "([^"]*)" then "([^"]*)"$/ do |contents1, contents2|
183
- contents1 = unescape_text(contents1)
184
- contents2 = unescape_text(contents2)
185
- doc = implicit_edit_view.document
186
- doc.text = (contents1 + "\n")*100 + contents2
269
+ Swt.sync_exec do
270
+ contents1 = unescape_text(contents1)
271
+ contents2 = unescape_text(contents2)
272
+ doc = implicit_edit_view.document
273
+ doc.text = (contents1 + "\n")*100 + contents2
274
+ end
187
275
  end
188
276
 
189
277
  When /^I replace the contents with (\d+) "([^"]*)" then "([^"]*)"$/ do |count, contents1, contents2|
190
- contents1 = unescape_text(contents1)
191
- contents2 = unescape_text(contents2)
192
- doc = implicit_edit_view.document
193
- doc.text = (contents1)*count.to_i + contents2
278
+ Swt.sync_exec do
279
+ contents1 = unescape_text(contents1)
280
+ contents2 = unescape_text(contents2)
281
+ doc = implicit_edit_view.document
282
+ doc.text = (contents1)*count.to_i + contents2
283
+ end
194
284
  end
195
285
 
196
286
  When /^I scroll to the top of the document$/ do
197
- doc = implicit_edit_view.document
198
- doc.scroll_to_line(0)
287
+ Swt.sync_exec do
288
+ doc = implicit_edit_view.document
289
+ doc.scroll_to_line(0)
290
+ end
199
291
  end
200
292
 
201
293
  Then /^line number (\d+) should be visible$/ do |line_num|
202
- line_num = line_num.to_i
203
- doc = implicit_edit_view.document
204
- (doc.biggest_visible_line >= line_num).should be_true
205
- (doc.smallest_visible_line <= line_num).should be_true
294
+ Swt.sync_exec do
295
+ line_num = line_num.to_i
296
+ doc = implicit_edit_view.document
297
+ (doc.biggest_visible_line >= line_num).should be_true
298
+ (doc.smallest_visible_line <= line_num).should be_true
299
+ end
206
300
  end
207
301
 
208
302
  Then /^horizontal offset (\d+) should be visible$/ do |offset|
209
- offset = offset.to_i
210
- doc = implicit_edit_view.document
211
- (doc.largest_visible_horizontal_index >= offset).should be_true
212
- (doc.smallest_visible_horizontal_index <= offset).should be_true
303
+ Swt.sync_exec do
304
+ offset = offset.to_i
305
+ doc = implicit_edit_view.document
306
+ (doc.largest_visible_horizontal_index >= offset).should be_true
307
+ (doc.smallest_visible_horizontal_index <= offset).should be_true
308
+ end
213
309
  end
214
310
 
215
311
  When /^I select the word (right of|left of|around|at) (\d+)$/ do |direction, offset|
216
- offset = offset.to_i
217
- doc = implicit_edit_view.document
218
- case direction
219
- when "right of"
220
- range = doc.match_word_right_of(offset)
221
- when "left of"
222
- range = doc.match_word_left_of(offset)
223
- when "around"
224
- range = doc.match_word_around(offset)
225
- when "at"
226
- range = doc.word_range_at_offset(offset)
227
- else
228
- warn "unrecognized direction"
229
- range = offset..offset
312
+ Swt.sync_exec do
313
+ offset = offset.to_i
314
+ doc = implicit_edit_view.document
315
+ case direction
316
+ when "right of"
317
+ range = doc.match_word_right_of(offset)
318
+ when "left of"
319
+ range = doc.match_word_left_of(offset)
320
+ when "around"
321
+ range = doc.match_word_around(offset)
322
+ when "at"
323
+ range = doc.word_range_at_offset(offset)
324
+ else
325
+ warn "unrecognized direction"
326
+ range = offset..offset
327
+ end
328
+ doc.set_selection_range(range.first, range.last)
230
329
  end
231
- doc.set_selection_range(range.first, range.last)
232
330
  end
233
331
 
234
332
  When /^I turn block selection on$/ do
235
- implicit_edit_view.document.block_selection_mode?.should == false
236
- Redcar::Top::ToggleBlockSelectionCommand.new.run(:env => {:edit_view => implicit_edit_view})
333
+ Swt.sync_exec do
334
+ implicit_edit_view.document.block_selection_mode?.should == false
335
+ Redcar::Top::ToggleBlockSelectionCommand.new.run(:env => {:edit_view => implicit_edit_view})
336
+ end
237
337
  end
238
338
 
239
339
  When /^I turn block selection off$/ do
240
- implicit_edit_view.document.block_selection_mode?.should == true
241
- Redcar::Top::ToggleBlockSelectionCommand.new.run(:env => {:edit_view => implicit_edit_view})
340
+ Swt.sync_exec do
341
+ implicit_edit_view.document.block_selection_mode?.should == true
342
+ Redcar::Top::ToggleBlockSelectionCommand.new.run(:env => {:edit_view => implicit_edit_view})
343
+ end
242
344
  end
243
345
 
244
346
  def escape_text(text)
@@ -246,20 +348,22 @@ def escape_text(text)
246
348
  end
247
349
 
248
350
  Given /^the contents? is:$/ do |string|
249
- cursor_index = string.index('<c>')
250
- selection_index = string.index('<s>')
251
- string = string.gsub('<s>', '').gsub('<c>', '')
252
- When %{I replace the contents with "#{string}"}
253
-
254
- if cursor_index and selection_index
255
- if cursor_index < selection_index
256
- selection_index -= 3
257
- else
258
- cursor_index -= 3
351
+ Swt.sync_exec do
352
+ cursor_index = string.index('<c>')
353
+ selection_index = string.index('<s>')
354
+ string = string.gsub('<s>', '').gsub('<c>', '')
355
+ When %{I replace the contents with "#{string}"}
356
+
357
+ if cursor_index and selection_index
358
+ if cursor_index < selection_index
359
+ selection_index -= 3
360
+ else
361
+ cursor_index -= 3
362
+ end
363
+ When %{I select #{cursor_index - selection_index} from #{selection_index}}
364
+ elsif cursor_index
365
+ When "I move the cursor to #{cursor_index}"
259
366
  end
260
- When %{I select from #{selection_index} to #{cursor_index}}
261
- elsif cursor_index
262
- When "I move the cursor to #{cursor_index}"
263
367
  end
264
368
  end
265
369
 
@@ -296,10 +400,7 @@ end
296
400
 
297
401
  When /^I type "((?:[^"]|\\")*)"$/ do |text|
298
402
  text = text.gsub("\\t", "\t").gsub("\\n", "\n").gsub("\\\"", "\"")
299
- edit_view = implicit_edit_view
300
- text.split(//).each do |letter|
301
- edit_view.type_character(letter[0])
302
- end
403
+ Swt.bot.styled_text.type_text(text)
303
404
  end
304
405
 
305
406
  edit_view_action_steps = {
@@ -317,7 +418,7 @@ edit_view_action_steps = {
317
418
  :TEXT_END => "I move to the end of the text",
318
419
  :WINDOW_START => "I move to the start of the window",
319
420
  :WINDOW_END => "I move to the end of the window",
320
- :SELECT_ALL => "I select all",
421
+ # :SELECT_ALL => "I select all",
321
422
  :SELECT_LINE_UP => "I select up",
322
423
  :SELECT_LINE_DOWN => "I select down",
323
424
  :SELECT_LINE_START => "I select to the start of the line",
@@ -341,9 +442,18 @@ edit_view_action_steps = {
341
442
  :DELETE_WORD_NEXT => "I delete to the next word"
342
443
  }
343
444
 
445
+ When "I select all" do
446
+ char_count = Redcar.update_gui do
447
+ Swt.bot.styled_text.widget.get_char_count
448
+ end
449
+ Swt.bot.styled_text.select_range(0, 0, char_count)
450
+ end
451
+
344
452
  edit_view_action_steps.each do |action_symbol, step_text|
345
453
  When step_text do
346
- implicit_edit_view.invoke_action(action_symbol)
454
+ Swt.sync_exec do
455
+ implicit_edit_view.invoke_action(action_symbol)
456
+ end
347
457
  end
348
458
  end
349
459