qsciabstractapis.h 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // This module defines interface to the QsciAbstractAPIs class.
  2. //
  3. // Copyright (c) 2017 Riverbank Computing Limited <info@riverbankcomputing.com>
  4. //
  5. // This file is part of QScintilla.
  6. //
  7. // This file may be used under the terms of the GNU General Public License
  8. // version 3.0 as published by the Free Software Foundation and appearing in
  9. // the file LICENSE included in the packaging of this file. Please review the
  10. // following information to ensure the GNU General Public License version 3.0
  11. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  12. //
  13. // If you do not wish to use this file under the terms of the GPL version 3.0
  14. // then you may purchase a commercial license. For more information contact
  15. // info@riverbankcomputing.com.
  16. //
  17. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  18. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  19. #ifndef QSCIABSTRACTAPIS_H
  20. #define QSCIABSTRACTAPIS_H
  21. #include <QList>
  22. #include <QObject>
  23. #include <QStringList>
  24. #include <Qsci/qsciglobal.h>
  25. #include <Qsci/qsciscintilla.h>
  26. class QsciLexer;
  27. //! \brief The QsciAbstractAPIs class represents the interface to the textual
  28. //! API information used in call tips and for auto-completion. A sub-class
  29. //! will provide the actual implementation of the interface.
  30. //!
  31. //! API information is specific to a particular language lexer but can be
  32. //! shared by multiple instances of the lexer.
  33. class QSCINTILLA_EXPORT QsciAbstractAPIs : public QObject
  34. {
  35. Q_OBJECT
  36. public:
  37. //! Constructs a QsciAbstractAPIs instance attached to lexer \a lexer. \a
  38. //! lexer becomes the instance's parent object although the instance can
  39. //! also be subsequently attached to other lexers.
  40. QsciAbstractAPIs(QsciLexer *lexer);
  41. //! Destroy the QsciAbstractAPIs instance.
  42. virtual ~QsciAbstractAPIs();
  43. //! Return the lexer that the instance is attached to.
  44. QsciLexer *lexer() const;
  45. //! Update the list \a list with API entries derived from \a context. \a
  46. //! context is the list of words in the text preceding the cursor position.
  47. //! The characters that make up a word and the characters that separate
  48. //! words are defined by the lexer. The last word is a partial word and
  49. //! may be empty if the user has just entered a word separator.
  50. virtual void updateAutoCompletionList(const QStringList &context,
  51. QStringList &list) = 0;
  52. //! This is called when the user selects the entry \a selection from the
  53. //! auto-completion list. A sub-class can use this as a hint to provide
  54. //! more specific API entries in future calls to
  55. //! updateAutoCompletionList(). The default implementation does nothing.
  56. virtual void autoCompletionSelected(const QString &selection);
  57. //! Return the call tips valid for the context \a context. (Note that the
  58. //! last word of the context will always be empty.) \a commas is the number
  59. //! of commas the user has typed after the context and before the cursor
  60. //! position. The exact position of the list of call tips can be adjusted
  61. //! by specifying a corresponding left character shift in \a shifts. This
  62. //! is normally done to correct for any displayed context according to \a
  63. //! style.
  64. //!
  65. //! \sa updateAutoCompletionList()
  66. virtual QStringList callTips(const QStringList &context, int commas,
  67. QsciScintilla::CallTipsStyle style, QList<int> &shifts) = 0;
  68. private:
  69. QsciLexer *lex;
  70. QsciAbstractAPIs(const QsciAbstractAPIs &);
  71. QsciAbstractAPIs &operator=(const QsciAbstractAPIs &);
  72. };
  73. #endif