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.
-
#move_cursor_by(row, col) ⇒ Boolean
Moves the cursor of the given amount.
- #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 109 110 111 |
# File 'lib/ruber/editor/editor_view.rb', line 72 def initialize doc, internal, parent = nil super parent set_attribute Qt::WA_DeleteOnClose, true @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)) self.focus_policy = Qt::WheelFocus 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
143 144 145 |
# File 'lib/ruber/editor/editor_view.rb', line 143 def block_selection? @view.block_selection.to_bool end |
#close ⇒ Object
147 148 149 150 |
# File 'lib/ruber/editor/editor_view.rb', line 147 def close emit closing self 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.
165 166 167 168 169 170 171 172 173 |
# File 'lib/ruber/editor/editor_view.rb', line 165 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
131 132 133 |
# File 'lib/ruber/editor/editor_view.rb', line 131 def go_to row, col @view.set_cursor_position KTextEditor::Cursor.new(row, col) end |
#hide_annotation_border ⇒ Object
139 140 141 |
# File 'lib/ruber/editor/editor_view.rb', line 139 def hide_annotation_border set_annotation_border_visible false end |
#move_cursor_by(row, col) ⇒ Boolean
Moves the cursor of the given amount
If the cursor ends up being out of range, nothing is done
124 125 126 127 128 129 |
# File 'lib/ruber/editor/editor_view.rb', line 124 def move_cursor_by row, col cur = @view.cursor_position cur.line += row cur.column += col @view.set_cursor_position cur end |
#set_annotation_border_visible(vis) ⇒ Object
152 153 154 |
# File 'lib/ruber/editor/editor_view.rb', line 152 def set_annotation_border_visible vis @view.qobject_cast(KTextEditor::AnnotationViewInterface).set_annotation_border_visible vis end |
#show_annotation_border ⇒ Object
135 136 137 |
# File 'lib/ruber/editor/editor_view.rb', line 135 def show_annotation_border set_annotation_border_visible true end |