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