texteditoractionhandler.cpp 34.2 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
con's avatar
con committed
2
**
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
con's avatar
con committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
con's avatar
con committed
7
**
hjk's avatar
hjk committed
8
9
10
11
12
13
14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15
**
16
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17
18
19
20
21
22
23
24
25
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
26
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
hjk's avatar
hjk committed
29

con's avatar
con committed
30
#include "texteditoractionhandler.h"
31

con's avatar
con committed
32
#include "basetexteditor.h"
33
#include "displaysettings.h"
con's avatar
con committed
34
#include "linenumberfilter.h"
35
36
#include "texteditorconstants.h"
#include "texteditorplugin.h"
con's avatar
con committed
37

con's avatar
con committed
38
#include <locator/locatormanager.h>
39
#include <coreplugin/icore.h>
con's avatar
con committed
40
#include <coreplugin/coreconstants.h>
41
#include <coreplugin/actionmanager/actionmanager.h>
42
#include <coreplugin/actionmanager/actioncontainer.h>
hjk's avatar
hjk committed
43
#include <utils/qtcassert.h>
con's avatar
con committed
44

hjk's avatar
hjk committed
45
#include <QDebug>
46
#include <QAction>
con's avatar
con committed
47
48
49
50

using namespace TextEditor;
using namespace TextEditor::Internal;

51
TextEditorActionHandler::TextEditorActionHandler(const char *context,
52
                                                 uint optionalActions)
53
  : QObject(Core::ICore::instance()),
54
55
56
57
58
    m_undoAction(0),
    m_redoAction(0),
    m_copyAction(0),
    m_cutAction(0),
    m_pasteAction(0),
59
    m_circularPasteAction(0),
60
    m_switchUtf8bomAction(0),
61
62
63
64
65
66
67
68
    m_selectAllAction(0),
    m_gotoAction(0),
    m_printAction(0),
    m_formatAction(0),
    m_visualizeWhitespaceAction(0),
    m_cleanWhitespaceAction(0),
    m_textWrappingAction(0),
    m_unCommentSelectionAction(0),
mae's avatar
mae committed
69
70
71
    m_unfoldAllAction(0),
    m_foldAction(0),
    m_unfoldAction(0),
72
    m_cutLineAction(0),
73
    m_copyLineAction(0),
74
    m_deleteLineAction(0),
75
76
77
78
    m_deleteEndOfWordAction(0),
    m_deleteEndOfWordCamelCaseAction(0),
    m_deleteStartOfWordAction(0),
    m_deleteStartOfWordCamelCaseAction(0),
79
80
81
    m_selectEncodingAction(0),
    m_increaseFontSizeAction(0),
    m_decreaseFontSizeAction(0),
mae's avatar
mae committed
82
    m_resetFontSizeAction(0),
83
84
85
86
87
88
89
90
91
92
    m_gotoBlockStartAction(0),
    m_gotoBlockEndAction(0),
    m_gotoBlockStartWithSelectionAction(0),
    m_gotoBlockEndWithSelectionAction(0),
    m_selectBlockUpAction(0),
    m_selectBlockDownAction(0),
    m_moveLineUpAction(0),
    m_moveLineDownAction(0),
    m_copyLineUpAction(0),
    m_copyLineDownAction(0),
93
    m_joinLinesAction(0),
94
95
96
97
    m_insertLineAboveAction(0),
    m_insertLineBelowAction(0),
    m_upperCaseSelectionAction(0),
    m_lowerCaseSelectionAction(0),
98
99
    m_indentAction(0),
    m_unindentAction(0),
100
    m_followSymbolAction(0),
101
    m_followSymbolInNextSplitAction(0),
102
    m_jumpToFileAction(0),
103
    m_jumpToFileInNextSplitAction(0),
con's avatar
con committed
104
105
    m_optionalActions(optionalActions),
    m_currentEditor(0),
106
    m_contextId(context),
con's avatar
con committed
107
108
    m_initialized(false)
{
hjk's avatar
hjk committed
109
    connect(Core::ICore::editorManager(), SIGNAL(currentEditorChanged(Core::IEditor*)),
110
        this, SLOT(updateCurrentEditor(Core::IEditor*)));
con's avatar
con committed
111
112
}

113
114
115
116
TextEditorActionHandler::~TextEditorActionHandler()
{
}

117
void TextEditorActionHandler::setupActions(BaseTextEditorWidget *editor)
con's avatar
con committed
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
{
    initializeActions();
    editor->setActionHack(this);
    QObject::connect(editor, SIGNAL(undoAvailable(bool)), this, SLOT(updateUndoAction()));
    QObject::connect(editor, SIGNAL(redoAvailable(bool)), this, SLOT(updateRedoAction()));
    QObject::connect(editor, SIGNAL(copyAvailable(bool)), this, SLOT(updateCopyAction()));
}


void TextEditorActionHandler::initializeActions()
{
    if (!m_initialized) {
        createActions();
        m_initialized = true;
    }
}

