redcar-dev 0.12.17dev
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +664 -0
- data/LICENSE +32 -0
- data/README.md +119 -0
- data/Rakefile +283 -0
- data/bin/redcar +29 -0
- data/lib/redcar.rb +307 -0
- data/lib/redcar/installer.rb +178 -0
- data/lib/redcar/instance_exec.rb +25 -0
- data/lib/redcar/logger.rb +64 -0
- data/lib/redcar/plist.rb +83 -0
- data/lib/redcar/ruby_extensions.rb +201 -0
- data/lib/redcar/runner.rb +130 -0
- data/lib/redcar/usage.rb +42 -0
- data/lib/redcar_quick_start.rb +100 -0
- data/lib/regex_replace.rb +221 -0
- data/lib/tasks/app-bundle.rake +63 -0
- data/plugins/application/features/main_menu.feature +9 -0
- data/plugins/application/features/navigation_history.feature +66 -0
- data/plugins/application/features/step_definitions/command_steps.rb +10 -0
- data/plugins/application/features/step_definitions/dialog_steps.rb +25 -0
- data/plugins/application/features/step_definitions/filter_list_dialog_steps.rb +42 -0
- data/plugins/application/features/step_definitions/key_steps.rb +18 -0
- data/plugins/application/features/step_definitions/menu_steps.rb +42 -0
- data/plugins/application/features/step_definitions/navigation_history_steps.rb +4 -0
- data/plugins/application/features/step_definitions/speedbar_steps.rb +88 -0
- data/plugins/application/features/step_definitions/tree_steps.rb +107 -0
- data/plugins/application/features/step_definitions/window_steps.rb +17 -0
- data/plugins/application/features/support/env.rb +257 -0
- data/plugins/application/features/support/fake_event.rb +26 -0
- data/plugins/application/lib/application.rb +425 -0
- data/plugins/application/lib/application/assets/file.png +0 -0
- data/plugins/application/lib/application/clipboard.rb +95 -0
- data/plugins/application/lib/application/command.rb +108 -0
- data/plugins/application/lib/application/command/executor.rb +80 -0
- data/plugins/application/lib/application/command/history.rb +54 -0
- data/plugins/application/lib/application/commands/application_commands.rb +21 -0
- data/plugins/application/lib/application/commands/notebook_commands.rb +73 -0
- data/plugins/application/lib/application/commands/tab_commands.rb +105 -0
- data/plugins/application/lib/application/commands/treebook_commands.rb +117 -0
- data/plugins/application/lib/application/commands/window_commands.rb +68 -0
- data/plugins/application/lib/application/dialog.rb +170 -0
- data/plugins/application/lib/application/dialogs/filter_list_dialog.rb +123 -0
- data/plugins/application/lib/application/dialogs/modeless_list_dialog.rb +85 -0
- data/plugins/application/lib/application/event_spewer.rb +32 -0
- data/plugins/application/lib/application/keymap.rb +41 -0
- data/plugins/application/lib/application/keymap/builder.rb +23 -0
- data/plugins/application/lib/application/menu.rb +117 -0
- data/plugins/application/lib/application/menu/builder.rb +80 -0
- data/plugins/application/lib/application/menu/builder/group.rb +47 -0
- data/plugins/application/lib/application/menu/item.rb +79 -0
- data/plugins/application/lib/application/menu/lazy_menu.rb +25 -0
- data/plugins/application/lib/application/navigation_history.rb +71 -0
- data/plugins/application/lib/application/notebook.rb +163 -0
- data/plugins/application/lib/application/sensitive.rb +57 -0
- data/plugins/application/lib/application/sensitivity.rb +82 -0
- data/plugins/application/lib/application/speedbar.rb +100 -0
- data/plugins/application/lib/application/tab.rb +92 -0
- data/plugins/application/lib/application/tab/command.rb +5 -0
- data/plugins/application/lib/application/toolbar.rb +83 -0
- data/plugins/application/lib/application/toolbar/builder.rb +80 -0
- data/plugins/application/lib/application/toolbar/builder/group.rb +47 -0
- data/plugins/application/lib/application/toolbar/item.rb +71 -0
- data/plugins/application/lib/application/toolbar/lazy_toolbar.rb +25 -0
- data/plugins/application/lib/application/tree.rb +94 -0
- data/plugins/application/lib/application/tree/command.rb +5 -0
- data/plugins/application/lib/application/tree/controller.rb +64 -0
- data/plugins/application/lib/application/tree/mirror.rb +132 -0
- data/plugins/application/lib/application/treebook.rb +83 -0
- data/plugins/application/lib/application/window.rb +274 -0
- data/plugins/application/plugin.rb +8 -0
- data/plugins/application/spec/application/application_spec.rb +23 -0
- data/plugins/application/spec/application/clipboard_spec.rb +55 -0
- data/plugins/application/spec/application/command/executor_spec.rb +78 -0
- data/plugins/application/spec/application/command/history_spec.rb +49 -0
- data/plugins/application/spec/application/command_spec.rb +78 -0
- data/plugins/application/spec/application/controllers/application_controller.rb +4 -0
- data/plugins/application/spec/application/controllers/notebook_controller.rb +4 -0
- data/plugins/application/spec/application/controllers/window_controller.rb +5 -0
- data/plugins/application/spec/application/keymap/builder_spec.rb +17 -0
- data/plugins/application/spec/application/menu/builder_spec.rb +61 -0
- data/plugins/application/spec/application/menu/menu_item_spec.rb +17 -0
- data/plugins/application/spec/application/menu_spec.rb +171 -0
- data/plugins/application/spec/application/navigation_history_spec.rb +96 -0
- data/plugins/application/spec/application/notebook_spec.rb +31 -0
- data/plugins/application/spec/application/sensitive_spec.rb +156 -0
- data/plugins/application/spec/application/speedbar_spec.rb +77 -0
- data/plugins/application/spec/application/treebook_spec.rb +27 -0
- data/plugins/application/spec/application/window_spec.rb +24 -0
- data/plugins/application/spec/spec_helper.rb +18 -0
- data/plugins/application_swt/build.xml +74 -0
- data/plugins/application_swt/lib/application_swt.rb +218 -0
- data/plugins/application_swt/lib/application_swt/bring_to_front.rb +53 -0
- data/plugins/application_swt/lib/application_swt/clipboard.rb +42 -0
- data/plugins/application_swt/lib/application_swt/dialog_adapter.rb +180 -0
- data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +233 -0
- data/plugins/application_swt/lib/application_swt/dialogs/input_dialog.rb +46 -0
- data/plugins/application_swt/lib/application_swt/dialogs/modeless_dialog.rb +113 -0
- data/plugins/application_swt/lib/application_swt/dialogs/modeless_html_dialog.rb +85 -0
- data/plugins/application_swt/lib/application_swt/dialogs/modeless_list_dialog_controller.rb +143 -0
- data/plugins/application_swt/lib/application_swt/dialogs/no_buttons_dialog.rb +24 -0
- data/plugins/application_swt/lib/application_swt/dialogs/text_and_file_dialog.rb +118 -0
- data/plugins/application_swt/lib/application_swt/gradient.rb +61 -0
- data/plugins/application_swt/lib/application_swt/html_tab.rb +79 -0
- data/plugins/application_swt/lib/application_swt/icon.rb +35 -0
- data/plugins/application_swt/lib/application_swt/listener_helpers.rb +20 -0
- data/plugins/application_swt/lib/application_swt/menu.rb +167 -0
- data/plugins/application_swt/lib/application_swt/menu/binding_translator.rb +94 -0
- data/plugins/application_swt/lib/application_swt/notebook.rb +148 -0
- data/plugins/application_swt/lib/application_swt/notebook/tab_drag_and_drop_listener.rb +124 -0
- data/plugins/application_swt/lib/application_swt/notebook/tab_transfer.rb +83 -0
- data/plugins/application_swt/lib/application_swt/speedbar.rb +185 -0
- data/plugins/application_swt/lib/application_swt/speedbar/button_item.rb +20 -0
- data/plugins/application_swt/lib/application_swt/speedbar/combo_item.rb +55 -0
- data/plugins/application_swt/lib/application_swt/speedbar/label_item.rb +15 -0
- data/plugins/application_swt/lib/application_swt/speedbar/slider_item.rb +32 -0
- data/plugins/application_swt/lib/application_swt/speedbar/text_box_item.rb +36 -0
- data/plugins/application_swt/lib/application_swt/speedbar/toggle_item.rb +29 -0
- data/plugins/application_swt/lib/application_swt/tab.rb +84 -0
- data/plugins/application_swt/lib/application_swt/toolbar.rb +138 -0
- data/plugins/application_swt/lib/application_swt/toolbar/binding_translator.rb +94 -0
- data/plugins/application_swt/lib/application_swt/treebook.rb +78 -0
- data/plugins/application_swt/lib/application_swt/window.rb +419 -0
- data/plugins/application_swt/lib/dist/application_swt.jar +0 -0
- data/plugins/application_swt/lib/swt/graphics_utils.rb +193 -0
- data/plugins/application_swt/lib/swt/vtab_folder.rb +177 -0
- data/plugins/application_swt/lib/swt/vtab_item.rb +78 -0
- data/plugins/application_swt/lib/swt/vtab_label.rb +127 -0
- data/plugins/application_swt/plugin.rb +8 -0
- data/plugins/application_swt/spec/application_swt/gradient_spec.rb +133 -0
- data/plugins/application_swt/spec/application_swt/menu/binding_translator_spec.rb +73 -0
- data/plugins/application_swt/spec/application_swt/menu_spec.rb +7 -0
- data/plugins/application_swt/spec/spec_helper.rb +20 -0
- data/plugins/application_swt/src/com/redcareditor/application_swt/CocoaUIEnhancer.java +313 -0
- data/plugins/auto_completer/features/auto_complete.feature +65 -0
- data/plugins/auto_completer/features/step_definitions/auto_complete_steps.rb +4 -0
- data/plugins/auto_completer/features/support/env.rb +2 -0
- data/plugins/auto_completer/lib/auto_completer.rb +129 -0
- data/plugins/auto_completer/lib/auto_completer/current_document_completion_source.rb +19 -0
- data/plugins/auto_completer/lib/auto_completer/document_controller.rb +52 -0
- data/plugins/auto_completer/lib/auto_completer/list_dialog.rb +21 -0
- data/plugins/auto_completer/lib/auto_completer/word_iterator.rb +48 -0
- data/plugins/auto_completer/lib/auto_completer/word_list.rb +47 -0
- data/plugins/auto_completer/plugin.rb +10 -0
- data/plugins/auto_indenter/features/java_style_indentation.feature +36 -0
- data/plugins/auto_indenter/features/ruby_style_indentation.feature +42 -0
- data/plugins/auto_indenter/features/step_definitions/indentation_steps.rb +15 -0
- data/plugins/auto_indenter/features/support/env.rb +1 -0
- data/plugins/auto_indenter/lib/auto_indenter.rb +108 -0
- data/plugins/auto_indenter/lib/auto_indenter/analyzer.rb +100 -0
- data/plugins/auto_indenter/lib/auto_indenter/commands.rb +66 -0
- data/plugins/auto_indenter/lib/auto_indenter/document_controller.rb +103 -0
- data/plugins/auto_indenter/lib/auto_indenter/rules.rb +41 -0
- data/plugins/auto_indenter/plugin.rb +9 -0
- data/plugins/auto_indenter/spec/auto_indenter/analyzer_spec.rb +151 -0
- data/plugins/auto_indenter/spec/spec_helper.rb +5 -0
- data/plugins/auto_pairer/features/auto_pairer.feature +92 -0
- data/plugins/auto_pairer/features/step_definitions/auto_pairer_steps.rb +0 -0
- data/plugins/auto_pairer/features/support/env.rb +1 -0
- data/plugins/auto_pairer/lib/auto_pairer.rb +12 -0
- data/plugins/auto_pairer/lib/auto_pairer/document_controller.rb +168 -0
- data/plugins/auto_pairer/lib/auto_pairer/pairs_for_scope.rb +57 -0
- data/plugins/auto_pairer/plugin.rb +9 -0
- 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 +19 -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 +249 -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 +268 -0
- data/plugins/comment/plugin.rb +7 -0
- data/plugins/comment/vendor/comment_lib.json +47 -0
- data/plugins/connection_manager/lib/connection_manager.rb +57 -0
- data/plugins/connection_manager/lib/connection_manager/commands.rb +14 -0
- data/plugins/connection_manager/lib/connection_manager/connection_store.rb +87 -0
- data/plugins/connection_manager/lib/connection_manager/controller.rb +100 -0
- data/plugins/connection_manager/lib/connection_manager/filter_dialog.rb +38 -0
- data/plugins/connection_manager/lib/connection_manager/private_key_store.rb +93 -0
- data/plugins/connection_manager/plugin.rb +12 -0
- data/plugins/connection_manager/views/index.html.erb +284 -0
- data/plugins/core/lib/core.rb +41 -0
- data/plugins/core/lib/core/controller.rb +23 -0
- data/plugins/core/lib/core/gui.rb +100 -0
- data/plugins/core/lib/core/has_spi.rb +10 -0
- data/plugins/core/lib/core/interface.rb +73 -0
- data/plugins/core/lib/core/model.rb +11 -0
- data/plugins/core/lib/core/observable.rb +115 -0
- data/plugins/core/lib/core/observable_struct.rb +34 -0
- data/plugins/core/lib/core/persistent_cache.rb +57 -0
- data/plugins/core/lib/core/plugin.rb +12 -0
- data/plugins/core/lib/core/plugin/storage.rb +133 -0
- data/plugins/core/lib/core/reentry_helpers.rb +13 -0
- data/plugins/core/lib/core/resource.rb +86 -0
- data/plugins/core/lib/core/task.rb +62 -0
- data/plugins/core/lib/core/task_queue.rb +72 -0
- data/plugins/core/plugin.rb +7 -0
- data/plugins/core/spec/core/base_storage_spec.rb +81 -0
- data/plugins/core/spec/core/gui_spec.rb +27 -0
- data/plugins/core/spec/core/observable_spec.rb +104 -0
- data/plugins/core/spec/core/persistent_cache_spec.rb +100 -0
- data/plugins/core/spec/core/resource_spec.rb +125 -0
- data/plugins/core/spec/core/shared_storage_spec.rb +49 -0
- data/plugins/core/spec/core/storage_spec.rb +27 -0
- data/plugins/core/spec/core/task_queue_spec.rb +199 -0
- data/plugins/core/spec/spec_helper.rb +27 -0
- data/plugins/declarations/lib/declarations.rb +159 -0
- data/plugins/declarations/lib/declarations/completion_source.rb +22 -0
- data/plugins/declarations/lib/declarations/file.rb +68 -0
- data/plugins/declarations/lib/declarations/parser.rb +186 -0
- data/plugins/declarations/lib/declarations/select_tag_dialog.rb +45 -0
- data/plugins/declarations/plugin.rb +7 -0
- data/plugins/declarations/spec/declarations/file_spec.rb +62 -0
- data/plugins/declarations/spec/fixtures/federalist.rb +15 -0
- data/plugins/declarations/spec/spec_helper.rb +5 -0
- data/plugins/document_search/Readme.md +14 -0
- data/plugins/document_search/features/find.feature +541 -0
- data/plugins/document_search/features/incremental_search.feature +351 -0
- data/plugins/document_search/features/replace.feature +178 -0
- data/plugins/document_search/features/step_definitions/find_steps.rb +16 -0
- data/plugins/document_search/features/support/env.rb +14 -0
- data/plugins/document_search/lib/document_search.rb +191 -0
- data/plugins/document_search/lib/document_search/commands.rb +307 -0
- data/plugins/document_search/lib/document_search/find_speedbar.rb +162 -0
- data/plugins/document_search/lib/document_search/incremental_search_speedbar.rb +70 -0
- data/plugins/document_search/lib/document_search/query_options.rb +21 -0
- data/plugins/document_search/plugin.rb +8 -0
- data/plugins/edit_view/features/align_assignment.feature +106 -0
- data/plugins/edit_view/features/case_change.feature +67 -0
- data/plugins/edit_view/features/cursor_navigation.feature +36 -0
- data/plugins/edit_view/features/cut_and_paste.feature +45 -0
- data/plugins/edit_view/features/grammar.feature +11 -0
- data/plugins/edit_view/features/indentation_commands.feature +49 -0
- data/plugins/edit_view/features/line_delimiter.feature +47 -0
- data/plugins/edit_view/features/multiple_notebooks.feature +52 -0
- data/plugins/edit_view/features/multiple_windows.feature +48 -0
- data/plugins/edit_view/features/new_tab.feature +11 -0
- data/plugins/edit_view/features/soft_tabs.feature +243 -0
- data/plugins/edit_view/features/sort_lines.feature +15 -0
- data/plugins/edit_view/features/step_definitions/editing_steps.rb +350 -0
- data/plugins/edit_view/features/step_definitions/grammar_steps.rb +4 -0
- data/plugins/edit_view/features/step_definitions/key_steps.rb +48 -0
- data/plugins/edit_view/features/step_definitions/notebook_steps.rb +59 -0
- data/plugins/edit_view/features/step_definitions/tab_steps.rb +113 -0
- data/plugins/edit_view/features/step_definitions/window_steps.rb +86 -0
- data/plugins/edit_view/features/support/env.rb +59 -0
- data/plugins/edit_view/features/switch_tabs.feature +106 -0
- data/plugins/edit_view/features/tabs.feature +146 -0
- data/plugins/edit_view/features/undo_and_redo.feature +73 -0
- data/plugins/edit_view/features/word_matching.feature +67 -0
- data/plugins/edit_view/lib/edit_view.rb +659 -0
- data/plugins/edit_view/lib/edit_view/actions/arrow_keys.rb +170 -0
- data/plugins/edit_view/lib/edit_view/actions/cmd_enter.rb +11 -0
- data/plugins/edit_view/lib/edit_view/actions/deletion.rb +40 -0
- data/plugins/edit_view/lib/edit_view/actions/esc.rb +15 -0
- data/plugins/edit_view/lib/edit_view/actions/tab.rb +70 -0
- data/plugins/edit_view/lib/edit_view/command.rb +14 -0
- data/plugins/edit_view/lib/edit_view/commands/align_assignment_command.rb +55 -0
- data/plugins/edit_view/lib/edit_view/commands/text_conversion_commands.rb +85 -0
- data/plugins/edit_view/lib/edit_view/document.rb +796 -0
- data/plugins/edit_view/lib/edit_view/document/command.rb +25 -0
- data/plugins/edit_view/lib/edit_view/document/controller.rb +43 -0
- data/plugins/edit_view/lib/edit_view/document/history.rb +41 -0
- data/plugins/edit_view/lib/edit_view/document/indentation.rb +40 -0
- data/plugins/edit_view/lib/edit_view/document/mirror.rb +42 -0
- data/plugins/edit_view/lib/edit_view/edit_tab.rb +59 -0
- data/plugins/edit_view/lib/edit_view/grammar.rb +58 -0
- data/plugins/edit_view/lib/edit_view/grammars/default.rb +10 -0
- data/plugins/edit_view/lib/edit_view/grammars/ruby.rb +10 -0
- data/plugins/edit_view/lib/edit_view/grammars/ruby_on_rails.rb +7 -0
- data/plugins/edit_view/lib/edit_view/info_speedbar.rb +98 -0
- data/plugins/edit_view/lib/edit_view/modified_tabs_checker.rb +35 -0
- data/plugins/edit_view/lib/edit_view/select_font_dialog.rb +45 -0
- data/plugins/edit_view/lib/edit_view/select_theme_dialog.rb +42 -0
- data/plugins/edit_view/lib/edit_view/tab_settings.rb +135 -0
- data/plugins/edit_view/plugin.rb +9 -0
- data/plugins/edit_view/spec/edit_view/document/indentation_spec.rb +112 -0
- data/plugins/edit_view/spec/edit_view/document_spec.rb +130 -0
- data/plugins/edit_view/spec/spec_helper.rb +5 -0
- data/plugins/edit_view_swt/lib/edit_view_swt.rb +621 -0
- data/plugins/edit_view_swt/lib/edit_view_swt/document.rb +224 -0
- data/plugins/edit_view_swt/lib/edit_view_swt/edit_tab.rb +50 -0
- data/plugins/edit_view_swt/lib/edit_view_swt/word_movement.rb +68 -0
- data/plugins/edit_view_swt/plugin.rb +9 -0
- data/plugins/edit_view_swt/spec/edit_view_swt/word_movement_spec.rb +29 -0
- data/plugins/edit_view_swt/spec/spec_helper.rb +5 -0
- data/plugins/encryption/encryption.rb +52 -0
- data/plugins/encryption/ezcrypto.rb +652 -0
- data/plugins/encryption/jarmor-1.1.jar +0 -0
- data/plugins/encryption/plugin.rb +9 -0
- data/plugins/execute_current_tab/lib/execute_current_tab.rb +68 -0
- data/plugins/execute_current_tab/plugin.rb +8 -0
- data/plugins/help/lib/help.rb +64 -0
- data/plugins/help/lib/help/help_tab.rb +11 -0
- data/plugins/help/lib/help/view_controller.rb +30 -0
- data/plugins/help/plugin.rb +9 -0
- data/plugins/help/views/default.css +31 -0
- data/plugins/help/views/index.html.erb +41 -0
- data/plugins/help/views/redcar_small_icon.png +0 -0
- data/plugins/html_view/assets/blueprint/ie.css +35 -0
- data/plugins/html_view/assets/blueprint/print.css +29 -0
- data/plugins/html_view/assets/blueprint/screen.css +257 -0
- data/plugins/html_view/assets/blueprint/src/forms.css +65 -0
- data/plugins/html_view/assets/blueprint/src/grid.css +281 -0
- data/plugins/html_view/assets/blueprint/src/grid.png +0 -0
- data/plugins/html_view/assets/blueprint/src/ie.css +76 -0
- data/plugins/html_view/assets/blueprint/src/print.css +85 -0
- data/plugins/html_view/assets/blueprint/src/reset.css +38 -0
- data/plugins/html_view/assets/blueprint/src/typography.css +106 -0
- data/plugins/html_view/assets/jquery-1.4.min.js +151 -0
- data/plugins/html_view/assets/json2.js +476 -0
- data/plugins/html_view/assets/redcar.css +44 -0
- data/plugins/html_view/features/browser_bar.feature +47 -0
- data/plugins/html_view/features/fixtures/other.html +1 -0
- data/plugins/html_view/features/fixtures/sample.html +1 -0
- data/plugins/html_view/features/step_definitions/html_view_steps.rb +64 -0
- data/plugins/html_view/features/step_definitions/web_view_steps.rb +12 -0
- data/plugins/html_view/features/support/env.rb +27 -0
- data/plugins/html_view/features/web_preview.feature +21 -0
- data/plugins/html_view/lib/html_controller.rb +50 -0
- data/plugins/html_view/lib/html_view.rb +170 -0
- data/plugins/html_view/lib/html_view/browser_bar.rb +82 -0
- data/plugins/html_view/lib/html_view/commands.rb +64 -0
- data/plugins/html_view/lib/html_view/default_controller.rb +23 -0
- data/plugins/html_view/lib/html_view/html_tab.rb +40 -0
- data/plugins/html_view/plugin.rb +13 -0
- data/plugins/html_view/views/default.css +117 -0
- data/plugins/html_view/views/index.html.erb +5 -0
- data/plugins/html_view/views/watermark-48.png +0 -0
- data/plugins/java/features/fixtures/lib/classes.jar +0 -0
- data/plugins/java/features/fixtures/test.java +0 -0
- data/plugins/java/features/support/env.rb +27 -0
- data/plugins/java/features/syntax_check_java.feature +86 -0
- data/plugins/java/lib/syntax_check/java.rb +86 -0
- data/plugins/java/plugin.rb +7 -0
- data/plugins/key_bindings/lib/key_bindings.rb +34 -0
- data/plugins/key_bindings/plugin.rb +8 -0
- data/plugins/key_bindings/spec/spec_helper.rb +5 -0
- data/plugins/line_tools/features/clear_line.feature +25 -0
- data/plugins/line_tools/features/kill_line.feature +25 -0
- data/plugins/line_tools/features/lower_text.feature +54 -0
- data/plugins/line_tools/features/raise_text.feature +50 -0
- data/plugins/line_tools/features/replace_line.feature +33 -0
- data/plugins/line_tools/features/step_definitions/line_tools_steps.rb +23 -0
- data/plugins/line_tools/features/support/env.rb +0 -0
- data/plugins/line_tools/features/trim_line.feature +73 -0
- data/plugins/line_tools/lib/line_tools.rb +217 -0
- data/plugins/line_tools/plugin.rb +9 -0
- data/plugins/macros/features/block_selection_in_macros.feature +48 -0
- data/plugins/macros/features/predictive_macros.feature +79 -0
- data/plugins/macros/features/record_and_run_macro.feature +87 -0
- data/plugins/macros/features/step_definitions/macro_steps.rb +11 -0
- data/plugins/macros/features/step_definitions/prediction_steps.rb +8 -0
- data/plugins/macros/features/support/env.rb +0 -0
- data/plugins/macros/lib/macros.rb +167 -0
- data/plugins/macros/lib/macros/action_sequence.rb +30 -0
- data/plugins/macros/lib/macros/commands.rb +108 -0
- data/plugins/macros/lib/macros/macro.rb +37 -0
- data/plugins/macros/lib/macros/manager_controller.rb +67 -0
- data/plugins/macros/lib/macros/predictive/document_controller.rb +69 -0
- data/plugins/macros/lib/macros/predictive/sequence_finder.rb +112 -0
- data/plugins/macros/plugin.rb +9 -0
- data/plugins/macros/spec/macros/predictive/sequence_finder_spec.rb +142 -0
- data/plugins/macros/spec/spec_helper.rb +6 -0
- data/plugins/macros/views/macro_manager.html.erb +92 -0
- data/plugins/my_plugin/lib/my_plugin.rb +47 -0
- data/plugins/my_plugin/plugin.rb +8 -0
- data/plugins/open_default_app/lib/open_default_app.rb +61 -0
- data/plugins/open_default_app/plugin.rb +8 -0
- data/plugins/open_default_app/screenshot.png +0 -0
- data/plugins/outline_view/features/outline_view.feature +79 -0
- data/plugins/outline_view/features/step_definitions/outline_steps.rb +45 -0
- data/plugins/outline_view/lib/outline_view.rb +66 -0
- data/plugins/outline_view/lib/outline_view/commands.rb +13 -0
- data/plugins/outline_view/plugin.rb +10 -0
- data/plugins/outline_view/spec/fixtures/some_project/javascript.js +10 -0
- data/plugins/outline_view/spec/fixtures/some_project/nothing_to_see.rb +0 -0
- data/plugins/outline_view/spec/fixtures/some_project/one_lonely_class.rb +2 -0
- data/plugins/outline_view/spec/fixtures/some_project/similar_names.rb +18 -0
- data/plugins/outline_view/spec/fixtures/some_project/something_fancy.rb +736 -0
- data/plugins/outline_view/spec/fixtures/some_project/trailing_space.rb +5 -0
- data/plugins/outline_view_swt/lib/outline_view_swt.rb +79 -0
- data/plugins/outline_view_swt/plugin.rb +7 -0
- data/plugins/pair_highlighter/lib/pair_highlighter.rb +34 -0
- data/plugins/pair_highlighter/lib/pair_highlighter/document_controller.rb +185 -0
- data/plugins/pair_highlighter/plugin.rb +9 -0
- data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +122 -0
- data/plugins/plugin_manager_ui/plugin.rb +13 -0
- data/plugins/plugin_manager_ui/views/index.html.erb +62 -0
- data/plugins/project/features/close_directory_tree.feature +28 -0
- data/plugins/project/features/find_file.feature +119 -0
- data/plugins/project/features/highlight_focussed_tab.feature +53 -0
- data/plugins/project/features/move_and_rename_files.feature +25 -0
- data/plugins/project/features/open_and_save_files.feature +85 -0
- data/plugins/project/features/open_directory_tree.feature +93 -0
- data/plugins/project/features/refresh_directory_tree.feature +44 -0
- data/plugins/project/features/step_definitions/directory_steps.rb +35 -0
- data/plugins/project/features/step_definitions/drb_steps.rb +40 -0
- data/plugins/project/features/step_definitions/file_steps.rb +66 -0
- data/plugins/project/features/step_definitions/find_file_steps.rb +7 -0
- data/plugins/project/features/step_definitions/project_tree_steps.rb +7 -0
- data/plugins/project/features/sub_project.feature +15 -0
- data/plugins/project/features/support/env.rb +35 -0
- data/plugins/project/features/watch_for_modified_files.feature +109 -0
- data/plugins/project/lib/project.rb +266 -0
- data/plugins/project/lib/project/adapters/local.rb +82 -0
- data/plugins/project/lib/project/adapters/remote.rb +96 -0
- data/plugins/project/lib/project/adapters/remote_protocols/ftp.rb +93 -0
- data/plugins/project/lib/project/adapters/remote_protocols/protocol.rb +94 -0
- data/plugins/project/lib/project/adapters/remote_protocols/sftp.rb +181 -0
- data/plugins/project/lib/project/commands.rb +449 -0
- data/plugins/project/lib/project/dir_controller.rb +275 -0
- data/plugins/project/lib/project/dir_mirror.rb +176 -0
- data/plugins/project/lib/project/drb_service.rb +86 -0
- data/plugins/project/lib/project/file_list.rb +164 -0
- data/plugins/project/lib/project/file_mirror.rb +85 -0
- data/plugins/project/lib/project/find_file_dialog.rb +118 -0
- data/plugins/project/lib/project/find_recent_dialog.rb +30 -0
- data/plugins/project/lib/project/manager.rb +545 -0
- data/plugins/project/lib/project/project_tree_controller.rb +24 -0
- data/plugins/project/lib/project/recent.rb +64 -0
- 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 +73 -0
- data/plugins/project/plugin.rb +11 -0
- data/plugins/project/spec/fixture_helper.rb +30 -0
- data/plugins/project/spec/project/adapters/remote_protocols/ftp_spec.rb +75 -0
- data/plugins/project/spec/project/adapters/remote_protocols/sftp_spec.rb +121 -0
- data/plugins/project/spec/project/adapters/remote_spec.rb +136 -0
- data/plugins/project/spec/project/dir_mirror_spec.rb +65 -0
- data/plugins/project/spec/project/file_list_spec.rb +151 -0
- data/plugins/project/spec/project/file_mirror_spec.rb +97 -0
- data/plugins/project/spec/spec_helper.rb +26 -0
- data/plugins/project/views/bulk_rename.html.erb +162 -0
- data/plugins/project_search/features/support/env.rb +6 -0
- data/plugins/project_search/features/word_search.feature +34 -0
- data/plugins/project_search/lib/project_search.rb +82 -0
- data/plugins/project_search/lib/project_search/binary_data_detector.rb +46 -0
- data/plugins/project_search/lib/project_search/commands.rb +50 -0
- data/plugins/project_search/lib/project_search/hit.rb +21 -0
- data/plugins/project_search/lib/project_search/images/spinner.gif +0 -0
- data/plugins/project_search/lib/project_search/lucene_index.rb +81 -0
- data/plugins/project_search/lib/project_search/lucene_refresh.rb +22 -0
- data/plugins/project_search/lib/project_search/project.rb +14 -0
- data/plugins/project_search/lib/project_search/query.rb +29 -0
- data/plugins/project_search/lib/project_search/stylesheets/style.css +279 -0
- data/plugins/project_search/lib/project_search/views/_file.html.erb +58 -0
- data/plugins/project_search/lib/project_search/views/index.html.erb +156 -0
- data/plugins/project_search/lib/project_search/word_search.rb +143 -0
- data/plugins/project_search/lib/project_search/word_search_controller.rb +219 -0
- data/plugins/project_search/plugin.rb +8 -0
- data/plugins/project_search/spec/fixtures/project/binary_file.bin +0 -0
- data/plugins/project_search/spec/fixtures/project/foo.txt +43 -0
- data/plugins/project_search/spec/fixtures/project/qux.rb +3 -0
- data/plugins/project_search/spec/project_search/binary_data_detector_spec.rb +24 -0
- data/plugins/project_search/spec/project_search/word_search_spec.rb +157 -0
- data/plugins/project_search/spec/spec_helper.rb +27 -0
- data/plugins/redcar/features/alter_font_size.feature +26 -0
- data/plugins/redcar/features/goto_line_command.feature +20 -0
- data/plugins/redcar/features/step_definitions/env.rb +5 -0
- data/plugins/redcar/features/step_definitions/font_steps.rb +34 -0
- data/plugins/redcar/features/text_editing.feature +34 -0
- data/plugins/redcar/features/text_navigation.feature +30 -0
- data/plugins/redcar/plugin.rb +17 -0
- data/plugins/redcar/redcar.rb +1097 -0
- data/plugins/redcar_debug/lib/redcar_debug.rb +91 -0
- data/plugins/redcar_debug/plugin.rb +8 -0
- data/plugins/redcar_debug/views/history.html.erb +34 -0
- data/plugins/redcar_debug/views/index.html.erb +36 -0
- data/plugins/repl/features/command_editing.feature +55 -0
- data/plugins/repl/features/command_history.feature +75 -0
- data/plugins/repl/features/step_definitions/repl_steps.rb +19 -0
- data/plugins/repl/features/support/env.rb +24 -0
- data/plugins/repl/features/support/fake_repl.rb +16 -0
- data/plugins/repl/lib/repl.rb +40 -0
- data/plugins/repl/lib/repl/repl_command.rb +20 -0
- data/plugins/repl/lib/repl/repl_mirror.rb +255 -0
- data/plugins/repl/lib/repl/repl_tab.rb +154 -0
- data/plugins/repl/plugin.rb +8 -0
- data/plugins/repl/spec/repl/repl_mirror_spec.rb +72 -0
- data/plugins/repl/spec/spec_helper.rb +5 -0
- data/plugins/repl_swt/lib/repl_swt.rb +7 -0
- data/plugins/repl_swt/lib/repl_swt/key_listener.rb +43 -0
- data/plugins/repl_swt/plugin.rb +8 -0
- data/plugins/ruby/features/fixtures/test.rb +0 -0
- data/plugins/ruby/features/support/env.rb +4 -0
- data/plugins/ruby/features/syntax_check_ruby.feature +26 -0
- data/plugins/ruby/lib/ruby.rb +35 -0
- data/plugins/ruby/lib/ruby/repl_mirror.rb +46 -0
- data/plugins/ruby/lib/ruby/syntax_checker.rb +30 -0
- data/plugins/ruby/plugin.rb +8 -0
- data/plugins/ruby/spec/ruby/repl_mirror_spec.rb +202 -0
- data/plugins/ruby/spec/spec_helper.rb +5 -0
- data/plugins/runnables/features/command_tree.feature +63 -0
- data/plugins/runnables/features/file_runner_input.feature +21 -0
- data/plugins/runnables/features/parameter_input.feature +43 -0
- data/plugins/runnables/features/run_alternate_command.feature +15 -0
- data/plugins/runnables/features/run_command_tab.feature +47 -0
- data/plugins/runnables/features/step_definitions/runnable_steps.rb +28 -0
- data/plugins/runnables/features/support/env.rb +124 -0
- data/plugins/runnables/lib/runnables.rb +180 -0
- data/plugins/runnables/lib/runnables/command_output_controller.rb +183 -0
- data/plugins/runnables/lib/runnables/commands.rb +82 -0
- data/plugins/runnables/lib/runnables/output_processor.rb +74 -0
- data/plugins/runnables/lib/runnables/running_process_checker.rb +34 -0
- data/plugins/runnables/lib/runnables/tree_mirror/nodes/runnable.rb +62 -0
- data/plugins/runnables/lib/runnables/tree_mirror/nodes/runnable_group.rb +45 -0
- data/plugins/runnables/lib/runnables/tree_mirror/nodes/runnable_type_group.rb +30 -0
- data/plugins/runnables/lib/runnables/tree_mirror/tree_controller.rb +36 -0
- data/plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb +66 -0
- data/plugins/runnables/plugin.rb +9 -0
- data/plugins/runnables/spec/runnables/output_processor_spec.rb +57 -0
- data/plugins/runnables/spec/spec_helper.rb +5 -0
- data/plugins/runnables/views/basic_ansi.css +34 -0
- data/plugins/runnables/views/color_tester.html +50 -0
- data/plugins/runnables/views/command_output.html.erb +32 -0
- data/plugins/runnables/views/default.css +79 -0
- data/plugins/runnables/views/indicator.gif +0 -0
- data/plugins/runnables/views/redcar_small_icon.png +0 -0
- data/plugins/runnables/views/reset.css +53 -0
- data/plugins/runnables/views/running_test.html +41 -0
- data/plugins/runnables/views/wedgeDown.png +0 -0
- data/plugins/runnables/views/wedgeRight.png +0 -0
- data/plugins/scm/lib/scm.rb +296 -0
- data/plugins/scm/lib/scm/commands.rb +48 -0
- data/plugins/scm/lib/scm/commit_mirror.rb +72 -0
- data/plugins/scm/lib/scm/diff_mirror.rb +31 -0
- data/plugins/scm/lib/scm/errors.rb +8 -0
- data/plugins/scm/lib/scm/model.rb +275 -0
- data/plugins/scm/lib/scm/scm_changes_controller.rb +107 -0
- data/plugins/scm/lib/scm/scm_changes_mirror.rb +51 -0
- data/plugins/scm/lib/scm/scm_changes_mirror/change.rb +63 -0
- data/plugins/scm/lib/scm/scm_changes_mirror/changes_node.rb +47 -0
- data/plugins/scm/lib/scm/scm_changes_mirror/drag_controller.rb +78 -0
- data/plugins/scm/lib/scm/scm_commits_controller.rb +49 -0
- data/plugins/scm/lib/scm/scm_commits_mirror.rb +36 -0
- data/plugins/scm/lib/scm/scm_commits_mirror/commit.rb +26 -0
- data/plugins/scm/lib/scm/scm_commits_mirror/commits_node.rb +38 -0
- data/plugins/scm/plugin.rb +8 -0
- data/plugins/scm/spec/spec_helper.rb +5 -0
- data/plugins/scm_git/lib/scm_git.rb +543 -0
- data/plugins/scm_git/lib/scm_git/change.rb +137 -0
- data/plugins/scm_git/lib/scm_git/commit.rb +18 -0
- data/plugins/scm_git/lib/scm_git/config_file.rb +31 -0
- data/plugins/scm_git/plugin.rb +7 -0
- data/plugins/scm_hg/lib/scm_hg.rb +30 -0
- data/plugins/scm_hg/plugin.rb +7 -0
- data/plugins/scm_svn/LICENSE +48 -0
- data/plugins/scm_svn/features/add_and_commit.feature +18 -0
- data/plugins/scm_svn/features/checkout.feature +5 -0
- data/plugins/scm_svn/features/edit_and_index.feature +12 -0
- data/plugins/scm_svn/features/ignore_files.feature +14 -0
- data/plugins/scm_svn/features/merge.feature +34 -0
- data/plugins/scm_svn/features/resolve_conflict.feature +23 -0
- data/plugins/scm_svn/features/revert_and_delete.feature +21 -0
- data/plugins/scm_svn/features/step_definitions/branch_and_merge_steps.rb +27 -0
- data/plugins/scm_svn/features/step_definitions/checkout_steps.rb +25 -0
- data/plugins/scm_svn/features/step_definitions/edit_and_index_steps.rb +50 -0
- data/plugins/scm_svn/features/step_definitions/scm_svn_steps.rb +57 -0
- data/plugins/scm_svn/features/support/env.rb +71 -0
- data/plugins/scm_svn/features/switch_branches.feature +53 -0
- data/plugins/scm_svn/features/update.feature +16 -0
- data/plugins/scm_svn/lib/scm_svn.rb +445 -0
- data/plugins/scm_svn/lib/scm_svn/change.rb +116 -0
- data/plugins/scm_svn/plugin.rb +7 -0
- data/plugins/snippets/features/snippet_indenting.feature +87 -0
- data/plugins/snippets/features/snippets.feature +398 -0
- data/plugins/snippets/features/step_definitions/snippet_steps.rb +16 -0
- data/plugins/snippets/features/support/env.rb +1 -0
- data/plugins/snippets/lib/snippets.rb +111 -0
- data/plugins/snippets/lib/snippets/document_controller.rb +591 -0
- data/plugins/snippets/lib/snippets/explorer.rb +48 -0
- data/plugins/snippets/lib/snippets/tab_handler.rb +117 -0
- data/plugins/snippets/plugin.rb +9 -0
- data/plugins/splash_screen/plugin.rb +8 -0
- data/plugins/splash_screen/splash_screen.rb +62 -0
- data/plugins/strip_trailing_spaces/features/fixtures/test.txt +3 -0
- data/plugins/strip_trailing_spaces/features/strip_trailing_spaces.feature +34 -0
- data/plugins/strip_trailing_spaces/lib/strip_trailing_spaces.rb +60 -0
- data/plugins/strip_trailing_spaces/plugin.rb +8 -0
- data/plugins/syntax_check/README +6 -0
- data/plugins/syntax_check/features/step_definitions/syntax_check_steps.rb +11 -0
- data/plugins/syntax_check/features/support/env.rb +3 -0
- data/plugins/syntax_check/lib/syntax_check.rb +100 -0
- data/plugins/syntax_check/lib/syntax_check/annotation.rb +61 -0
- data/plugins/syntax_check/lib/syntax_check/checker.rb +47 -0
- data/plugins/syntax_check/lib/syntax_check/error.rb +24 -0
- data/plugins/syntax_check/plugin.rb +7 -0
- data/plugins/task_manager/lib/task_manager.rb +30 -0
- data/plugins/task_manager/plugin.rb +11 -0
- data/plugins/task_manager/views/index.html.erb +70 -0
- data/plugins/test_runner/lib/test_runner.rb +40 -0
- data/plugins/test_runner/lib/test_runner/jasmine_test_runner.rb +15 -0
- data/plugins/test_runner/lib/test_runner/rspec_runner.rb +20 -0
- data/plugins/test_runner/lib/test_runner/run_test_command.rb +63 -0
- data/plugins/test_runner/lib/test_runner/runnable_test_runner.rb +42 -0
- data/plugins/test_runner/plugin.rb +8 -0
- data/plugins/test_runner/spec/run_test_command_spec.rb +51 -0
- data/plugins/test_runner/spec/spec_helper.rb +5 -0
- data/plugins/textmate/features/bundle_tree.feature +23 -0
- data/plugins/textmate/features/step_definitions/tree_steps.rb +57 -0
- data/plugins/textmate/features/support/env.rb +19 -0
- data/plugins/textmate/features/support/test_bundle.tmbundle/Snippets/If.tmSnippet +18 -0
- data/plugins/textmate/features/support/test_bundle.tmbundle/Snippets/If__Else.tmSnippet +20 -0
- data/plugins/textmate/features/support/test_bundle.tmbundle/Snippets/Include.tmSnippet +16 -0
- data/plugins/textmate/features/support/test_bundle.tmbundle/Snippets/Loop.tmSnippet +18 -0
- data/plugins/textmate/features/support/test_bundle.tmbundle/Snippets/Unless.tmSnippet +18 -0
- data/plugins/textmate/features/support/test_bundle.tmbundle/Snippets/Var.tmSnippet +16 -0
- data/plugins/textmate/features/support/test_bundle.tmbundle/Snippets/next_If__Else.tmSnippet +20 -0
- data/plugins/textmate/features/support/test_bundle.tmbundle/info.plist +26 -0
- data/plugins/textmate/lib/textmate.rb +202 -0
- data/plugins/textmate/lib/textmate/bundle.rb +100 -0
- data/plugins/textmate/lib/textmate/commands.rb +79 -0
- data/plugins/textmate/lib/textmate/environment.rb +76 -0
- data/plugins/textmate/lib/textmate/plist.rb +80 -0
- data/plugins/textmate/lib/textmate/preference.rb +125 -0
- data/plugins/textmate/lib/textmate/snippet.rb +47 -0
- data/plugins/textmate/lib/textmate/tree_mirror.rb +206 -0
- data/plugins/textmate/plugin.rb +8 -0
- data/plugins/textmate/views/installed_bundles.html.erb +24 -0
- data/plugins/todo_list/README.md +22 -0
- data/plugins/todo_list/features/support/env.rb +8 -0
- data/plugins/todo_list/features/todo_list.feature +26 -0
- data/plugins/todo_list/lib/todo_list.rb +49 -0
- data/plugins/todo_list/lib/todo_list/file_parser.rb +58 -0
- data/plugins/todo_list/lib/todo_list/todo_controller.rb +99 -0
- data/plugins/todo_list/plugin.rb +11 -0
- data/plugins/todo_list/spec/fixtures/project/FIXME.file +3 -0
- data/plugins/todo_list/spec/fixtures/project/NOTE.ignored.file +1 -0
- data/plugins/todo_list/spec/fixtures/project/OPTIMIZE_colon.file +1 -0
- data/plugins/todo_list/spec/fixtures/project/XXX.ignored +1 -0
- data/plugins/todo_list/spec/fixtures/project/ignored_directory/TODO.file +2 -0
- data/plugins/todo_list/spec/fixtures/settings.rb +11 -0
- data/plugins/todo_list/spec/spec_helper.rb +6 -0
- data/plugins/todo_list/spec/todo_list/file_parser_spec.rb +35 -0
- data/plugins/todo_list/views/default.css +15 -0
- data/plugins/todo_list/views/index.html.erb +19 -0
- data/plugins/todo_list/views/redcar_small_icon.png +0 -0
- data/plugins/tree_view_swt/lib/tree_view_swt.rb +496 -0
- data/plugins/tree_view_swt/plugin.rb +9 -0
- data/plugins/web_bookmarks/Screenshot.png +0 -0
- data/plugins/web_bookmarks/features/bookmark.feature +37 -0
- data/plugins/web_bookmarks/features/fixtures/other.html +1 -0
- data/plugins/web_bookmarks/features/fixtures/sample.html +1 -0
- data/plugins/web_bookmarks/features/step_definitions/web_steps.rb +4 -0
- data/plugins/web_bookmarks/features/support/env.rb +26 -0
- data/plugins/web_bookmarks/lib/web_bookmarks.rb +49 -0
- data/plugins/web_bookmarks/lib/web_bookmarks/bookmark.rb +52 -0
- data/plugins/web_bookmarks/lib/web_bookmarks/commands.rb +65 -0
- data/plugins/web_bookmarks/lib/web_bookmarks/tree.rb +74 -0
- data/plugins/web_bookmarks/plugin.rb +10 -0
- metadata +937 -0
@@ -0,0 +1,224 @@
|
|
1
|
+
|
2
|
+
module Redcar
|
3
|
+
class EditViewSWT
|
4
|
+
class Document
|
5
|
+
include Redcar::Observable
|
6
|
+
attr_reader :jface_document
|
7
|
+
|
8
|
+
def initialize(model, swt_mate_document)
|
9
|
+
@model = model
|
10
|
+
@swt_mate_document = swt_mate_document
|
11
|
+
@jface_document = swt_mate_document.mateText.get_document
|
12
|
+
end
|
13
|
+
|
14
|
+
def right_click(edit_view)
|
15
|
+
menu = Menu.new
|
16
|
+
Redcar.plugin_manager.objects_implementing(:edit_view_context_menus).each do |object|
|
17
|
+
case object.method(:edit_view_context_menus).arity
|
18
|
+
when 0
|
19
|
+
menu.merge(object.edit_view_context_menus)
|
20
|
+
when 1
|
21
|
+
menu.merge(object.edit_view_context_menus(edit_view))
|
22
|
+
else
|
23
|
+
puts("Invalid edit_view_context_menus hook detected in "+object.class.name)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
Application::Dialog.popup_menu(menu, :pointer)
|
27
|
+
end
|
28
|
+
|
29
|
+
def attach_modification_listeners
|
30
|
+
jface_document.add_document_listener(DocumentListener.new(@model))
|
31
|
+
styledText.add_selection_listener(SelectionListener.new(@model))
|
32
|
+
styledText.add_caret_listener(CaretListener.new(@model))
|
33
|
+
end
|
34
|
+
|
35
|
+
def single_line?
|
36
|
+
@swt_mate_document.mateText.isSingleLine
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_s
|
40
|
+
jface_document.get
|
41
|
+
end
|
42
|
+
|
43
|
+
def length
|
44
|
+
jface_document.length
|
45
|
+
end
|
46
|
+
|
47
|
+
def line_count
|
48
|
+
jface_document.get_number_of_lines
|
49
|
+
end
|
50
|
+
|
51
|
+
def get_line_delimiter
|
52
|
+
styledText.get_line_delimiter
|
53
|
+
end
|
54
|
+
|
55
|
+
def line_at_offset(offset)
|
56
|
+
jface_document.get_line_of_offset(offset)
|
57
|
+
end
|
58
|
+
|
59
|
+
def offset_at_line(line_ix)
|
60
|
+
line_ix = [line_ix, line_count - 1].min
|
61
|
+
jface_document.get_line_offset(line_ix)
|
62
|
+
end
|
63
|
+
|
64
|
+
def get_line(line_ix)
|
65
|
+
line_info = jface_document.get_line_information(line_ix)
|
66
|
+
jface_document.get(line_info.offset, line_info.length)
|
67
|
+
end
|
68
|
+
|
69
|
+
def get_range(start, length)
|
70
|
+
jface_document.get(start, length)
|
71
|
+
end
|
72
|
+
|
73
|
+
def replace(offset, length, text)
|
74
|
+
@model.verify_text(offset, offset+length, text)
|
75
|
+
jface_document.replace(offset, length, text)
|
76
|
+
@model.modify_text
|
77
|
+
end
|
78
|
+
|
79
|
+
def text=(text)
|
80
|
+
@model.verify_text(0, length, text)
|
81
|
+
top_pixel = styledText.getTopPixel
|
82
|
+
caret = cursor_offset
|
83
|
+
line = line_at_offset(caret)
|
84
|
+
caret = caret - offset_at_line(line)
|
85
|
+
|
86
|
+
styledText.setRedraw(false)
|
87
|
+
styledText.setText(text)
|
88
|
+
|
89
|
+
unless line > line_count - 1
|
90
|
+
# The documents new text is still longer than our previous position, restore position
|
91
|
+
line_offset = offset_at_line(line)
|
92
|
+
styledText.setCaretOffset([line_offset + caret, offset_at_line(line + 1) - 1].min)
|
93
|
+
styledText.setTopPixel(top_pixel)
|
94
|
+
end
|
95
|
+
|
96
|
+
styledText.setRedraw(true)
|
97
|
+
@model.modify_text
|
98
|
+
notify_listeners(:set_text)
|
99
|
+
end
|
100
|
+
|
101
|
+
def cursor_offset
|
102
|
+
styledText.get_caret_offset
|
103
|
+
end
|
104
|
+
|
105
|
+
def selection_offset
|
106
|
+
range = styledText.get_selection_range
|
107
|
+
range.x == cursor_offset ? range.x + range.y : range.x
|
108
|
+
end
|
109
|
+
|
110
|
+
def cursor_offset=(offset)
|
111
|
+
styledText.set_caret_offset(offset)
|
112
|
+
end
|
113
|
+
|
114
|
+
def selection_range
|
115
|
+
range = styledText.get_selection_range
|
116
|
+
range.x...(range.x + range.y)
|
117
|
+
end
|
118
|
+
|
119
|
+
def selection_ranges
|
120
|
+
ranges = styledText.get_selection_ranges
|
121
|
+
ranges.to_a.each_slice(2).map do |from, length|
|
122
|
+
from...(from + length)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def set_selection_range(cursor_offset, selection_offset)
|
127
|
+
if block_selection_mode?
|
128
|
+
start_offset, end_offset = *[cursor_offset, selection_offset].sort
|
129
|
+
start_location = styledText.getLocationAtOffset(start_offset)
|
130
|
+
end_location = styledText.getLocationAtOffset(end_offset)
|
131
|
+
styledText.set_block_selection_bounds(
|
132
|
+
start_location.x,
|
133
|
+
start_location.y,
|
134
|
+
end_location.x - start_location.x,
|
135
|
+
end_location.y - start_location.y + styledText.get_line_height
|
136
|
+
)
|
137
|
+
else
|
138
|
+
styledText.set_selection_range(selection_offset, cursor_offset - selection_offset)
|
139
|
+
end
|
140
|
+
@model.selection_range_changed(cursor_offset, selection_offset)
|
141
|
+
end
|
142
|
+
|
143
|
+
@markStruct ||= Struct.new(:location, :category) # save away the parent class
|
144
|
+
class Mark < @markStruct
|
145
|
+
def get_offset; location.get_offset; end
|
146
|
+
def get_line; location.get_line; end
|
147
|
+
def get_line_offset; location.get_line_offset; end
|
148
|
+
def inspect; "<Mark #{get_line}:#{get_line_offset} (#{get_offset})>"; end
|
149
|
+
end
|
150
|
+
|
151
|
+
def create_mark(offset, gravity)
|
152
|
+
line = line_at_offset(offset)
|
153
|
+
line_offset = offset - offset_at_line(line)
|
154
|
+
case gravity
|
155
|
+
when :left
|
156
|
+
category = "lefts"
|
157
|
+
when :right
|
158
|
+
category = "rights"
|
159
|
+
end
|
160
|
+
location = @swt_mate_document.get_text_location(line, line_offset)
|
161
|
+
@swt_mate_document.add_text_location(category, location)
|
162
|
+
Mark.new(location, category)
|
163
|
+
end
|
164
|
+
|
165
|
+
def delete_mark(mark)
|
166
|
+
@swt_mate_document.remove_text_location(mark.category, mark.location)
|
167
|
+
end
|
168
|
+
|
169
|
+
def block_selection_mode?
|
170
|
+
styledText.get_block_selection
|
171
|
+
end
|
172
|
+
|
173
|
+
def block_selection_mode=(bool)
|
174
|
+
styledText.set_block_selection(bool)
|
175
|
+
end
|
176
|
+
|
177
|
+
def styledText
|
178
|
+
@swt_mate_document.mateText.getControl
|
179
|
+
end
|
180
|
+
|
181
|
+
def scope_at(line, line_offset)
|
182
|
+
@swt_mate_document.mateText.scope_at(line, line_offset)
|
183
|
+
end
|
184
|
+
|
185
|
+
class CaretListener
|
186
|
+
def initialize(model)
|
187
|
+
@model = model
|
188
|
+
end
|
189
|
+
|
190
|
+
def caret_moved(event)
|
191
|
+
@model.cursor_moved(event.caretOffset)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
class SelectionListener
|
196
|
+
def initialize(model)
|
197
|
+
@model = model
|
198
|
+
end
|
199
|
+
|
200
|
+
def widget_default_selected(e)
|
201
|
+
@model.selection_range_changed(e.x, e.y)
|
202
|
+
end
|
203
|
+
|
204
|
+
def widget_selected(e)
|
205
|
+
@model.selection_range_changed(e.x, e.y)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
class DocumentListener
|
210
|
+
def initialize(model)
|
211
|
+
@model = model
|
212
|
+
end
|
213
|
+
|
214
|
+
def document_about_to_be_changed(e)
|
215
|
+
@model.about_to_be_changed(e.offset, e.length, e.text)
|
216
|
+
end
|
217
|
+
|
218
|
+
def document_changed(e)
|
219
|
+
@model.changed(e.offset, e.length, e.text)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Redcar
|
2
|
+
class EditViewSWT
|
3
|
+
class Tab < ApplicationSWT::Tab
|
4
|
+
include Redcar::Observable
|
5
|
+
|
6
|
+
attr_reader :item, :edit_view
|
7
|
+
|
8
|
+
def initialize(*args)
|
9
|
+
super
|
10
|
+
@model.add_listener(:changed_title) { |title| @item.text = title }
|
11
|
+
end
|
12
|
+
|
13
|
+
# Focuses the CTabItem within the CTabFolder, and gives the keyboard
|
14
|
+
# focus to the EditViewSWT.
|
15
|
+
def focus
|
16
|
+
super
|
17
|
+
edit_view.focus
|
18
|
+
end
|
19
|
+
|
20
|
+
# Close the EditTab, disposing of any resources along the way.
|
21
|
+
def close
|
22
|
+
@edit_view.dispose
|
23
|
+
@widget.dispose
|
24
|
+
super
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def create_tab_widget
|
30
|
+
@widget = Swt::Widgets::Composite.new(notebook.tab_folder, Swt::SWT::NONE)
|
31
|
+
layout = Swt::Layout::GridLayout.new(1, false)
|
32
|
+
layout.verticalSpacing = 0
|
33
|
+
layout.marginHeight = 0
|
34
|
+
layout.horizontalSpacing = 0
|
35
|
+
layout.marginWidth = 0
|
36
|
+
@widget.layout = layout
|
37
|
+
@edit_view = EditViewSWT.new(model.edit_view, @widget)
|
38
|
+
|
39
|
+
grid_data = Swt::Layout::GridData.new(
|
40
|
+
Swt::Layout::GridData::FILL_BOTH |
|
41
|
+
Swt::Layout::GridData::VERTICAL_ALIGN_FILL |
|
42
|
+
Swt::Layout::GridData::HORIZONTAL_ALIGN_FILL)
|
43
|
+
@edit_view.mate_text.get_control.parent.set_layout_data(grid_data)
|
44
|
+
|
45
|
+
@item.control = @widget
|
46
|
+
@widget.pack
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
|
2
|
+
module Redcar
|
3
|
+
class EditViewSWT
|
4
|
+
class WordMoveListener
|
5
|
+
MOVE_FORWARD_RE = /\s{3,}|[^\w]{2,}|(\s|[^\w])?\w+/
|
6
|
+
|
7
|
+
def initialize(controller)
|
8
|
+
@controller = controller
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_next_offset(e)
|
12
|
+
if [Swt::SWT::MOVEMENT_WORD, Swt::SWT::MOVEMENT_WORD_END].include? e.movement
|
13
|
+
e.newOffset = next_offset(e.offset, e.lineOffset, e.lineText)
|
14
|
+
# SWT gets pissy without this:
|
15
|
+
if e.newOffset == e.lineOffset + e.lineText.chars.length + 1
|
16
|
+
e.newOffset += 1
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def next_offset(chars_offset, chars_line_offset, line_text)
|
22
|
+
if chars_offset == chars_line_offset + line_text.chars.length
|
23
|
+
chars_offset + 1
|
24
|
+
else
|
25
|
+
future_text = line_text.chars[(chars_offset - chars_line_offset)..-1].to_s
|
26
|
+
if future_text == nil or future_text == ""
|
27
|
+
chars_line_offset + line_text.chars.length
|
28
|
+
else
|
29
|
+
if md = future_text.match(MOVE_FORWARD_RE)
|
30
|
+
chars_match_end = future_text.byte_offset_to_char_offset(md.end(0))
|
31
|
+
chars_offset + chars_match_end
|
32
|
+
else
|
33
|
+
chars_line_offset + line_text.chars.length
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def get_previous_offset(e)
|
40
|
+
if [Swt::SWT::MOVEMENT_WORD, Swt::SWT::MOVEMENT_WORD_START].include? e.movement
|
41
|
+
e.newOffset = previous_offset(e.offset, e.lineOffset, e.lineText)
|
42
|
+
# SWT gets pissy without this:
|
43
|
+
if e.newOffset == e.lineOffset - 1
|
44
|
+
e.newOffset -= 1
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def previous_offset(chars_offset, chars_line_offset, line_text)
|
50
|
+
if chars_offset == chars_line_offset
|
51
|
+
chars_offset - 1
|
52
|
+
else
|
53
|
+
future_text = line_text.chars[0..(chars_offset - chars_line_offset - 1)].reverse.to_s
|
54
|
+
if future_text == nil or future_text == ""
|
55
|
+
chars_line_offset
|
56
|
+
else
|
57
|
+
if md = future_text.match(MOVE_FORWARD_RE)
|
58
|
+
chars_match_end = future_text.byte_offset_to_char_offset(md.end(0))
|
59
|
+
chars_offset - chars_match_end
|
60
|
+
else
|
61
|
+
chars_line_offset
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "spec_helper")
|
2
|
+
|
3
|
+
describe Redcar::EditViewSWT::WordMoveListener do
|
4
|
+
before do
|
5
|
+
@word = Redcar::EditViewSWT::WordMoveListener.new(nil)
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "moving forwards" do
|
9
|
+
it "should move over a word to the next non-word char" do
|
10
|
+
@word.next_offset(0, 0, "foo.bar").should == 3
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should move over a symbol and a word to the next non-word char" do
|
14
|
+
@word.next_offset(0, 0, ".foo.bar").should == 4
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should move over multiple symbols to the next word" do
|
18
|
+
@word.next_offset(0, 0, "..foo.bar").should == 2
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should move over a space and the next word " do
|
22
|
+
@word.next_offset(0, 0, " foo.bar").should == 4
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should move over multiple spaces to the next word " do
|
26
|
+
@word.next_offset(0, 0, " foo.bar").should == 2
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Encryption
|
4
|
+
def self.encrypt(text, password)
|
5
|
+
EncryptionTools.encrypt_and_armour(text, password)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.decrypt(text, password)
|
9
|
+
EncryptionTools.dearmour_and_decrypt(text, password)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.menus
|
13
|
+
Redcar::Menu::Builder.build do
|
14
|
+
sub_menu "Plugins" do
|
15
|
+
sub_menu "Encryption", :priority => 55 do
|
16
|
+
item "Encrypt Document", EncryptDocumentCommand
|
17
|
+
item "Decrypt Document", DecryptDocumentCommand
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.lazy_load
|
24
|
+
require File.dirname(__FILE__) + "/jarmor-1.1"
|
25
|
+
require File.dirname(__FILE__) + "/ezcrypto"
|
26
|
+
end
|
27
|
+
|
28
|
+
class DecryptDocumentCommand < Redcar::EditTabCommand
|
29
|
+
def execute
|
30
|
+
Encryption.lazy_load
|
31
|
+
result = Redcar::Application::Dialog.input("Password", "Enter password")
|
32
|
+
return if result[:button] == :cancel
|
33
|
+
pw = result[:value]
|
34
|
+
begin
|
35
|
+
doc.text = Encryption.decrypt(doc.to_s, pw)
|
36
|
+
rescue => e
|
37
|
+
Redcar::Application::Dialog.message_box("Couldn't decrypt!", :type => :error)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class EncryptDocumentCommand < Redcar::EditTabCommand
|
43
|
+
def execute
|
44
|
+
Encryption.lazy_load
|
45
|
+
result = Redcar::Application::Dialog.input("Password", "Enter password")
|
46
|
+
return if result[:button] == :cancel
|
47
|
+
pw = result[:value]
|
48
|
+
doc.text = Encryption.encrypt(doc.to_s, pw)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
@@ -0,0 +1,652 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
require 'digest/sha2'
|
3
|
+
require 'digest/sha1'
|
4
|
+
require 'base64'
|
5
|
+
|
6
|
+
class EncryptionTools
|
7
|
+
def self.dearmour_and_decrypt(data, pw)
|
8
|
+
encrypted = EncryptionTools.dearmour(data.gsub("\n", ""))
|
9
|
+
EncryptionTools.decrypt(encrypted, pw)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.encrypt_and_armour(data, pw)
|
13
|
+
encrypted = EncryptionTools.encrypt(data, pw)
|
14
|
+
"\n" + EncryptionTools.armour(encrypted)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.dearmour(data)
|
18
|
+
stream = java.io.ByteArrayInputStream.new(java.lang.String.new(data).getBytes)
|
19
|
+
armour = org.spaceroots.jarmor.Base64Decoder.new(stream)
|
20
|
+
encrypted = ""
|
21
|
+
while (byte = armour.read) != -1
|
22
|
+
encrypted << byte
|
23
|
+
end
|
24
|
+
armour.close
|
25
|
+
encrypted
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.decrypt(data, pw)
|
29
|
+
key = EzCrypto::Key.with_password pw, "system salt"
|
30
|
+
key.decrypt(data)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.encrypt(data, pw)
|
34
|
+
key = EzCrypto::Key.with_password pw, "system salt"
|
35
|
+
key.encrypt(data)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.armour(data)
|
39
|
+
stream = java.io.ByteArrayOutputStream.new
|
40
|
+
armour = org.spaceroots.jarmor.Base64Encoder.new(stream, 80, java.lang.String.new("").getBytes, java.lang.String.new("\n").getBytes)
|
41
|
+
data.each_byte {|byte| armour.write(byte) }
|
42
|
+
armour.close
|
43
|
+
stream.toString
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
module EzCrypto #:nodoc:
|
48
|
+
|
49
|
+
=begin rdoc
|
50
|
+
The Key is the only class you need to understand for simple use.
|
51
|
+
|
52
|
+
=== Algorithms
|
53
|
+
|
54
|
+
The crypto algorithms default to aes-128-cbc however on any of the class methods you can change it to one of the standard openssl cipher names using the
|
55
|
+
optional <tt>:algorithm=>alg name</tt> parameter.
|
56
|
+
|
57
|
+
Eg.
|
58
|
+
Key.new @raw, :algorithm=>"des"
|
59
|
+
Key.generate :algorithm=>"blowfish"
|
60
|
+
Key.with_password @pwd,@salt,:algorithm=>"aes256"
|
61
|
+
|
62
|
+
|
63
|
+
== License
|
64
|
+
|
65
|
+
ActiveCrypto and EzCrypto are released under the MIT license.
|
66
|
+
|
67
|
+
|
68
|
+
== Support
|
69
|
+
|
70
|
+
To contact the author, send mail to pelleb@gmail.com
|
71
|
+
|
72
|
+
Also see my blogs at:
|
73
|
+
http://stakeventures.com and
|
74
|
+
http://neubia.com
|
75
|
+
|
76
|
+
This project was based on code used in my project StakeItOut, where you can securely share web services with your partners.
|
77
|
+
https://stakeitout.com
|
78
|
+
|
79
|
+
(C) 2005 Pelle Braendgaard
|
80
|
+
|
81
|
+
=end
|
82
|
+
|
83
|
+
class Key
|
84
|
+
|
85
|
+
attr_reader :raw, :algorithm
|
86
|
+
|
87
|
+
@@block_size = 512
|
88
|
+
|
89
|
+
=begin rdoc
|
90
|
+
Set the block-size for IO-operations (default: 512 bytes)
|
91
|
+
=end
|
92
|
+
def self.block_size=(size)
|
93
|
+
@@block_size = size
|
94
|
+
end
|
95
|
+
|
96
|
+
=begin rdoc
|
97
|
+
Return the block-size for IO-operations.
|
98
|
+
=end
|
99
|
+
def self.block_size
|
100
|
+
@@block_size
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
=begin rdoc
|
105
|
+
Initialize the key with raw unencoded binary key data. This needs to be at least
|
106
|
+
16 bytes long for the default aes-128 algorithm.
|
107
|
+
=end
|
108
|
+
def initialize(raw,options = {})
|
109
|
+
@raw=raw
|
110
|
+
@algorithm=options[:algorithm]||"aes-128-cbc"
|
111
|
+
end
|
112
|
+
|
113
|
+
=begin rdoc
|
114
|
+
Generate random key.
|
115
|
+
=end
|
116
|
+
def self.generate(options = {})
|
117
|
+
Key.new(EzCrypto::Digester.generate_key(calculate_key_size(options[:algorithm])),options)
|
118
|
+
end
|
119
|
+
|
120
|
+
=begin rdoc
|
121
|
+
Create key generated from the given password and salt
|
122
|
+
=end
|
123
|
+
def self.with_password(password,salt,options = {})
|
124
|
+
Key.new(EzCrypto::Digester.get_key(password,salt,calculate_key_size(options[:algorithm])),options)
|
125
|
+
end
|
126
|
+
|
127
|
+
=begin rdoc
|
128
|
+
Initialize the key with Base64 encoded key data.
|
129
|
+
=end
|
130
|
+
def self.decode(encoded,options = {})
|
131
|
+
Key.new(Base64.decode64(encoded),options)
|
132
|
+
end
|
133
|
+
|
134
|
+
=begin rdoc
|
135
|
+
Encrypts the data with the given password and a salt. Short hand for:
|
136
|
+
|
137
|
+
key=Key.with_password(password,salt,options)
|
138
|
+
key.encrypt(data)
|
139
|
+
|
140
|
+
=end
|
141
|
+
def self.encrypt_with_password(password,salt,data,options = {})
|
142
|
+
key=Key.with_password(password,salt,options)
|
143
|
+
key.encrypt(data)
|
144
|
+
end
|
145
|
+
|
146
|
+
=begin rdoc
|
147
|
+
Decrypts the data with the given password and a salt. Short hand for:
|
148
|
+
|
149
|
+
key=Key.with_password(password,salt,options)
|
150
|
+
key.decrypt(data)
|
151
|
+
|
152
|
+
|
153
|
+
=end
|
154
|
+
def self.decrypt_with_password(password,salt,data,options = {})
|
155
|
+
key=Key.with_password(password,salt,options)
|
156
|
+
key.decrypt(data)
|
157
|
+
end
|
158
|
+
|
159
|
+
=begin rdoc
|
160
|
+
Given an algorithm this calculates the keysize. This is used by both
|
161
|
+
the generate and with_password methods. This is not yet 100% complete.
|
162
|
+
=end
|
163
|
+
def self.calculate_key_size(algorithm)
|
164
|
+
if !algorithm.nil?
|
165
|
+
algorithm=~/^([[:alnum:]]+)(-(\d+))?/
|
166
|
+
if $3
|
167
|
+
size=($3.to_i)/8
|
168
|
+
else
|
169
|
+
case $1
|
170
|
+
when "bf"
|
171
|
+
size = 16
|
172
|
+
when "blowfish"
|
173
|
+
size = 16
|
174
|
+
when "des"
|
175
|
+
size = 8
|
176
|
+
when "des3"
|
177
|
+
size = 24
|
178
|
+
when "aes128"
|
179
|
+
size = 16
|
180
|
+
when "aes192"
|
181
|
+
size = 24
|
182
|
+
when "aes256"
|
183
|
+
size = 32
|
184
|
+
when "rc2"
|
185
|
+
size = 16
|
186
|
+
when "rc4"
|
187
|
+
size = 16
|
188
|
+
else
|
189
|
+
size = 16
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
if size.nil?
|
194
|
+
size = 16
|
195
|
+
end
|
196
|
+
|
197
|
+
size
|
198
|
+
end
|
199
|
+
|
200
|
+
=begin rdoc
|
201
|
+
returns the Base64 encoded key.
|
202
|
+
=end
|
203
|
+
def encode
|
204
|
+
Base64.encode64(@raw).chop
|
205
|
+
end
|
206
|
+
|
207
|
+
=begin rdoc
|
208
|
+
returns the Base64 encoded key. Synonym for encode.
|
209
|
+
=end
|
210
|
+
def to_s
|
211
|
+
encode
|
212
|
+
end
|
213
|
+
|
214
|
+
=begin rdoc
|
215
|
+
Encrypts the data and returns it in encrypted binary form.
|
216
|
+
=end
|
217
|
+
def encrypt(data)
|
218
|
+
if data==nil || data==""
|
219
|
+
nil
|
220
|
+
else
|
221
|
+
encrypter("")
|
222
|
+
@cipher.encrypt(data)
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
=begin rdoc
|
227
|
+
Encrypts the data and returns it in encrypted Base64 encoded form.
|
228
|
+
=end
|
229
|
+
def encrypt64(data)
|
230
|
+
Base64.encode64(encrypt(data))
|
231
|
+
end
|
232
|
+
|
233
|
+
=begin rdoc
|
234
|
+
Decrypts the data passed to it in binary format.
|
235
|
+
=end
|
236
|
+
def decrypt(data)
|
237
|
+
if data==nil || data==""
|
238
|
+
nil
|
239
|
+
else
|
240
|
+
decrypter("")
|
241
|
+
@cipher.gulp(data)
|
242
|
+
end
|
243
|
+
# rescue
|
244
|
+
# puts @algorithm
|
245
|
+
# puts self.encode
|
246
|
+
# puts data.size
|
247
|
+
# throw $!
|
248
|
+
end
|
249
|
+
|
250
|
+
=begin rdoc
|
251
|
+
Decrypts a Base64 formatted string
|
252
|
+
=end
|
253
|
+
def decrypt64(data)
|
254
|
+
decrypt(Base64.decode64(data))
|
255
|
+
end
|
256
|
+
|
257
|
+
=begin rdoc
|
258
|
+
Allows keys to be marshalled
|
259
|
+
=end
|
260
|
+
def marshal_dump
|
261
|
+
"#{self.algorithm}$$$#{self.encode}"
|
262
|
+
end
|
263
|
+
|
264
|
+
=begin rdoc
|
265
|
+
Allows keys to be unmarshalled
|
266
|
+
=end
|
267
|
+
def marshal_load(s)
|
268
|
+
a, r = s.split '$$$'
|
269
|
+
@algorithm = a
|
270
|
+
@raw = Base64.decode64(r)
|
271
|
+
end
|
272
|
+
|
273
|
+
=begin rdoc
|
274
|
+
Create a file with minimal permissions, and yield
|
275
|
+
it to a block. By default only the owner may read it.
|
276
|
+
=end
|
277
|
+
def safe_create(file, mod=0400, mask=0066)
|
278
|
+
begin
|
279
|
+
old_umask = File.umask
|
280
|
+
File.umask(mask)
|
281
|
+
File.open(file, File::CREAT | File::EXCL | File::WRONLY) do |f|
|
282
|
+
yield(f) if block_given?
|
283
|
+
end
|
284
|
+
ensure
|
285
|
+
File.umask(old_umask)
|
286
|
+
end
|
287
|
+
File.chmod(mod, file) if File.exists?(file)
|
288
|
+
File.size(file)
|
289
|
+
end
|
290
|
+
|
291
|
+
|
292
|
+
=begin rdoc
|
293
|
+
Overwrite a file with zero values before removing it's filesystem inode.
|
294
|
+
This is not very safe :-)
|
295
|
+
=end
|
296
|
+
def safe_delete(file)
|
297
|
+
begin
|
298
|
+
to_clear = File.size(file)
|
299
|
+
zeroes = Array.new(Key.block_size, "\0").join
|
300
|
+
File.chmod(0600, file)
|
301
|
+
File.open(file, File::WRONLY) do |f|
|
302
|
+
f.rewind
|
303
|
+
while to_clear > 0
|
304
|
+
f.write(zeroes)
|
305
|
+
to_clear -= Key.block_size
|
306
|
+
end
|
307
|
+
f.flush
|
308
|
+
end
|
309
|
+
ensure
|
310
|
+
File.delete(file) if File.exists?(file)
|
311
|
+
end
|
312
|
+
return !File.exists?(file)
|
313
|
+
end
|
314
|
+
|
315
|
+
|
316
|
+
=begin rdoc
|
317
|
+
Open a file readonly and yield it to a block.
|
318
|
+
=end
|
319
|
+
def safe_read(file)
|
320
|
+
File.open(file, File::RDONLY) do |i|
|
321
|
+
yield(i) if block_given?
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
private :safe_create, :safe_read, :safe_delete
|
326
|
+
|
327
|
+
=begin rdoc
|
328
|
+
Load a key from a yaml_file generated via Key#store.
|
329
|
+
=end
|
330
|
+
def self.load(filename)
|
331
|
+
require 'yaml'
|
332
|
+
hash = YAML::load_file(filename)
|
333
|
+
req = proc { |k| hash[k] or raise "Missing element #{k} in #{filename}" }
|
334
|
+
key = self.new Base64.decode64(req.call(:key)) , :algorithm => req.call(:algorithm)
|
335
|
+
return key
|
336
|
+
end
|
337
|
+
|
338
|
+
|
339
|
+
=begin rdoc
|
340
|
+
Save the key data into a file, try to do this in a secure manner.
|
341
|
+
NOTE: YAML::store & friends are not used to encance control over
|
342
|
+
the generated file format.
|
343
|
+
=end
|
344
|
+
def store(filename)
|
345
|
+
safe_create(filename) do |f|
|
346
|
+
selfenc = self.encode
|
347
|
+
f.puts "---"
|
348
|
+
f.puts ":EZCRYPTO KEY FILE: KEEP THIS SECURE !"
|
349
|
+
f.puts ":created: #{Time.now}"
|
350
|
+
f.puts ":algorithm: #{@algorithm}"
|
351
|
+
f.puts ":key: #{selfenc}"
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
355
|
+
|
356
|
+
=begin rdoc
|
357
|
+
Get a Encrypter object. You have to call #final on it by yourself!
|
358
|
+
=end
|
359
|
+
def encrypter(target='')
|
360
|
+
@cipher = EzCrypto::Encrypter.new(self,target,@algorithm)
|
361
|
+
end
|
362
|
+
|
363
|
+
|
364
|
+
=begin rdoc
|
365
|
+
Get a Decrypter object. You have to call #final on it by yourself!
|
366
|
+
=end
|
367
|
+
def decrypter(target='')
|
368
|
+
@cipher = EzCrypto::Decrypter.new(self,target,@algorithm)
|
369
|
+
end
|
370
|
+
|
371
|
+
=begin rdoc
|
372
|
+
Create a Decrypter object and yield it to a block.
|
373
|
+
You must *not* call #final by yourself, the method
|
374
|
+
does this.
|
375
|
+
=end
|
376
|
+
def on_decrypter(target='', &block)
|
377
|
+
decrypter(target)
|
378
|
+
on_cipher(&block)
|
379
|
+
end
|
380
|
+
|
381
|
+
=begin rdoc
|
382
|
+
Create an Encrypter object and yield it to a block.
|
383
|
+
You must *not* call #final by yourself, the method
|
384
|
+
does this.
|
385
|
+
=end
|
386
|
+
def on_encrypter(target='', &block)
|
387
|
+
encrypter(target)
|
388
|
+
on_cipher(&block)
|
389
|
+
end
|
390
|
+
|
391
|
+
|
392
|
+
=begin rdoc
|
393
|
+
Helper method, yields the current cipher to a block.
|
394
|
+
=end
|
395
|
+
def on_cipher(&block)
|
396
|
+
begin
|
397
|
+
block.call @cipher
|
398
|
+
ensure
|
399
|
+
@cipher.final
|
400
|
+
end
|
401
|
+
end
|
402
|
+
|
403
|
+
private :on_cipher
|
404
|
+
|
405
|
+
|
406
|
+
=begin rdoc
|
407
|
+
Encrypt a file 'inplace' and add a suffix
|
408
|
+
see #cipher_file.
|
409
|
+
IMPORTANT: The inputfile will be deleted by default.
|
410
|
+
=end
|
411
|
+
def encrypt_file(src, tgt=nil, options = {} )
|
412
|
+
options = { :suffix => '.ez', :autoclean => 'true' }.update(options)
|
413
|
+
tgt = "#{src}#{options[:suffix]}" unless tgt
|
414
|
+
cipher_file :on_encrypter, src, tgt, options[:autoclean]
|
415
|
+
end
|
416
|
+
|
417
|
+
|
418
|
+
=begin rdoc
|
419
|
+
Decrypt a file 'inplace' and remove a suffix
|
420
|
+
see #cipher_file
|
421
|
+
IMPORTANT: The inputfile will be deleted by default.
|
422
|
+
=end
|
423
|
+
def decrypt_file(src, tgt=nil, options = {} )
|
424
|
+
options = { :suffix => '.ez', :autoclean => 'true' }.update(options)
|
425
|
+
unless tgt
|
426
|
+
tgt = src
|
427
|
+
tgt = tgt.gsub(/#{options[:suffix]}$/, '')
|
428
|
+
end
|
429
|
+
cipher_file :on_decrypter, src, tgt, options[:autoclean]
|
430
|
+
end
|
431
|
+
|
432
|
+
|
433
|
+
=begin rdoc
|
434
|
+
uses either #on_decrypter or #on_encrypter to transform a given sourcefile
|
435
|
+
to a targetfile. the sourcefile is deleted after sucessful transformation
|
436
|
+
the delete_source is 'true'.
|
437
|
+
=end
|
438
|
+
def cipher_file(method, sourcefile, targetfile, delete_source)
|
439
|
+
raise(ArgumentError, "source == target #{sourcefile}") if sourcefile == targetfile
|
440
|
+
safe_create(targetfile,0600) do |o|
|
441
|
+
self.send(method, o) do |c|
|
442
|
+
safe_read(sourcefile) do |i|
|
443
|
+
loop do
|
444
|
+
buffer = i.read(Key.block_size) or break
|
445
|
+
c << buffer
|
446
|
+
end
|
447
|
+
end
|
448
|
+
end
|
449
|
+
end
|
450
|
+
safe_delete(sourcefile) if delete_source && File.exists?(targetfile)
|
451
|
+
return targetfile
|
452
|
+
end
|
453
|
+
|
454
|
+
private :cipher_file
|
455
|
+
|
456
|
+
end
|
457
|
+
|
458
|
+
=begin rdoc
|
459
|
+
Abstract Wrapper around OpenSSL's Cipher object. Extended by Encrypter and Decrypter.
|
460
|
+
|
461
|
+
You probably should be using the Key class instead.
|
462
|
+
|
463
|
+
Warning! The interface may change.
|
464
|
+
|
465
|
+
=end
|
466
|
+
class CipherWrapper #:nodoc:
|
467
|
+
|
468
|
+
=begin rdoc
|
469
|
+
|
470
|
+
=end
|
471
|
+
def initialize(key,target,mode,algorithm)
|
472
|
+
@cipher = OpenSSL::Cipher::Cipher.new(algorithm)
|
473
|
+
if mode
|
474
|
+
@cipher.encrypt
|
475
|
+
else
|
476
|
+
@cipher.decrypt
|
477
|
+
end
|
478
|
+
@cipher.key=key.raw
|
479
|
+
@cipher.padding=1
|
480
|
+
@target=target
|
481
|
+
@finished=false
|
482
|
+
end
|
483
|
+
|
484
|
+
|
485
|
+
def to_target(data)
|
486
|
+
return data
|
487
|
+
end
|
488
|
+
|
489
|
+
=begin rdoc
|
490
|
+
Process the givend data with the cipher.
|
491
|
+
=end
|
492
|
+
def update(data)
|
493
|
+
reset if @finished
|
494
|
+
@target<< to_target(@cipher.update(data))
|
495
|
+
end
|
496
|
+
|
497
|
+
=begin rdoc
|
498
|
+
|
499
|
+
=end
|
500
|
+
def <<(data)
|
501
|
+
update(data)
|
502
|
+
end
|
503
|
+
|
504
|
+
=begin rdoc
|
505
|
+
Finishes up any last bits of data in the cipher and returns the final result.
|
506
|
+
=end
|
507
|
+
def final
|
508
|
+
@target<< to_target(@cipher.final)
|
509
|
+
@finished=true
|
510
|
+
@target
|
511
|
+
end
|
512
|
+
|
513
|
+
=begin rdoc
|
514
|
+
Processes the entire data string using update and performs a final on it returning the data.
|
515
|
+
=end
|
516
|
+
def gulp(data)
|
517
|
+
update(data)
|
518
|
+
final
|
519
|
+
# rescue
|
520
|
+
# breakpoint
|
521
|
+
end
|
522
|
+
|
523
|
+
=begin rdoc
|
524
|
+
|
525
|
+
=end
|
526
|
+
def reset(target="")
|
527
|
+
@target=target
|
528
|
+
@finished=false
|
529
|
+
end
|
530
|
+
end
|
531
|
+
|
532
|
+
=begin rdoc
|
533
|
+
Wrapper around OpenSSL Cipher for Encryption use.
|
534
|
+
|
535
|
+
You probably should be using Key instead.
|
536
|
+
|
537
|
+
Warning! The interface may change.
|
538
|
+
|
539
|
+
=end
|
540
|
+
class Encrypter<EzCrypto::CipherWrapper #:nodoc:
|
541
|
+
|
542
|
+
=begin rdoc
|
543
|
+
|
544
|
+
=end
|
545
|
+
def initialize(key,target="",algorithm="aes-128-cbc")
|
546
|
+
super(key,target,true,algorithm)
|
547
|
+
end
|
548
|
+
|
549
|
+
=begin rdoc
|
550
|
+
|
551
|
+
=end
|
552
|
+
def encrypt(data)
|
553
|
+
gulp(data)
|
554
|
+
end
|
555
|
+
end
|
556
|
+
|
557
|
+
=begin rdoc
|
558
|
+
Wrapper around OpenSSL Cipher for Decryption use.
|
559
|
+
|
560
|
+
You probably should be using Key instead.
|
561
|
+
|
562
|
+
Warning! The interface may change.
|
563
|
+
=end
|
564
|
+
class Decrypter<EzCrypto::CipherWrapper #:nodoc:
|
565
|
+
=begin rdoc
|
566
|
+
|
567
|
+
=end
|
568
|
+
def initialize(key,target="",algorithm="aes-128-cbc")
|
569
|
+
super(key,target,false,algorithm)
|
570
|
+
end
|
571
|
+
|
572
|
+
=begin rdoc
|
573
|
+
|
574
|
+
=end
|
575
|
+
def decrypt(data)
|
576
|
+
gulp(data)
|
577
|
+
end
|
578
|
+
end
|
579
|
+
|
580
|
+
=begin rdoc
|
581
|
+
|
582
|
+
=end
|
583
|
+
class Digester
|
584
|
+
=begin rdoc
|
585
|
+
Various handy Digest methods.
|
586
|
+
|
587
|
+
Warning! The interface may change.
|
588
|
+
=end
|
589
|
+
def self.get_key(password,salt,size)
|
590
|
+
digest(salt+password,size)
|
591
|
+
end
|
592
|
+
|
593
|
+
=begin rdoc
|
594
|
+
|
595
|
+
=end
|
596
|
+
def self.generate_key(size=16)
|
597
|
+
key=OpenSSL::Random.random_bytes(size)
|
598
|
+
digest(key,size)
|
599
|
+
end
|
600
|
+
|
601
|
+
=begin rdoc
|
602
|
+
|
603
|
+
=end
|
604
|
+
def self.generate_key64(size=32)
|
605
|
+
key=OpenSSL::Random.random_bytes(size)
|
606
|
+
digest64(key,size)
|
607
|
+
end
|
608
|
+
=begin rdoc
|
609
|
+
|
610
|
+
=end
|
611
|
+
def self.generate_hexkey(size=40)
|
612
|
+
key=OpenSSL::Random.random_bytes(size)
|
613
|
+
hexdigest(key,size)
|
614
|
+
end
|
615
|
+
|
616
|
+
=begin rdoc
|
617
|
+
|
618
|
+
=end
|
619
|
+
def self.digest(data,size=16)
|
620
|
+
if size==0
|
621
|
+
""
|
622
|
+
elsif size<=16
|
623
|
+
Digest::SHA1.digest(data)[0..(size-1)]
|
624
|
+
else
|
625
|
+
Digest::SHA256.digest(data)[0..(size-1)]
|
626
|
+
end
|
627
|
+
end
|
628
|
+
|
629
|
+
=begin rdoc
|
630
|
+
|
631
|
+
=end
|
632
|
+
def self.hexdigest(data,size=40)
|
633
|
+
if size==0
|
634
|
+
""
|
635
|
+
elsif size<=40
|
636
|
+
Digest::SHA1.hexdigest(data)[0..(size-1)]
|
637
|
+
else
|
638
|
+
Digest::SHA256.hexdigest(data)[0..(size-1)]
|
639
|
+
end
|
640
|
+
end
|
641
|
+
|
642
|
+
=begin rdoc
|
643
|
+
|
644
|
+
=end
|
645
|
+
def self.digest64(data,size=16)
|
646
|
+
Base64.encode64(digest(data,size))
|
647
|
+
end
|
648
|
+
end
|
649
|
+
|
650
|
+
end
|
651
|
+
|
652
|
+
|