qtextcursor.sip 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. // qtextcursor.sip generated by MetaSIP
  2. //
  3. // This file is part of the QtGui Python extension module.
  4. //
  5. // Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
  6. //
  7. // This file is part of PyQt6.
  8. //
  9. // This file may be used under the terms of the GNU General Public License
  10. // version 3.0 as published by the Free Software Foundation and appearing in
  11. // the file LICENSE included in the packaging of this file. Please review the
  12. // following information to ensure the GNU General Public License version 3.0
  13. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  14. //
  15. // If you do not wish to use this file under the terms of the GPL version 3.0
  16. // then you may purchase a commercial license. For more information contact
  17. // info@riverbankcomputing.com.
  18. //
  19. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  20. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  21. class QTextCursor
  22. {
  23. %TypeHeaderCode
  24. #include <qtextcursor.h>
  25. %End
  26. public:
  27. QTextCursor();
  28. explicit QTextCursor(QTextDocument *document);
  29. explicit QTextCursor(QTextFrame *frame);
  30. explicit QTextCursor(const QTextBlock &block);
  31. QTextCursor(const QTextCursor &cursor);
  32. ~QTextCursor();
  33. bool isNull() const;
  34. enum MoveMode
  35. {
  36. MoveAnchor,
  37. KeepAnchor,
  38. };
  39. void setPosition(int pos, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
  40. int position() const;
  41. int anchor() const;
  42. void insertText(const QString &text);
  43. void insertText(const QString &text, const QTextCharFormat &format);
  44. enum MoveOperation
  45. {
  46. NoMove,
  47. Start,
  48. Up,
  49. StartOfLine,
  50. StartOfBlock,
  51. StartOfWord,
  52. PreviousBlock,
  53. PreviousCharacter,
  54. PreviousWord,
  55. Left,
  56. WordLeft,
  57. End,
  58. Down,
  59. EndOfLine,
  60. EndOfWord,
  61. EndOfBlock,
  62. NextBlock,
  63. NextCharacter,
  64. NextWord,
  65. Right,
  66. WordRight,
  67. NextCell,
  68. PreviousCell,
  69. NextRow,
  70. PreviousRow,
  71. };
  72. bool movePosition(QTextCursor::MoveOperation op, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor, int n = 1);
  73. void deleteChar();
  74. void deletePreviousChar();
  75. enum SelectionType
  76. {
  77. WordUnderCursor,
  78. LineUnderCursor,
  79. BlockUnderCursor,
  80. Document,
  81. };
  82. void select(QTextCursor::SelectionType selection);
  83. bool hasSelection() const;
  84. bool hasComplexSelection() const;
  85. void removeSelectedText();
  86. void clearSelection();
  87. int selectionStart() const;
  88. int selectionEnd() const;
  89. QString selectedText() const;
  90. QTextDocumentFragment selection() const;
  91. void selectedTableCells(int *firstRow, int *numRows, int *firstColumn, int *numColumns) const;
  92. QTextBlock block() const;
  93. QTextCharFormat charFormat() const;
  94. void setCharFormat(const QTextCharFormat &format);
  95. void mergeCharFormat(const QTextCharFormat &modifier);
  96. QTextBlockFormat blockFormat() const;
  97. void setBlockFormat(const QTextBlockFormat &format);
  98. void mergeBlockFormat(const QTextBlockFormat &modifier);
  99. QTextCharFormat blockCharFormat() const;
  100. void setBlockCharFormat(const QTextCharFormat &format);
  101. void mergeBlockCharFormat(const QTextCharFormat &modifier);
  102. bool atBlockStart() const;
  103. bool atBlockEnd() const;
  104. bool atStart() const;
  105. bool atEnd() const;
  106. void insertBlock();
  107. void insertBlock(const QTextBlockFormat &format);
  108. void insertBlock(const QTextBlockFormat &format, const QTextCharFormat &charFormat);
  109. QTextList *insertList(const QTextListFormat &format);
  110. QTextList *insertList(QTextListFormat::Style style);
  111. QTextList *createList(const QTextListFormat &format);
  112. QTextList *createList(QTextListFormat::Style style);
  113. QTextList *currentList() const;
  114. QTextTable *insertTable(int rows, int cols, const QTextTableFormat &format);
  115. QTextTable *insertTable(int rows, int cols);
  116. QTextTable *currentTable() const;
  117. QTextFrame *insertFrame(const QTextFrameFormat &format);
  118. QTextFrame *currentFrame() const;
  119. void insertFragment(const QTextDocumentFragment &fragment);
  120. void insertHtml(const QString &html);
  121. void insertImage(const QTextImageFormat &format);
  122. void insertImage(const QTextImageFormat &format, QTextFrameFormat::Position alignment);
  123. void insertImage(const QString &name);
  124. void insertImage(const QImage &image, const QString &name = QString());
  125. void beginEditBlock();
  126. void joinPreviousEditBlock();
  127. void endEditBlock();
  128. int blockNumber() const;
  129. int columnNumber() const;
  130. bool operator!=(const QTextCursor &rhs) const;
  131. bool operator<(const QTextCursor &rhs) const;
  132. bool operator<=(const QTextCursor &rhs) const;
  133. bool operator==(const QTextCursor &rhs) const;
  134. bool operator>=(const QTextCursor &rhs) const;
  135. bool operator>(const QTextCursor &rhs) const;
  136. bool isCopyOf(const QTextCursor &other) const;
  137. bool visualNavigation() const;
  138. void setVisualNavigation(bool b);
  139. QTextDocument *document() const;
  140. int positionInBlock() const;
  141. void setVerticalMovementX(int x);
  142. int verticalMovementX() const;
  143. void setKeepPositionOnInsert(bool b);
  144. bool keepPositionOnInsert() const;
  145. void swap(QTextCursor &other /Constrained/);
  146. %If (Qt_6_4_0 -)
  147. void insertMarkdown(const QString &markdown, QTextDocument::MarkdownFeatures features = QTextDocument::MarkdownDialectGitHub);
  148. %End
  149. };