redcar 0.7 → 0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. data/CHANGES +42 -0
  2. data/README.md +5 -3
  3. data/Rakefile +39 -81
  4. data/bin/redcar +1 -1
  5. data/lib/redcar.rb +9 -6
  6. data/lib/redcar/installer.rb +1 -1
  7. data/lib/redcar/ruby_extensions.rb +19 -0
  8. data/lib/redcar/runner.rb +1 -1
  9. data/lib/redcar/usage.rb +3 -0
  10. data/lib/redcar_quick_start.rb +11 -11
  11. data/plugins/application/features/step_definitions/tree_steps.rb +22 -5
  12. data/plugins/application/features/step_definitions/window_steps.rb +9 -1
  13. data/plugins/application/features/support/env.rb +5 -2
  14. data/plugins/application/lib/application.rb +51 -46
  15. data/plugins/application/lib/application/window.rb +60 -30
  16. data/plugins/application_swt/lib/application_swt.rb +16 -16
  17. data/plugins/application_swt/lib/application_swt/window.rb +35 -7
  18. data/plugins/auto_completer/features/support/env.rb +0 -2
  19. data/plugins/auto_indenter/features/support/env.rb +0 -1
  20. data/plugins/auto_pairer/features/auto_pairer.feature +50 -45
  21. data/plugins/auto_pairer/features/support/env.rb +0 -1
  22. data/plugins/auto_pairer/lib/auto_pairer/document_controller.rb +11 -6
  23. data/plugins/clipboard-viewer/Screenshot.png +0 -0
  24. data/plugins/clipboard-viewer/lib/clipboard_viewer.rb +50 -0
  25. data/plugins/clipboard-viewer/lib/clipboard_viewer/browser_controller.rb +27 -0
  26. data/plugins/clipboard-viewer/lib/clipboard_viewer/clipboard_bar.rb +67 -0
  27. data/plugins/clipboard-viewer/plugin.rb +9 -0
  28. data/plugins/clipboard-viewer/views/clipboard.html.erb +15 -0
  29. data/plugins/clipboard-viewer/views/default.css +43 -0
  30. data/plugins/clipboard-viewer/views/redcar_small_icon.png +0 -0
  31. data/plugins/comment/features/line_comment.feature +137 -0
  32. data/plugins/comment/features/selection_comment.feature +21 -0
  33. data/plugins/comment/features/step_definitions/comment_steps.rb +7 -0
  34. data/plugins/comment/lib/comment.rb +266 -0
  35. data/plugins/comment/plugin.rb +7 -0
  36. data/plugins/comment/vendor/comment_lib.json +47 -0
  37. data/plugins/declarations/lib/declarations.rb +1 -1
  38. data/plugins/document_search/features/replace.feature +10 -2
  39. data/plugins/document_search/features/support/env.rb +0 -1
  40. data/plugins/document_search/lib/document_search.rb +4 -1
  41. data/plugins/document_search/lib/document_search/replace.rb +11 -3
  42. data/plugins/document_search/lib/document_search/search_and_replace.rb +5 -2
  43. data/plugins/edit_view/features/case_change.feature +9 -9
  44. data/plugins/edit_view/features/cursor_navigation.feature +36 -0
  45. data/plugins/edit_view/features/step_definitions/editing_steps.rb +63 -8
  46. data/plugins/edit_view/features/step_definitions/notebook_steps.rb +2 -0
  47. data/plugins/edit_view/features/step_definitions/tab_steps.rb +8 -5
  48. data/plugins/edit_view/features/support/env.rb +8 -2
  49. data/plugins/edit_view/lib/edit_view.rb +16 -1
  50. data/plugins/edit_view/lib/edit_view/actions/cmd_enter.rb +11 -0
  51. data/plugins/edit_view/lib/edit_view/document.rb +27 -10
  52. data/plugins/edit_view/lib/edit_view/edit_tab.rb +17 -4
  53. data/plugins/edit_view/spec/edit_view/document_spec.rb +3 -0
  54. data/plugins/edit_view_swt/lib/edit_view_swt.rb +42 -3
  55. data/plugins/edit_view_swt/lib/edit_view_swt/word_movement.rb +17 -15
  56. data/plugins/help/lib/help.rb +40 -0
  57. data/plugins/help/plugin.rb +8 -0
  58. data/plugins/html_view/features/step_definitions/html_view_steps.rb +6 -4
  59. data/plugins/line_tools/features/support/env.rb +0 -1
  60. data/plugins/macros/features/step_definitions/macro_steps.rb +0 -55
  61. data/plugins/macros/features/support/env.rb +0 -2
  62. data/plugins/open_default_app/lib/open_default_app.rb +35 -0
  63. data/plugins/open_default_app/plugin.rb +8 -0
  64. data/plugins/open_default_app/screenshot.png +0 -0
  65. data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +17 -3
  66. data/plugins/project/features/find_file.feature +3 -2
  67. data/plugins/project/features/highlight_focussed_tab.feature +8 -0
  68. data/plugins/project/features/move_and_rename_files.feature +25 -0
  69. data/plugins/project/features/open_and_save_files.feature +10 -1
  70. data/plugins/project/features/open_directory_tree.feature +32 -2
  71. data/plugins/project/features/step_definitions/directory_steps.rb +17 -0
  72. data/plugins/project/features/step_definitions/project_tree_steps.rb +3 -0
  73. data/plugins/project/features/sub_project.feature +14 -0
  74. data/plugins/project/features/support/env.rb +22 -3
  75. data/plugins/project/features/watch_for_modified_files.feature +32 -9
  76. data/plugins/project/lib/project.rb +53 -21
  77. data/plugins/project/lib/project/adapters/local.rb +21 -16
  78. data/plugins/project/lib/project/adapters/remote.rb +15 -13
  79. data/plugins/project/lib/project/commands.rb +37 -16
  80. data/plugins/project/lib/project/dir_controller.rb +41 -42
  81. data/plugins/project/lib/project/drb_service.rb +35 -21
  82. data/plugins/project/lib/project/file_list.rb +7 -1
  83. data/plugins/project/lib/project/manager.rb +28 -3
  84. data/plugins/project/lib/project/sub_project.rb +17 -0
  85. data/plugins/project/lib/project/support/recycle.js +2 -0
  86. data/plugins/project/lib/project/support/trash.rb +72 -0
  87. data/plugins/project/spec/fixtures/multi-byte-files/a/341/204/200/341/205/247/341/206/274/341/204/205/341/205/251/foo +1 -0
  88. data/plugins/project/spec/fixtures/multi-byte-files//341/204/220/341/205/246/341/204/211/341/205/263/341/204/220/341/205/263.py +1 -0
  89. data/plugins/project/spec/project/file_list_spec.rb +4 -0
  90. data/plugins/redcar/features/goto_line_command.feature +20 -0
  91. data/plugins/redcar/redcar.rb +107 -47
  92. data/plugins/repl/lib/repl.rb +20 -20
  93. data/plugins/repl/lib/repl/clojure_mirror.rb +50 -58
  94. data/plugins/repl/lib/repl/groovy_mirror.rb +22 -41
  95. data/plugins/repl/lib/repl/repl_mirror.rb +85 -14
  96. data/plugins/repl/lib/repl/ruby_mirror.rb +12 -39
  97. data/plugins/repl/spec/repl/groovy_mirror_spec.rb +1 -1
  98. data/plugins/repl/spec/repl/ruby_mirror_spec.rb +12 -12
  99. data/plugins/ruby/README +6 -0
  100. data/plugins/ruby/lib/syntax_check/ruby.rb +28 -0
  101. data/plugins/ruby/plugin.rb +7 -0
  102. data/plugins/runnables/features/command_tree.feature +9 -0
  103. data/plugins/runnables/features/file_runner_input.feature +20 -0
  104. data/plugins/runnables/features/run_alternate_command.feature +14 -0
  105. data/plugins/runnables/features/support/env.rb +42 -5
  106. data/plugins/runnables/lib/runnables.rb +67 -21
  107. data/plugins/runnables/lib/runnables/commands.rb +35 -18
  108. data/plugins/runnables/lib/runnables/tree_mirror/nodes/runnable_group.rb +23 -37
  109. data/plugins/runnables/lib/runnables/tree_mirror/nodes/runnable_type_group.rb +16 -18
  110. data/plugins/scm_svn/features/support/env.rb +0 -3
  111. data/plugins/snippets/features/snippets.feature +17 -2
  112. data/plugins/snippets/features/support/env.rb +0 -1
  113. data/plugins/snippets/lib/snippets/tab_handler.rb +51 -18
  114. data/plugins/swt/lib/swt/cucumber_patches.rb +13 -68
  115. data/plugins/swt/lib/swt/cucumber_runner.rb +2 -3
  116. data/plugins/syntax_check/README +6 -0
  117. data/plugins/syntax_check/lib/syntax_check.rb +16 -0
  118. data/plugins/syntax_check/lib/syntax_check/checker.rb +47 -0
  119. data/plugins/syntax_check/lib/syntax_check/error.rb +23 -0
  120. data/plugins/syntax_check/plugin.rb +7 -0
  121. data/plugins/tree_view_swt/lib/tree_view_swt.rb +6 -0
  122. data/plugins/web_bookmarks/Screenshot.png +0 -0
  123. data/plugins/web_bookmarks/lib/web_bookmarks.rb +42 -0
  124. data/plugins/web_bookmarks/lib/web_bookmarks/bookmark.rb +43 -0
  125. data/plugins/web_bookmarks/lib/web_bookmarks/browser_bar.rb +70 -0
  126. data/plugins/web_bookmarks/lib/web_bookmarks/commands.rb +111 -0
  127. data/plugins/web_bookmarks/lib/web_bookmarks/tree.rb +67 -0
  128. data/plugins/web_bookmarks/lib/web_bookmarks/view_controller.rb +22 -0
  129. data/plugins/web_bookmarks/plugin.rb +11 -0
  130. data/plugins/web_bookmarks/views/index.html.erb +5 -0
  131. metadata +60 -10
