ruber 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +54 -0
- data/bin/ruber +12 -1
- data/data/share/apps/ruber/ruberui.rc +5 -0
- data/data/share/icons/pin.png +0 -0
- data/lib/ruber/application/application.rb +1 -1
- data/lib/ruber/documents/document_list.rb +1 -1
- data/lib/ruber/editor/document.rb +26 -6
- data/lib/ruber/editor/editor_view.rb +21 -2
- data/lib/ruber/filtered_output_widget.rb +1 -1
- data/lib/ruber/ktexteditor_sugar.rb +124 -0
- data/lib/ruber/main_window/main_window.rb +34 -16
- data/lib/ruber/main_window/main_window_actions.rb +98 -5
- data/lib/ruber/main_window/main_window_internal.rb +1 -1
- data/lib/ruber/main_window/plugin.yaml +5 -0
- data/lib/ruber/main_window/ui/choose_plugins_widget.rb +2 -2
- data/lib/ruber/main_window/ui/main_window_settings_widget.rb +67 -34
- data/lib/ruber/main_window/ui/main_window_settings_widget.ui +77 -30
- data/lib/ruber/main_window/ui/new_project_widget.rb +2 -2
- data/lib/ruber/main_window/ui/open_file_in_project_dlg.rb +2 -2
- data/lib/ruber/main_window/ui/output_color_widget.rb +2 -2
- data/lib/ruber/main_window/ui/workspace_settings_widget.rb +1 -1
- data/lib/ruber/main_window/view_manager.rb +14 -1
- data/lib/ruber/output_widget.rb +409 -288
- data/lib/ruber/pane.rb +22 -0
- data/lib/ruber/projects/ui/project_files_rule_chooser_widget.rb +2 -2
- data/lib/ruber/projects/ui/project_files_widget.rb +2 -2
- data/lib/ruber/qt_sugar.rb +11 -0
- data/lib/ruber/version.rb +1 -1
- data/plugins/auto_end/auto_end.rb +122 -0
- data/plugins/auto_end/plugin.yaml +11 -0
- data/plugins/autosave/ui/autosave_config_widget.rb +2 -2
- data/plugins/command/command.rb +71 -12
- data/plugins/command/output.rb +592 -0
- data/plugins/command/ui/tool_widget.rb +143 -0
- data/plugins/command/ui/tool_widget.ui +147 -0
- data/plugins/find_in_files/ui/config_widget.rb +2 -2
- data/plugins/find_in_files/ui/find_in_files_widget.rb +2 -2
- data/plugins/rake/ui/add_quick_task_widget.rb +2 -2
- data/plugins/rake/ui/choose_task_widget.rb +2 -2
- data/plugins/rake/ui/config_widget.rb +2 -2
- data/plugins/rake/ui/project_widget.rb +2 -2
- data/plugins/rspec/plugin.yaml +7 -2
- data/plugins/rspec/rspec.rb +178 -53
- data/plugins/rspec/rspecui.rc +2 -3
- data/plugins/rspec/ui/config_widget.rb +79 -0
- data/plugins/rspec/ui/config_widget.ui +89 -0
- data/plugins/rspec/ui/rspec_project_widget.rb +2 -2
- data/plugins/ruby_development/ruby_development.rb +1 -1
- data/plugins/ruby_development/ui/config_widget.rb +1 -1
- data/plugins/ruby_development/ui/project_widget.rb +2 -2
- data/plugins/ruby_runner/ruby_runner.rb +13 -12
- data/plugins/ruby_runner/ui/config_widget.rb +2 -2
- data/plugins/ruby_runner/ui/project_widget.rb +2 -2
- data/plugins/ruby_runner/ui/ruby_runnner_plugin_option_widget.rb +2 -2
- data/plugins/state/ui/config_widget.rb +2 -2
- data/plugins/syntax_checker/syntax_checker.rb +1 -1
- data/spec/auto_end_spec.rb +272 -0
- data/spec/common.rb +1 -0
- data/spec/document_spec.rb +83 -0
- data/spec/editor_view_spec.rb +41 -0
- data/spec/filtered_output_widget_spec.rb +2 -2
- data/spec/ktexteditor_sugar_spec.rb +190 -0
- data/spec/output_widget_spec.rb +120 -11
- data/spec/pane_spec.rb +1 -1
- data/spec/qt_sugar_spec.rb +14 -0
- data/spec/state_spec.rb +0 -26
- metadata +14 -3
data/CHANGES
CHANGED
@@ -1,5 +1,59 @@
|
|
1
1
|
h1. Changes
|
2
2
|
|
3
|
+
h2. Ruber 0.0.8
|
4
|
+
|
5
|
+
h3. Features
|
6
|
+
|
7
|
+
* Added a new plugin: Auto End. As the name says, it automatically inserts @end@
|
8
|
+
keywords after @module@, @class@, @if@... Its implementation is a bit naive at
|
9
|
+
the moment (in particular, it doesn't know whether the current line is in the
|
10
|
+
middle of a string or of a block comment), so it can insert @end@ in the wrong
|
11
|
+
places. If it does, just Undo the last action and the end'll go away
|
12
|
+
* Changed the way you open a file in the editor from a tool widget without closing
|
13
|
+
the tool widget itself. Now there's a little button on the right of the tool
|
14
|
+
widget with a pin on it. Clicking on it prevents the widget being closed when
|
15
|
+
clicking on a file name. This change was made because the Meta key is now used
|
16
|
+
for something else
|
17
|
+
* When clicking on a file name while keeping the Meta key pressed, a new editor
|
18
|
+
for the file is open (even if there was already one open). The new editor can
|
19
|
+
be opened by splitting the current editor or in a new tab, depending on an
|
20
|
+
option chosen by the user
|
21
|
+
* The RSpec tool widget now displays an horizontal scroll bar if a failure description
|
22
|
+
is too long to fit on the tool widget. Unfortunately, I haven't as yet found
|
23
|
+
out how to do the same for the example descriptions
|
24
|
+
* Replaced Switch to File and Switch to Spec menu entries in the Ruby/Test menu
|
25
|
+
with a single menu entry, which changes its name and behaviour depending on
|
26
|
+
whether the current file is a spec file or not
|
27
|
+
* Added an option allowing to choose whether switching from spec file to code file
|
28
|
+
(and the other way round) should be done by opening another tab or splitting
|
29
|
+
the current editor
|
30
|
+
* Added a widget to display the output in the Command plugin. The widget is hidden
|
31
|
+
by default and can be shown using a button
|
32
|
+
* Added menu entries (with the corresponding shortcuts) to move between split views
|
33
|
+
in the current pane
|
34
|
+
* Disabled autoscrolling in tool widgets if the scroll bar is not at the end. This
|
35
|
+
way, the user can look at a particular piece of output while other lines are
|
36
|
+
appended at the end. This behaviour is the same used, for example, by Konsole
|
37
|
+
|
38
|
+
h3. Minor changes
|
39
|
+
|
40
|
+
* Scrolling on an editor using the mouse wheel gives focus to the editor
|
41
|
+
|
42
|
+
h3. Bug fixes
|
43
|
+
|
44
|
+
* Restored the Close Current Tab menu entry, which disappeared during the previous
|
45
|
+
round of changes to ruberui.rc
|
46
|
+
* Do not attempt to require @kio@ if using KDE 4.4. @kio.rb@ was split from
|
47
|
+
@korundum4.rb@ in KDE 4.5, so requiring it in KDE 4.4 fails
|
48
|
+
* When an exception is raised while executing code from the Command plugin, display
|
49
|
+
an OK button, rather than a Quit Ruber button, since pressing the button will
|
50
|
+
not (and should not) quit Ruber
|
51
|
+
* Fixed a crash involved nested split views
|
52
|
+
* Fixed a crash happening every time you tried to customize shortcuts after closing
|
53
|
+
a document (which meant always if you use the State plugin). The problem was
|
54
|
+
was caused by the Window/Switch to Document submenu being updated incorrectly
|
55
|
+
when a document was closed
|
56
|
+
|
3
57
|
h2. Ruber 0.0.7
|
4
58
|
|
5
59
|
* Ability to split views in tabs
|
data/bin/ruber
CHANGED
@@ -22,12 +22,23 @@ module QtEnumerable
|
|
22
22
|
end
|
23
23
|
|
24
24
|
require 'korundum4'
|
25
|
-
|
25
|
+
|
26
|
+
#In korundum 4.4, there's no kio.rb. So, check whether KDE::IconButton (one of
|
27
|
+
#the classes defined in kio.rb in korundum 4.5) is defined and only attempt to
|
28
|
+
#require kio if it isn't.
|
29
|
+
#
|
30
|
+
#In theory, one should check the KDE version, but there's no way to do that (at
|
31
|
+
#least as far as I know)
|
32
|
+
unless defined? KDE::IconButton
|
33
|
+
require 'kio'
|
34
|
+
end
|
35
|
+
|
26
36
|
require 'facets/kernel/require_relative'
|
27
37
|
|
28
38
|
require 'ruber/version'
|
29
39
|
require 'ruber/qt_sugar'
|
30
40
|
require 'ruber/kde_sugar'
|
41
|
+
require 'ruber/ktexteditor_sugar'
|
31
42
|
require 'ruber/utils'
|
32
43
|
require 'ruber/exception_widgets'
|
33
44
|
require 'ruber/component_manager.rb'
|
@@ -79,6 +79,11 @@
|
|
79
79
|
</Menu>
|
80
80
|
<Menu name="window">
|
81
81
|
<text>&Window</text>
|
82
|
+
<Action name="window-next_horizontally"/>
|
83
|
+
<Action name="window-next_vertically"/>
|
84
|
+
<Action name="window-previous_horizontally"/>
|
85
|
+
<Action name="window-previous_vertically"/>
|
86
|
+
<Separator/>
|
82
87
|
<Action name="window-split_horizontally"/>
|
83
88
|
<Action name="window-split_vertically"/>
|
84
89
|
<Separator/>
|
Binary file
|
@@ -62,7 +62,7 @@ The default plugins to load
|
|
62
62
|
|
63
63
|
Currently, they are: ruby_development, find_in_files, syntax_checker, command and state
|
64
64
|
=end
|
65
|
-
DEFAULT_PLUGINS = %w[ruby_development find_in_files rake command syntax_checker state]
|
65
|
+
DEFAULT_PLUGINS = %w[ruby_development find_in_files rake command syntax_checker state auto_end project_browser]
|
66
66
|
|
67
67
|
include PluginLike
|
68
68
|
|
@@ -349,14 +349,34 @@ Returns the path of the document
|
|
349
349
|
end
|
350
350
|
|
351
351
|
=begin rdoc
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
352
|
+
The document's text
|
353
|
+
|
354
|
+
@overload text
|
355
|
+
The text in the whole document
|
356
|
+
@return [String] the text in the whole document
|
357
|
+
@overload text range, block = false
|
358
|
+
The text contained in the given range
|
359
|
+
@param [KTextEditor::Range] range the range of text to retrieve
|
360
|
+
@param [Boolean] block whether or not to consider the range as a visual block
|
361
|
+
@return [String] the text inside the range. An empty string is returned if
|
362
|
+
the range is invalid
|
363
|
+
@note We can't just delegate this method to the internal @KTextEditor::Document@
|
364
|
+
because its @text@ method returns nil if there's no text in the document, instead
|
356
365
|
of an empty string.
|
357
366
|
=end
|
358
|
-
def text
|
359
|
-
@doc.text || ''
|
367
|
+
def text *args
|
368
|
+
@doc.text(*args) || ''
|
369
|
+
end
|
370
|
+
|
371
|
+
=begin rdoc
|
372
|
+
As @KTextEditor::Document#line@
|
373
|
+
|
374
|
+
@param [Integer] n the line number
|
375
|
+
@return [String] the text in the given line or an empty string if the line is out
|
376
|
+
of range
|
377
|
+
=end
|
378
|
+
def line n
|
379
|
+
@doc.line(n) || ''
|
360
380
|
end
|
361
381
|
|
362
382
|
=begin rdoc
|
@@ -106,10 +106,30 @@ module Ruber
|
|
106
106
|
|
107
107
|
@view.context_menu = @view.default_context_menu(Qt::Menu.new(@view))
|
108
108
|
|
109
|
+
self.focus_policy = Qt::WheelFocus
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
=begin rdoc
|
114
|
+
Moves the cursor of the given amount
|
115
|
+
|
116
|
+
If the cursor ends up being out of range, nothing is done
|
117
|
+
@param [Integer] row the amount of rows to move the cursor of. If it's negative,
|
118
|
+
the cursor will be moved upwards, otherwise it'll be moved downwards
|
119
|
+
@param [Integer] col the amount of columns to move the cursor of. If it's negative,
|
120
|
+
the cursor will be moved to the left, otherwise it'll be moved to the right
|
121
|
+
@return [Boolean] *true* if the cursor was moved successfully and *false* if it
|
122
|
+
was out of range
|
123
|
+
=end
|
124
|
+
def move_cursor_by row, col
|
125
|
+
cur = @view.cursor_position
|
126
|
+
cur.line += row
|
127
|
+
cur.column += col
|
128
|
+
@view.set_cursor_position cur
|
109
129
|
end
|
110
130
|
|
111
131
|
def go_to row, col
|
112
|
-
@view.
|
132
|
+
@view.set_cursor_position KTextEditor::Cursor.new(row, col)
|
113
133
|
end
|
114
134
|
|
115
135
|
def show_annotation_border
|
@@ -127,7 +147,6 @@ module Ruber
|
|
127
147
|
def close
|
128
148
|
emit closing self
|
129
149
|
super
|
130
|
-
# delete_later
|
131
150
|
end
|
132
151
|
|
133
152
|
def set_annotation_border_visible vis
|
@@ -84,7 +84,7 @@ will be used
|
|
84
84
|
connect view.selection_model, SIGNAL('selectionChanged(QItemSelection, QItemSelection)'), self, SLOT('selection_changed(QItemSelection, QItemSelection)')
|
85
85
|
@editor = KDE::LineEdit.new self
|
86
86
|
connect @editor, SIGNAL('returnPressed(QString)'), self, SLOT(:create_filter_from_editor)
|
87
|
-
layout.add_widget @editor,
|
87
|
+
layout.add_widget @editor, 2, 0
|
88
88
|
def @editor.keyReleaseEvent e
|
89
89
|
super
|
90
90
|
hide if e.key == Qt::Key_Escape and e.modifiers == 0
|
@@ -0,0 +1,124 @@
|
|
1
|
+
=begin
|
2
|
+
Copyright (C) 2011 by Stefano Crocco
|
3
|
+
stefano.crocco@alice.it
|
4
|
+
|
5
|
+
This program is free software; you can redistribute it andor modify
|
6
|
+
it under the terms of the GNU General Public License as published by
|
7
|
+
the Free Software Foundation; either version 2 of the License, or
|
8
|
+
(at your option) any later version.
|
9
|
+
|
10
|
+
This program is distributed in the hope that it will be useful,
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
GNU General Public License for more details.
|
14
|
+
|
15
|
+
You should have received a copy of the GNU General Public License
|
16
|
+
along with this program; if not, write to the
|
17
|
+
Free Software Foundation, Inc.,
|
18
|
+
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
19
|
+
=end
|
20
|
+
|
21
|
+
require 'korundum4'
|
22
|
+
require 'ktexteditor'
|
23
|
+
|
24
|
+
module KTextEditor
|
25
|
+
|
26
|
+
class Cursor
|
27
|
+
|
28
|
+
=begin rdoc
|
29
|
+
Override of @Object#inspect@
|
30
|
+
|
31
|
+
@return [String] a string representation of the cursor which displays line and column
|
32
|
+
number
|
33
|
+
=end
|
34
|
+
def inspect
|
35
|
+
if !disposed?
|
36
|
+
"<#{self.class}:#{object_id} line=#{line} column=#{column}>"
|
37
|
+
else "<#{self.class}:#{object_id} DISPOSED>"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
=begin rdoc
|
42
|
+
Override of @Object#==@
|
43
|
+
|
44
|
+
@param [Object] other the object to compare with *self*
|
45
|
+
@return [Boolean] *true* if _other_ is a @KTextEditor::Cursor@ with the same line
|
46
|
+
and column number and *false* otherwise
|
47
|
+
=end
|
48
|
+
def == other
|
49
|
+
return false unless other.is_a? KTextEditor::Cursor
|
50
|
+
line == other.line and column == other.column
|
51
|
+
end
|
52
|
+
|
53
|
+
=begin rdoc
|
54
|
+
Override of @Object#dup@
|
55
|
+
|
56
|
+
@return [Cursor] a {Cursor} with the same line and column number
|
57
|
+
=end
|
58
|
+
def dup
|
59
|
+
self.class.new self.line, self.column
|
60
|
+
end
|
61
|
+
|
62
|
+
=begin rdoc
|
63
|
+
Override of @Object#clone@
|
64
|
+
|
65
|
+
@return [Cursor] a {Cursor} with the same line and column number
|
66
|
+
=end
|
67
|
+
def clone
|
68
|
+
res = dup
|
69
|
+
res.freeze if self.frozen?
|
70
|
+
res
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
class Range
|
76
|
+
|
77
|
+
=begin rdoc
|
78
|
+
Override of @Object#inspect@
|
79
|
+
|
80
|
+
@return [String] a string representation of the cursor which displays the
|
81
|
+
start and end line and column
|
82
|
+
=end
|
83
|
+
def inspect
|
84
|
+
return "<#{self.class}:#{object_id} DISPOSED>" if disposed?
|
85
|
+
start_c = self.start
|
86
|
+
end_c = self.end
|
87
|
+
"<#{self.class}:#{object_id} start=(#{start_c.line};#{start_c.column}) end=(#{end_c.line};#{end_c.column})>"
|
88
|
+
end
|
89
|
+
|
90
|
+
=begin rdoc
|
91
|
+
Override of @Object#==@
|
92
|
+
|
93
|
+
@param [Object] other the object to compare with *self*
|
94
|
+
@return [Boolean] *true* if _other_ is a @KTextEditor::Range@ with the same start
|
95
|
+
and end and *false* otherwise
|
96
|
+
=end
|
97
|
+
def == other
|
98
|
+
return false unless other.is_a? KTextEditor::Range
|
99
|
+
start == other.start and self.end == other.end
|
100
|
+
end
|
101
|
+
|
102
|
+
=begin rdoc
|
103
|
+
Override of @Object#dup@
|
104
|
+
|
105
|
+
@return [Range] a {Range} with the same start and end
|
106
|
+
=end
|
107
|
+
def dup
|
108
|
+
self.class.new self.start, self.end
|
109
|
+
end
|
110
|
+
|
111
|
+
=begin rdoc
|
112
|
+
Override of @Object#clone@
|
113
|
+
|
114
|
+
@return [Range] a {Range} with the same start and end
|
115
|
+
=end
|
116
|
+
def clone
|
117
|
+
res = dup
|
118
|
+
res.freeze if self.frozen?
|
119
|
+
res
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
@@ -249,7 +249,7 @@ hint, a new one will be created, unless the @create_if_needed@ hint is *false*.
|
|
249
249
|
the given document should be created if none exists. This is different from
|
250
250
|
passing @:always@ as the value of the @:existing@ option because the latter would
|
251
251
|
cause a new editor to be created in case no one already exists for the document
|
252
|
-
@option hints [Symbol, Array<Symbol>] :
|
252
|
+
@option hints [Symbol, Array<Symbol>] :strategy ([:current, :current_tab, :first])
|
253
253
|
how to choose the exisiting editor to use in case there's more than one. If it
|
254
254
|
is an array, the strategies will be applied in turn until one has success.
|
255
255
|
If none of the given strategies succeed, @:first@ will be used. The possible
|
@@ -275,6 +275,9 @@ hint, a new one will be created, unless the @create_if_needed@ hint is *false*.
|
|
275
275
|
current editor
|
276
276
|
* @:current_tab@: place the new editor in the pane obtained splitting the first
|
277
277
|
editor in the current tab
|
278
|
+
* @:replace@: replace the current editor, if any, with the new one. If no active
|
279
|
+
editor exists, it's the same as @:new_tab@. This value (if there's an active
|
280
|
+
editor), implies that the @:existing@ option is set to @:never@
|
278
281
|
* an integer: place the new editor in the tab associated with that index (0-based),
|
279
282
|
in the pane obtained by splitting the first view
|
280
283
|
* an {EditorView}: place the new editor in the pane obtained splitting the
|
@@ -295,6 +298,13 @@ hint, a new one will be created, unless the @create_if_needed@ hint is *false*.
|
|
295
298
|
=end
|
296
299
|
def editor_for! doc, hints = DEFAULT_HINTS
|
297
300
|
hints = DEFAULT_HINTS.merge hints
|
301
|
+
if hints[:new] == :replace
|
302
|
+
if active_editor
|
303
|
+
hints[:existing] = :never
|
304
|
+
hints[:show] = false
|
305
|
+
else hints[:new] = :new_tab
|
306
|
+
end
|
307
|
+
end
|
298
308
|
docs = Ruber[:documents].documents
|
299
309
|
unless doc.is_a? Document
|
300
310
|
unless hints.has_key? :close_starting_document
|
@@ -313,7 +323,11 @@ hint, a new one will be created, unless the @create_if_needed@ hint is *false*.
|
|
313
323
|
doc = Ruber[:documents].document url
|
314
324
|
end
|
315
325
|
return unless doc
|
316
|
-
@view_manager.without_activating{@view_manager.editor_for doc, hints}
|
326
|
+
ed = @view_manager.without_activating{@view_manager.editor_for doc, hints}
|
327
|
+
if hints[:new] == :replace
|
328
|
+
replace_editor active_editor, ed
|
329
|
+
else ed
|
330
|
+
end
|
317
331
|
end
|
318
332
|
|
319
333
|
=begin rdoc
|
@@ -461,20 +475,24 @@ This method is similar to {#editor_for!} but, after retrieving the editor (creat
|
|
461
475
|
it and/or the document as needed), it activates and gives focus to it and moves
|
462
476
|
the cursor to the given position.
|
463
477
|
|
478
|
+
Besides the keys listed in {#editor_for!}, _hints_ can also contain the two entries
|
479
|
+
@:line@ and @:column@.
|
480
|
+
|
464
481
|
@see #editor_for! editor_for! for the possible entries in _hints_
|
465
482
|
@param (see #editor_for!)
|
466
|
-
@
|
467
|
-
|
468
|
-
@
|
469
|
-
|
483
|
+
@option hints [Integer,nil] line (nil) the line to move the cursor to. If *nil*,
|
484
|
+
the cursor won't be moved
|
485
|
+
@option hints [Integer] column (0) the column to move the cursor to. Ignored if
|
486
|
+
the @:line@ entry is *nil*
|
470
487
|
@return [EditorView,nil] the editor which has been activated or *nil* if the
|
471
488
|
editor couldn't be found (or created)
|
472
489
|
=end
|
473
|
-
def display_doc doc,
|
490
|
+
def display_doc doc, hints = DEFAULT_HINTS
|
474
491
|
ed = editor_for! doc, hints
|
475
492
|
return unless ed
|
476
493
|
activate_editor ed
|
477
|
-
|
494
|
+
line = hints[:line]
|
495
|
+
ed.go_to line, hints[:column] || 0 if line
|
478
496
|
ed.set_focus
|
479
497
|
ed
|
480
498
|
end
|
@@ -528,20 +546,20 @@ the latter will be closed without affecting the document.
|
|
528
546
|
method directly, unless you want to leave the corresponding document without a view
|
529
547
|
=end
|
530
548
|
def close_editor editor, ask = true
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
549
|
+
# editor_tab = self.tab(editor)
|
550
|
+
# has_focus = editor_tab.is_active_window if editor_tab
|
551
|
+
# if has_focus
|
552
|
+
# views = editor_tab.to_a
|
553
|
+
# idx = views.index(editor)
|
554
|
+
# new_view = views[idx-1] || views[idx+1]
|
555
|
+
# end
|
538
556
|
doc = editor.document
|
539
557
|
if doc.views.size > 1
|
540
558
|
editor.close
|
541
559
|
true
|
542
560
|
else doc.close ask
|
543
561
|
end
|
544
|
-
|
562
|
+
# focus_on_editor new_view if new_view
|
545
563
|
end
|
546
564
|
|
547
565
|
=begin rdoc
|
@@ -459,7 +459,7 @@ It splits the active view horizontally, so that a new copy of the view is create
|
|
459
459
|
=end
|
460
460
|
def split_horizontally
|
461
461
|
ed = active_editor
|
462
|
-
display_document ed.document,
|
462
|
+
display_document ed.document, :existing => :never, :new => ed, :split => :horizontal
|
463
463
|
end
|
464
464
|
slots :split_horizontally
|
465
465
|
|
@@ -473,7 +473,7 @@ It splits the active view vertically, so that a new copy of the view is created.
|
|
473
473
|
=end
|
474
474
|
def split_vertically
|
475
475
|
ed = active_editor
|
476
|
-
new_ed = display_document ed.document,
|
476
|
+
new_ed = display_document ed.document, :existing => :never, :new => ed, :split => :vertical
|
477
477
|
end
|
478
478
|
slots :split_vertically
|
479
479
|
|
@@ -519,8 +519,7 @@ This method is called whenever a document is created or deleted. It updates the
|
|
519
519
|
action list so that it contains an action for each of the open documents
|
520
520
|
=end
|
521
521
|
def update_switch_to_list
|
522
|
-
unplug_action_list
|
523
|
-
@switch_to_actions.each{|a| a.delete_later}
|
522
|
+
unplug_action_list "window-switch_to_open_document_list"
|
524
523
|
@switch_to_actions = Ruber[:documents].map do |doc|
|
525
524
|
a = action_collection.add_action "switch_to_#{doc.document_name}", self, SLOT(:switch_to_document)
|
526
525
|
a.text = KDE.i18n("Switch to %s") % [doc.document_name]
|
@@ -528,7 +527,7 @@ action list so that it contains an action for each of the open documents
|
|
528
527
|
a
|
529
528
|
end
|
530
529
|
@switch_to_actions = @switch_to_actions.sort_by{|a| a.object_name}
|
531
|
-
plug_action_list
|
530
|
+
plug_action_list "window-switch_to_open_document_list", @switch_to_actions
|
532
531
|
end
|
533
532
|
slots :update_switch_to_list
|
534
533
|
|
@@ -567,6 +566,73 @@ for it, replaces the active editor with it and gives focus to it.
|
|
567
566
|
end
|
568
567
|
slots 'switch_to_recent_file(KUrl)'
|
569
568
|
|
569
|
+
=begin rdoc
|
570
|
+
Slot associated with the Next/Previous View Horizontally/Vertically actions
|
571
|
+
|
572
|
+
According to the name of the action, it gives focus to the next/previous view in
|
573
|
+
the current tab going horizontally/vertically. If the current tab only contains
|
574
|
+
one view, nothing is done.
|
575
|
+
|
576
|
+
@note@ this method uses @sender@ to find out which action emitted the signal,
|
577
|
+
so you can't call it directly
|
578
|
+
@return [EditorView] the view which received focus
|
579
|
+
=end
|
580
|
+
def move_among_views
|
581
|
+
action_name = sender.object_name
|
582
|
+
direction = action_name.match('next') ? :next : :previous
|
583
|
+
orientation = action_name.match(/horizontal/) ? Qt::Horizontal : Qt::Vertical
|
584
|
+
pane = find_next_pane active_editor.parent, orientation, direction
|
585
|
+
view = pane ? pane.view : @tabs.current_widget.views[direction == :next ? 0 : -1]
|
586
|
+
focus_on_editor view
|
587
|
+
end
|
588
|
+
slots :move_among_views
|
589
|
+
|
590
|
+
=begin rdoc
|
591
|
+
Finds the next or previous pane in single view mode from a given pane
|
592
|
+
|
593
|
+
According to the second argument, the direction will be either horizontal or
|
594
|
+
vertical.
|
595
|
+
|
596
|
+
The search will be carried out first among siblings and their children, then among
|
597
|
+
ancestors.
|
598
|
+
|
599
|
+
@param [Pane] from the pane next/previous is relative to. It *must* be a single
|
600
|
+
view pane
|
601
|
+
@param [Integer] orientation whether to look for the next/previous pane horizontally
|
602
|
+
or vertically. It may be either @Qt::Horizontal@ or @Qt::Vertical@
|
603
|
+
@param [Symbol] direction whether to look for the next or previous pane. It must
|
604
|
+
be either @:next@ or @:previous@
|
605
|
+
@return [Pane,nil] the next/previous single view mode pane or *nil* if no such pane
|
606
|
+
has been found (either because the pane is toplevel or because it's the first/last)
|
607
|
+
@todo Maybe move this method to {Pane} class
|
608
|
+
=end
|
609
|
+
def find_next_pane from, orientation, direction
|
610
|
+
loop do
|
611
|
+
parent = from.parent_pane
|
612
|
+
return nil unless parent
|
613
|
+
idx = parent.splitter.index_of from
|
614
|
+
if parent.orientation == orientation
|
615
|
+
new_idx = idx + (direction == :next ? 1 : -1)
|
616
|
+
pane = parent.splitter.widget new_idx
|
617
|
+
return pane.views[0].parent if pane
|
618
|
+
end
|
619
|
+
to_try = parent.panes[direction == :next ? (idx+1)..-1 : 0...idx]
|
620
|
+
until to_try.empty? do
|
621
|
+
idx = direction == :next ? 0 : -1
|
622
|
+
pane = to_try[idx]
|
623
|
+
if pane.single_view? then to_try.delete_at idx
|
624
|
+
else
|
625
|
+
if pane.orientation == orientation then return pane.views[idx].parent
|
626
|
+
else
|
627
|
+
to_try.delete_at idx
|
628
|
+
to_try.unshift *pane.panes
|
629
|
+
end
|
630
|
+
end
|
631
|
+
end
|
632
|
+
from = parent
|
633
|
+
end
|
634
|
+
end
|
635
|
+
|
570
636
|
end
|
571
637
|
|
572
638
|
=begin rdoc
|
@@ -574,6 +640,12 @@ Class containing the settings associated with the main window
|
|
574
640
|
=end
|
575
641
|
class MainWindowSettingsWidget < Qt::Widget
|
576
642
|
|
643
|
+
=begin rdoc
|
644
|
+
Mapping between modes to open files from tool widgets and indexes in the corresponding
|
645
|
+
combo box
|
646
|
+
=end
|
647
|
+
TOOL_OPEN_FILES = [:split_horizontally, :split_vertically, :new_tab]
|
648
|
+
|
577
649
|
=begin rdoc
|
578
650
|
@param [Qt::Widget,nil] parent the parent widget
|
579
651
|
=end
|
@@ -594,6 +666,27 @@ Override of @Qt::Widget#sizeHint@
|
|
594
666
|
Qt::Size.new(380,150)
|
595
667
|
end
|
596
668
|
|
669
|
+
=begin rdoc
|
670
|
+
Read method for the @general/tool_open_files@ setting
|
671
|
+
@param [Symbol] value the value of the option. It can have any value contained
|
672
|
+
in the {TOOL_OPEN_FILES} array
|
673
|
+
@return [Symbol] value
|
674
|
+
=end
|
675
|
+
def tool_open_files= value
|
676
|
+
@ui._general__tool_open_files.current_index = TOOL_OPEN_FILES.index(value) || 0
|
677
|
+
value
|
678
|
+
end
|
679
|
+
|
680
|
+
=begin rdoc
|
681
|
+
Store method for the @general/tool_open_files@ setting
|
682
|
+
|
683
|
+
@return [Integer] the entry in {TOOL_OPEN_FILES} corresponding to the one selected in
|
684
|
+
the combo box
|
685
|
+
=end
|
686
|
+
def tool_open_files
|
687
|
+
TOOL_OPEN_FILES[@ui._general__tool_open_files.current_index]
|
688
|
+
end
|
689
|
+
|
597
690
|
end
|
598
691
|
|
599
692
|
=begin rdoc
|