void TextEditorActionHandler::createActions()
{
hjk's avatar
hjk committed
137
    m_undoAction      = registerNewAction(Core::Constants::UNDO,      this, SLOT(undoAction()),
138
                                          true, tr("&Undo"));
hjk's avatar
hjk committed
139
    m_redoAction      = registerNewAction(Core::Constants::REDO,      this, SLOT(redoAction()),
140
                                          true, tr("&Redo"));
hjk's avatar
hjk committed
141
142
143
    m_copyAction      = registerNewAction(Core::Constants::COPY,      this, SLOT(copyAction()), true);
    m_cutAction       = registerNewAction(Core::Constants::CUT,       this, SLOT(cutAction()), true);
    m_pasteAction     = registerNewAction(Core::Constants::PASTE,     this, SLOT(pasteAction()), true);
144
    m_modifyingActions << m_pasteAction;
hjk's avatar
hjk committed
145
146
147
    m_selectAllAction = registerNewAction(Core::Constants::SELECTALL, this, SLOT(selectAllAction()), true);
    m_gotoAction      = registerNewAction(Core::Constants::GOTO,      this, SLOT(gotoAction()));
    m_printAction     = registerNewAction(Core::Constants::PRINT,     this, SLOT(printAction()));
con's avatar
con committed
148

Eike Ziller's avatar
Eike Ziller committed
149
150
    Core::ActionContainer *medit = Core::ActionManager::actionContainer(Core::Constants::M_EDIT);
    Core::ActionContainer *advancedMenu = Core::ActionManager::actionContainer(Core::Constants::M_EDIT_ADVANCED);
con's avatar
con committed
151
152

    m_selectEncodingAction = new QAction(tr("Select Encoding..."), this);
Eike Ziller's avatar
Eike Ziller committed
153
    Core::Command *command = Core::ActionManager::registerAction(m_selectEncodingAction, Constants::SELECT_ENCODING, m_contextId);
con's avatar
con committed
154
155
156
157
158
    connect(m_selectEncodingAction, SIGNAL(triggered()), this, SLOT(selectEncoding()));
    medit->addAction(command, Core::Constants::G_EDIT_OTHER);


    m_formatAction = new QAction(tr("Auto-&indent Selection"), this);
159
    m_modifyingActions << m_formatAction;
Eike Ziller's avatar
Eike Ziller committed
160
    command = Core::ActionManager::registerAction(m_formatAction, TextEditor::Constants::AUTO_INDENT_SELECTION, m_contextId, true);
con's avatar
con committed
161
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+I")));
162
    advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT);
con's avatar
con committed
163
164
    connect(m_formatAction, SIGNAL(triggered(bool)), this, SLOT(formatAction()));

165
    m_rewrapParagraphAction = new QAction(tr("&Rewrap Paragraph"), this);
166
    m_modifyingActions << m_rewrapParagraphAction;
Eike Ziller's avatar
Eike Ziller committed
167
    command = Core::ActionManager::registerAction(m_rewrapParagraphAction, TextEditor::Constants::REWRAP_PARAGRAPH, m_contextId, true);
168
    command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+E, R") : tr("Ctrl+E, R")));
169
170
171
    advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT);
    connect(m_rewrapParagraphAction, SIGNAL(triggered(bool)), this, SLOT(rewrapParagraphAction()));

con's avatar
con committed
172

173
    m_visualizeWhitespaceAction = new QAction(tr("&Visualize Whitespace"), this);
con's avatar
con committed
174
    m_visualizeWhitespaceAction->setCheckable(true);
Eike Ziller's avatar
Eike Ziller committed
175
    command = Core::ActionManager::registerAction(m_visualizeWhitespaceAction,
176
                                 TextEditor::Constants::VISUALIZE_WHITESPACE, m_contextId);
177
    command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+E, Meta+V") : tr("Ctrl+E, Ctrl+V")));
178
    advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT);
con's avatar
con committed
179
180
    connect(m_visualizeWhitespaceAction, SIGNAL(triggered(bool)), this, SLOT(setVisualizeWhitespace(bool)));

181
    m_cleanWhitespaceAction = new QAction(tr("Clean Whitespace"), this);
182
    m_modifyingActions << m_cleanWhitespaceAction;
Eike Ziller's avatar
Eike Ziller committed
183
    command = Core::ActionManager::registerAction(m_cleanWhitespaceAction,
184
                                 TextEditor::Constants::CLEAN_WHITESPACE, m_contextId, true);
185

186
    advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT);
187
188
    connect(m_cleanWhitespaceAction, SIGNAL(triggered()), this, SLOT(cleanWhitespace()));

con's avatar
con committed
189
190
    m_textWrappingAction = new QAction(tr("Enable Text &Wrapping"), this);
    m_textWrappingAction->setCheckable(true);
Eike Ziller's avatar
Eike Ziller committed
191
    command = Core::ActionManager::registerAction(m_textWrappingAction, TextEditor::Constants::TEXT_WRAPPING, m_contextId);
192
    command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+E, Meta+W") : tr("Ctrl+E, Ctrl+W")));
193
    advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT);
con's avatar
con committed
194
195
196
    connect(m_textWrappingAction, SIGNAL(triggered(bool)), this, SLOT(setTextWrapping(bool)));


197
    m_unCommentSelectionAction = new QAction(tr("Toggle Comment &Selection"), this);
198
    m_modifyingActions << m_unCommentSelectionAction;
Eike Ziller's avatar
Eike Ziller committed
199
    command = Core::ActionManager::registerAction(m_unCommentSelectionAction, Constants::UN_COMMENT_SELECTION, m_contextId, true);
con's avatar
con committed
200
201
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+/")));
    connect(m_unCommentSelectionAction, SIGNAL(triggered()), this, SLOT(unCommentSelection()));
202
    advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT);
con's avatar
con committed
203

204
    m_cutLineAction = new QAction(tr("Cut &Line"), this);
205
    m_modifyingActions << m_cutLineAction;
Eike Ziller's avatar
Eike Ziller committed
206
    command = Core::ActionManager::registerAction(m_cutLineAction, Constants::CUT_LINE, m_contextId, true);
207
208
209
    command->setDefaultKeySequence(QKeySequence(tr("Shift+Del")));
    connect(m_cutLineAction, SIGNAL(triggered()), this, SLOT(cutLine()));

210
    m_copyLineAction = new QAction(tr("Copy &Line"), this);
Eike Ziller's avatar
Eike Ziller committed
211
    command = Core::ActionManager::registerAction(m_copyLineAction, Constants::COPY_LINE, m_contextId);
212
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Ins")));
213
214
    connect(m_copyLineAction, SIGNAL(triggered()), this, SLOT(copyLine()));

con's avatar
con committed
215
    m_deleteLineAction = new QAction(tr("Delete &Line"), this);
216
    m_modifyingActions << m_deleteLineAction;
Eike Ziller's avatar
Eike Ziller committed
217
    command = Core::ActionManager::registerAction(m_deleteLineAction, Constants::DELETE_LINE, m_contextId, true);
