2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#ifndef TEXTEDITORACTIONHANDLER_H
|
|
|
|
|
#define TEXTEDITORACTIONHANDLER_H
|
|
|
|
|
|
|
|
|
|
#include "texteditor_global.h"
|
|
|
|
|
|
2011-08-18 14:23:06 +02:00
|
|
|
#include <coreplugin/icontext.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QObject>
|
|
|
|
|
#include <QPointer>
|
|
|
|
|
#include <QList>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-08-18 14:23:06 +02:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QAction)
|
|
|
|
|
|
|
|
|
|
namespace Core {
|
|
|
|
|
class ICore;
|
|
|
|
|
class IEditor;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
namespace TextEditor {
|
2011-08-18 14:23:06 +02:00
|
|
|
class BaseTextEditorWidget;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// Redirects slots from global actions to the respective editor.
|
|
|
|
|
|
|
|
|
|
class TEXTEDITOR_EXPORT TextEditorActionHandler : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
enum OptionalActionsMask {
|
|
|
|
|
None = 0,
|
|
|
|
|
Format = 1,
|
|
|
|
|
UnCommentSelection = 2,
|
2012-03-27 23:18:46 +04:00
|
|
|
UnCollapseAll = 4,
|
|
|
|
|
FollowSymbolUnderCursor = 8,
|
|
|
|
|
JumpToFileUnderCursor = 16
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2010-08-26 18:35:30 +02:00
|
|
|
explicit TextEditorActionHandler(const char *context, uint optionalActions = None);
|
2011-08-18 14:23:06 +02:00
|
|
|
~TextEditorActionHandler();
|
|
|
|
|
|
2011-02-21 16:02:26 +01:00
|
|
|
void setupActions(BaseTextEditorWidget *editor);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
void initializeActions();
|
|
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
void updateActions();
|
|
|
|
|
void updateRedoAction();
|
|
|
|
|
void updateUndoAction();
|
|
|
|
|
void updateCopyAction();
|
|
|
|
|
|
|
|
|
|
protected:
|
2011-02-21 16:02:26 +01:00
|
|
|
const QPointer<BaseTextEditorWidget> ¤tEditor() const;
|
2011-11-10 11:36:51 +01:00
|
|
|
QAction *registerNewAction(const Core::Id &id, bool scriptable = false, const QString &title = QString());
|
|
|
|
|
QAction *registerNewAction(const Core::Id &id, QObject *receiver, const char *slot, bool scriptable = false,
|
2008-12-02 12:01:29 +01:00
|
|
|
const QString &title = QString());
|
|
|
|
|
|
2009-02-16 12:50:15 +01:00
|
|
|
enum UpdateMode { ReadOnlyMode, WriteMode };
|
2008-12-02 12:01:29 +01:00
|
|
|
UpdateMode updateMode() const;
|
|
|
|
|
|
2013-05-13 19:18:04 +02:00
|
|
|
void createActions();
|
|
|
|
|
void updateActions(UpdateMode um);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
void undoAction();
|
|
|
|
|
void redoAction();
|
|
|
|
|
void copyAction();
|
|
|
|
|
void cutAction();
|
|
|
|
|
void pasteAction();
|
2011-12-13 12:15:30 +01:00
|
|
|
void circularPasteAction();
|
2012-03-02 08:16:23 +08:00
|
|
|
void switchUtf8bomAction();
|
2008-12-02 12:01:29 +01:00
|
|
|
void selectAllAction();
|
|
|
|
|
void gotoAction();
|
|
|
|
|
void printAction();
|
|
|
|
|
void formatAction();
|
2009-07-21 10:37:00 +02:00
|
|
|
void rewrapParagraphAction();
|
2008-12-02 12:01:29 +01:00
|
|
|
void setVisualizeWhitespace(bool);
|
2008-12-09 17:43:31 +01:00
|
|
|
void cleanWhitespace();
|
2008-12-02 12:01:29 +01:00
|
|
|
void setTextWrapping(bool);
|
|
|
|
|
void unCommentSelection();
|
2010-05-20 15:10:26 +02:00
|
|
|
void unfoldAll();
|
|
|
|
|
void fold();
|
|
|
|
|
void unfold();
|
2009-05-14 17:24:35 +02:00
|
|
|
void cutLine();
|
2010-11-27 14:02:20 +09:00
|
|
|
void copyLine();
|
2008-12-02 12:01:29 +01:00
|
|
|
void deleteLine();
|
2011-09-26 14:21:19 +02:00
|
|
|
void deleteEndOfWord();
|
|
|
|
|
void deleteEndOfWordCamelCase();
|
|
|
|
|
void deleteStartOfWord();
|
|
|
|
|
void deleteStartOfWordCamelCase();
|
2008-12-02 12:01:29 +01:00
|
|
|
void selectEncoding();
|
|
|
|
|
void increaseFontSize();
|
|
|
|
|
void decreaseFontSize();
|
2009-11-30 19:00:36 +01:00
|
|
|
void resetFontSize();
|
2008-12-04 18:37:02 +01:00
|
|
|
void gotoBlockStart();
|
|
|
|
|
void gotoBlockEnd();
|
|
|
|
|
void gotoBlockStartWithSelection();
|
|
|
|
|
void gotoBlockEndWithSelection();
|
2008-12-04 19:25:20 +01:00
|
|
|
void selectBlockUp();
|
|
|
|
|
void selectBlockDown();
|
2008-12-10 18:01:33 +01:00
|
|
|
void moveLineUp();
|
|
|
|
|
void moveLineDown();
|
2009-05-15 23:17:11 +02:00
|
|
|
void copyLineUp();
|
|
|
|
|
void copyLineDown();
|
2010-01-20 17:51:05 +01:00
|
|
|
void joinLines();
|
2010-05-03 17:03:11 +02:00
|
|
|
void insertLineAbove();
|
|
|
|
|
void insertLineBelow();
|
2011-02-25 11:10:42 +01:00
|
|
|
void uppercaseSelection();
|
|
|
|
|
void lowercaseSelection();
|
2009-02-16 12:50:15 +01:00
|
|
|
void updateCurrentEditor(Core::IEditor *editor);
|
2012-01-22 17:05:02 -05:00
|
|
|
void indent();
|
|
|
|
|
void unindent();
|
2012-03-27 23:18:46 +04:00
|
|
|
void openLinkUnderCursor();
|
2013-02-05 14:14:33 +01:00
|
|
|
void openLinkUnderCursorInNextSplit();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-05-07 15:24:30 +02:00
|
|
|
void gotoLineStart();
|
|
|
|
|
void gotoLineStartWithSelection();
|
|
|
|
|
void gotoLineEnd();
|
|
|
|
|
void gotoLineEndWithSelection();
|
|
|
|
|
void gotoNextLine();
|
|
|
|
|
void gotoNextLineWithSelection();
|
|
|
|
|
void gotoPreviousLine();
|
|
|
|
|
void gotoPreviousLineWithSelection();
|
|
|
|
|
void gotoPreviousCharacter();
|
|
|
|
|
void gotoPreviousCharacterWithSelection();
|
|
|
|
|
void gotoNextCharacter();
|
|
|
|
|
void gotoNextCharacterWithSelection();
|
|
|
|
|
void gotoPreviousWord();
|
|
|
|
|
void gotoPreviousWordWithSelection();
|
|
|
|
|
void gotoNextWord();
|
|
|
|
|
void gotoNextWordWithSelection();
|
2010-11-10 12:53:45 +01:00
|
|
|
void gotoPreviousWordCamelCase();
|
|
|
|
|
void gotoPreviousWordCamelCaseWithSelection();
|
|
|
|
|
void gotoNextWordCamelCase();
|
|
|
|
|
void gotoNextWordCamelCaseWithSelection();
|
2010-05-07 15:24:30 +02:00
|
|
|
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
|
|
|
|
QAction *m_undoAction;
|
|
|
|
|
QAction *m_redoAction;
|
|
|
|
|
QAction *m_copyAction;
|
|
|
|
|
QAction *m_cutAction;
|
|
|
|
|
QAction *m_pasteAction;
|
2011-12-13 12:15:30 +01:00
|
|
|
QAction *m_circularPasteAction;
|
2012-03-02 08:16:23 +08:00
|
|
|
QAction *m_switchUtf8bomAction;
|
2008-12-02 12:01:29 +01:00
|
|
|
QAction *m_selectAllAction;
|
|
|
|
|
QAction *m_gotoAction;
|
|
|
|
|
QAction *m_printAction;
|
|
|
|
|
QAction *m_formatAction;
|
2009-07-21 10:37:00 +02:00
|
|
|
QAction *m_rewrapParagraphAction;
|
2008-12-02 12:01:29 +01:00
|
|
|
QAction *m_visualizeWhitespaceAction;
|
2008-12-09 17:43:31 +01:00
|
|
|
QAction *m_cleanWhitespaceAction;
|
2008-12-02 12:01:29 +01:00
|
|
|
QAction *m_textWrappingAction;
|
|
|
|
|
QAction *m_unCommentSelectionAction;
|
2010-05-20 15:10:26 +02:00
|
|
|
QAction *m_unfoldAllAction;
|
|
|
|
|
QAction *m_foldAction;
|
|
|
|
|
QAction *m_unfoldAction;
|
2009-05-14 17:24:35 +02:00
|
|
|
QAction *m_cutLineAction;
|
2010-11-27 14:02:20 +09:00
|
|
|
QAction *m_copyLineAction;
|
2008-12-02 12:01:29 +01:00
|
|
|
QAction *m_deleteLineAction;
|
2011-09-26 14:21:19 +02:00
|
|
|
QAction *m_deleteEndOfWordAction;
|
|
|
|
|
QAction *m_deleteEndOfWordCamelCaseAction;
|
|
|
|
|
QAction *m_deleteStartOfWordAction;
|
|
|
|
|
QAction *m_deleteStartOfWordCamelCaseAction;
|
2008-12-02 12:01:29 +01:00
|
|
|
QAction *m_selectEncodingAction;
|
|
|
|
|
QAction *m_increaseFontSizeAction;
|
|
|
|
|
QAction *m_decreaseFontSizeAction;
|
2009-11-30 19:00:36 +01:00
|
|
|
QAction *m_resetFontSizeAction;
|
2008-12-04 18:37:02 +01:00
|
|
|
QAction *m_gotoBlockStartAction;
|
|
|
|
|
QAction *m_gotoBlockEndAction;
|
|
|
|
|
QAction *m_gotoBlockStartWithSelectionAction;
|
|
|
|
|
QAction *m_gotoBlockEndWithSelectionAction;
|
2008-12-04 19:25:20 +01:00
|
|
|
QAction *m_selectBlockUpAction;
|
|
|
|
|
QAction *m_selectBlockDownAction;
|
2008-12-10 18:01:33 +01:00
|
|
|
QAction *m_moveLineUpAction;
|
|
|
|
|
QAction *m_moveLineDownAction;
|
2009-05-15 23:17:11 +02:00
|
|
|
QAction *m_copyLineUpAction;
|
|
|
|
|
QAction *m_copyLineDownAction;
|
2010-01-20 17:51:05 +01:00
|
|
|
QAction *m_joinLinesAction;
|
2010-05-03 17:03:11 +02:00
|
|
|
QAction *m_insertLineAboveAction;
|
|
|
|
|
QAction *m_insertLineBelowAction;
|
2011-02-25 11:10:42 +01:00
|
|
|
QAction *m_upperCaseSelectionAction;
|
|
|
|
|
QAction *m_lowerCaseSelectionAction;
|
2012-01-22 17:05:02 -05:00
|
|
|
QAction *m_indentAction;
|
|
|
|
|
QAction *m_unindentAction;
|
2012-03-27 23:18:46 +04:00
|
|
|
QAction *m_followSymbolAction;
|
2013-02-05 14:14:33 +01:00
|
|
|
QAction *m_followSymbolInNextSplitAction;
|
2012-03-27 23:18:46 +04:00
|
|
|
QAction *m_jumpToFileAction;
|
2013-02-05 14:14:33 +01:00
|
|
|
QAction *m_jumpToFileInNextSplitAction;
|
2011-05-19 12:25:27 +02:00
|
|
|
QList<QAction *> m_modifyingActions;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
uint m_optionalActions;
|
2011-02-21 16:02:26 +01:00
|
|
|
QPointer<BaseTextEditorWidget> m_currentEditor;
|
2010-06-25 12:56:16 +02:00
|
|
|
Core::Context m_contextId;
|
2008-12-02 12:01:29 +01:00
|
|
|
bool m_initialized;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace TextEditor
|
|
|
|
|
|
|
|
|
|
#endif // TEXTEDITORACTIONHANDLER_H
|