redcar 0.7 → 0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +42 -0
- data/README.md +5 -3
- data/Rakefile +39 -81
- data/bin/redcar +1 -1
- data/lib/redcar.rb +9 -6
- data/lib/redcar/installer.rb +1 -1
- data/lib/redcar/ruby_extensions.rb +19 -0
- data/lib/redcar/runner.rb +1 -1
- data/lib/redcar/usage.rb +3 -0
- data/lib/redcar_quick_start.rb +11 -11
- data/plugins/application/features/step_definitions/tree_steps.rb +22 -5
- data/plugins/application/features/step_definitions/window_steps.rb +9 -1
- data/plugins/application/features/support/env.rb +5 -2
- data/plugins/application/lib/application.rb +51 -46
- data/plugins/application/lib/application/window.rb +60 -30
- data/plugins/application_swt/lib/application_swt.rb +16 -16
- data/plugins/application_swt/lib/application_swt/window.rb +35 -7
- data/plugins/auto_completer/features/support/env.rb +0 -2
- data/plugins/auto_indenter/features/support/env.rb +0 -1
- data/plugins/auto_pairer/features/auto_pairer.feature +50 -45
- data/plugins/auto_pairer/features/support/env.rb +0 -1
- data/plugins/auto_pairer/lib/auto_pairer/document_controller.rb +11 -6
- data/plugins/clipboard-viewer/Screenshot.png +0 -0
- data/plugins/clipboard-viewer/lib/clipboard_viewer.rb +50 -0
- data/plugins/clipboard-viewer/lib/clipboard_viewer/browser_controller.rb +27 -0
- data/plugins/clipboard-viewer/lib/clipboard_viewer/clipboard_bar.rb +67 -0
- data/plugins/clipboard-viewer/plugin.rb +9 -0
- data/plugins/clipboard-viewer/views/clipboard.html.erb +15 -0
- data/plugins/clipboard-viewer/views/default.css +43 -0
- data/plugins/clipboard-viewer/views/redcar_small_icon.png +0 -0
- data/plugins/comment/features/line_comment.feature +137 -0
- data/plugins/comment/features/selection_comment.feature +21 -0
- data/plugins/comment/features/step_definitions/comment_steps.rb +7 -0
- data/plugins/comment/lib/comment.rb +266 -0
- data/plugins/comment/plugin.rb +7 -0
- data/plugins/comment/vendor/comment_lib.json +47 -0
- data/plugins/declarations/lib/declarations.rb +1 -1
- data/plugins/document_search/features/replace.feature +10 -2
- data/plugins/document_search/features/support/env.rb +0 -1
- data/plugins/document_search/lib/document_search.rb +4 -1
- data/plugins/document_search/lib/document_search/replace.rb +11 -3
- data/plugins/document_search/lib/document_search/search_and_replace.rb +5 -2
- data/plugins/edit_view/features/case_change.feature +9 -9
- data/plugins/edit_view/features/cursor_navigation.feature +36 -0
- data/plugins/edit_view/features/step_definitions/editing_steps.rb +63 -8
- data/plugins/edit_view/features/step_definitions/notebook_steps.rb +2 -0
- data/plugins/edit_view/features/step_definitions/tab_steps.rb +8 -5
- data/plugins/edit_view/features/support/env.rb +8 -2
- data/plugins/edit_view/lib/edit_view.rb +16 -1
- data/plugins/edit_view/lib/edit_view/actions/cmd_enter.rb +11 -0
- data/plugins/edit_view/lib/edit_view/document.rb +27 -10
- data/plugins/edit_view/lib/edit_view/edit_tab.rb +17 -4
- data/plugins/edit_view/spec/edit_view/document_spec.rb +3 -0
- data/plugins/edit_view_swt/lib/edit_view_swt.rb +42 -3
- data/plugins/edit_view_swt/lib/edit_view_swt/word_movement.rb +17 -15
- data/plugins/help/lib/help.rb +40 -0
- data/plugins/help/plugin.rb +8 -0
- data/plugins/html_view/features/step_definitions/html_view_steps.rb +6 -4
- data/plugins/line_tools/features/support/env.rb +0 -1
- data/plugins/macros/features/step_definitions/macro_steps.rb +0 -55
- data/plugins/macros/features/support/env.rb +0 -2
- data/plugins/open_default_app/lib/open_default_app.rb +35 -0
- data/plugins/open_default_app/plugin.rb +8 -0
- data/plugins/open_default_app/screenshot.png +0 -0
- data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +17 -3
- data/plugins/project/features/find_file.feature +3 -2
- data/plugins/project/features/highlight_focussed_tab.feature +8 -0
- data/plugins/project/features/move_and_rename_files.feature +25 -0
- data/plugins/project/features/open_and_save_files.feature +10 -1
- data/plugins/project/features/open_directory_tree.feature +32 -2
- data/plugins/project/features/step_definitions/directory_steps.rb +17 -0
- data/plugins/project/features/step_definitions/project_tree_steps.rb +3 -0
- data/plugins/project/features/sub_project.feature +14 -0
- data/plugins/project/features/support/env.rb +22 -3
- data/plugins/project/features/watch_for_modified_files.feature +32 -9
- data/plugins/project/lib/project.rb +53 -21
- data/plugins/project/lib/project/adapters/local.rb +21 -16
- data/plugins/project/lib/project/adapters/remote.rb +15 -13
- data/plugins/project/lib/project/commands.rb +37 -16
- data/plugins/project/lib/project/dir_controller.rb +41 -42
- data/plugins/project/lib/project/drb_service.rb +35 -21
- data/plugins/project/lib/project/file_list.rb +7 -1
- data/plugins/project/lib/project/manager.rb +28 -3
- data/plugins/project/lib/project/sub_project.rb +17 -0
- data/plugins/project/lib/project/support/recycle.js +2 -0
- data/plugins/project/lib/project/support/trash.rb +72 -0
- 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
- 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
- data/plugins/project/spec/project/file_list_spec.rb +4 -0
- data/plugins/redcar/features/goto_line_command.feature +20 -0
- data/plugins/redcar/redcar.rb +107 -47
- data/plugins/repl/lib/repl.rb +20 -20
- data/plugins/repl/lib/repl/clojure_mirror.rb +50 -58
- data/plugins/repl/lib/repl/groovy_mirror.rb +22 -41
- data/plugins/repl/lib/repl/repl_mirror.rb +85 -14
- data/plugins/repl/lib/repl/ruby_mirror.rb +12 -39
- data/plugins/repl/spec/repl/groovy_mirror_spec.rb +1 -1
- data/plugins/repl/spec/repl/ruby_mirror_spec.rb +12 -12
- data/plugins/ruby/README +6 -0
- data/plugins/ruby/lib/syntax_check/ruby.rb +28 -0
- data/plugins/ruby/plugin.rb +7 -0
- data/plugins/runnables/features/command_tree.feature +9 -0
- data/plugins/runnables/features/file_runner_input.feature +20 -0
- data/plugins/runnables/features/run_alternate_command.feature +14 -0
- data/plugins/runnables/features/support/env.rb +42 -5
- data/plugins/runnables/lib/runnables.rb +67 -21
- data/plugins/runnables/lib/runnables/commands.rb +35 -18
- data/plugins/runnables/lib/runnables/tree_mirror/nodes/runnable_group.rb +23 -37
- data/plugins/runnables/lib/runnables/tree_mirror/nodes/runnable_type_group.rb +16 -18
- data/plugins/scm_svn/features/support/env.rb +0 -3
- data/plugins/snippets/features/snippets.feature +17 -2
- data/plugins/snippets/features/support/env.rb +0 -1
- data/plugins/snippets/lib/snippets/tab_handler.rb +51 -18
- data/plugins/swt/lib/swt/cucumber_patches.rb +13 -68
- data/plugins/swt/lib/swt/cucumber_runner.rb +2 -3
- data/plugins/syntax_check/README +6 -0
- data/plugins/syntax_check/lib/syntax_check.rb +16 -0
- data/plugins/syntax_check/lib/syntax_check/checker.rb +47 -0
- data/plugins/syntax_check/lib/syntax_check/error.rb +23 -0
- data/plugins/syntax_check/plugin.rb +7 -0
- data/plugins/tree_view_swt/lib/tree_view_swt.rb +6 -0
- data/plugins/web_bookmarks/Screenshot.png +0 -0
- data/plugins/web_bookmarks/lib/web_bookmarks.rb +42 -0
- data/plugins/web_bookmarks/lib/web_bookmarks/bookmark.rb +43 -0
- data/plugins/web_bookmarks/lib/web_bookmarks/browser_bar.rb +70 -0
- data/plugins/web_bookmarks/lib/web_bookmarks/commands.rb +111 -0
- data/plugins/web_bookmarks/lib/web_bookmarks/tree.rb +67 -0
- data/plugins/web_bookmarks/lib/web_bookmarks/view_controller.rb +22 -0
- data/plugins/web_bookmarks/plugin.rb +11 -0
- data/plugins/web_bookmarks/views/index.html.erb +5 -0
- metadata +60 -10
@@ -140,36 +140,36 @@ module Redcar
|
|
140
140
|
@model.add_listener(:refresh_menu, &method(:refresh_menu))
|
141
141
|
end
|
142
142
|
|
143
|
-
class
|
143
|
+
class CocoaUIListener
|
144
|
+
|
144
145
|
def initialize(name)
|
145
146
|
@name = name
|
146
147
|
end
|
147
148
|
|
148
149
|
def handle_event(e)
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
150
|
+
if @name == :prefs
|
151
|
+
Redcar::PluginManagerUi::OpenPreferencesCommand.new.run
|
152
|
+
elsif @name == :about
|
153
|
+
Redcar::Top::AboutCommand.new.run
|
154
|
+
elsif @name == :quit
|
155
|
+
unless Redcar.app.events.ignore?(:application_close, Redcar.app)
|
156
|
+
e.doit = false
|
157
|
+
Redcar.app.events.create(:application_close, Redcar.app)
|
158
|
+
end
|
159
|
+
else
|
160
|
+
Application::Dialog.message_box("#{@name} menu is not hooked up yet")
|
158
161
|
end
|
159
162
|
end
|
160
163
|
end
|
161
164
|
|
162
165
|
def add_swt_listeners
|
163
166
|
if Redcar.platform == :osx
|
164
|
-
quit_listener = Listener.new(:quit)
|
165
|
-
about_listener = Listener.new(:about)
|
166
|
-
prefs_listener = Listener.new(:prefs)
|
167
167
|
enhancer = com.redcareditor.application_swt.CocoaUIEnhancer.new("Redcar")
|
168
168
|
enhancer.hook_application_menu(
|
169
169
|
ApplicationSWT.display,
|
170
|
-
|
171
|
-
|
172
|
-
|
170
|
+
CocoaUIListener.new(:quit),
|
171
|
+
CocoaUIListener.new(:about),
|
172
|
+
CocoaUIListener.new(:prefs)
|
173
173
|
)
|
174
174
|
end
|
175
175
|
end
|
@@ -64,8 +64,10 @@ module Redcar
|
|
64
64
|
@window.add_listener(:speedbar_opened, &method(:speedbar_opened))
|
65
65
|
@window.add_listener(:speedbar_closed, &method(:speedbar_closed))
|
66
66
|
|
67
|
+
@window.add_listener(:toggle_trees_visible, &method(:toggle_sash_widths))
|
68
|
+
|
67
69
|
@window.treebook.add_listener(:tree_added) do
|
68
|
-
if @treebook_unopened
|
70
|
+
if @treebook_unopened or not @window.trees_visible?
|
69
71
|
reset_sash_widths
|
70
72
|
@treebook_unopened = false
|
71
73
|
end
|
@@ -77,6 +79,18 @@ module Redcar
|
|
77
79
|
@shell.add_key_listener(KeyListener.new(self))
|
78
80
|
end
|
79
81
|
|
82
|
+
def treebook_visible?
|
83
|
+
@sash.layout_data.left.offset > SASH_WIDTH
|
84
|
+
end
|
85
|
+
|
86
|
+
def fullscreen
|
87
|
+
@shell.fullScreen()
|
88
|
+
end
|
89
|
+
|
90
|
+
def fullscreen=(value)
|
91
|
+
@shell.setFullScreen(value)
|
92
|
+
end
|
93
|
+
|
80
94
|
class KeyListener
|
81
95
|
def initialize(edit_view_swt)
|
82
96
|
@edit_view_swt = edit_view_swt
|
@@ -118,11 +132,11 @@ module Redcar
|
|
118
132
|
|
119
133
|
def refresh_menu
|
120
134
|
old_menu_bar = shell.menu_bar
|
121
|
-
@menu_controller = ApplicationSWT::Menu.new(self, Redcar.app.main_menu, Redcar.app.main_keymap, Swt::SWT::BAR)
|
135
|
+
@menu_controller = ApplicationSWT::Menu.new(self, Redcar.app.main_menu(@window), Redcar.app.main_keymap, Swt::SWT::BAR)
|
122
136
|
shell.menu_bar = @menu_controller.menu_bar
|
123
137
|
old_menu_bar.dispose if old_menu_bar
|
124
138
|
end
|
125
|
-
|
139
|
+
|
126
140
|
def refresh_toolbar
|
127
141
|
if Redcar.app.show_toolbar?
|
128
142
|
@toolbar_controller = ApplicationSWT::ToolBar.new(self, Redcar.app.main_toolbar, Swt::SWT::HORIZONTAL | Swt::SWT::BORDER)
|
@@ -134,7 +148,7 @@ module Redcar
|
|
134
148
|
end
|
135
149
|
reset_sash_height
|
136
150
|
end
|
137
|
-
|
151
|
+
|
138
152
|
def set_icon
|
139
153
|
path = File.join(icon_dir, icon_file)
|
140
154
|
icon = Swt::Graphics::Image.new(ApplicationSWT.display, path)
|
@@ -323,20 +337,34 @@ module Redcar
|
|
323
337
|
@shell.layout
|
324
338
|
end
|
325
339
|
|
340
|
+
def toggle_sash_widths
|
341
|
+
if not treebook_visible?
|
342
|
+
reset_sash_widths
|
343
|
+
else
|
344
|
+
@sash.layout_data.left = Swt::Layout::FormAttachment.new(0, 0)
|
345
|
+
@shell.layout
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
349
|
+
def set_sash_widths(offset)
|
350
|
+
@sash.layout_data.left = Swt::Layout::FormAttachment.new(0, offset)
|
351
|
+
@shell.layout
|
352
|
+
end
|
353
|
+
|
326
354
|
def reset_notebook_sash_widths
|
327
355
|
width = (100/@window.notebooks.length).to_i
|
328
356
|
widths = [width]*@window.notebooks.length
|
329
357
|
@notebook_sash.setWeights(widths.to_java(:int))
|
330
358
|
end
|
331
|
-
|
359
|
+
|
332
360
|
def reset_sash_height
|
333
361
|
@sash.layout_data.top = Swt::Layout::FormAttachment.new(0, @toolbar_height.to_i)
|
334
362
|
@left_composite.layout_data.top = Swt::Layout::FormAttachment.new(0, 5 + @toolbar_height.to_i)
|
335
363
|
@right_composite.layout_data.top = Swt::Layout::FormAttachment.new(0, 5 + @toolbar_height.to_i)
|
336
|
-
@shell.layout
|
364
|
+
@shell.layout
|
337
365
|
@shell.redraw
|
338
366
|
end
|
339
|
-
|
367
|
+
|
340
368
|
end
|
341
369
|
end
|
342
370
|
end
|
@@ -1,86 +1,91 @@
|
|
1
1
|
Feature: Automatically insert paired characters
|
2
|
-
# This isn't a proper test because I haven't found a way to simulate
|
3
|
-
# a keypress so that text is inserted and the cursor moves. Therefore these
|
4
|
-
# tests assume that the cursor may be in the wrong place at any moment.
|
5
2
|
|
6
3
|
Scenario: Inserts quote marks
|
7
4
|
When I open a new edit tab
|
8
|
-
And I
|
9
|
-
Then the contents should be "\"
|
5
|
+
And I type "\""
|
6
|
+
Then the contents should be "\"<c>\""
|
7
|
+
|
8
|
+
Scenario: Don't insert quote mark if we're already open
|
9
|
+
When I open a new edit tab
|
10
|
+
And I replace the contents with "foo \" bár q"
|
11
|
+
And I move to the end of the line
|
12
|
+
And I move left
|
13
|
+
When I type "\""
|
14
|
+
Then the contents should be "foo \" bár \"q"
|
10
15
|
|
11
16
|
Scenario: Inserts parentheses
|
12
17
|
When I open a new edit tab
|
13
|
-
And I
|
14
|
-
Then the contents should be "()"
|
18
|
+
And I type "("
|
19
|
+
Then the contents should be "(<c>)"
|
15
20
|
|
16
21
|
Scenario: Delete start character (quotes)
|
17
22
|
When I open a new edit tab
|
18
|
-
And I
|
19
|
-
And I
|
20
|
-
And I press the Backspace key in the edit tab
|
23
|
+
And I type "\""
|
24
|
+
And I backspace
|
21
25
|
Then the contents should be ""
|
22
26
|
|
23
27
|
Scenario: Delete start character (parentheses)
|
24
28
|
When I open a new edit tab
|
25
|
-
And I
|
26
|
-
And I
|
27
|
-
And I press the Backspace key in the edit tab
|
29
|
+
And I type "("
|
30
|
+
And I backspace
|
28
31
|
Then the contents should be ""
|
29
32
|
|
30
33
|
Scenario: Type over ends
|
31
34
|
When I open a new edit tab
|
32
|
-
And I
|
33
|
-
And I
|
34
|
-
|
35
|
-
Then the contents should be "()"
|
35
|
+
And I type "("
|
36
|
+
And I type ")"
|
37
|
+
Then the contents should be "()<c>"
|
36
38
|
|
37
39
|
Scenario: Wrap selected text
|
38
40
|
When I open a new edit tab
|
39
|
-
And I
|
41
|
+
And I type "Boris"
|
40
42
|
And I select from 0 to 5
|
41
|
-
And I
|
42
|
-
Then the contents should be "(Boris)"
|
43
|
+
And I type "("
|
44
|
+
Then the contents should be "(Boris)<c>"
|
43
45
|
|
44
46
|
Scenario: Inserts ending character nested
|
45
47
|
When I open a new edit tab
|
46
|
-
And I
|
47
|
-
And I
|
48
|
-
Then the contents should be "\"()\""
|
48
|
+
And I type "\""
|
49
|
+
And I type "("
|
50
|
+
Then the contents should be "\"(<c>)\""
|
49
51
|
|
50
52
|
Scenario: Delete start character nested
|
51
53
|
When I open a new edit tab
|
52
|
-
And I
|
53
|
-
And I
|
54
|
-
And I
|
55
|
-
|
56
|
-
|
57
|
-
And I move the cursor to 1
|
58
|
-
And I press the Backspace key in the edit tab
|
54
|
+
And I type "\""
|
55
|
+
And I type "("
|
56
|
+
And I backspace
|
57
|
+
Then the contents should be "\"<c>\""
|
58
|
+
When I backspace
|
59
59
|
Then the contents should be ""
|
60
60
|
|
61
61
|
Scenario: Type over ends nested
|
62
62
|
When I open a new edit tab
|
63
|
-
And I
|
64
|
-
And I
|
65
|
-
And I
|
66
|
-
And I
|
67
|
-
Then the contents should be "(\"\")"
|
63
|
+
And I type "("
|
64
|
+
And I type "\""
|
65
|
+
And I type "\""
|
66
|
+
And I type ")"
|
67
|
+
Then the contents should be "(\"\")<c>"
|
68
68
|
|
69
69
|
Scenario: Don't delete start character if moved away
|
70
70
|
When I open a new edit tab
|
71
|
-
And I
|
72
|
-
And I
|
73
|
-
And I
|
74
|
-
And I move the
|
75
|
-
And I
|
76
|
-
|
71
|
+
And I type "0123456789"
|
72
|
+
And I move to the start of the line
|
73
|
+
And I type "("
|
74
|
+
And I move to the end of the line
|
75
|
+
And I move to the start of the line
|
76
|
+
And I move right
|
77
|
+
And I backspace
|
78
|
+
Then the contents should be "<c>)0123456789"
|
77
79
|
|
78
80
|
Scenario: Don't type over end if moved away
|
79
81
|
When I open a new edit tab
|
80
|
-
And I
|
81
|
-
And I
|
82
|
-
And I
|
83
|
-
And I
|
82
|
+
And I type "0123456789"
|
83
|
+
And I move to the start of the line
|
84
|
+
And I type "("
|
85
|
+
And I move to the end of the line
|
86
|
+
And I move to the start of the line
|
87
|
+
And I move right
|
88
|
+
And I type ")"
|
84
89
|
Then the contents should be "())0123456789"
|
85
90
|
|
86
91
|
|
@@ -85,16 +85,21 @@ module Redcar
|
|
85
85
|
end_mark_pair = find_mark_pair_by_end(start_offset)
|
86
86
|
if end_mark_pair and end_mark_pair.text == text
|
87
87
|
@type_over_end = true
|
88
|
-
#@buffer.parser.stop_parsing
|
89
88
|
end
|
90
89
|
end
|
91
90
|
# Insert matching ends
|
92
|
-
if !@type_over_end and @rules.include?(text) and !@ignore_insert and !@done
|
93
|
-
|
94
|
-
|
95
|
-
|
91
|
+
if !@type_over_end and @rules.include?(text) and !@ignore_insert and !@done and
|
92
|
+
line_num = document.line_at_offset(start_offset)
|
93
|
+
line = document.get_line(line_num)
|
94
|
+
offset_of_line = document.offset_at_line(line_num)
|
95
|
+
pre_text = line.chars[0..(start_offset-offset_of_line)].to_s
|
96
|
+
equal_ends = (@rules[text] == text)
|
97
|
+
if !equal_ends or pre_text.scan(text).length % 2 == 0
|
98
|
+
@insert_end = true
|
99
|
+
if document.selection?
|
100
|
+
@selected_text = document.selected_text
|
101
|
+
end
|
96
102
|
end
|
97
|
-
# @buffer.parser.stop_parsing
|
98
103
|
end
|
99
104
|
end
|
100
105
|
end
|
Binary file
|
@@ -0,0 +1,50 @@
|
|
1
|
+
|
2
|
+
require 'clipboard_viewer/clipboard_bar'
|
3
|
+
require 'clipboard_viewer/browser_controller'
|
4
|
+
|
5
|
+
module Redcar
|
6
|
+
class ClipboardViewer
|
7
|
+
|
8
|
+
def self.menus
|
9
|
+
Redcar::Menu::Builder.build do
|
10
|
+
sub_menu "Plugins" do
|
11
|
+
sub_menu "Clipboard" do
|
12
|
+
item "Clipboard Viewer Bar", :command => OpenClipboardBar , :priority => 18
|
13
|
+
item "Clipboard Browser" , :command => OpenClipboardBrowser, :priority => 18
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.storage
|
20
|
+
@storage ||= begin
|
21
|
+
storage = Plugin::Storage.new('clipboard_viewer')
|
22
|
+
storage.set_default('chars_to_display', 50)
|
23
|
+
storage.set_default('lines_to_display', 3)
|
24
|
+
storage
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class OpenClipboardBar < Redcar::Command
|
29
|
+
def execute
|
30
|
+
window = Redcar.app.focussed_window
|
31
|
+
speedbar = Redcar::ClipboardViewer::ClipboardBar.new
|
32
|
+
window.open_speedbar(speedbar)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class OpenClipboardBrowser < Redcar::Command
|
37
|
+
|
38
|
+
def initialize(list=Redcar.app.clipboard)
|
39
|
+
@list = list || []
|
40
|
+
end
|
41
|
+
|
42
|
+
def execute
|
43
|
+
controller = BrowserController.new(@list)
|
44
|
+
tab = win.new_tab(HtmlTab)
|
45
|
+
tab.html_view.controller = controller
|
46
|
+
tab.focus
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
module Redcar
|
3
|
+
class ClipboardViewer
|
4
|
+
class BrowserController
|
5
|
+
include HtmlController
|
6
|
+
|
7
|
+
def initialize(list)
|
8
|
+
@list = list.to_a.reverse
|
9
|
+
end
|
10
|
+
|
11
|
+
def title
|
12
|
+
"Clipboard History"
|
13
|
+
end
|
14
|
+
|
15
|
+
def copy(idx)
|
16
|
+
text = @list[idx]
|
17
|
+
Redcar.app.clipboard >> text if text
|
18
|
+
false
|
19
|
+
end
|
20
|
+
|
21
|
+
def index
|
22
|
+
rhtml = ERB.new(File.read(File.join(File.dirname(__FILE__), "..","..", "views", "clipboard.html.erb")))
|
23
|
+
rhtml.result(binding)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Redcar
|
2
|
+
class ClipboardViewer
|
3
|
+
class ClipboardBar < Redcar::Speedbar
|
4
|
+
include Redcar::Observable
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@size = ClipboardViewer.storage['chars_to_display'].to_i
|
8
|
+
@line_limit = ClipboardViewer.storage['lines_to_display'].to_i
|
9
|
+
load_list
|
10
|
+
@listener = Redcar.app.clipboard.add_listener(:added) {|t|load_list}
|
11
|
+
end
|
12
|
+
|
13
|
+
def close
|
14
|
+
Redcar.app.clipboard.remove_listener(@listener)
|
15
|
+
end
|
16
|
+
|
17
|
+
def load_list
|
18
|
+
@list = Redcar.app.clipboard || []
|
19
|
+
values = display_values(@list)
|
20
|
+
if values.length > 0
|
21
|
+
clip_list.items = values
|
22
|
+
clip_list.value = values.first
|
23
|
+
else
|
24
|
+
clip_list.items = [" "*(@size+5)]
|
25
|
+
clip_list.value = clip_list.items.first
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
combo :clip_list
|
30
|
+
button :paste_selected, "Paste!", "Return" do
|
31
|
+
tab = Redcar.app.focussed_window.focussed_notebook_tab
|
32
|
+
content = @list.to_a.reverse.detect do |r|
|
33
|
+
l = r.to_s
|
34
|
+
val = clip_list.value.to_s
|
35
|
+
val = val[0,val.length-3] if val =~ /\.\.\.$/
|
36
|
+
l.length >= val.length and l[0,val.length].to_s == val.to_s
|
37
|
+
end
|
38
|
+
tab.edit_view.document.insert_at_cursor(content.to_s) if tab.is_a?(EditTab) and content
|
39
|
+
load_list
|
40
|
+
end
|
41
|
+
|
42
|
+
button :browse, "Browse", nil do
|
43
|
+
OpenClipboardBrowser.new(@list).run
|
44
|
+
end
|
45
|
+
|
46
|
+
def display_values(list)
|
47
|
+
display = list.to_a.reverse.map do |l|
|
48
|
+
value = ""
|
49
|
+
r=0
|
50
|
+
l.to_s.each_line do |line|
|
51
|
+
value += line if r <= @line_limit - 1
|
52
|
+
value += "..." if r == @line_limit
|
53
|
+
r+=1
|
54
|
+
break if r > @line_limit - 1
|
55
|
+
end
|
56
|
+
value = value[0,value.length-1] if value =~ /\n$/
|
57
|
+
if value.length > @size
|
58
|
+
value[0,@size]+"..."
|
59
|
+
else
|
60
|
+
value
|
61
|
+
end
|
62
|
+
end
|
63
|
+
display || []
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|