redcar 0.3.5 → 0.3.6

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.
Files changed (102) hide show
  1. data/CHANGES +28 -0
  2. data/README.md +7 -0
  3. data/ROADMAP.md +11 -1
  4. data/Rakefile +61 -2
  5. data/bin/redcar +2 -1
  6. data/lib/redcar.rb +4 -3
  7. data/lib/redcar/installer.rb +3 -1
  8. data/lib/redcar/runner.rb +1 -1
  9. data/lib/redcar/usage.rb +4 -7
  10. data/lib/redcar_quick_start.rb +39 -5
  11. data/plugins/application/features/step_definitions/tree_steps.rb +6 -0
  12. data/plugins/application/features/support/env.rb +2 -6
  13. data/plugins/application/icons/redcar_icon_beta_dev.png +0 -0
  14. data/plugins/application/lib/application/command/executor.rb +8 -0
  15. data/plugins/application/lib/application/dialog.rb +25 -2
  16. data/plugins/application/lib/application/notebook.rb +4 -0
  17. data/plugins/application/lib/application/window.rb +4 -0
  18. data/plugins/application_swt/lib/application_swt.rb +2 -0
  19. data/plugins/application_swt/lib/application_swt/dialog_adapter.rb +28 -1
  20. data/plugins/application_swt/lib/application_swt/menu.rb +4 -0
  21. data/plugins/application_swt/lib/application_swt/menu/binding_translator.rb +4 -0
  22. data/plugins/application_swt/lib/application_swt/notebook.rb +22 -1
  23. data/plugins/application_swt/lib/application_swt/notebook/tab_drag_and_drop_listener.rb +124 -0
  24. data/plugins/application_swt/lib/application_swt/notebook/tab_transfer.rb +83 -0
  25. data/plugins/application_swt/lib/application_swt/swt_wrapper.rb +14 -0
  26. data/plugins/application_swt/lib/application_swt/tab.rb +28 -6
  27. data/plugins/application_swt/lib/application_swt/window.rb +88 -43
  28. data/plugins/application_swt/spec/application_swt/menu/binding_translator_spec.rb +11 -0
  29. data/plugins/application_swt/spec/spec_helper.rb +1 -1
  30. data/plugins/auto_completer/lib/auto_completer.rb +3 -20
  31. data/plugins/auto_pairer/lib/auto_pairer/document_controller.rb +1 -1
  32. data/plugins/declarations/lib/declarations/parser.rb +2 -2
  33. data/plugins/declarations/spec/spec_helper.rb +1 -0
  34. data/plugins/edit_view/features/step_definitions/notebook_steps.rb +3 -3
  35. data/plugins/edit_view/features/step_definitions/window_steps.rb +24 -9
  36. data/plugins/edit_view/features/support/env.rb +11 -9
  37. data/plugins/edit_view/lib/edit_view.rb +106 -6
  38. data/plugins/edit_view/lib/edit_view/info_speedbar.rb +32 -3
  39. data/plugins/edit_view/lib/edit_view/select_font_dialog.rb +39 -0
  40. data/plugins/edit_view/lib/edit_view/select_theme_dialog.rb +34 -0
  41. data/plugins/edit_view/lib/edit_view/tab_settings.rb +103 -8
  42. data/plugins/edit_view_swt/lib/edit_view_swt.rb +40 -3
  43. data/plugins/edit_view_swt/lib/edit_view_swt/edit_tab.rb +1 -1
  44. data/plugins/execute_current_tab/lib/execute_current_tab.rb +15 -6
  45. data/plugins/project/features/open_directory_tree.feature +10 -0
  46. data/plugins/project/lib/project.rb +10 -8
  47. data/plugins/project/lib/project/dir_mirror.rb +6 -5
  48. data/plugins/project/lib/project/drb_service.rb +16 -0
  49. data/plugins/project/lib/project/manager.rb +31 -5
  50. data/plugins/redcar/redcar.rb +115 -19
  51. data/plugins/tree_view_swt/lib/tree_view_swt.rb +15 -0
  52. data/textmate/Bundles/Cucumber.tmbundle/Preferences/Cucumber_Plain_Text_Feature_Completions.tmPreferences +3 -3
  53. data/textmate/Bundles/Cucumber.tmbundle/Preferences/Symbol_list___Scenario.tmPreferences +1 -1
  54. data/textmate/Bundles/Cucumber.tmbundle/Syntaxes/Cucumber_Plain_Text_Feature.tmLanguage +18 -76
  55. data/textmate/Bundles/Cucumber.tmbundle/Syntaxes/Cucumber_Steps.tmLanguage +1 -1
  56. data/textmate/Bundles/Palm-WebOS-Development.tmbundle/Snippets/Animation_animateStyle.tmSnippet +23 -0
  57. data/textmate/Bundles/Palm-WebOS-Development.tmbundle/Snippets/Event_listen.tmSnippet +16 -0
  58. data/textmate/Bundles/{Cucumber.tmbundle/Snippets/When_Step_Plaintext.tmSnippet → Palm-WebOS-Development.tmbundle/Snippets/Event_stop.tmSnippet} +5 -5
  59. data/textmate/Bundles/{Cucumber.tmbundle/Snippets/Then_Step.tmSnippet → Palm-WebOS-Development.tmbundle/Snippets/Event_stopListening.tmSnippet} +5 -9
  60. data/textmate/Bundles/{Cucumber.tmbundle/Snippets/Cucumber_Multiline_Steps.tmSnippet → Palm-WebOS-Development.tmbundle/Snippets/List_Model.tmSnippet} +10 -7
  61. data/textmate/Bundles/Palm-WebOS-Development.tmbundle/Snippets/Log_addLoggingMethodsToPrototype.tmSnippet +16 -0
  62. data/textmate/Bundles/{Cucumber.tmbundle/Snippets/Then_Step_Plaintext.tmSnippet → Palm-WebOS-Development.tmbundle/Snippets/Log_info.tmSnippet} +5 -5
  63. data/textmate/Bundles/{Cucumber.tmbundle/Snippets/Scenario___heading_only__.tmSnippet → Palm-WebOS-Development.tmbundle/Snippets/Log_logProperties.tmSnippet} +5 -7
  64. data/textmate/Bundles/{Cucumber.tmbundle/Snippets/When_Step.tmSnippet → Palm-WebOS-Development.tmbundle/Snippets/Model.tmSnippet} +7 -9
  65. data/textmate/Bundles/Palm-WebOS-Development.tmbundle/Snippets/__L____.tmSnippet +16 -0
  66. data/textmate/Bundles/Palm-WebOS-Development.tmbundle/Snippets/_insert____.tmSnippet +16 -0
  67. data/textmate/Bundles/Palm-WebOS-Development.tmbundle/Snippets/_update____.tmSnippet +16 -0
  68. data/textmate/Bundles/Palm-WebOS-Development.tmbundle/Snippets/controller_get.tmSnippet +16 -0
  69. data/textmate/Bundles/Palm-WebOS-Development.tmbundle/Snippets/controller_pushScene.tmSnippet +16 -0
  70. data/textmate/Bundles/Palm-WebOS-Development.tmbundle/Snippets/controller_serviceRequest.tmSnippet +21 -0
  71. data/textmate/Bundles/{Cucumber.tmbundle/Snippets/Scenario_Outline.tmSnippet → Palm-WebOS-Development.tmbundle/Snippets/controller_setupWidget.tmSnippet} +5 -9
  72. data/textmate/Bundles/{Cucumber.tmbundle/Snippets/Given_Step.tmSnippet → Palm-WebOS-Development.tmbundle/Snippets/controller_showBanner.tmSnippet} +5 -9
  73. data/textmate/Bundles/Palm-WebOS-Development.tmbundle/Syntaxes/Mojo.tmLanguage +713 -0
  74. data/textmate/Bundles/Palm-WebOS-Development.tmbundle/info.plist +188 -0
  75. data/textmate/Bundles/Smalltalk.tmbundle/Preferences/GNU_Smalltalk.tmPreferences +32 -0
  76. data/textmate/Bundles/{asciidoc.tmbundle/Preferences/Symbol_List___Heading.tmPreferences → Smalltalk.tmbundle/Preferences/GNU___Symbol_List___Method.tmPreferences} +7 -6
  77. data/textmate/Bundles/{Cucumber.tmbundle/Preferences/next_Symbol_list___Scenario.tmPreferences → Smalltalk.tmbundle/Preferences/GNU___Symbol_List___Section.tmPreferences} +7 -4
  78. data/textmate/Bundles/{asciidoc.tmbundle/Snippets/Bold.tmSnippet → Smalltalk.tmbundle/Preferences/MIST_Smalltalk_Format.tmPreferences} +8 -7
  79. data/textmate/Bundles/Smalltalk.tmbundle/Syntaxes/GNU_Smalltalk.tmLanguage +493 -0
  80. data/textmate/Bundles/Smalltalk.tmbundle/Syntaxes/GNU_Smalltalk_2.tmLanguage +807 -0
  81. data/textmate/Bundles/Smalltalk.tmbundle/Syntaxes/MIST_Smalltalk_Format.tmLanguage +645 -0
  82. data/textmate/Bundles/Smalltalk.tmbundle/info.plist +21 -0
  83. data/textmate/Themes/Twilight.tmTheme +4 -0
  84. metadata +2604 -2586
  85. data/textmate/Bundles/Cucumber.tmbundle/Preferences/next_Cucumber_Plain_Text_Feature_Completions.tmPreferences +0 -30
  86. data/textmate/Bundles/Cucumber.tmbundle/Syntaxes/next_Cucumber_Plain_Text_Feature.tmLanguage +0 -221
  87. data/textmate/Bundles/Cucumber.tmbundle/Syntaxes/next_Cucumber_Steps.tmLanguage +0 -424
  88. data/textmate/Bundles/asciidoc.tmbundle/Preferences/Typing_Pairs___Defaults.tmPreferences +0 -54
  89. data/textmate/Bundles/asciidoc.tmbundle/Snippets/Anchor.tmSnippet +0 -16
  90. data/textmate/Bundles/asciidoc.tmbundle/Snippets/Comment_Block.tmSnippet +0 -19
  91. data/textmate/Bundles/asciidoc.tmbundle/Snippets/Example_Block.tmSnippet +0 -19
  92. data/textmate/Bundles/asciidoc.tmbundle/Snippets/Italic.tmSnippet +0 -16
  93. data/textmate/Bundles/asciidoc.tmbundle/Snippets/Listing_Block.tmSnippet +0 -20
  94. data/textmate/Bundles/asciidoc.tmbundle/Snippets/Literal_Block.tmSnippet +0 -19
  95. data/textmate/Bundles/asciidoc.tmbundle/Snippets/Passthrough_Block.tmSnippet +0 -19
  96. data/textmate/Bundles/asciidoc.tmbundle/Snippets/Quote_Block.tmSnippet +0 -19
  97. data/textmate/Bundles/asciidoc.tmbundle/Snippets/Quoted.tmSnippet +0 -16
  98. data/textmate/Bundles/asciidoc.tmbundle/Snippets/Sidebar_Block.tmSnippet +0 -19
  99. data/textmate/Bundles/asciidoc.tmbundle/Snippets/Subscript.tmSnippet +0 -16
  100. data/textmate/Bundles/asciidoc.tmbundle/Snippets/Superscript.tmSnippet +0 -16
  101. data/textmate/Bundles/asciidoc.tmbundle/Syntaxes/AsciiDoc.tmLanguage +0 -428
  102. data/textmate/Bundles/asciidoc.tmbundle/info.plist +0 -91