@@ -0,0 +1,7 @@
1
+ Plugin.define do
2
+ name "comment"
3
+ version "0.1"
4
+ file "lib", "comment"
5
+ object "Redcar::Comment"
6
+ dependencies "redcar", ">0"
7
+ end
@@ -0,0 +1,47 @@
1
+ {
2
+ "Ada" : { "line_comment" : "--" },
3
+ "BASIC" : { "line_comment" : "REM" },
4
+ "C" : { "line_comment" : "//" , "start_block" : "/*", "end_block" : "*/" },
5
+ "C#" : { "line_comment" : "//" , "start_block" : "/*", "end_block" : "*/" },
6
+ "C++" : { "line_comment" : "//" , "start_block" : "/*", "end_block" : "*/" },
7
+ "Cucumber Plain Text Feature" : { "line_comment" : "#" },
8
+ "Clojure" : { "line_comment" : ";" , "start_block" : "(comment", "end_block" : ")" },
9
+ "CoffeeScript" : { "line_comment" : "#" , "start_block" : "###\n" , "end_block" : "\n###" },
10
+ "D" : { "line_comment" : "//" , "start_block" : "/+" , "end_block" : "+/" },
11
+ "Easyb" : { "line_comment" : "//" , "start_block" : "/*" , "end_block" : "*/" },
12
+ "FORTRAN" : { "line_comment" : "C" },
13
+ "GNU Smalltalk" : { "start_block" : "\"" , "end_block" : "\"" },
14
+ "Grails Server Page" : { "start_block" : "<%--", "end_block" : "--%>" },
15
+ "Groovy" : { "line_comment" : "//" , "start_block" : "/*" , "end_block" : "*/" },
16
+ "Haskell" : { "start_block" : "{-" , "end_block" : "-}" },
17
+ "HTML" : { "start_block" : "<!--", "end_block" : "-->" },
18
+ "Java" : { "line_comment" : "//" , "start_block" : "/*" , "end_block" : "*/" },
19
+ "JavaScript" : { "line_comment" : "//" , "start_block" : "/*" , "end_block" : "*/" },
20
+ "LaTeX" : { "line_comment" : "%" },
21
+ "Lisp" : { "line_comment" : ";" , "start_block" : "#|" , "end_block" : "|#" },
22
+ "Lua" : { "line_comment" : "--" , "start_block" : "--[[" , "end_block" : "]]" },
23
+ "Mathematica" : { "start_block" : "% (*", "end_block" : "*)" },
24
+ "Matlab" : { "line_comment" : "%" , "start_block" : "%{\n" , "end_block" : "\n%}" },
25
+ "Perl" : { "line_comment" : "#" , "start_block" : "=begin\n", "end_block" : "\n=end" },
26
+ "PHP" : { "line_comment" : "//" , "start_block" : "/*" , "end_block" : "*/" },
27
+ "Postscript" : { "line_comment" : "%" },
28
+ "Powershell" : { "line_comment" : "#" , "start_block" : "<#" , "end_block" : "#>" },
29
+ "Python" : { "line_comment" : "#" , "start_block" : "\"\"\"" , "end_block" : "\"\"\"" },
30
+ "RSpec" : { "line_comment" : "#" , "start_block" : "=begin\n", "end_block" : "\n=end" },
31
+ "Ruby" : { "line_comment" : "#" , "start_block" : "=begin\n", "end_block" : "\n=end" },
32
+ "Ruby on Rails" : { "line_comment" : "#" , "start_block" : "=begin\n", "end_block" : "\n=end" },
33
+ "Scala" : { "line_comment" : "//" , "start_block" : "/*" , "end_block" : "*/" },
34
+ "Scheme" : { "line_comment" : ";" , "start_block" : "#|" , "end_block" : "|#" },
35
+ "Shell Script (Bash)" : { "line_comment" : "#" },
36
+ "Simula" : { "start_block" : "comment", "end_block": ";" },
37
+ "Smarty" : { "start_block" : "{*" , "end_block" : "*}" },
38
+ "SQL" : { "line_comment" : "--" , "start_block" : "/*" , "end_block" : "*/" },
39
+ "Standard ML" : { "start_block" : "(*" , "end_block" : "*)" },
40
+ "TeX" : { "line_comment" : "%" },
41
+ "Vala" : { "line_comment" : "//" , "start_block" : "/*", "end_block" : "*/" },
42
+ "VBscript" : { "line_comment" : "'" },
43
+ "Vim Script" : { "line_comment" : "\"" },
44
+ "Visual Basic" : { "line_comment" : "'" },
45
+ "XHTML" : { "start_block" : "<!--", "end_block" : "-->" },
46
+ "XML" : { "start_block" : "<!--", "end_block" : "-->" }
47
+ }
@@ -113,7 +113,7 @@ module Redcar
113
113
  Application::Dialog.message_box("The declarations file 'tags' has not been generated yet.")