con's avatar
con committed
218
219
    connect(m_deleteLineAction, SIGNAL(triggered()), this, SLOT(deleteLine()));

220
    m_deleteEndOfWordAction = new QAction(tr("Delete Word from Cursor On"), this);
221
    m_modifyingActions << m_deleteEndOfWordAction;
Eike Ziller's avatar
Eike Ziller committed
222
    Core::ActionManager::registerAction(m_deleteEndOfWordAction, Constants::DELETE_END_OF_WORD, m_contextId, true);
223
224
    connect(m_deleteEndOfWordAction, SIGNAL(triggered()), this, SLOT(deleteEndOfWord()));

225
    m_deleteEndOfWordCamelCaseAction = new QAction(tr("Delete Word Camel Case from Cursor On"), this);
226
    m_modifyingActions << m_deleteEndOfWordCamelCaseAction;
Eike Ziller's avatar
Eike Ziller committed
227
    Core::ActionManager::registerAction(m_deleteEndOfWordCamelCaseAction, Constants::DELETE_END_OF_WORD_CAMEL_CASE, m_contextId, true);
228
229
    connect(m_deleteEndOfWordCamelCaseAction, SIGNAL(triggered()), this, SLOT(deleteEndOfWordCamelCase()));

230
    m_deleteStartOfWordAction = new QAction(tr("Delete Word up to Cursor"), this);
231
    m_modifyingActions << m_deleteStartOfWordAction;
Eike Ziller's avatar
Eike Ziller committed
232
    Core::ActionManager::registerAction(m_deleteStartOfWordAction, Constants::DELETE_START_OF_WORD, m_contextId, true);
233
234
    connect(m_deleteStartOfWordAction, SIGNAL(triggered()), this, SLOT(deleteStartOfWord()));

235
    m_deleteStartOfWordCamelCaseAction = new QAction(tr("Delete Word Camel Case up to Cursor"), this);
236
    m_modifyingActions << m_deleteStartOfWordCamelCaseAction;
Eike Ziller's avatar
Eike Ziller committed
237
    Core::ActionManager::registerAction(m_deleteStartOfWordCamelCaseAction, Constants::DELETE_START_OF_WORD_CAMEL_CASE, m_contextId, true);
238
239
    connect(m_deleteStartOfWordCamelCaseAction, SIGNAL(triggered()), this, SLOT(deleteStartOfWordCamelCase()));

mae's avatar
mae committed
240
    m_foldAction = new QAction(tr("Fold"), this);
Eike Ziller's avatar
Eike Ziller committed
241
    command = Core::ActionManager::registerAction(m_foldAction, Constants::FOLD, m_contextId, true);
con's avatar
con committed
242
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+<")));
mae's avatar
mae committed
243
    connect(m_foldAction, SIGNAL(triggered()), this, SLOT(fold()));
244
    advancedMenu->addAction(command, Core::Constants::G_EDIT_COLLAPSING);
con's avatar
con committed
245

mae's avatar
mae committed
246
    m_unfoldAction = new QAction(tr("Unfold"), this);
Eike Ziller's avatar
Eike Ziller committed
247
    command = Core::ActionManager::registerAction(m_unfoldAction, Constants::UNFOLD, m_contextId, true);
con's avatar
con committed
248
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+>")));
mae's avatar
mae committed
249
    connect(m_unfoldAction, SIGNAL(triggered()), this, SLOT(unfold()));
250
    advancedMenu->addAction(command, Core::Constants::G_EDIT_COLLAPSING);
con's avatar
con committed
251

252
    m_unfoldAllAction = new QAction(tr("Toggle &Fold All"), this);
Eike Ziller's avatar
Eike Ziller committed
253
    command = Core::ActionManager::registerAction(m_unfoldAllAction, Constants::UNFOLD_ALL, m_contextId, true);
mae's avatar
mae committed
254
    connect(m_unfoldAllAction, SIGNAL(triggered()), this, SLOT(unfoldAll()));
255
    advancedMenu->addAction(command, Core::Constants::G_EDIT_COLLAPSING);
con's avatar
con committed
256
257

    m_increaseFontSizeAction = new QAction(tr("Increase Font Size"), this);
Eike Ziller's avatar
Eike Ziller committed
258
    command = Core::ActionManager::registerAction(m_increaseFontSizeAction, Constants::INCREASE_FONT_SIZE, m_contextId);
con's avatar
con committed
259
260
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl++")));
    connect(m_increaseFontSizeAction, SIGNAL(triggered()), this, SLOT(increaseFontSize()));
261
    advancedMenu->addAction(command, Core::Constants::G_EDIT_FONT);
262

con's avatar
con committed
263
    m_decreaseFontSizeAction = new QAction(tr("Decrease Font Size"), this);
Eike Ziller's avatar
Eike Ziller committed
264
    command = Core::ActionManager::registerAction(m_decreaseFontSizeAction, Constants::DECREASE_FONT_SIZE, m_contextId);
con's avatar
con committed
265
266
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+-")));
    connect(m_decreaseFontSizeAction, SIGNAL(triggered()), this, SLOT(decreaseFontSize()));
267
    advancedMenu->addAction(command, Core::Constants::G_EDIT_FONT);
268

mae's avatar
mae committed
269
    m_resetFontSizeAction = new QAction(tr("Reset Font Size"), this);
Eike Ziller's avatar
Eike Ziller committed
270
    command = Core::ActionManager::registerAction(m_resetFontSizeAction, Constants::RESET_FONT_SIZE, m_contextId);
Eike Ziller's avatar
Eike Ziller committed
271
    command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+0") : tr("Ctrl+0")));
mae's avatar
mae committed
272
273
274
    connect(m_resetFontSizeAction, SIGNAL(triggered()), this, SLOT(resetFontSize()));
    advancedMenu->addAction(command, Core::Constants::G_EDIT_FONT);

con's avatar
con committed
275
    m_gotoBlockStartAction = new QAction(tr("Go to Block Start"), this);
Eike Ziller's avatar
Eike Ziller committed
276
    command = Core::ActionManager::registerAction(m_gotoBlockStartAction, Constants::GOTO_BLOCK_START, m_contextId, true);