@@ -0,0 +1,34 @@
1
+ module Redcar
2
+ class EditView
3
+ class SelectThemeDialog < FilterListDialog
4
+
5
+ def initialize
6
+ super()
7
+ @matches = EditView.themes.sort
8
+ end
9
+
10
+ def close
11
+ super
12
+ end
13
+
14
+ def update_list(filter)
15
+ @last_list = @matches
16
+ filtered_list = @last_list
17
+ if filter.length >= 1
18
+ filtered_list = filter_and_rank_by(filtered_list, filter, filtered_list.length) do |match|
19
+ match
20
+ end
21
+ end
22
+ filtered_list
23
+ end
24
+
25
+ def selected(text, ix, closing=false)
26
+ if @last_list
27
+ close
28
+ Redcar::EditView.theme = text
29
+ end
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -3,18 +3,39 @@ module Redcar
3
3
  class TabSettings
4
4
  DEFAULT_SOFTNESS = true
5
5
  DEFAULT_TAB_WIDTH = 2
6
+ DEFAULT_WORD_WRAP = false
7
+ DEFAULT_SETTING_NAME = "Default"
6
8
  TAB_WIDTHS = %w(2 3 4 5 6 8)
7
-
8
- attr_reader :tab_widths, :softnesses, :show_invisibles
9
-
9
+ DEFAULT_MARGIN_COLUMN = 80
10
+ DEFAULT_MARGIN_PRESENT = false
11
+
12
+ attr_reader :tab_widths, :softnesses, :word_wraps, :margin_columns
13
+ attr_reader :show_margins
14
+ attr_reader :show_invisibles, :show_line_numbers, :show_annotations
15
+
10
16
  def initialize
