qsyntaxhighlighter.sip 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // qsyntaxhighlighter.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 QSyntaxHighlighter : public QObject
  22. {
  23. %TypeHeaderCode
  24. #include <qsyntaxhighlighter.h>
  25. %End
  26. public:
  27. explicit QSyntaxHighlighter(QTextDocument *parent /TransferThis/);
  28. explicit QSyntaxHighlighter(QObject *parent /TransferThis/);
  29. virtual ~QSyntaxHighlighter();
  30. void setDocument(QTextDocument *doc /KeepReference/);
  31. QTextDocument *document() const;
  32. public slots:
  33. void rehighlight();
  34. void rehighlightBlock(const QTextBlock &block);
  35. protected:
  36. virtual void highlightBlock(const QString &text) = 0;
  37. void setFormat(int start, int count, const QTextCharFormat &format);
  38. void setFormat(int start, int count, const QColor &color);
  39. void setFormat(int start, int count, const QFont &font);
  40. QTextCharFormat format(int pos) const;
  41. int previousBlockState() const;
  42. int currentBlockState() const;
  43. void setCurrentBlockState(int newState);
  44. void setCurrentBlockUserData(QTextBlockUserData *data /GetWrapper/);
  45. %MethodCode
  46. // Ownership of the user data is with the document not the syntax highlighter.
  47. typedef PyObject *(*helper_func)(QObject *, const sipTypeDef *);
  48. static helper_func helper = 0;
  49. if (!helper)
  50. {
  51. helper = (helper_func)sipImportSymbol("qtgui_wrap_ancestors");
  52. Q_ASSERT(helper);
  53. }
  54. QTextDocument *td = sipCpp->document();
  55. if (td)
  56. {
  57. PyObject *py_td = helper(td, sipType_QTextDocument);
  58. if (!py_td)
  59. {
  60. sipIsErr = 1;
  61. }
  62. else
  63. {
  64. sipTransferTo(a0Wrapper, py_td);
  65. Py_DECREF(py_td);
  66. }
  67. }
  68. #if defined(SIP_PROTECTED_IS_PUBLIC)
  69. sipCpp->setCurrentBlockUserData(a0);
  70. #else
  71. sipCpp->sipProtect_setCurrentBlockUserData(a0);
  72. #endif
  73. %End
  74. QTextBlockUserData *currentBlockUserData() const;
  75. QTextBlock currentBlock() const;
  76. };