114
114
  return
115
115
  end
116
- matches = find_tag(tags_path, token)
116
+ matches = find_tag(tags_path, token).uniq
117
117
  case matches.size
118
118
  when 0
119
119
  Application::Dialog.message_box("There is no declaration for '#{token}' in the 'tags' file.")
@@ -131,6 +131,14 @@ Feature: Replace in file
131
131
  And I press "Replace" in the speedbar
132
132
  Then the contents should be "foobar\nfoobar\nfoobar"
133
133
  And the selection range should be from 14 to 20
134
-
135
-
134
+
135
+ Scenario: The Search-and-Replace Speedbar should get initialized with the currently selected text
136
+ When I replace the contents with "Foo\nBar\nFoo"
137
+ And I select from 4 to 7
138
+ When I run the command DocumentSearch::SearchAndReplaceCommand
139
+ Then the "Search" field in the speedbar should have text "Bar"
140
+ When I type "Foo" into the "Replace" field in the speedbar
141
+ And I press "Replace" in the speedbar
142
+ Then the contents should be "Foo\nFoo\nFoo"
143
+
136
144
 
@@ -1,4 +1,3 @@
1
1
 
2
- RequireSupportFiles File.dirname(__FILE__) + "/../../../edit_view/features/"
3
2
 
4
3
 