11
- @tab_widths = EditView.storage['tab_widths'] || {}
12
- @softnesses = EditView.storage['softnesses'] || {}
13
- @show_invisibles = !!EditView.storage['show_invisibles']
17
+ @tab_widths =
18
+ {DEFAULT_SETTING_NAME => DEFAULT_TAB_WIDTH}.merge(
19
+ EditView.storage['tab_widths'] || {})
20
+ @softnesses =
21
+ {DEFAULT_SETTING_NAME => DEFAULT_SOFTNESS}.merge(
22
+ EditView.storage['softnesses'] || {})
23
+ @word_wraps =
24
+ {DEFAULT_SETTING_NAME => DEFAULT_WORD_WRAP}.merge(
25
+ EditView.storage['word_wraps'] || {})
26
+ @margin_columns =
27
+ {DEFAULT_SETTING_NAME => DEFAULT_MARGIN_COLUMN}.merge(
28
+ EditView.storage['margin_columns'] || {})
29
+ @show_margins =
30
+ {DEFAULT_SETTING_NAME => DEFAULT_MARGIN_PRESENT}.merge(
31
+ EditView.storage['show_margins'] || {})
32
+ @show_invisibles = !!EditView.storage['show_invisibles']
33
+ @show_line_numbers = !!EditView.storage['show_line_numbers']
34
+ @show_annotations = !!EditView.storage['show_annotations']
14
35
  end
