1 /**************************************************************************** 2 ** 3 ** DQt - D bindings for the Qt Toolkit 4 ** 5 ** GNU Lesser General Public License Usage 6 ** This file may be used under the terms of the GNU Lesser 7 ** General Public License version 3 as published by the Free Software 8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 9 ** packaging of this file. Please review the following information to 10 ** ensure the GNU Lesser General Public License version 3 requirements 11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 12 ** 13 ****************************************************************************/ 14 module qt.gui.textcursor; 15 extern(C++): 16 17 import qt.config; 18 import qt.core.shareddata; 19 import qt.core.string; 20 import qt.core.typeinfo; 21 import qt.gui.image; 22 import qt.gui.textdocument; 23 import qt.gui.textdocumentfragment; 24 import qt.gui.textformat; 25 import qt.gui.textlist; 26 import qt.gui.textobject; 27 import qt.gui.texttable; 28 import qt.helpers; 29 30 /+ class QTextDocument; +/ 31 extern(C++, class) struct QTextCursorPrivate; 32 /+ class QTextDocumentFragment; 33 class QTextCharFormat; 34 class QTextBlockFormat; 35 class QTextListFormat; 36 class QTextTableFormat; 37 class QTextFrameFormat; 38 class QTextImageFormat;class QTextList; 39 class QTextTable; 40 class QTextFrame; 41 class QTextBlock; +/ 42 43 @Q_MOVABLE_TYPE extern(C++, class) struct /+ Q_GUI_EXPORT +/ QTextCursor 44 { 45 public: 46 /+this();+/ 47 48 /+ explicit +/this(QTextDocument document); 49 this(QTextDocumentPrivate* p, int pos); 50 /+ explicit +/this(QTextCursorPrivate* d); 51 /+ explicit +/this(QTextFrame frame); 52 /+ explicit +/this(ref const(QTextBlock) block); 53 //@disable this(this); 54 //this(ref const(QTextCursor) cursor); 55 /+ QTextCursor &operator=(QTextCursor &&other) noexcept { swap(other); return *this; } +/ 56 /+ref QTextCursor operator =(ref const(QTextCursor) other);+/ 57 ~this(); 58 59 /+ void swap(QTextCursor &other) noexcept { qSwap(d, other.d); } +/ 60 61 bool isNull() const; 62 63 enum MoveMode { 64 MoveAnchor, 65 KeepAnchor 66 } 67 68 void setPosition(int pos, MoveMode mode = MoveMode.MoveAnchor); 69 int position() const; 70 int positionInBlock() const; 71 72 int anchor() const; 73 74 void insertText(ref const(QString) text); 75 void insertText(ref const(QString) text, ref const(QTextCharFormat) format); 76 77 enum MoveOperation { 78 NoMove, 79 80 Start, 81 Up, 82 StartOfLine, 83 StartOfBlock, 84 StartOfWord, 85 PreviousBlock, 86 PreviousCharacter, 87 PreviousWord, 88 Left, 89 WordLeft, 90 91 End, 92 Down, 93 EndOfLine, 94 EndOfWord, 95 EndOfBlock, 96 NextBlock, 97 NextCharacter, 98 NextWord, 99 Right, 100 WordRight, 101 102 NextCell, 103 PreviousCell, 104 NextRow, 105 PreviousRow 106 } 107 108 bool movePosition(MoveOperation op, MoveMode /+ = MoveAnchor +/, int n = 1); 109 110 bool visualNavigation() const; 111 void setVisualNavigation(bool b); 112 113 void setVerticalMovementX(int x); 114 int verticalMovementX() const; 115 116 void setKeepPositionOnInsert(bool b); 117 bool keepPositionOnInsert() const; 118 119 void deleteChar(); 120 void deletePreviousChar(); 121 122 enum SelectionType { 123 WordUnderCursor, 124 LineUnderCursor, 125 BlockUnderCursor, 126 Document 127 } 128 void select(SelectionType selection); 129 130 bool hasSelection() const; 131 bool hasComplexSelection() const; 132 void removeSelectedText(); 133 void clearSelection(); 134 int selectionStart() const; 135 int selectionEnd() const; 136 137 QString selectedText() const; 138 QTextDocumentFragment selection() const; 139 void selectedTableCells(int* firstRow, int* numRows, int* firstColumn, int* numColumns) const; 140 141 QTextBlock block() const; 142 143 QTextCharFormat charFormat() const; 144 void setCharFormat(ref const(QTextCharFormat) format); 145 void mergeCharFormat(ref const(QTextCharFormat) modifier); 146 147 QTextBlockFormat blockFormat() const; 148 void setBlockFormat(ref const(QTextBlockFormat) format); 149 void mergeBlockFormat(ref const(QTextBlockFormat) modifier); 150 151 QTextCharFormat blockCharFormat() const; 152 void setBlockCharFormat(ref const(QTextCharFormat) format); 153 void mergeBlockCharFormat(ref const(QTextCharFormat) modifier); 154 155 bool atBlockStart() const; 156 bool atBlockEnd() const; 157 bool atStart() const; 158 bool atEnd() const; 159 160 void insertBlock(); 161 void insertBlock(ref const(QTextBlockFormat) format); 162 void insertBlock(ref const(QTextBlockFormat) format, ref const(QTextCharFormat) charFormat); 163 164 QTextList insertList(ref const(QTextListFormat) format); 165 QTextList insertList(QTextListFormat.Style style); 166 167 QTextList createList(ref const(QTextListFormat) format); 168 QTextList createList(QTextListFormat.Style style); 169 QTextList currentList() const; 170 171 QTextTable insertTable(int rows, int cols, ref const(QTextTableFormat) format); 172 QTextTable insertTable(int rows, int cols); 173 QTextTable currentTable() const; 174 175 QTextFrame insertFrame(ref const(QTextFrameFormat) format); 176 QTextFrame currentFrame() const; 177 178 void insertFragment(ref const(QTextDocumentFragment) fragment); 179 180 version(QT_NO_TEXTHTMLPARSER){}else 181 { 182 void insertHtml(ref const(QString) html); 183 } 184 185 void insertImage(ref const(QTextImageFormat) format, QTextFrameFormat.Position alignment); 186 void insertImage(ref const(QTextImageFormat) format); 187 void insertImage(ref const(QString) name); 188 void insertImage(ref const(QImage) image, ref const(QString) name = globalInitVar!QString); 189 190 void beginEditBlock(); 191 void joinPreviousEditBlock(); 192 void endEditBlock(); 193 194 /+bool operator !=(ref const(QTextCursor) rhs) const;+/ 195 /+bool operator <(ref const(QTextCursor) rhs) const;+/ 196 /+bool operator <=(ref const(QTextCursor) rhs) const;+/ 197 /+bool operator ==(ref const(QTextCursor) rhs) const;+/ 198 /+bool operator >=(ref const(QTextCursor) rhs) const;+/ 199 /+bool operator >(ref const(QTextCursor) rhs) const;+/ 200 201 bool isCopyOf(ref const(QTextCursor) other) const; 202 203 int blockNumber() const; 204 int columnNumber() const; 205 206 QTextDocument document() const; 207 208 private: 209 QSharedDataPointer!(QTextCursorPrivate) d; 210 /+ friend class QTextCursorPrivate; +/ 211 /+ friend class QTextDocumentPrivate; +/ 212 /+ friend class QTextDocumentFragmentPrivate; +/ 213 /+ friend class QTextCopyHelper; +/ 214 /+ friend class QWidgetTextControlPrivate; +/ 215 } 216 217 /+ Q_DECLARE_SHARED(QTextCursor) +/ 218