@@ -7,7 +7,7 @@ module DocumentSearch
7
7
  Redcar::Menu::Builder.build do
8
8
  sub_menu "Edit" do
9
9
  sub_menu "Search", :priority => 50 do
10
- item "Document Search", SearchForwardCommand
10
+ item "Document Search", SearchForwardCommand
11
11
  item "Repeat Last Search", RepeatPreviousSearchForwardCommand
12
12
  item "Search and Replace", SearchAndReplaceCommand
13
13
  end
@@ -89,6 +89,9 @@ module DocumentSearch
89
89
  class SearchAndReplaceCommand < Redcar::EditTabCommand
90
90
  def execute
91
91
  @speedbar = SearchAndReplaceSpeedbar.new
92
+ if doc.selection?
93
+ @speedbar.initial_query = doc.selected_text
94
+ end
92
95
  win.open_speedbar(@speedbar)
93
96
  end
94
97
  end
@@ -12,8 +12,16 @@ module DocumentSearch
12
12
  end
13
13
 
14
14
  def execute
15
- # Get the current line and then get the line segment from the cursor or selection to the end of the line
16
- latest_point = [doc.cursor_offset, doc.selection_offset].max
15
+ # The current selection is usually not used for the next replacement, unless
16
+ # it matches the query string, in which case we assume that the user meant replace it, too
17
+ offsets = [doc.cursor_offset, doc.selection_offset]
18
+ if query == doc.selected_text
19
+ latest_point = offsets.min
20
+ else
21
+ latest_point = offsets.max
22
+ end
23
+
24
+ # Get the current line and then get the line segment from the cursor to the end of the line
17
25
  curr_line_number = doc.line_at_offset(latest_point)