15
36
 
16
37
  def width_for(grammar_name)
17
- tab_widths[grammar_name] || DEFAULT_TAB_WIDTH
38
+ tab_widths[grammar_name] || tab_widths[DEFAULT_SETTING_NAME]
18
39
  end
19
40
 
20
41
  def set_width_for(grammar_name, width)
@@ -26,7 +47,11 @@ module Redcar
26
47
  end
27
48
 
28
49
  def softness_for(grammar_name)
29
- softnesses[grammar_name] == nil ? DEFAULT_SOFTNESS : softnesses[grammar_name]
50
+ if softnesses[grammar_name] == nil
51
+ softnesses[DEFAULT_SETTING_NAME]
52
+ else
53
+ softnesses[grammar_name]
54
+ end
30
55
  end
31
56
 
32
57
  def set_softness_for(grammar_name, boolean)
@@ -37,6 +62,49 @@ module Redcar
37
62
  end
38
63
  end
39
64
 
65
+ def word_wrap_for(grammar_name)
66
+ if word_wraps[grammar_name] == nil
67
+ word_wraps[DEFAULT_SETTING_NAME]
68
+ else
69
+ word_wraps[grammar_name]
70
+ end
71
+ end
72
+
73
+ def set_word_wrap_for(grammar_name, boolean)
74
+ boolean = !!boolean
75
+ if word_wraps[grammar_name] != boolean
76
+ word_wraps[grammar_name] = boolean
77
+ EditView.storage['word_wraps'] = word_wraps
78
+ end
79
+ end
80
+
81
+ def margin_column_for(grammar_name)
82
+ margin_columns[grammar_name] || margin_columns[DEFAULT_SETTING_NAME]
83
+ end
84
+
85
+ def set_margin_column_for(grammar_name, column)
86
+ if margin_columns[grammar_name] != column
87
+ margin_columns[grammar_name] = column
88
+ EditView.storage['margin_columns'] = margin_columns
89
+ end
90
+ end
91
+
92
+ def show_margin_for(grammar_name)
93
+ if show_margins[grammar_name] == nil
94
+ show_margins[DEFAULT_SETTING_NAME]
95
+ else
96
+ show_margins[grammar_name]
97
+ end
98
+ end
99
+
100
+ def set_show_margin_for(grammar_name, boolean)
101
+ boolean = !!boolean
102
+ if show_margins[grammar_name] != boolean
103
+ show_margins[grammar_name] = boolean
104
+ EditView.storage['show_margins'] = show_margins
105
+ end
106
+ end
107
+
40
108
  def show_invisibles?