277
278
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+[")));
    connect(m_gotoBlockStartAction, SIGNAL(triggered()), this, SLOT(gotoBlockStart()));
mae's avatar
mae committed
279
    advancedMenu->addAction(command, Core::Constants::G_EDIT_BLOCKS);
280

con's avatar
con committed
281
    m_gotoBlockEndAction = new QAction(tr("Go to Block End"), this);
Eike Ziller's avatar
Eike Ziller committed
282
    command = Core::ActionManager::registerAction(m_gotoBlockEndAction, Constants::GOTO_BLOCK_END, m_contextId, true);
283
284
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+]")));
    connect(m_gotoBlockEndAction, SIGNAL(triggered()), this, SLOT(gotoBlockEnd()));
mae's avatar
mae committed
285
    advancedMenu->addAction(command, Core::Constants::G_EDIT_BLOCKS);
286

287
    m_gotoBlockStartWithSelectionAction = new QAction(tr("Go to Block Start with Selection"), this);
Eike Ziller's avatar
Eike Ziller committed
288
    command = Core::ActionManager::registerAction(m_gotoBlockStartWithSelectionAction, Constants::GOTO_BLOCK_START_WITH_SELECTION, m_contextId, true);
289
290
291
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+{")));
    connect(m_gotoBlockStartWithSelectionAction, SIGNAL(triggered()), this, SLOT(gotoBlockStartWithSelection()));

292
    m_gotoBlockEndWithSelectionAction = new QAction(tr("Go to Block End with Selection"), this);
Eike Ziller's avatar
Eike Ziller committed
293
    command = Core::ActionManager::registerAction(m_gotoBlockEndWithSelectionAction, Constants::GOTO_BLOCK_END_WITH_SELECTION, m_contextId, true);
294
295
296
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+}")));
    connect(m_gotoBlockEndWithSelectionAction, SIGNAL(triggered()), this, SLOT(gotoBlockEndWithSelection()));

hjk's avatar
hjk committed
297
    m_selectBlockUpAction = new QAction(tr("Select Block Up"), this);
Eike Ziller's avatar
Eike Ziller committed
298
    command = Core::ActionManager::registerAction(m_selectBlockUpAction, Constants::SELECT_BLOCK_UP, m_contextId, true);
299
300
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+U")));
    connect(m_selectBlockUpAction, SIGNAL(triggered()), this, SLOT(selectBlockUp()));
mae's avatar
mae committed
301
    advancedMenu->addAction(command, Core::Constants::G_EDIT_BLOCKS);
302

hjk's avatar
hjk committed
303
    m_selectBlockDownAction = new QAction(tr("Select Block Down"), this);
Eike Ziller's avatar
Eike Ziller committed
304
    command = Core::ActionManager::registerAction(m_selectBlockDownAction, Constants::SELECT_BLOCK_DOWN, m_contextId, true);
305
    connect(m_selectBlockDownAction, SIGNAL(triggered()), this, SLOT(selectBlockDown()));
mae's avatar
mae committed
306
    advancedMenu->addAction(command, Core::Constants::G_EDIT_BLOCKS);
307

hjk's avatar
hjk committed
308
    m_moveLineUpAction = new QAction(tr("Move Line Up"), this);
309
    m_modifyingActions << m_moveLineUpAction;
Eike Ziller's avatar
Eike Ziller committed
310
    command = Core::ActionManager::registerAction(m_moveLineUpAction, Constants::MOVE_LINE_UP, m_contextId, true);
311
312
313
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+Up")));
    connect(m_moveLineUpAction, SIGNAL(triggered()), this, SLOT(moveLineUp()));

hjk's avatar
hjk committed
314
    m_moveLineDownAction = new QAction(tr("Move Line Down"), this);
315
    m_modifyingActions << m_moveLineDownAction;
Eike Ziller's avatar
Eike Ziller committed
316
    command = Core::ActionManager::registerAction(m_moveLineDownAction, Constants::MOVE_LINE_DOWN, m_contextId, true);
317
318
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+Down")));
    connect(m_moveLineDownAction, SIGNAL(triggered()), this, SLOT(moveLineDown()));
319

hjk's avatar
hjk committed
320
    m_copyLineUpAction = new QAction(tr("Copy Line Up"), this);
321
    m_modifyingActions << m_copyLineUpAction;
Eike Ziller's avatar
Eike Ziller committed
322
    command = Core::ActionManager::registerAction(m_copyLineUpAction, Constants::COPY_LINE_UP, m_contextId, true);
323
324
325
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Up")));
    connect(m_copyLineUpAction, SIGNAL(triggered()), this, SLOT(copyLineUp()));

hjk's avatar
hjk committed
326
    m_copyLineDownAction = new QAction(tr("Copy Line Down"), this);
327
    m_modifyingActions << m_copyLineDownAction;
Eike Ziller's avatar
Eike Ziller committed
328
    command = Core::ActionManager::registerAction(m_copyLineDownAction, Constants::COPY_LINE_DOWN, m_contextId, true);
329
330
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Down")));
    connect(m_copyLineDownAction, SIGNAL(triggered()), this, SLOT(copyLineDown()));
331

hjk's avatar
hjk committed
332
    m_joinLinesAction = new QAction(tr("Join Lines"), this);
333
    m_modifyingActions << m_joinLinesAction;
Eike Ziller's avatar
Eike Ziller committed
334
    command = Core::ActionManager::registerAction(m_joinLinesAction, Constants::JOIN_LINES, m_contextId, true);
335
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+J")));
336
    connect(m_joinLinesAction, SIGNAL(triggered()), this, SLOT(joinLines()));
337
338

    m_insertLineAboveAction = new QAction(tr("Insert Line Above Current Line"), this);
339
    m_modifyingActions << m_insertLineAboveAction;
Eike Ziller's avatar
Eike Ziller committed
340
    command = Core::ActionManager::registerAction(m_insertLineAboveAction, Constants::INSERT_LINE_ABOVE, m_contextId, true);