18
26
  cursor_line_offset = latest_point - doc.offset_at_line(curr_line_number)
19
27
  curr_line = doc.get_line(curr_line_number)
@@ -90,7 +98,7 @@ module DocumentSearch
90
98
  doc.replace_line(i, line.chomp)
91
99
  count += 1
92
100
  end
93
- end while line != nil
101
+ end
94
102
  end
95
103
  if last_match_line
96
104
  line_offset = doc.offset_at_line(last_match_line)
@@ -6,9 +6,12 @@ module DocumentSearch
6
6
  attr_accessor :previous_replace
7
7
  attr_accessor :previous_search_type
8
8
  end
9
-
9
+
10
+ attr_accessor :initial_query
11
+
10
12
  def after_draw
11
- self.query.value = SearchAndReplaceSpeedbar.previous_query || ""
13
+ SearchSpeedbar.previous_query ||= ""
14
+ self.query.value = @initial_query || SearchSpeedbar.previous_query
12
15
  self.replace.value = SearchAndReplaceSpeedbar.previous_replace || ""
13
16
  self.search_type.value = SearchAndReplaceSpeedbar.previous_search_type
14
17
  self.query.edit_view.document.select_all
@@ -7,13 +7,13 @@ Feature: Change Case
7
7
  When I replace the contents with "Curry Chicken"
8
8
  And I select from 5 to 0
9
9
  And I run the command Redcar::EditView::UpcaseTextCommand
10
- Then the contents should be "<s>CURRY<c> Chicken"
10
+ Then the contents should be "<c>CURRY<s> Chicken"
11
11
 
12
12
  Scenario: Upcase selected text and preserve cursor position
13
13
  When I replace the contents with "Curry Chicken"
14
14
  And I select from 0 to 5
15
15
  And I run the command Redcar::EditView::UpcaseTextCommand
16
- Then the contents should be "<c>CURRY<s> Chicken"
16
+ Then the contents should be "<s>CURRY<c> Chicken"
17
17
 
18
18
  Scenario: Upcase word if no selection
19
19
  When I replace the contents with "Curry Chicken"
@@ -25,19 +25,19 @@ Feature: Change Case
25
25
  When I replace the contents with "CURRY CHICKEN"
26
26
  And I select from 0 to 5
27
27
  And I run the command Redcar::EditView::DowncaseTextCommand
28
- Then the contents should be "curry CHICKEN"
28
+ Then the contents should be "<s>curry<c> CHICKEN"
29
29
 
30
30
  Scenario: Titlize text
31
31
  When I replace the contents with "curry chicken"
32
32
  And I select from 0 to 13
33
33
  And I run the command Redcar::EditView::TitlizeTextCommand
34
- Then the contents should be "Curry Chicken"
34
+ Then the contents should be "<s>Curry Chicken<c>"
35
35
 
36
36
  Scenario: Opposite case
37
37
  When I replace the contents with "Curry Chicken"
38
38
  And I select from 0 to 13
39
39
  And I run the command Redcar::EditView::OppositeCaseTextCommand
40
- Then the contents should be "cURRY cHICKEN"
40
+ Then the contents should be "<s>cURRY cHICKEN<c>"
41
41
 
42
42
  Scenario: Camel case
43
43
  When I replace the contents with "curry_chicken"
@@ -49,15 +49,15 @@ Feature: Change Case
49
49
  When I replace the contents with "CurryChicken"
50
50
  And I move the cursor to 12
51
51
  And I run the command Redcar::EditView::UnderscoreTextCommand
52
- Then the contents should be "curry_chicken"
52
+ Then the contents should be "curry_chicke<c>n"
53
53
 
54
54
  Scenario: Pascal to Underscore to Camel Case rotation
55
55
  When I replace the contents with "CurryChicken"
56
56
  And I move the cursor to 12