41
109
  show_invisibles
42
110
  end
@@ -45,6 +113,33 @@ module Redcar
45
113
  @show_invisibles = bool
46
114
  EditView.storage['show_invisibles'] = bool
47
115
  end
116
+
117
+ def show_line_numbers?
118
+ show_line_numbers
119
+ end
120
+
121
+ def set_show_line_numbers(bool)
122
+ @show_line_numbers = bool
123
+ EditView.storage['show_line_numbers'] = bool
124
+ end
125
+
126
+ def show_annotations?
127
+ show_annotations
128
+ end
129
+
130
+ def set_show_annotations(bool)
131
+ @show_annotations = bool
132
+ EditView.storage['show_annotations'] = bool
133
+ end
134
+
135
+ def show_margin?
136
+ show_margin
137
+ end
138
+
139
+ def set_show_margin(bool)
140
+ @show_margin = bool
141
+ EditView.storage['show_margin'] = bool
142
+ end
48
143
  end
49
144
  end
50
145
  end
@@ -20,8 +20,18 @@ module Redcar
20
20
  end
21
21
 
22
22
  def self.load_textmate_assets
23
- JavaMateView::Bundle.load_bundles(Redcar.root + "/textmate/")
24
- JavaMateView::ThemeManager.load_themes(Redcar.root + "/textmate/")
23
+ load_textmate_assets_from_dir(Redcar.root + "/textmate/")
24
+ Redcar.plugin_manager.loaded_plugins.each do |plugin|
25
+ load_textmate_assets_from_dir(File.dirname(plugin.definition_file) + "/")
26
+ end
27
+ load_textmate_assets_from_dir(Redcar.user_dir + "/")
28
+
29
+ EditView.themes.unshift(*JavaMateView::ThemeManager.themes.to_a.map {|th| th.name })
30
+ end
31
+
32
+ def self.load_textmate_assets_from_dir(dir)
33
+ JavaMateView::Bundle.load_bundles(dir)
34
+ JavaMateView::ThemeManager.load_themes(dir)
25
35
  end
26
36
 
27
37
  attr_reader :mate_text, :widget, :model
@@ -108,12 +118,39 @@ module Redcar
108
118
  h5 = @model.add_listener(:invisibles_changed) do |new_bool|
109
119
  @mate_text.showInvisibles(new_bool)
110
120
  end
121
+ h6 = @model.add_listener(:word_wrap_changed) do |new_bool|
122
+ @mate_text.set_word_wrap(new_bool)
123
+ end
124
+ h7 = @model.add_listener(:font_changed) do
125
+ @mate_text.set_font(EditView.font, EditView.font_size)
126
+ end
127
+ h8 = @model.add_listener(:theme_changed) do
128
+ @mate_text.set_theme_by_name(EditView.theme)
129
+ end
130
+ h9 = @model.add_listener(:line_number_visibility_changed) do |new_bool|
131
+ @mate_text.set_line_numbers_visible(new_bool)
132
+ end
133
+ h10 = @model.add_listener(:annotations_visibility_changed) do |new_bool|
134
+ @mate_text.set_annotations_visible(new_bool)
135
+ end
136
+ h11 = @model.add_listener(:margin_column_changed) do |new_column|
137
+ @mate_text.set_margin_column(new_column)
138
+ end
139
+ h12 = @model.add_listener(:show_margin_changed) do |new_bool|
140
+ if new_bool
141
+ @mate_text.set_margin_column(@model.margin_column)
142
+ else
143
+ @mate_text.set_margin_column(-1)
144
+ end
145
+ end
111
146
  @mate_text.getTextWidget.addFocusListener(FocusListener.new(self))