341
342
343
344
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+Return")));
    connect(m_insertLineAboveAction, SIGNAL(triggered()), this, SLOT(insertLineAbove()));

    m_insertLineBelowAction = new QAction(tr("Insert Line Below Current Line"), this);
345
    m_modifyingActions << m_insertLineBelowAction;
Eike Ziller's avatar
Eike Ziller committed
346
    command = Core::ActionManager::registerAction(m_insertLineBelowAction, Constants::INSERT_LINE_BELOW, m_contextId, true);
347
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Return")));
348
    connect(m_insertLineBelowAction, SIGNAL(triggered()), this, SLOT(insertLineBelow()));
mae's avatar
mae committed
349

350
    m_upperCaseSelectionAction = new QAction(tr("Uppercase Selection"), this);
351
    m_modifyingActions << m_upperCaseSelectionAction;
Eike Ziller's avatar
Eike Ziller committed
352
    command = Core::ActionManager::registerAction(m_upperCaseSelectionAction, Constants::UPPERCASE_SELECTION, m_contextId, true);
353
    command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+Shift+U") : tr("Alt+Shift+U")));
354
355
356
    connect(m_upperCaseSelectionAction, SIGNAL(triggered()), this, SLOT(uppercaseSelection()));

    m_lowerCaseSelectionAction = new QAction(tr("Lowercase Selection"), this);
357
    m_modifyingActions << m_lowerCaseSelectionAction;
Eike Ziller's avatar
Eike Ziller committed
358
    command = Core::ActionManager::registerAction(m_lowerCaseSelectionAction, Constants::LOWERCASE_SELECTION, m_contextId, true);
359
    command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+U") : tr("Alt+U")));
360
361
    connect(m_lowerCaseSelectionAction, SIGNAL(triggered()), this, SLOT(lowercaseSelection()));

362
    m_circularPasteAction = new QAction(tr("Paste from Clipboard History"), this);
363
    m_modifyingActions << m_circularPasteAction;
Eike Ziller's avatar
Eike Ziller committed
364
    command = Core::ActionManager::registerAction(m_circularPasteAction, Constants::CIRCULAR_PASTE, m_contextId, true);
365
366
367
368
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+V")));
    connect(m_circularPasteAction, SIGNAL(triggered()), this, SLOT(circularPasteAction()));
    medit->addAction(command, Core::Constants::G_EDIT_COPYPASTE);

369
370
    m_switchUtf8bomAction = new QAction(this);
    m_modifyingActions << m_switchUtf8bomAction;
Eike Ziller's avatar
Eike Ziller committed
371
    command = Core::ActionManager::registerAction(m_switchUtf8bomAction, Constants::SWITCH_UTF8BOM, m_contextId, true);
372
373
    connect(m_switchUtf8bomAction, SIGNAL(triggered()), this, SLOT(switchUtf8bomAction()));

374
375
    m_indentAction = new QAction(tr("Indent"), this);
    m_modifyingActions << m_indentAction;
Eike Ziller's avatar
Eike Ziller committed
376
    command = Core::ActionManager::registerAction(m_indentAction, Constants::INDENT, m_contextId, true);
377
378
379
380
    connect(m_indentAction, SIGNAL(triggered()), this, SLOT(indent()));

    m_unindentAction = new QAction(tr("Unindent"), this);
    m_modifyingActions << m_unindentAction;
Eike Ziller's avatar
Eike Ziller committed
381
    command = Core::ActionManager::registerAction(m_unindentAction, Constants::UNINDENT, m_contextId, true);
382
383
    connect(m_unindentAction, SIGNAL(triggered()), this, SLOT(unindent()));

384
    m_followSymbolAction = new QAction(tr("Follow Symbol Under Cursor"), this);
Eike Ziller's avatar
Eike Ziller committed
385
    command = Core::ActionManager::registerAction(m_followSymbolAction, Constants::FOLLOW_SYMBOL_UNDER_CURSOR, m_contextId, true);
386
387
388
    command->setDefaultKeySequence(QKeySequence(Qt::Key_F2));
    connect(m_followSymbolAction, SIGNAL(triggered()), this, SLOT(openLinkUnderCursor()));

389
    m_followSymbolInNextSplitAction = new QAction(tr("Follow Symbol Under Cursor in Next Split"), this);
390
391
392
393
    command = Core::ActionManager::registerAction(m_followSymbolInNextSplitAction, Constants::FOLLOW_SYMBOL_UNDER_CURSOR_IN_NEXT_SPLIT, m_contextId, true);
    command->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_E, Qt::Key_F2));
    connect(m_followSymbolInNextSplitAction, SIGNAL(triggered()), this, SLOT(openLinkUnderCursorInNextSplit()));

394
    m_jumpToFileAction = new QAction(tr("Jump To File Under Cursor"), this);
Eike Ziller's avatar
Eike Ziller committed
395
    command = Core::ActionManager::registerAction(m_jumpToFileAction, Constants::JUMP_TO_FILE_UNDER_CURSOR, m_contextId, true);
396
397
398
    command->setDefaultKeySequence(QKeySequence(Qt::Key_F2));
    connect(m_jumpToFileAction, SIGNAL(triggered()), this, SLOT(openLinkUnderCursor()));

399
    m_jumpToFileInNextSplitAction = new QAction(tr("Jump to File Under Cursor in Next Split"), this);
400
401
402
403
    command = Core::ActionManager::registerAction(m_jumpToFileInNextSplitAction, Constants::JUMP_TO_FILE_UNDER_CURSOR_IN_NEXT_SPLIT, m_contextId, true);
    command->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_E, Qt::Key_F2));
    connect(m_jumpToFileInNextSplitAction, SIGNAL(triggered()), this, SLOT(openLinkUnderCursorInNextSplit()));

mae's avatar
mae committed
404
    QAction *a = 0;
405
    a = new QAction(tr("Go to Line Start"), this);
Eike Ziller's avatar
Eike Ziller committed
406
    command = Core::ActionManager::registerAction(a, Constants::GOTO_LINE_START, m_contextId, true);