57
57
  And I run the command Redcar::EditView::CamelSnakePascalRotateTextCommand
58
- Then the contents should be "curry_chicken"
58
+ Then the contents should be "curry_chicke<c>n"
59
59
  When I run the command Redcar::EditView::CamelSnakePascalRotateTextCommand
60
- Then the contents should be "curryChicken"
60
+ Then the contents should be "curryChicken<c>"
61
61
  When I run the command Redcar::EditView::CamelSnakePascalRotateTextCommand
62
62
  Then the contents should be "CurryChicken<c>"
63
-
63
+
@@ -0,0 +1,36 @@
1
+ Feature: Cursor navigation
2
+
3
+ Background:
4
+ When I open a new edit tab
5
+
6
+ Scenario: Move forward word works with multi-byte chars
7
+ When I replace the contents with "<h1>'Oáy z' wee"
8
+ And I move the cursor to 0
9
+ When I move to the next word
10
+ Then the contents should be "<h1<c>>'Oáy z' wee"
11
+ When I move to the next word
12
+ Then the contents should be "<h1>'<c>Oáy z' wee"
13
+ When I move to the next word
14
+ Then the contents should be "<h1>'Oáy<c> z' wee"
15
+ When I move to the next word
16
+ Then the contents should be "<h1>'Oáy z<c>' wee"
17
+ When I move to the next word
18
+ Then the contents should be "<h1>'Oáy z' <c>wee"
19
+ When I move to the next word
20
+ Then the contents should be "<h1>'Oáy z' wee<c>"
21
+
22
+ Scenario: Move backward word works with multi-byte chars
23
+ When I replace the contents with "<h1>'Oáy z' wee"
24
+ And I move the cursor to 15
25
+ When I move to the previous word
26
+ Then the contents should be "<h1>'Oáy z' <c>wee"
27
+ When I move to the previous word
28
+ Then the contents should be "<h1>'Oáy z<c>' wee"
29
+ When I move to the previous word
30
+ Then the contents should be "<h1>'Oáy <c>z' wee"
31
+ When I move to the previous word
32
+ Then the contents should be "<h1>'<c>Oáy z' wee"
33
+ When I move to the previous word
34
+ Then the contents should be "<h1<c>>'Oáy z' wee"
35
+ When I move to the previous word
36
+ Then the contents should be "<<c>h1>'Oáy z' wee"
@@ -17,7 +17,7 @@ end
17
17
 
18
18
  When /^I select from (\d+) to (\d+)$/ do |start_offset, end_offset|
19
19
  doc = Redcar.app.focussed_window.focussed_notebook.focussed_tab.edit_view.document
20
- doc.set_selection_range(start_offset.to_i, end_offset.to_i)
20
+ doc.set_selection_range(end_offset.to_i, start_offset.to_i)
21
21
  end
22
22
 
23
23
  When /^I copy text$/ do
@@ -108,13 +108,13 @@ Then /^the contents should be "(.*)"$/ do |text|
108
108
  doc = Redcar::EditView.focussed_edit_view_document
109
109
  actual = doc.to_s
110
110
  if expected.include?("<c>")
111
- curoff = doc.cursor_offset
112
- actual = actual.insert(curoff, "<c>")
113
- seloff = doc.selection_offset
114
- if seloff > curoff
115
- seloff += 3
111
+ char_curoff = doc.cursor_offset
112
+ actual = actual.insert(actual.char_offset_to_byte_offset(char_curoff), "<c>")
113
+ char_seloff = doc.selection_offset
114
+ if char_seloff > char_curoff
115
+ char_seloff += 3
116
116
  end
117
- actual = actual.insert(seloff, "<s>") unless curoff == seloff
117
+ actual = actual.insert(actual.char_offset_to_byte_offset(char_seloff), "<s>") unless char_curoff == char_seloff
118
118
  end
119
119
  actual.should == expected
120
120
  end
@@ -169,7 +169,7 @@ Then /^the cursor should be on line (\d+)$/ do |num|
169
169
  doc.cursor_line.should == num.to_i
170
170
  end
171
171
 
172
- When /^I replace the contents with "([^\"]*)"$/ do |contents|
172
+ When /^I replace the contents with "((?:[^\"]|\\")*)"$/ do |contents|
173
173
  contents = unescape_text(contents)
174
174
  doc = Redcar::EditView.focussed_edit_view_document
