Class: Ruber::EditorView
- Includes:
- KTextEditorWrapper
- Defined in:
- lib/ruber/editor/editor_view.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
(also: #document)
readonly
signals ‘closing()’, ‘information_message(QString, QObject*)’, ‘cursor_position_changed(KTextEditor::Cursor, QObject*)’, ‘view_mode_changed(QString, QObject*)’, ‘edit_mode_changed(KTextEditor::View::EditMode, QObject*)’, ‘selection_mode_changed(bool, QObject*)’, ‘context_menu_about_to_show(QMenu*, QObject*)’, ‘focus_in(QObject*)’, ‘focus_out(QObject*)’, ‘horizontal_scroll_position_changed(QObject*)’, ‘mouse_position_changed(KTextEditor::Cursor, QObject*)’, ‘selection_changed(QObject*)’, ‘text_inserted(KTextEditor::Cursor, QString, QObject*)’, ‘vertical_scroll_position_changed(KTextEditor::Cursor, QObject*)’.
Instance Method Summary collapse
- #block_selection? ⇒ Boolean
- #close ⇒ Object
-
#execute_action(name, arg = nil) ⇒ Object
Executes the action with name the view’s action collection.
- #go_to(row, col) ⇒ Object
- #hide_annotation_border ⇒ Object
-
#initialize(doc, internal, parent = nil) ⇒ EditorView
constructor
A new instance of EditorView.
- #set_annotation_border_visible(vis) ⇒ Object
- #show_annotation_border ⇒ Object
Methods included from KTextEditorWrapper
#interface, #method_missing, prepare_wrapper_connections
Constructor Details
#initialize(doc, internal, parent = nil) ⇒ EditorView
Returns a new instance of EditorView.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/ruber/editor/editor_view.rb', line 72 def initialize doc, internal, parent = nil super parent @block_selection = false @doc = doc @view = internal @view.parent = self initialize_wrapper @view, self.class.instance_variable_get(:@signal_table) self.focus_proxy = @view self.layout = Qt::VBoxLayout.new self layout.set_contents_margins 0,0,0,0 layout.spacing = 0 layout. @view connect @view, SIGNAL('selectionChanged(KTextEditor::View*)'), self, SLOT('slot_selection_changed(KTextEditor::View*)') @view.connect(SIGNAL('cursorPositionChanged(KTextEditor::View*, KTextEditor::Cursor)'))do |v, c| emit cursor_position_changed( @view.cursor_position_virtual, self) end @view.connect(SIGNAL('mousePositionChanged(KTextEditor::View*, KTextEditor::Cursor)')) do |v, c| emit mouse_position_changed( @view.cursor_position_virtual, self) end @view.connect(SIGNAL('viewModeChanged(KTextEditor::View*)')) do |v| emit view_mode_changed( view_mode, self) end @view.connect(SIGNAL('viewEditModeChanged(KTextEditor::View*, KTextEditor::View::EditMode)')) do |v, m| emit edit_mode_changed( m, self) end am = @doc.interface('annotation_interface').annotation_model am.connect(SIGNAL('annotations_changed()')) do show = Ruber[:config][:general, :auto_annotations] && am.has_annotations? set_annotation_border_visible(show) rescue NoMethodError end @view. = @view.(Qt::Menu.new(@view)) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Ruber::KTextEditorWrapper
Instance Attribute Details
#doc ⇒ Object (readonly) Also known as: document
signals ‘closing()’, ‘information_message(QString, QObject*)’, ‘cursor_position_changed(KTextEditor::Cursor, QObject*)’, ‘view_mode_changed(QString, QObject*)’, ‘edit_mode_changed(KTextEditor::View::EditMode, QObject*)’, ‘selection_mode_changed(bool, QObject*)’, ‘context_menu_about_to_show(QMenu*, QObject*)’, ‘focus_in(QObject*)’, ‘focus_out(QObject*)’, ‘horizontal_scroll_position_changed(QObject*)’, ‘mouse_position_changed(KTextEditor::Cursor, QObject*)’, ‘selection_changed(QObject*)’, ‘text_inserted(KTextEditor::Cursor, QString, QObject*)’, ‘vertical_scroll_position_changed(KTextEditor::Cursor, QObject*)’
70 71 72 |
# File 'lib/ruber/editor/editor_view.rb', line 70 def doc @doc end |
Instance Method Details
#block_selection? ⇒ Boolean
122 123 124 |
# File 'lib/ruber/editor/editor_view.rb', line 122 def block_selection? @view.block_selection.to_bool end |
#close ⇒ Object
126 127 128 129 |
# File 'lib/ruber/editor/editor_view.rb', line 126 def close emit closing super end |
#execute_action(name, arg = nil) ⇒ Object
Executes the action with name the view’s action collection. This is made by having the action emit the triggered()
or toggled(bool)
signal (depending on whether it’s a standard action or a KDE::ToggleAction
). In the second case, arg is the argument passed to the signal.
Returns true if an action with name name was found and false otherwise.
144 145 146 147 148 149 150 151 152 |
# File 'lib/ruber/editor/editor_view.rb', line 144 def execute_action name, arg = nil a = action_collection.action(name) case a when KDE::ToggleAction then a.instance_eval{emit toggled(arg)} when nil then return false else a.instance_eval{emit triggered} end true end |
#go_to(row, col) ⇒ Object
110 111 112 |
# File 'lib/ruber/editor/editor_view.rb', line 110 def go_to row, col @view.cursor_position = KTextEditor::Cursor.new(row, col) end |
#hide_annotation_border ⇒ Object
118 119 120 |
# File 'lib/ruber/editor/editor_view.rb', line 118 def hide_annotation_border set_annotation_border_visible false end |
#set_annotation_border_visible(vis) ⇒ Object
131 132 133 |
# File 'lib/ruber/editor/editor_view.rb', line 131 def set_annotation_border_visible vis @view.qobject_cast(KTextEditor::AnnotationViewInterface).set_annotation_border_visible vis end |
#show_annotation_border ⇒ Object
114 115 116 |
# File 'lib/ruber/editor/editor_view.rb', line 114 def show_annotation_border set_annotation_border_visible true end |