mae's avatar
mae committed
407
    connect(a, SIGNAL(triggered()), this, SLOT(gotoLineStart()));
408
    a = new QAction(tr("Go to Line End"), this);
Eike Ziller's avatar
Eike Ziller committed
409
    command = Core::ActionManager::registerAction(a, Constants::GOTO_LINE_END, m_contextId, true);
mae's avatar
mae committed
410
    connect(a, SIGNAL(triggered()), this, SLOT(gotoLineEnd()));
411
    a = new QAction(tr("Go to Next Line"), this);
Eike Ziller's avatar
Eike Ziller committed
412
    command = Core::ActionManager::registerAction(a, Constants::GOTO_NEXT_LINE, m_contextId, true);
mae's avatar
mae committed
413
    connect(a, SIGNAL(triggered()), this, SLOT(gotoNextLine()));
414
    a = new QAction(tr("Go to Previous Line"), this);
Eike Ziller's avatar
Eike Ziller committed
415
    command = Core::ActionManager::registerAction(a, Constants::GOTO_PREVIOUS_LINE, m_contextId, true);
mae's avatar
mae committed
416
    connect(a, SIGNAL(triggered()), this, SLOT(gotoPreviousLine()));
417
    a = new QAction(tr("Go to Previous Character"), this);
Eike Ziller's avatar
Eike Ziller committed
418
    command = Core::ActionManager::registerAction(a, Constants::GOTO_PREVIOUS_CHARACTER, m_contextId, true);
mae's avatar
mae committed
419
    connect(a, SIGNAL(triggered()), this, SLOT(gotoPreviousCharacter()));
420
    a = new QAction(tr("Go to Next Character"), this);
Eike Ziller's avatar
Eike Ziller committed
421
    command = Core::ActionManager::registerAction(a, Constants::GOTO_NEXT_CHARACTER, m_contextId, true);
mae's avatar
mae committed
422
    connect(a, SIGNAL(triggered()), this, SLOT(gotoNextCharacter()));
423
    a = new QAction(tr("Go to Previous Word"), this);
Eike Ziller's avatar
Eike Ziller committed
424
    command = Core::ActionManager::registerAction(a, Constants::GOTO_PREVIOUS_WORD, m_contextId, true);
mae's avatar
mae committed
425
    connect(a, SIGNAL(triggered()), this, SLOT(gotoPreviousWord()));
426
    a = new QAction(tr("Go to Next Word"), this);
Eike Ziller's avatar
Eike Ziller committed
427
    command = Core::ActionManager::registerAction(a, Constants::GOTO_NEXT_WORD, m_contextId, true);
mae's avatar
mae committed
428
    connect(a, SIGNAL(triggered()), this, SLOT(gotoNextWord()));
429
    a = new QAction(tr("Go to Previous Word Camel Case"), this);
Eike Ziller's avatar
Eike Ziller committed
430
    command = Core::ActionManager::registerAction(a, Constants::GOTO_PREVIOUS_WORD_CAMEL_CASE, m_contextId);
mae's avatar
mae committed
431
    connect(a, SIGNAL(triggered()), this, SLOT(gotoPreviousWordCamelCase()));
432
    a = new QAction(tr("Go to Next Word Camel Case"), this);
Eike Ziller's avatar
Eike Ziller committed
433
    command = Core::ActionManager::registerAction(a, Constants::GOTO_NEXT_WORD_CAMEL_CASE, m_contextId);
mae's avatar
mae committed
434
    connect(a, SIGNAL(triggered()), this, SLOT(gotoNextWordCamelCase()));
mae's avatar
mae committed
435

436
    a = new QAction(tr("Go to Line Start with Selection"), this);
Eike Ziller's avatar
Eike Ziller committed
437
    command = Core::ActionManager::registerAction(a, Constants::GOTO_LINE_START_WITH_SELECTION, m_contextId, true);
mae's avatar
mae committed
438
    connect(a, SIGNAL(triggered()), this, SLOT(gotoLineStartWithSelection()));
439
    a = new QAction(tr("Go to Line End with Selection"), this);
Eike Ziller's avatar
Eike Ziller committed
440
    command = Core::ActionManager::registerAction(a, Constants::GOTO_LINE_END_WITH_SELECTION, m_contextId, true);
mae's avatar
mae committed
441
    connect(a, SIGNAL(triggered()), this, SLOT(gotoLineEndWithSelection()));
442
    a = new QAction(tr("Go to Next Line with Selection"), this);
Eike Ziller's avatar
Eike Ziller committed
443
    command = Core::ActionManager::registerAction(a, Constants::GOTO_NEXT_LINE_WITH_SELECTION, m_contextId, true);
mae's avatar
mae committed
444
    connect(a, SIGNAL(triggered()), this, SLOT(gotoNextLineWithSelection()));
445
    a = new QAction(tr("Go to Previous Line with Selection"), this);
Eike Ziller's avatar
Eike Ziller committed
446
    command = Core::ActionManager::registerAction(a, Constants::GOTO_PREVIOUS_LINE_WITH_SELECTION, m_contextId, true);
mae's avatar
mae committed
447
    connect(a, SIGNAL(triggered()), this, SLOT(gotoPreviousLineWithSelection()));
448
    a = new QAction(tr("Go to Previous Character with Selection"), this);
Eike Ziller's avatar
Eike Ziller committed
449
    command = Core::ActionManager::registerAction(a, Constants::GOTO_PREVIOUS_CHARACTER_WITH_SELECTION, m_contextId, true);
mae's avatar
mae committed
450
    connect(a, SIGNAL(triggered()), this, SLOT(gotoPreviousCharacterWithSelection()));
451
    a = new QAction(tr("Go to Next Character with Selection"), this);
Eike Ziller's avatar
Eike Ziller committed
452
    command = Core::ActionManager::registerAction(a, Constants::GOTO_NEXT_CHARACTER_WITH_SELECTION, m_contextId, true);