175
175
  cursor_offset = (contents =~ /<c>/)
@@ -251,3 +251,58 @@ Then /^the content? should be:$/ do |string|
251
251
  Then %{the contents should be "#{escape_text(string)}"}
252
252
  end
253
253
 
254
+
255
+ When /^I type "((?:[^"]|\\")*)"$/ do |text|
256
+ text = text.gsub("\\t", "\t").gsub("\\n", "\n").gsub("\\\"", "\"")
257
+ text.split(//).each do |letter|
258
+ edit_view = Redcar::EditView.focussed_edit_view
259
+ edit_view.type_character(letter[0])
260
+ end
261
+ end
262
+
263
+ edit_view_action_steps = {
264
+ :LINE_UP => "I move up",
265
+ :LINE_DOWN => "I move down",
266
+ :LINE_START => "I move to the start of the line",
267
+ :LINE_END => "I move to the end of the line",
268
+ :COLUMN_PREVIOUS => "I move left",
269
+ :COLUMN_NEXT => "I move right",
270
+ :PAGE_UP => "I page up",
271
+ :PAGE_DOWN => "I page down",
272
+ :WORD_PREVIOUS => "I move to the previous word",
273
+ :WORD_NEXT => "I move to the next word",
274
+ :TEXT_START => "I move to the start of the text",
275
+ :TEXT_END => "I move to the end of the text",
276
+ :WINDOW_START => "I move to the start of the window",
277
+ :WINDOW_END => "I move to the end of the window",
278
+ :SELECT_ALL => "I select all",
279
+ :SELECT_LINE_UP => "I select up",
280
+ :SELECT_LINE_DOWN => "I select down",
281
+ :SELECT_LINE_START => "I select to the start of the line",
282
+ :SELECT_LINE_END => "I select to the end of the line",
283
+ :SELECT_COLUMN_PREVIOUS => "I select left",
284
+ :SELECT_COLUMN_NEXT => "I select right",
285
+ :SELECT_PAGE_UP => "I select page up",
286
+ :SELECT_PAGE_DOWN => "I select page down",
287
+ :SELECT_WORD_PREVIOUS => "I select to the previous word",
288
+ :SELECT_WORD_NEXT => "I select to the next word",
289
+ :SELECT_TEXT_START => "I select to the start of the text",
290
+ :SELECT_TEXT_END => "I select to the end of the text",
291
+ :SELECT_WINDOW_START => "I select to the start of the window",
292
+ :SELECT_WINDOW_END => "I select to the end of the window",
293
+ :CUT => "dsafjl;fjsadfk",
294
+ :COPY => "asdfkjalsgj",
295
+ :PASTE => "asdfasdfe",
296
+ :DELETE_PREVIOUS => "I backspace",
297
+ :DELETE_NEXT => "I delete",
298
+ :DELETE_WORD_PREVIOUS => "I delete to the previous word",
299
+ :DELETE_WORD_NEXT => "I delete to the next word"
300
+ }
301
+
302
+ edit_view_action_steps.each do |action_symbol, step_text|
303
+ When step_text do
304
+ Redcar::EditView.focussed_edit_view.invoke_action(action_symbol)
305
+ end
306
+ end
307
+
308
+
@@ -1,6 +1,8 @@
1
1
 
2
2
  module NotebookSwtHelper
3
3
  def notebook_sash
4
+ Redcar.app.show_toolbar = false
5
+ Redcar.app.refresh_toolbar!
4
6
  active_shell.children.to_a.last.children.to_a[0]
5
7
  end
6
8
 
@@ -10,7 +10,7 @@ Given /^there is an edit tab containing "([^\"]*)"$/ do |contents|
10
10
  end
11
11
  end
12
12
 
13
- When /^I open a new edit tab$/ do
13
+ When /^I open a new edit tab$/ do
14
14
  Redcar::Top::NewCommand.new.run
15
15
  end
16
16
 
@@ -42,17 +42,17 @@ Then /^there should be (one|\d+) (.*) tabs?$/ do |num, tab_type|
42
42
  else
43
43
  num = num.to_i
44
44
  end
45
-
45
+
46
46
  # in the model
47
47
  tabs = Redcar.app.focussed_window.notebooks.map {|nb| nb.tabs }.flatten
48
48
  tabs.length.should == num
49
-
49
+
50
50
  # in the GUI
51
51
  case tab_type
52
52
  when "edit"
53
53
  tab_class = Redcar::EditTab
54
54
  end
55
-
55
+
56
56
  tabs = get_tabs
57
57
  tabs.length.should == num
58
58
  end
@@ -64,7 +64,7 @@ Then /^the edit tab should have the focus$/ do
64
64
  edit_tabs.first.controller.edit_view.mate_text.get_text_widget.is_focus_control?.should be_true
65
65
  end
66
66
 
67
- Then /^there should be no open tabs$/ do
67
+ Then /^there should be no open tabs$/ do
68
68
  get_tab_folder.getItems.to_a.length.should == 0
69
69
  end
70
70
 
@@ -89,4 +89,7 @@ Then /^my active tab should be "([^"]*)"$/ do |name|
89
89
  focussed_tab.title.should == name
