Class: Redcar::EditView
- Inherits:
-
Object
- Object
- Redcar::EditView
- Extended by:
- Forwardable, Observable
- Includes:
- Model, Observable
- Defined in:
- plugins/edit_view/lib/edit_view.rb,
plugins/edit_view/lib/edit_view/actions/tab.rb,
plugins/edit_view/lib/edit_view/actions/esc.rb,
plugins/edit_view/lib/edit_view/tab_settings.rb,
plugins/edit_view/lib/edit_view/actions/deletion.rb,
plugins/edit_view/lib/edit_view/actions/cmd_enter.rb,
plugins/edit_view/lib/edit_view/actions/arrow_keys.rb,
plugins/edit_view/lib/edit_view/select_font_dialog.rb,
plugins/edit_view/lib/edit_view/select_theme_dialog.rb,
plugins/edit_view/lib/edit_view/modified_tabs_checker.rb,
plugins/edit_view/lib/edit_view/commands/change_language_command.rb,
plugins/edit_view/lib/edit_view/commands/text_conversion_commands.rb,
plugins/edit_view/lib/edit_view/commands/align_assignment_command.rb,
plugins/edit_view/lib/edit_view/commands/language_settings_commands.rb
Defined Under Namespace
Modules: Actions, Handler Classes: AlignAssignmentCommand, CamelCaseTextCommand, CamelSnakePascalRotateTextCommand, ChangeLanguageCommand, DowncaseTextCommand, ModifiedTabsChecker, OppositeCaseTextCommand, SelectFontDialog, SelectThemeDialog, SetMarginColumnCommand, SetTabWidthCommand, TabSettings, TextConversionCommand, TitlizeTextCommand, ToggleIndentSelectionOnTabCommand, ToggleShowMarginCommand, ToggleSoftTabsCommand, ToggleWordWrapCommand, UnderscoreTextCommand, UpcaseTextCommand
Constant Summary
- ACTIONS =
[ :LINE_UP, :LINE_DOWN, :LINE_START, :LINE_END, :COLUMN_PREVIOUS, :COLUMN_NEXT, :PAGE_UP, :PAGE_DOWN, :WORD_PREVIOUS, :WORD_NEXT, :TEXT_START, :TEXT_END, :WINDOW_START, :WINDOW_END, :SELECT_ALL, :SELECT_LINE_UP, :SELECT_LINE_DOWN, :SELECT_LINE_START, :SELECT_LINE_END, :SELECT_COLUMN_PREVIOUS, :SELECT_COLUMN_NEXT, :SELECT_PAGE_UP, :SELECT_PAGE_DOWN, :SELECT_WORD_PREVIOUS, :SELECT_WORD_NEXT, :SELECT_TEXT_START, :SELECT_TEXT_END, :SELECT_WINDOW_START, :SELECT_WINDOW_END, :CUT, :COPY, :PASTE, :DELETE_PREVIOUS, :DELETE_NEXT, :DELETE_WORD_PREVIOUS, :DELETE_WORD_NEXT ]
- MAX_FONT_SIZE =
25- MIN_FONT_SIZE =
6- OVERRIDDEN_CHARACTERS =
This characters have custom Redcar behaviour.
{ 9 => [:tab_pressed, []] }
- OVERRIDDEN_ACTIONS =
These actions have custom Redcar implementations that override the default StyledText implementation. (Mainly for soft tabs purposes.)
{ :COLUMN_PREVIOUS => Actions::ArrowLeftHandler, :COLUMN_NEXT => Actions::ArrowRightHandler, :SELECT_COLUMN_PREVIOUS => Actions::ArrowLeftHandler, :SELECT_COLUMN_NEXT => Actions::ArrowRightHandler, :DELETE_PREVIOUS => Actions::BackspaceHandler, :DELETE_NEXT => Actions::DeleteHandler }
Constants included from Observable
Class Attribute Summary (collapse)
-
+ (Object) focussed_edit_view
Returns the value of attribute focussed_edit_view.
-
+ (Object) redo_sensitivity
readonly
Returns the value of attribute redo_sensitivity.
-
+ (Object) undo_sensitivity
readonly
Returns the value of attribute undo_sensitivity.
Instance Attribute Summary (collapse)
-
- (Object) document
readonly
Returns the value of attribute document.
-
- (Object) history
readonly
Returns the value of attribute history.
Attributes included from Model
Class Method Summary (collapse)
- + (Object) all_arrow_left_handlers
- + (Object) all_arrow_right_handlers
- + (Object) all_backspace_handlers
- + (Object) all_cmd_enter_handlers
- + (Object) all_delete_handlers
- + (Object) all_edit_views
- + (Object) all_esc_handlers
- + (Object) all_handlers(type)
- + (Object) all_tab_handlers
- + (Object) arrow_left_handlers
- + (Object) arrow_right_handlers
- + (Object) backspace_handlers
- + (Object) close_tab_guard(tab)
- + (Object) close_window_guard(win)
- + (Object) cmd_enter_handlers
- + (Object) current
- + (Object) default_font
- + (Object) default_font_size
- + (Object) delete_handlers
- + (Object) edit_view_context_menus
- + (Object) esc_handlers
- + (Object) focussed_document_mirror
- + (Object) focussed_edit_view_document
- + (Object) focussed_tab_edit_view
- + (Object) font
- + (Object) font=(font)
- + (Object) font_info
- + (Object) font_size
- + (Object) font_size=(size)
- + (Object) indent_selection_on_tab=(doit)
- + (Boolean) indent_selection_on_tab?
- + (Object) menus
- + (Object) protect_edit_view_focus
- + (Object) quit_guard
- + (Object) sensitivities
- + (Object) show_invisibles=(bool)
- + (Boolean) show_invisibles?
- + (Object) show_line_numbers=(bool)
- + (Boolean) show_line_numbers?
- + (Object) storage
- + (Object) tab_handlers
- + (Object) tab_settings
- + (Object) theme
- + (Object) theme=(theme)
- + (Object) themes
- + (Object) toolbars
Instance Method Summary (collapse)
- - (Object) add_annotation(annotation_name, line, text, start, length)
- - (Object) add_annotation_type(name, image, rgb)
- - (Object) backspace_pressed(modifiers)
- - (Object) check_for_updated_document
- - (Object) cmd_enter_pressed(modifiers)
- - (Object) create_document
- - (Object) create_history
- - (Object) custom_character_handle(character)
- - (Object) delay_parsing
- - (Object) delete_pressed(modifiers)
- - (Object) deserialize(data)
- - (Object) esc_pressed(modifiers)
- - (Boolean) exists?
- - (Object) focus
- - (Object) grammar
- - (Object) grammar=(name)
- - (Object) handle_key(handlers, modifiers)
-
- (EditView) initialize
constructor
A new instance of EditView.
- - (Object) inspect
- - (Object) invoke_action(action_symbol)
- - (Object) invoke_overridden_action(action_symbol)
- - (Object) left_pressed(modifiers)
- - (Object) margin_column
- - (Object) margin_column=(val)
- - (Object) refresh_font
- - (Object) refresh_show_invisibles
- - (Object) refresh_show_line_numbers
- - (Object) refresh_theme
- - (Object) reset_last_checked
- - (Object) right_pressed(modifiers)
- - (Object) serialize
- - (Object) set_grammar(name)
- - (Object) set_tab_width(val)
- - (Boolean) show_invisibles?
- - (Boolean) show_line_numbers?
- - (Object) show_margin=(bool)
- - (Boolean) show_margin?
- - (Object) soft_tabs=(bool)
- - (Boolean) soft_tabs?
- - (Object) tab_pressed(modifiers)
- - (Object) tab_width
- - (Object) tab_width=(val)
- - (Object) title=(title)
- - (Object) type_character(character)
- - (Object) word_wrap=(bool)
- - (Boolean) word_wrap?
Methods included from Observable
add_listener, notify_listeners, remove_listener
Methods included from ReentryHelpers
Constructor Details
- (EditView) initialize
A new instance of EditView
486 487 488 489 490 491 |
# File 'plugins/edit_view/lib/edit_view.rb', line 486 def initialize create_document @grammar = nil @focussed = nil create_history end |
Class Attribute Details
+ (Object) focussed_edit_view
Returns the value of attribute focussed_edit_view
85 86 87 |
# File 'plugins/edit_view/lib/edit_view.rb', line 85 def focussed_edit_view @focussed_edit_view end |
+ (Object) redo_sensitivity (readonly)
Returns the value of attribute redo_sensitivity
84 85 86 |
# File 'plugins/edit_view/lib/edit_view.rb', line 84 def redo_sensitivity @redo_sensitivity end |
+ (Object) undo_sensitivity (readonly)
Returns the value of attribute undo_sensitivity
84 85 86 |
# File 'plugins/edit_view/lib/edit_view.rb', line 84 def undo_sensitivity @undo_sensitivity end |
Instance Attribute Details
- (Object) document (readonly)
Returns the value of attribute document
484 485 486 |
# File 'plugins/edit_view/lib/edit_view.rb', line 484 def document @document end |
- (Object) history (readonly)
Returns the value of attribute history
484 485 486 |
# File 'plugins/edit_view/lib/edit_view.rb', line 484 def history @history end |
Class Method Details
+ (Object) all_arrow_left_handlers
274 275 276 |
# File 'plugins/edit_view/lib/edit_view.rb', line 274 def self.all_arrow_left_handlers all_handlers(:arrow_left) end |
+ (Object) all_arrow_right_handlers
278 279 280 |
# File 'plugins/edit_view/lib/edit_view.rb', line 278 def self.all_arrow_right_handlers all_handlers(:arrow_right) end |
+ (Object) all_backspace_handlers
286 287 288 |
# File 'plugins/edit_view/lib/edit_view.rb', line 286 def self.all_backspace_handlers all_handlers(:backspace) end |
+ (Object) all_cmd_enter_handlers
290 291 292 |
# File 'plugins/edit_view/lib/edit_view.rb', line 290 def self.all_cmd_enter_handlers all_handlers(:cmd_enter) end |
+ (Object) all_delete_handlers
282 283 284 |
# File 'plugins/edit_view/lib/edit_view.rb', line 282 def self.all_delete_handlers all_handlers(:delete) end |
+ (Object) all_edit_views
480 481 482 |
# File 'plugins/edit_view/lib/edit_view.rb', line 480 def self.all_edit_views Redcar.app.windows.map {|w| w.notebooks.map {|n| n.tabs}.flatten }.flatten.select {|t| t.is_a?(EditTab)}.map {|t| t.edit_view} end |
+ (Object) all_esc_handlers
270 271 272 |
# File 'plugins/edit_view/lib/edit_view.rb', line 270 def self.all_esc_handlers all_handlers(:esc) end |
+ (Object) all_handlers(type)
229 230 231 232 233 234 235 236 |
# File 'plugins/edit_view/lib/edit_view.rb', line 229 def self.all_handlers(type) result = [] method_name = :#{type}_handlers" Redcar.plugin_manager.objects_implementing(method_name).each do |object| result += object.send(method_name) end result.each {|h| Handler.verify_interface!(h) } end |
+ (Object) all_tab_handlers
266 267 268 |
# File 'plugins/edit_view/lib/edit_view.rb', line 266 def self.all_tab_handlers all_handlers(:tab) end |
+ (Object) arrow_left_handlers
238 239 240 |
# File 'plugins/edit_view/lib/edit_view.rb', line 238 def self.arrow_left_handlers [Actions::ArrowLeftHandler] end |
+ (Object) arrow_right_handlers
242 243 244 |
# File 'plugins/edit_view/lib/edit_view.rb', line 242 def self.arrow_right_handlers [Actions::ArrowRightHandler] end |
+ (Object) backspace_handlers
250 251 252 |
# File 'plugins/edit_view/lib/edit_view.rb', line 250 def self.backspace_handlers [Actions::BackspaceHandler] end |
+ (Object) close_tab_guard(tab)
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'plugins/edit_view/lib/edit_view.rb', line 202 def self.close_tab_guard(tab) if tab.respond_to?(:edit_view) && tab.edit_view.document.modified? tab.focus result = Application::Dialog.( "This tab has unsaved changes. \n\nSave before closing?", :buttons => :yes_no_cancel ) case result when :yes # check if the tab was saved properly, # it would return false for example if the permission is not granted t = Project::SaveFileCommand.new(tab).run if t true else false end when :no true when :cancel false end else true end end |
+ (Object) close_window_guard(win)
195 196 197 198 199 200 |
# File 'plugins/edit_view/lib/edit_view.rb', line 195 def self.close_window_guard(win) EditView::ModifiedTabsChecker.new( win.notebooks.map(&:tabs).flatten.select {|t| t.is_a?(EditTab)}, "Save all before closing the window?" ).check end |
+ (Object) cmd_enter_handlers
262 263 264 |
# File 'plugins/edit_view/lib/edit_view.rb', line 262 def self.cmd_enter_handlers [Actions::CmdEnterHandler] end |
+ (Object) current
355 356 357 358 359 360 |
# File 'plugins/edit_view/lib/edit_view.rb', line 355 def self.current tab = Redcar.app.focussed_window.focussed_notebook.focussed_tab if tab.is_a?(Redcar::EditTab) tab.edit_view end end |
+ (Object) default_font
402 403 404 405 406 407 408 409 410 |
# File 'plugins/edit_view/lib/edit_view.rb', line 402 def self.default_font if Redcar.platform == :osx "Monaco" elsif Redcar.platform == :linux "Monospace" elsif Redcar.platform == :windows "Courier New" end end |
+ (Object) default_font_size
392 393 394 395 396 397 398 399 400 |
# File 'plugins/edit_view/lib/edit_view.rb', line 392 def self.default_font_size if Redcar.platform == :osx 15 elsif Redcar.platform == :linux 11 elsif Redcar.platform == :windows 9 end end |
+ (Object) delete_handlers
254 255 256 |
# File 'plugins/edit_view/lib/edit_view.rb', line 254 def self.delete_handlers [Actions::DeleteHandler] end |
+ (Object) edit_view_context_menus
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'plugins/edit_view/lib/edit_view.rb', line 165 def self. Menu::Builder.build do group(:priority => :first) do item ("Cut" ) { Redcar::Top::CutCommand.new.run } item ("Copy" ) { Redcar::Top::CopyCommand.new.run } item ("Paste") { Redcar::Top::PasteCommand.new.run} end group(:priority => 20) do separator "Convert Text" do item ("to Uppercase") {EditView::UpcaseTextCommand.new.run} item ("to Lowercase") {EditView::DowncaseTextCommand.new.run} item ("to Titlecase") {EditView::TitlizeTextCommand.new.run} item ("to Opposite Case") {EditView::OppositeCaseTextCommand.new.run} separator item ("to CamelCase") {EditView::CamelCaseTextCommand.new.run} item ("to snake_case") {EditView::UnderscoreTextCommand.new.run} item ("Toggle PascalCase-underscore-camelCase") {EditView::CamelSnakePascalRotateTextCommand.new.run} end end end end |
+ (Object) esc_handlers
258 259 260 |
# File 'plugins/edit_view/lib/edit_view.rb', line 258 def self.esc_handlers [Actions::EscapeHandler] end |
+ (Object) focussed_document_mirror
476 477 478 |
# File 'plugins/edit_view/lib/edit_view.rb', line 476 def self.focussed_document_mirror focussed_edit_view_document.mirror if focussed_edit_view_document end |
+ (Object) focussed_edit_view_document
472 473 474 |
# File 'plugins/edit_view/lib/edit_view.rb', line 472 def self.focussed_edit_view_document focussed_tab_edit_view.document if focussed_tab_edit_view end |
+ (Object) focussed_tab_edit_view
468 469 470 |
# File 'plugins/edit_view/lib/edit_view.rb', line 468 def self.focussed_tab_edit_view Redcar.app.focussed_notebook_tab.edit_view if Redcar.app.focussed_notebook_tab and Redcar.app.focussed_notebook_tab.edit_tab? end |
+ (Object) font
417 418 419 |
# File 'plugins/edit_view/lib/edit_view.rb', line 417 def self.font font_info[0] end |
+ (Object) font=(font)
425 426 427 428 |
# File 'plugins/edit_view/lib/edit_view.rb', line 425 def self.font=(font) EditView.storage["font"] = font all_edit_views.each {|ev| ev.refresh_font } end |
+ (Object) font_info
412 413 414 415 |
# File 'plugins/edit_view/lib/edit_view.rb', line 412 def self.font_info [ EditView.storage["font"] || default_font, EditView.storage["font-size"] || default_font_size ] end |
+ (Object) font_size
421 422 423 |
# File 'plugins/edit_view/lib/edit_view.rb', line 421 def self.font_size font_info[1] end |
+ (Object) font_size=(size)
442 443 444 445 |
# File 'plugins/edit_view/lib/edit_view.rb', line 442 def self.font_size=(size) EditView.storage["font-size"] = size all_edit_views.each {|ev| ev.refresh_font } end |
+ (Object) indent_selection_on_tab=(doit)
434 435 436 |
# File 'plugins/edit_view/lib/edit_view.rb', line 434 def self.indent_selection_on_tab= doit EditView.storage["indent_selection_on_tab"] = !!doit end |
+ (Boolean) indent_selection_on_tab?
430 431 432 |
# File 'plugins/edit_view/lib/edit_view.rb', line 430 def self.indent_selection_on_tab? EditView.storage["indent_selection_on_tab"] end |
+ (Object) menus
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'plugins/edit_view/lib/edit_view.rb', line 100 def self. Menu::Builder.build do "Edit" do group(:priority => 20) do item "Change Language", ChangeLanguageCommand "Tabs" do item "Soft Tabs", :command => EditView::ToggleSoftTabsCommand, :type => :check, :checked => lambda { tab and tab.respond_to?(:edit_view) and tab.edit_view.soft_tabs? } item "Indent Selection on Tab", :command => EditView::ToggleIndentSelectionOnTabCommand, :type => :check, :checked => lambda { EditView.indent_selection_on_tab? } "Tab Width" do TabSettings::TAB_WIDTHS.each do |width| command_klass = Class.new(SetTabWidthCommand) command_klass.width = width.to_i already_checker = lambda { tab and tab.respond_to?(:edit_view) and tab.edit_view.tab_width.to_s == width.to_s } item width, :command => command_klass, :type => :check, :checked => already_checker end end end "Margin" do item "Word Wrap", :command => EditView::ToggleWordWrapCommand, :type => :check, :checked => lambda { tab and tab.respond_to?(:edit_view) and tab.edit_view.word_wrap? } item "Show Margin", :command => EditView::ToggleShowMarginCommand, :type => :check, :checked => lambda { tab and tab.respond_to?(:edit_view) and tab.edit_view.show_margin? } item lambda { tab && tab.respond_to?(:edit_view) ? "Margin Column: #{tab.edit_view.margin_column}" : "Margin Column" }, SetMarginColumnCommand end separator end "Formatting" do item "Align Assignments", EditView::AlignAssignmentCommand "Convert Text", :priority => 40 do item "to Uppercase", EditView::UpcaseTextCommand item "to Lowercase", EditView::DowncaseTextCommand item "to Titlecase", EditView::TitlizeTextCommand item "to Opposite Case", EditView::OppositeCaseTextCommand separator item "to CamelCase", EditView::CamelCaseTextCommand item "to snake_case", EditView::UnderscoreTextCommand item "Toggle PascalCase-underscore-camelCase", EditView::CamelSnakePascalRotateTextCommand end end end end end |
+ (Object) protect_edit_view_focus
349 350 351 352 353 |
# File 'plugins/edit_view/lib/edit_view.rb', line 349 def self.protect_edit_view_focus @protect_edit_view_focus = true yield @protect_edit_view_focus = false end |
+ (Object) quit_guard
188 189 190 191 192 193 |
# File 'plugins/edit_view/lib/edit_view.rb', line 188 def self.quit_guard EditView::ModifiedTabsChecker.new( Redcar.app.all_tabs.select {|t| t.is_a?(EditTab)}, "Save all before quitting?" ).check end |
+ (Object) sensitivities
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
# File 'plugins/edit_view/lib/edit_view.rb', line 362 def self.sensitivities [ Sensitivity.new(:edit_tab_focussed, Redcar.app, false, [:tab_focussed]) do |tab| tab and tab.is_a?(EditTab) end, Sensitivity.new(:edit_view_focussed, EditView, false, [:focussed_edit_view]) do |edit_view| edit_view end, Sensitivity.new(:selected_text, Redcar.app, false, [:focussed_tab_selection_changed, :tab_focussed]) do if win = Redcar.app.focussed_window tab = win.focussed_notebook.focussed_tab tab and tab.is_a?(EditTab) and tab.edit_view.document.selection? end end, @undo_sensitivity = Sensitivity.new(:undoable, Redcar.app, false, [:focussed_tab_changed, :tab_focussed]) do tab = Redcar.app.focussed_window.focussed_notebook.focussed_tab tab and tab.is_a?(EditTab) and tab.edit_view.undoable? end, @redo_sensitivity = Sensitivity.new(:redoable, Redcar.app, false, [:focussed_tab_changed, :tab_focussed]) do tab = Redcar.app.focussed_window.focussed_notebook.focussed_tab tab and tab.is_a?(EditTab) and tab.edit_view.redoable? end, Sensitivity.new(:clipboard_not_empty, Redcar.app, false, [:clipboard_added, :focussed_window]) do Redcar.app.clipboard.length > 0 end ] end |
+ (Object) show_invisibles=(bool)
603 604 605 606 |
# File 'plugins/edit_view/lib/edit_view.rb', line 603 def self.show_invisibles=(bool) EditView.tab_settings.set_show_invisibles(bool) all_edit_views.each {|ev| ev.refresh_show_invisibles } end |
+ (Boolean) show_invisibles?
599 600 601 |
# File 'plugins/edit_view/lib/edit_view.rb', line 599 def self.show_invisibles? EditView.tab_settings.show_invisibles? end |
+ (Object) show_line_numbers=(bool)
621 622 623 624 |
# File 'plugins/edit_view/lib/edit_view.rb', line 621 def self.show_line_numbers=(bool) EditView.tab_settings.set_show_line_numbers(bool) all_edit_views.each {|ev| ev.refresh_show_line_numbers } end |
+ (Boolean) show_line_numbers?
617 618 619 |
# File 'plugins/edit_view/lib/edit_view.rb', line 617 def self.show_line_numbers? EditView.tab_settings.show_line_numbers? end |
+ (Object) storage
92 93 94 95 96 97 98 |
# File 'plugins/edit_view/lib/edit_view.rb', line 92 def self.storage @storage ||= begin store = Plugin::Storage.new('edit_view_plugin') store.set_default('indent_selection_on_tab', true) store end end |
+ (Object) tab_handlers
246 247 248 |
# File 'plugins/edit_view/lib/edit_view.rb', line 246 def self.tab_handlers [Actions::IndentTabHandler] end |
+ (Object) tab_settings
88 89 90 |
# File 'plugins/edit_view/lib/edit_view.rb', line 88 def self.tab_settings @tab_settings ||= TabSettings.new end |
+ (Object) theme
447 448 449 |
# File 'plugins/edit_view/lib/edit_view.rb', line 447 def self.theme EditView.storage["theme"] || "Twilight" end |
+ (Object) theme=(theme)
451 452 453 454 455 456 457 458 |
# File 'plugins/edit_view/lib/edit_view.rb', line 451 def self.theme=(theme) theme.gsub!(/ \(Current\)$/, '') EditView.storage["theme"] = theme all_edit_views.each {|ev| ev.refresh_theme } Redcar.plugin_manager.objects_implementing(:theme_changed_update).each do |object| @cursor = object.theme_changed_update end end |
+ (Object) themes
460 461 462 |
# File 'plugins/edit_view/lib/edit_view.rb', line 460 def self.themes @themes ||= [] end |
+ (Object) toolbars
157 158 159 160 161 162 163 |
# File 'plugins/edit_view/lib/edit_view.rb', line 157 def self. ToolBar::Builder.build do item "Cut", :command => Redcar::Top::CutCommand, :icon => File.join(Redcar.icons_directory, "scissors-blue.png"), :barname => :edit item "Copy", :command => Redcar::Top::CopyCommand, :icon => File.join(Redcar.icons_directory, "blue-document-copy.png"), :barname => :edit item "Paste", :command => Redcar::Top::PasteCommand, :icon => File.join(Redcar.icons_directory, "clipboard.png"), :barname => :edit end end |
Instance Method Details
- (Object) add_annotation(annotation_name, line, text, start, length)
631 632 633 634 |
# File 'plugins/edit_view/lib/edit_view.rb', line 631 def add_annotation(annotation_name, line, text, start, length) start += document.offset_at_line(line) controller.add_annotation(annotation_name, line, text, start, length) end |
- (Object) add_annotation_type(name, image, rgb)
636 637 638 |
# File 'plugins/edit_view/lib/edit_view.rb', line 636 def add_annotation_type(name, image, rgb) controller.add_annotation_type(name, File.("#{image}.png", Redcar.icons_directory), rgb) end |
- (Object) backspace_pressed(modifiers)
326 327 328 |
# File 'plugins/edit_view/lib/edit_view.rb', line 326 def backspace_pressed(modifiers) handle_key(EditView.all_backspace_handlers, modifiers) end |
- (Object) check_for_updated_document
664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 |
# File 'plugins/edit_view/lib/edit_view.rb', line 664 def check_for_updated_document # awful forward dependency on the Project plugin here.... if document and document.mirror and document.mirror.is_a?(Project::FileMirror) and document.mirror.changed_since?(@last_checked) if document.modified? result = Application::Dialog.( "This file has been changed on disc, and you have unsaved changes in Redcar.\n\n" + "Revert to version on disc (and lose your changes)?", :buttons => :yes_no ) case result when :yes document.update_from_mirror end else document.update_from_mirror end end @last_checked = Time.now end |
- (Object) cmd_enter_pressed(modifiers)
330 331 332 |
# File 'plugins/edit_view/lib/edit_view.rb', line 330 def cmd_enter_pressed(modifiers) handle_key(EditView.all_cmd_enter_handlers, modifiers) end |
- (Object) create_document
500 501 502 |
# File 'plugins/edit_view/lib/edit_view.rb', line 500 def create_document @document = Redcar::Document.new(self) end |
- (Object) create_history
493 494 495 496 497 498 |
# File 'plugins/edit_view/lib/edit_view.rb', line 493 def create_history @history = Document::History.new(500) @history.subscribe do |action| document.controllers.each {|c| c.after_action(action) } end end |
- (Object) custom_character_handle(character)
699 700 701 702 703 |
# File 'plugins/edit_view/lib/edit_view.rb', line 699 def custom_character_handle(character) if method_call = OVERRIDDEN_CHARACTERS[character] send(*method_call) end end |
- (Object) delay_parsing
656 657 658 |
# File 'plugins/edit_view/lib/edit_view.rb', line 656 def delay_parsing controller.delay_parsing { yield } end |
- (Object) delete_pressed(modifiers)
322 323 324 |
# File 'plugins/edit_view/lib/edit_view.rb', line 322 def delete_pressed(modifiers) handle_key(EditView.all_delete_handlers, modifiers) end |
- (Object) deserialize(data)
650 651 652 653 654 |
# File 'plugins/edit_view/lib/edit_view.rb', line 650 def deserialize(data) self.grammar = data[:grammar] document.text = data[:contents] self.cursor_offset = data[:cursor_offset] end |
- (Object) esc_pressed(modifiers)
310 311 312 |
# File 'plugins/edit_view/lib/edit_view.rb', line 310 def esc_pressed(modifiers) handle_key(EditView.all_esc_handlers, modifiers) end |
- (Boolean) exists?
537 538 539 |
# File 'plugins/edit_view/lib/edit_view.rb', line 537 def exists? controller.exists? end |
- (Object) focus
533 534 535 |
# File 'plugins/edit_view/lib/edit_view.rb', line 533 def focus notify_listeners(:focussed) end |
- (Object) grammar
513 514 515 |
# File 'plugins/edit_view/lib/edit_view.rb', line 513 def grammar @grammar end |
- (Object) grammar=(name)
517 518 519 520 |
# File 'plugins/edit_view/lib/edit_view.rb', line 517 def grammar=(name) set_grammar(name) notify_listeners(:grammar_changed, name) end |
- (Object) handle_key(handlers, modifiers)
294 295 296 297 298 299 300 301 302 303 304 |
# File 'plugins/edit_view/lib/edit_view.rb', line 294 def handle_key(handlers, modifiers) sorted_handlers = handlers.sort_by {|h| (h.respond_to?(:priority) and h.priority) || 0 }.reverse sorted_handlers.detect do |h| begin h.handle(self, modifiers) rescue => e puts "*** Error in key handler: #{e.class} #{e.}" puts e.backtrace.map {|l| " - " + l } end end end |
- (Object) inspect
730 731 732 |
# File 'plugins/edit_view/lib/edit_view.rb', line 730 def inspect "#<Redcar::EditView document:#{document.inspect}>" end |
- (Object) invoke_action(action_symbol)
723 724 725 726 727 728 |
# File 'plugins/edit_view/lib/edit_view.rb', line 723 def invoke_action(action_symbol) unless invoke_overridden_action(action_symbol) notify_listeners(:invoke_action, action_symbol) end history.record(action_symbol) end |
- (Object) invoke_overridden_action(action_symbol)
717 718 719 720 721 |
# File 'plugins/edit_view/lib/edit_view.rb', line 717 def invoke_overridden_action(action_symbol) if handler = OVERRIDDEN_ACTIONS[action_symbol] handler.send(action_symbol.to_s.downcase, self) end end |
- (Object) left_pressed(modifiers)
314 315 316 |
# File 'plugins/edit_view/lib/edit_view.rb', line 314 def left_pressed(modifiers) handle_key(EditView.all_arrow_left_handlers, modifiers) end |
- (Object) margin_column
585 586 587 |
# File 'plugins/edit_view/lib/edit_view.rb', line 585 def margin_column @margin_column end |
- (Object) margin_column=(val)
589 590 591 592 593 |
# File 'plugins/edit_view/lib/edit_view.rb', line 589 def margin_column=(val) @margin_column = val EditView.tab_settings.set_margin_column_for(grammar, val) notify_listeners(:margin_column_changed, val) end |
- (Object) refresh_font
438 439 440 |
# File 'plugins/edit_view/lib/edit_view.rb', line 438 def refresh_font notify_listeners(:font_changed) end |
- (Object) refresh_show_invisibles
608 609 610 611 |
# File 'plugins/edit_view/lib/edit_view.rb', line 608 def refresh_show_invisibles @show_invisibles = EditView.tab_settings.show_invisibles? notify_listeners(:invisibles_changed, @show_invisibles) end |
- (Object) refresh_show_line_numbers
626 627 628 629 |
# File 'plugins/edit_view/lib/edit_view.rb', line 626 def refresh_show_line_numbers @show_line_numbers = EditView.tab_settings.show_line_numbers? notify_listeners(:line_number_visibility_changed, @show_line_numbers) end |
- (Object) refresh_theme
464 465 466 |
# File 'plugins/edit_view/lib/edit_view.rb', line 464 def refresh_theme notify_listeners(:theme_changed) end |
- (Object) reset_last_checked
660 661 662 |
# File 'plugins/edit_view/lib/edit_view.rb', line 660 def reset_last_checked @last_checked = Time.now end |
- (Object) right_pressed(modifiers)
318 319 320 |
# File 'plugins/edit_view/lib/edit_view.rb', line 318 def right_pressed(modifiers) handle_key(EditView.all_arrow_right_handlers, modifiers) end |
- (Object) serialize
644 645 646 647 648 |
# File 'plugins/edit_view/lib/edit_view.rb', line 644 def serialize { :contents => document.to_s, :cursor_offset => cursor_offset, :grammar => grammar } end |
- (Object) set_grammar(name)
522 523 524 525 526 527 528 529 530 531 |
# File 'plugins/edit_view/lib/edit_view.rb', line 522 def set_grammar(name) @grammar = name self.tab_width = EditView.tab_settings.width_for(name) self.soft_tabs = EditView.tab_settings.softness_for(name) self.word_wrap = EditView.tab_settings.word_wrap_for(name) self.margin_column = EditView.tab_settings.margin_column_for(name) self.show_margin = EditView.tab_settings.show_margin_for(name) refresh_show_invisibles refresh_show_line_numbers end |
- (Object) set_tab_width(val)
551 552 553 |
# File 'plugins/edit_view/lib/edit_view.rb', line 551 def set_tab_width(val) @tab_width = val end |
- (Boolean) show_invisibles?
595 596 597 |
# File 'plugins/edit_view/lib/edit_view.rb', line 595 def show_invisibles? @show_invisibles end |
- (Boolean) show_line_numbers?
613 614 615 |
# File 'plugins/edit_view/lib/edit_view.rb', line 613 def show_line_numbers? @show_line_numbers end |
- (Object) show_margin=(bool)
569 570 571 572 573 |
# File 'plugins/edit_view/lib/edit_view.rb', line 569 def show_margin=(bool) @show_margin = bool EditView.tab_settings.set_show_margin_for(grammar, bool) notify_listeners(:show_margin_changed, bool) end |
- (Boolean) show_margin?
565 566 567 |
# File 'plugins/edit_view/lib/edit_view.rb', line 565 def show_margin? @show_margin end |
- (Object) soft_tabs=(bool)
559 560 561 562 563 |
# File 'plugins/edit_view/lib/edit_view.rb', line 559 def soft_tabs=(bool) @soft_tabs = bool EditView.tab_settings.set_softness_for(grammar, bool) notify_listeners(:softness_changed, bool) end |
- (Boolean) soft_tabs?
555 556 557 |
# File 'plugins/edit_view/lib/edit_view.rb', line 555 def soft_tabs? @soft_tabs end |
- (Object) tab_pressed(modifiers)
306 307 308 |
# File 'plugins/edit_view/lib/edit_view.rb', line 306 def tab_pressed(modifiers) handle_key(EditView.all_tab_handlers, modifiers) end |
- (Object) tab_width
541 542 543 |
# File 'plugins/edit_view/lib/edit_view.rb', line 541 def tab_width @tab_width end |
- (Object) tab_width=(val)
545 546 547 548 549 |
# File 'plugins/edit_view/lib/edit_view.rb', line 545 def tab_width=(val) @tab_width = val EditView.tab_settings.set_width_for(grammar, val) notify_listeners(:tab_width_changed, val) end |
- (Object) title=(title)
640 641 642 |
# File 'plugins/edit_view/lib/edit_view.rb', line 640 def title=(title) notify_listeners(:title_changed, title) end |
- (Object) type_character(character)
692 693 694 695 696 697 |
# File 'plugins/edit_view/lib/edit_view.rb', line 692 def type_character(character) unless custom_character_handle(character) notify_listeners(:type_character, character) end history.record(character) end |
- (Object) word_wrap=(bool)
579 580 581 582 583 |
# File 'plugins/edit_view/lib/edit_view.rb', line 579 def word_wrap=(bool) @word_wrap = bool EditView.tab_settings.set_word_wrap_for(grammar, bool) notify_listeners(:word_wrap_changed, bool) end |
- (Boolean) word_wrap?
575 576 577 |
# File 'plugins/edit_view/lib/edit_view.rb', line 575 def word_wrap? @word_wrap end |