mae's avatar
mae committed
453
    connect(a, SIGNAL(triggered()), this, SLOT(gotoNextCharacterWithSelection()));
454
    a = new QAction(tr("Go to Previous Word with Selection"), this);
Eike Ziller's avatar
Eike Ziller committed
455
    command = Core::ActionManager::registerAction(a, Constants::GOTO_PREVIOUS_WORD_WITH_SELECTION, m_contextId, true);
mae's avatar
mae committed
456
    connect(a, SIGNAL(triggered()), this, SLOT(gotoPreviousWordWithSelection()));
457
    a = new QAction(tr("Go to Next Word with Selection"), this);
Eike Ziller's avatar
Eike Ziller committed
458
    command = Core::ActionManager::registerAction(a, Constants::GOTO_NEXT_WORD_WITH_SELECTION, m_contextId, true);
mae's avatar
mae committed
459
    connect(a, SIGNAL(triggered()), this, SLOT(gotoNextWordWithSelection()));
460
    a = new QAction(tr("Go to Previous Word Camel Case with Selection"), this);
Eike Ziller's avatar
Eike Ziller committed
461
    command = Core::ActionManager::registerAction(a, Constants::GOTO_PREVIOUS_WORD_CAMEL_CASE_WITH_SELECTION, m_contextId);
mae's avatar
mae committed
462
    connect(a, SIGNAL(triggered()), this, SLOT(gotoPreviousWordCamelCaseWithSelection()));
463
    a = new QAction(tr("Go to Next Word Camel Case with Selection"), this);
Eike Ziller's avatar
Eike Ziller committed
464
    command = Core::ActionManager::registerAction(a, Constants::GOTO_NEXT_WORD_CAMEL_CASE_WITH_SELECTION, m_contextId);
mae's avatar
mae committed
465
    connect(a, SIGNAL(triggered()), this, SLOT(gotoNextWordCamelCaseWithSelection()));
mae's avatar
mae committed
466

con's avatar
con committed
467
468
}

hjk's avatar
hjk committed
469
bool TextEditorActionHandler::supportsAction(const Core::Id & /*id */) const
con's avatar
con committed
470
471
472
473
{
    return true;
}

hjk's avatar
hjk committed
474
QAction *TextEditorActionHandler::registerNewAction(const Core::Id &id, bool scriptable, const QString &title)
con's avatar
con committed
475
476
477
478
479
{
    if (!supportsAction(id))
        return 0;

    QAction *result = new QAction(title, this);
Eike Ziller's avatar
Eike Ziller committed
480
    Core::ActionManager::registerAction(result, id, m_contextId, scriptable);
con's avatar
con committed
481
482
483
    return result;
}

hjk's avatar
hjk committed
484
QAction *TextEditorActionHandler::registerNewAction(const Core::Id &id,
con's avatar
con committed
485
486
                                                    QObject *receiver,
                                                    const char *slot,
487
                                                    bool scriptable,
con's avatar
con committed
488
489
                                                    const QString &title)
{
490
    QAction *rc = registerNewAction(id, scriptable, title);
con's avatar
con committed
491
492
493
494
495
496
497
498
499
    if (!rc)
        return 0;

    connect(rc, SIGNAL(triggered()), receiver, slot);
    return rc;
}

TextEditorActionHandler::UpdateMode TextEditorActionHandler::updateMode() const
{
500
    Q_ASSERT(m_currentEditor != 0);
501
    return m_currentEditor->isReadOnly() ? ReadOnlyMode : WriteMode;
con's avatar
con committed
502
503
504
505
}

void TextEditorActionHandler::updateActions()
{
506
507
    if (!m_currentEditor || !m_initialized)
        return;
con's avatar
con committed
508
509
510
511
512
    updateActions(updateMode());
}

void TextEditorActionHandler::updateActions(UpdateMode um)
{
513
514
    foreach (QAction *a, m_modifyingActions)
        a->setEnabled(um != ReadOnlyMode);
515
516
    m_formatAction->setEnabled((m_optionalActions & Format) && um != ReadOnlyMode);
    m_unCommentSelectionAction->setEnabled((m_optionalActions & UnCommentSelection) && um != ReadOnlyMode);
517
    m_followSymbolAction->setEnabled(m_optionalActions & FollowSymbolUnderCursor);
518
    m_followSymbolInNextSplitAction->setEnabled(m_optionalActions & FollowSymbolUnderCursor);
519
    m_jumpToFileAction->setEnabled(m_optionalActions & JumpToFileUnderCursor);
520
    m_jumpToFileInNextSplitAction->setEnabled(m_optionalActions & JumpToFileUnderCursor);
521

mae's avatar
mae committed
522
    m_unfoldAllAction->setEnabled((m_optionalActions & UnCollapseAll));
523
    m_visualizeWhitespaceAction->setChecked(m_currentEditor->displaySettings().m_visualizeWhitespace);
524
    if (m_textWrappingAction)
525
        m_textWrappingAction->setChecked(m_currentEditor->displaySettings().m_textWrapping);
con's avatar
con committed
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545

    updateRedoAction();
    updateUndoAction();
    updateCopyAction();
}

void TextEditorActionHandler::updateRedoAction()
{
    if (m_redoAction)
        m_redoAction->setEnabled(m_currentEditor && m_currentEditor->document()->isRedoAvailable());
}

void TextEditorActionHandler::updateUndoAction()
{
    if (m_undoAction)
        m_undoAction->setEnabled(m_currentEditor && m_currentEditor->document()->isUndoAvailable());
}

void TextEditorActionHandler::updateCopyAction()
{
546
    const bool hasCopyableText = m_currentEditor && m_currentEditor->textCursor().hasSelection();
con's avatar
con committed
547
548
    if (m_cutAction)
        m_cutAction->setEnabled(hasCopyableText && updateMode() == WriteMode);
549
    if (m_copyAction)
con's avatar
con committed
550
551
552
553
554
        m_copyAction->setEnabled(hasCopyableText);
}