112
147
  @mate_text.getTextWidget.addVerifyListener(VerifyListener.new(@model.document, self))
113
148
  @mate_text.getTextWidget.addModifyListener(ModifyListener.new(@model.document, self))
114
149
  @mate_text.get_control.add_verify_key_listener(VerifyKeyListener.new(self))
115
150
  @mate_text.get_control.add_key_listener(KeyListener.new(self))
116
- @handlers << [@model.document, h1] << [@model, h2] << [@model, h3] << [@model, h4] << [@model, h5]
151
+ @handlers << [@model.document, h1] << [@model, h2] << [@model, h3] << [@model, h4] <<
152
+ [@model, h5] << [@model, h6] << [@model, h7] << [@model, h8] <<
153
+ [@model, h9] << [@model, h10] << [@model, h11]
117
154
  end
118
155
 
119
156
  class VerifyKeyListener
@@ -5,7 +5,7 @@ module Redcar
5
5
 
6
6
  attr_reader :item, :edit_view
7
7
 
8
- def initialize(model, notebook)
8
+ def initialize(*args)
9
9
  super
10
10
  @model.add_listener(:changed_title) { |title| @item.text = title }
11
11
  end
@@ -21,6 +21,8 @@ module Redcar
21
21
 
22
22
  class Execute < EditTabCommand
23
23
 
24
+ TITLE = "Output"
25
+
24
26
  def execute
25
27
  path = doc.path
26
28
  if path
@@ -32,14 +34,21 @@ module Redcar
32
34
  FileUtils.rm(path)
33
35
  end
34
36
  end
37
+
38
+ def output_tab
39
+ tabs = win.notebooks.map {|nb| nb.tabs }.flatten
40
+ tabs.detect {|t| t.title == TITLE} || Top::NewCommand.new.run
41
+ end
35
42
 
36
43
  def execute_file(path)
37
- command = "ruby \"#{path}\" 2>&1"
38
- output = `#{command}`
39
- new_tab = Top::NewCommand.new.run
40
- title = "Output from #{command}"
41
- new_tab.document.text = title + "\n" + "="*title.length + "\n\n" + output
42
- new_tab.title = 'Output'
44
+ command = "ruby \"#{path}\""
45
+ output = `#{command} 2>&1`
46
+ tab = output_tab
47
+ title = "[#{DateTime.now}]$ #{command}"
48
+ tab.document.text = "#{tab.document.to_s}" +
49
+ "#{"="*title.length}\n#{title}\n#{"="*title.length}\n\n#{output}"
50
+ tab.title = TITLE
51
+ tab.focus
43
52
  end
44
53
  end
45
54
 
@@ -23,3 +23,13 @@ Feature: Open directory tree
23
23
  Then the window should have title "myproject"
24
24
  When I close the directory
25
25
  Then the window should have title "Redcar"
26
+
27
+ Scenario: Directory keeps the same width if maximized
28
+ Given I will choose "plugins/project/spec/fixtures/myproject" from the "open_directory" dialog
29
+ When I open a directory
30
+ Then the directory tree width should be the default
31
+ When I maximize the window size
32
+ Then the directory tree width should be the default
33
+ When I restore the window size
34
+ Then the directory tree width should be the default
35
+
@@ -21,17 +21,19 @@ module Redcar
21
21
  attr_reader :window, :tree, :path
22
22
 
23
23
  def initialize(path)
24
- path = File.expand_path(path)
25
- if !File.directory?(path)
26
- raise 'Not a directory: ' + path
24
+ @path = File.expand_path(path)
25
+ dir_mirror = Project::DirMirror.new(path)
26
+ if dir_mirror.exists?
27
+ @tree = Tree.new(dir_mirror, Project::DirController.new)
28
+ @window = nil
29
+ file_list_resource.compute
27
30
  end
28
- @path = path
29
- @tree = Tree.new(Project::DirMirror.new(path),
30
- Project::DirController.new)
31
- @window = nil
32
- file_list_resource.compute
33
31
  end
34
32
 
33
+ def ready?
34
+ @tree && @path
35
+ end
36
+
35
37
  def inspect
36
38
  "<Project #{path}>"
