2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 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
|
2014-10-15 14:46:23 +02:00
|
|
|
** conditions see http://www.qt.io/licensing. For further information
|
|
|
|
|
** use the contact form at http://www.qt.io/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
|
2014-10-15 14:46:23 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
|
|
|
|
** 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
|
|
|
|
2014-09-29 00:39:38 +03:00
|
|
|
#ifndef TEXTEDITOR_P_H
|
|
|
|
|
#define TEXTEDITOR_P_H
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-09-26 09:14:03 +02:00
|
|
|
#include "texteditor.h"
|
2009-12-09 16:27:34 +01:00
|
|
|
#include "behaviorsettings.h"
|
2009-12-08 17:43:01 +01:00
|
|
|
#include "displaysettings.h"
|
2014-01-09 14:44:25 +01:00
|
|
|
#include "marginsettings.h"
|
2009-12-08 17:43:01 +01:00
|
|
|
#include "fontsettings.h"
|
2010-07-02 13:47:14 +02:00
|
|
|
#include "refactoroverlay.h"
|
2009-12-08 17:43:01 +01:00
|
|
|
|
2012-11-21 21:47:17 +02:00
|
|
|
#include <coreplugin/id.h>
|
2009-11-26 12:19:58 +01:00
|
|
|
#include <utils/changeset.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QBasicTimer>
|
2013-01-09 13:31:15 +08:00
|
|
|
#include <QSharedPointer>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QPointer>
|
|
|
|
|
#include <QScopedPointer>
|
2013-03-12 12:06:15 +01:00
|
|
|
#include <QTextBlock>
|
2013-05-24 12:53:35 +02:00
|
|
|
#include <QTimer>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
namespace TextEditor {
|
|
|
|
|
|
2014-09-22 18:43:31 +02:00
|
|
|
class TextDocument;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
namespace Internal {
|
2011-08-18 14:23:06 +02:00
|
|
|
class TextEditorOverlay;
|
2012-03-12 17:38:54 +01:00
|
|
|
class ClipboardAssistProvider;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-09-26 11:37:54 +02:00
|
|
|
class TEXTEDITOR_EXPORT TextBlockSelection
|
2010-11-01 16:29:45 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2014-09-26 11:37:54 +02:00
|
|
|
TextBlockSelection()
|
2014-06-16 14:20:36 +02:00
|
|
|
: positionBlock(0), positionColumn(0)
|
|
|
|
|
, anchorBlock(0) , anchorColumn(0){}
|
2014-09-26 11:37:54 +02:00
|
|
|
TextBlockSelection(const TextBlockSelection &other);
|
2014-06-16 14:20:36 +02:00
|
|
|
|
|
|
|
|
void clear();
|
2014-09-22 18:43:31 +02:00
|
|
|
QTextCursor selection(const TextDocument *baseTextDocument) const;
|
|
|
|
|
QTextCursor cursor(const TextDocument *baseTextDocument) const;
|
2014-06-16 14:20:36 +02:00
|
|
|
void fromPostition(int positionBlock, int positionColumn, int anchorBlock, int anchorColumn);
|
|
|
|
|
bool hasSelection() { return !(positionBlock == anchorBlock && positionColumn == anchorColumn); }
|
|
|
|
|
|
|
|
|
|
// defines the first block
|
|
|
|
|
inline int firstBlockNumber() const { return qMin(positionBlock, anchorBlock); }
|
|
|
|
|
// defines the last block
|
|
|
|
|
inline int lastBlockNumber() const { return qMax(positionBlock, anchorBlock); }
|
|
|
|
|
// defines the first visual column of the selection
|
|
|
|
|
inline int firstVisualColumn() const { return qMin(positionColumn, anchorColumn); }
|
|
|
|
|
// defines the last visual column of the selection
|
|
|
|
|
inline int lastVisualColumn() const { return qMax(positionColumn, anchorColumn); }
|
2010-11-01 16:29:45 +01:00
|
|
|
|
2014-06-16 14:20:36 +02:00
|
|
|
public:
|
|
|
|
|
int positionBlock;
|
|
|
|
|
int positionColumn;
|
|
|
|
|
int anchorBlock;
|
|
|
|
|
int anchorColumn;
|
|
|
|
|
|
|
|
|
|
private:
|
2014-09-22 18:43:31 +02:00
|
|
|
QTextCursor cursor(const TextDocument *baseTextDocument, bool fullSelection) const;
|
2010-11-01 16:29:45 +01:00
|
|
|
};
|
|
|
|
|
|
2014-09-26 11:37:54 +02:00
|
|
|
//
|
|
|
|
|
// TextEditorPrivate
|
|
|
|
|
//
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-09-26 11:37:54 +02:00
|
|
|
struct TextEditorPrivateHighlightBlocks
|
2009-04-23 17:28:53 +02:00
|
|
|
{
|
|
|
|
|
QList<int> open;
|
|
|
|
|
QList<int> close;
|
|
|
|
|
QList<int> visualIndent;
|
2009-04-28 11:43:13 +02:00
|
|
|
inline int count() const { return visualIndent.size(); }
|
2009-04-24 16:44:48 +02:00
|
|
|
inline bool isEmpty() const { return open.isEmpty() || close.isEmpty() || visualIndent.isEmpty(); }
|
2014-09-26 11:37:54 +02:00
|
|
|
inline bool operator==(const TextEditorPrivateHighlightBlocks &o) const {
|
2009-04-23 17:28:53 +02:00
|
|
|
return (open == o.open && close == o.close && visualIndent == o.visualIndent);
|
|
|
|
|
}
|
2014-09-26 11:37:54 +02:00
|
|
|
inline bool operator!=(const TextEditorPrivateHighlightBlocks &o) const { return !(*this == o); }
|
2009-04-23 17:28:53 +02:00
|
|
|
};
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace TextEditor
|
|
|
|
|
|
2014-09-29 00:39:38 +03:00
|
|
|
#endif // TEXTEDITOR_P_H
|