2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
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
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
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
|
|
|
|
2009-12-08 17:43:01 +01:00
|
|
|
|
2015-02-26 13:22:35 +01:00
|
|
|
#include "texteditor_global.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-02-26 13:22:35 +01:00
|
|
|
#include <QList>
|
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
|