File indexing completed on 2024-04-21 03:57:44

0001 /*
0002     SPDX-FileCopyrightText: 2001, 2002 Joseph Wenninger <jowenn@kde.org>
0003     SPDX-FileCopyrightText: 2001 Christoph Cullmann <cullmann@kde.org>
0004     SPDX-FileCopyrightText: 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #ifndef KATE_SYNTAX_MANAGER_H
0010 #define KATE_SYNTAX_MANAGER_H
0011 
0012 #include <KSyntaxHighlighting/Definition>
0013 #include <KSyntaxHighlighting/Repository>
0014 #include <KSyntaxHighlighting/Theme>
0015 
0016 #include <QObject>
0017 
0018 #include <memory>
0019 #include <unordered_map>
0020 
0021 class KateHighlighting;
0022 
0023 class KateHlManager : public QObject
0024 {
0025     Q_OBJECT
0026 
0027 public:
0028     KateHlManager() = default;
0029 
0030     static KateHlManager *self();
0031 
0032     KateHighlighting *getHl(int n);
0033     int nameFind(const QString &name) const;
0034 
0035     void reload();
0036 
0037 Q_SIGNALS:
0038     void changed();
0039 
0040     //
0041     // methods to get the default style count + names
0042     //
0043 public:
0044     /**
0045      * Get the mode list
0046      * @return mode list
0047      */
0048     QList<KSyntaxHighlighting::Definition> modeList() const
0049     {
0050         return m_repository.definitions();
0051     }
0052 
0053     /**
0054      * Get repository.
0055      * @return repository
0056      */
0057     KSyntaxHighlighting::Repository &repository()
0058     {
0059         return m_repository;
0060     }
0061 
0062     /**
0063      * Get repository (const).
0064      * @return repository
0065      */
0066     const KSyntaxHighlighting::Repository &repository() const
0067     {
0068         return m_repository;
0069     }
0070 
0071     /**
0072      * Sorted list of KSyntaxHighlighting themes.
0073      * @return list sorted by translated names for e.g. menus/...
0074      */
0075     QList<KSyntaxHighlighting::Theme> sortedThemes() const;
0076 
0077 private:
0078     /**
0079      * Syntax highlighting definitions.
0080      */
0081     KSyntaxHighlighting::Repository m_repository;
0082 
0083     /**
0084      * All loaded highlightings.
0085      */
0086     std::unordered_map<QString, std::unique_ptr<KateHighlighting>> m_hlDict;
0087 };
0088 #endif