void TextEditorActionHandler::gotoAction()
{
con's avatar
con committed
555
    Locator::LocatorManager *locatorManager = Locator::LocatorManager::instance();
con's avatar
con committed
556
    QTC_ASSERT(locatorManager, return);
557
558
559
    QString locatorString = TextEditorPlugin::instance()->lineNumberFilter()->shortcutString();
    locatorString += QLatin1Char(' ');
    const int selectionStart = locatorString.size();
560
    locatorString += tr("<line>:<column>");
561
    locatorManager->show(locatorString, selectionStart, locatorString.size() - selectionStart);
con's avatar
con committed
562
563
564
565
566
}

void TextEditorActionHandler::printAction()
{
    if (m_currentEditor)
hjk's avatar
hjk committed
567
        m_currentEditor->print(Core::ICore::printer());
con's avatar
con committed
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
}

void TextEditorActionHandler::setVisualizeWhitespace(bool checked)
{
    if (m_currentEditor) {
        DisplaySettings ds = m_currentEditor->displaySettings();
        ds.m_visualizeWhitespace = checked;
        m_currentEditor->setDisplaySettings(ds);
    }
}

void TextEditorActionHandler::setTextWrapping(bool checked)
{
    if (m_currentEditor) {
        DisplaySettings ds = m_currentEditor->displaySettings();
        ds.m_textWrapping = checked;
        m_currentEditor->setDisplaySettings(ds);
    }
}

588
589
590
591
592
593
594
595
596
597
598
#define FUNCTION(funcname) void TextEditorActionHandler::funcname ()\
{\
    if (m_currentEditor)\
        m_currentEditor->funcname ();\
}
#define FUNCTION2(funcname, funcname2) void TextEditorActionHandler::funcname ()\
{\
    if (m_currentEditor)\
        m_currentEditor->funcname2 ();\
}

599
600
601
602
603
604

FUNCTION2(undoAction, undo)
FUNCTION2(redoAction, redo)
FUNCTION2(copyAction, copy)
FUNCTION2(cutAction, cut)
FUNCTION2(pasteAction, paste)
605
FUNCTION2(circularPasteAction, circularPaste)
606
FUNCTION2(switchUtf8bomAction, switchUtf8bom)
607
FUNCTION2(formatAction, format)
608
FUNCTION2(rewrapParagraphAction, rewrapParagraph)
609
610
FUNCTION2(selectAllAction, selectAll)
FUNCTION(cleanWhitespace)
611
FUNCTION(unCommentSelection)
612
FUNCTION(cutLine)
613
FUNCTION(copyLine)
614
FUNCTION(deleteLine)
615
616
617
618
FUNCTION(deleteEndOfWord)
FUNCTION(deleteEndOfWordCamelCase)
FUNCTION(deleteStartOfWord)
FUNCTION(deleteStartOfWordCamelCase)
mae's avatar
mae committed
619
620
621
FUNCTION(unfoldAll)
FUNCTION(fold)
FUNCTION(unfold)
622
623
FUNCTION2(increaseFontSize, zoomIn)
FUNCTION2(decreaseFontSize, zoomOut)
mae's avatar
mae committed
624
FUNCTION2(resetFontSize, zoomReset)
625
626
627
628
629
FUNCTION(selectEncoding)
FUNCTION(gotoBlockStart)
FUNCTION(gotoBlockEnd)
FUNCTION(gotoBlockStartWithSelection)
FUNCTION(gotoBlockEndWithSelection)
630
631
FUNCTION(selectBlockUp)
FUNCTION(selectBlockDown)
632
633
FUNCTION(moveLineUp)
FUNCTION(moveLineDown)
634
635
FUNCTION(copyLineUp)
FUNCTION(copyLineDown)
636
FUNCTION(joinLines)
637
638
FUNCTION(uppercaseSelection)
FUNCTION(lowercaseSelection)
639
640
FUNCTION(insertLineAbove)
FUNCTION(insertLineBelow)
641
642
FUNCTION(indent)
FUNCTION(unindent)
643
FUNCTION(openLinkUnderCursor)
644
FUNCTION(openLinkUnderCursorInNextSplit)
con's avatar
con committed
645

mae's avatar
mae committed
646
647
648
649
650
651
652
653
654
655
656
657
658
659
FUNCTION(gotoLineStart)
FUNCTION(gotoLineStartWithSelection)
FUNCTION(gotoLineEnd)
FUNCTION(gotoLineEndWithSelection)
FUNCTION(gotoNextLine)
FUNCTION(gotoNextLineWithSelection)
FUNCTION(gotoPreviousLine)
FUNCTION(gotoPreviousLineWithSelection)
FUNCTION(gotoPreviousCharacter)
FUNCTION(gotoPreviousCharacterWithSelection)
FUNCTION(gotoNextCharacter)
FUNCTION(gotoNextCharacterWithSelection)
FUNCTION(gotoPreviousWord)
FUNCTION(gotoPreviousWordWithSelection)
mae's avatar
mae committed
660
661
FUNCTION(gotoPreviousWordCamelCase)
FUNCTION(gotoPreviousWordCamelCaseWithSelection)
mae's avatar
mae committed
662
663
FUNCTION(gotoNextWord)
FUNCTION(gotoNextWordWithSelection)
mae's avatar
mae committed
664
665
FUNCTION(gotoNextWordCamelCase)
FUNCTION(gotoNextWordCamelCaseWithSelection)
mae's avatar
mae committed
666
667


668
void TextEditorActionHandler::updateCurrentEditor(Core::IEditor *editor)
con's avatar
con committed
669
{
670
671
672
673
674
    m_currentEditor = 0;

    if (!editor)
        return;

675
    BaseTextEditorWidget *baseEditor = qobject_cast<BaseTextEditorWidget *>(editor->widget());
676
677
678
679
680

    if (baseEditor && baseEditor->actionHack() == this) {
        m_currentEditor = baseEditor;
        updateActions();
    }
con's avatar
con committed
681
682
}

683
const QPointer<BaseTextEditorWidget> &TextEditorActionHandler::currentEditor() const
con's avatar
con committed
684
685
686
{
    return m_currentEditor;
}