90
90
  end
91
91
 
92
+ Then /^my active tab should have an "([^"]*)" icon$/ do |arg1|
93
+ focussed_tab.icon.should == :"#{arg1}"
94
+ end
92
95
 
@@ -1,7 +1,12 @@
1
- RequireSupportFiles File.dirname(__FILE__) + "/../../../application/features/"
2
1
 
3
2
  module SwtTabHelpers
3
+ def hide_toolbar
4
+ Redcar.app.show_toolbar = false
5
+ Redcar.app.refresh_toolbar!
6
+ end
7
+
4
8
  def get_tab_folders(shell=active_shell)
9
+ hide_toolbar
5
10
  right_composite = shell.children.to_a.last
6
11
  notebook_sash_form = right_composite.children.to_a[0]
7
12
  tab_folders = notebook_sash_form.children.to_a.select do |c|
@@ -25,7 +30,8 @@ module SwtTabHelpers
25
30
  end
26
31
 
27
32
  def focussed_tab
28
- Redcar.app.focussed_window.focussed_notebook.focussed_tab
33
+ # In case the focussed tab on the focussed window's notebook is empty, try another window
34
+ Redcar.app.focussed_window.focussed_notebook.focussed_tab or Redcar.app.windows.map {|w| w.focussed_notebook.focussed_tab}.first
29
35
  end
30
36
 
31
37
  def get_tabs
@@ -3,6 +3,7 @@ require "edit_view/actions/arrow_keys"
3
3
  require "edit_view/actions/deletion"
4
4
  require "edit_view/actions/esc"
5
5
  require "edit_view/actions/tab"
6
+ require "edit_view/actions/cmd_enter"
6
7
  require "edit_view/command"
7
8
  require "edit_view/document"
8
9
  require "edit_view/document/command"
@@ -173,6 +174,10 @@ module Redcar
173
174
  def self.esc_handlers
174
175
  [Actions::EscapeHandler]
175
176
  end
177
+
178
+ def self.cmd_enter_handlers
179
+ [Actions::CmdEnterHandler]
180
+ end
176
181
 
177
182
  def self.all_tab_handlers
178
183
  all_handlers(:tab)
@@ -197,6 +202,10 @@ module Redcar
197
202
  def self.all_backspace_handlers
198
203
  all_handlers(:backspace)
199
204
  end
205
+
206
+ def self.all_cmd_enter_handlers
207
+ all_handlers(:cmd_enter)
208
+ end
200
209
 
201
210
  def handle_key(handlers, modifiers)
202
211
  sorted_handlers = handlers.sort_by {|h| (h.respond_to?(:priority) and h.priority) || 0 }.reverse
@@ -233,6 +242,10 @@ module Redcar
233
242
  def backspace_pressed(modifiers)
234
243
  handle_key(EditView.all_backspace_handlers, modifiers)
235
244
  end
245
+
246
+ def cmd_enter_pressed(modifiers)
247
+ handle_key(EditView.all_cmd_enter_handlers, modifiers)
248
+ end
236
249
 
237
250
  # Called by the GUI whenever an EditView is focussed or
238
251
  # loses focus. Sends :focussed_edit_view event.
@@ -384,7 +397,9 @@ module Redcar
384
397
  :reset_undo,
385
398
  :cursor_offset, :cursor_offset=,
386
399
  :scroll_to_line, :compound,
387
- :begin_compound, :end_compound
400
+ :begin_compound, :end_compound,
401
+ :annotations, :remove_annotation,
402
+ :remove_all_annotations
388
403
 
389
404
  def grammar
390
405
  @grammar