37
39
  end
@@ -13,7 +13,7 @@ module Redcar
13
13
 
14
14
  # Does the directory exist?
15
15
  def exists?
16
- File.exist?(@path)
16
+ File.exist?(@path) && File.directory?(@path)
17
17
  end
18
18
 
19
19
  # Have the toplevel nodes changed?
@@ -32,6 +32,11 @@ module Redcar
32
32
  end
33
33
 
34
34
  class Node
35
+
36
+ include Redcar::Tree::Mirror::NodeMirror
37
+
38
+ attr_reader :path
39
+
35
40
  def self.create_all_from_path(path)
36
41
  Dir[path + "/*"].sort_by do |fn|
37
42
  File.basename(fn).downcase
@@ -48,10 +53,6 @@ module Redcar
48
53
  @cache ||= {}
49
54
  end
50
55
 
51
- include Redcar::Tree::Mirror::NodeMirror
52
-
53
- attr_reader :path
54
-
55
56
  def initialize(path)
56
57
  @path = path
57
58
  end
@@ -10,6 +10,22 @@ module Redcar
10
10
  end
11
11
  end
12
12
 
13
+ def open_item_untitled(path)
14
+ begin
15
+ puts 'drb opening untitled ' + full_path if $VERBOSE
16
+ if File.file?(path)
17
+ Redcar::ApplicationSWT.sync_exec do
18
+ Project::Manager.open_untitled_path(path)
19
+ Redcar.app.focussed_window.controller.bring_to_front
20
+ end
21
+ end
22
+ 'ok'
23
+ rescue Exception => e
24
+ puts 'drb got exception:' + e.class + " " + e.message, e.backtrace
25
+ raise e
26
+ end
27
+ end
28
+
13
29
  def open_item_drb(full_path)
14
30
  begin
15
31
  puts 'drb opening ' + full_path if $VERBOSE
@@ -111,15 +111,23 @@ module Redcar
111
111
  window.focus
112
112
  end
113
113
 
114
+ def self.open_tab_with_content(text)
115
+ win = Redcar.app.focussed_window || Redcar.app.new_window
116
+ tab = win.new_tab(Redcar::EditTab)
117
+ tab.edit_view.document.text = text
118
+ tab.edit_view.reset_undo
119
+ tab.focus
120
+ end
121
+
114
122
  # Opens a new Tree with a DirMirror and DirController for the given
115
123
  # path, in a new window.
116
124
  #
117
125
  # @param [String] path the path of the directory to view
118
126
  def self.open_project_for_path(path)
119
127
  win = Redcar.app.new_window
120
- project = Project.new(path)
121
- project.open(win)
122
- project
128
+ project = Project.new(path).tap do |p|
129
+ p.open(win) if p.ready?
130
+ end
123
131
  end
124
132
 
125
133
  # The currently focussed Project, or nil if none.
@@ -154,9 +162,28 @@ module Redcar
154
162
  open_file(arg)
155
163
  end
156
164
  end
165
+ args.each do |arg|
166
+ if arg =~ /--untitled-file=(.*)/
167
+ path = $1
168
+ found_path_args = true
169
+ open_untitled_path(path)
170
+ end
171
+ end
157
172
  found_path_args
158
173
  end
159
174
 
175
+ def self.open_untitled_path(path)
176
+ begin
177
+ if File.file?(path) and contents = File.read(path)
178
+ open_tab_with_content(contents)
179
+ end
180
+ rescue => e
181
+ puts "Error opening untitled file #{path}"
182
+ puts e.class.to_s + ":" + e.message
183
+ puts e.backtrace
184
+ end
185
+ end
186
+
160
187
  # Attaches a new listener to tab focus change events, so we can
161
188
  # keep the current_files list.
162
189
  def self.init_current_files_hooks
@@ -185,7 +212,6 @@ module Redcar
185
212
  if path = storage['last_open_dir']
186
213
  s = Time.now
187
214
  open_project_for_path(path)
188
- puts "open project took #{Time.now - s}s"
189
215
  end
190
216
 
191
217
  if files = storage['files_open_last_session']
@@ -207,4 +233,4 @@ module Redcar
207
233
  end
208
234
  end
209
235
  end
210
- end
236
+ end