File: lexer_configuration.h

package info (click to toggle)
codelite 6.1.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 48,992 kB
  • ctags: 43,502
  • sloc: cpp: 334,263; ansic: 18,441; xml: 4,713; yacc: 2,653; lex: 2,449; python: 1,188; sh: 385; makefile: 40
file content (168 lines) | stat: -rw-r--r-- 5,143 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright            : (C) 2008 by Eran Ifrah
// file name            : lexer_configuration.h
//
// -------------------------------------------------------------------------
// A
//              _____           _      _     _ _
//             /  __ \         | |    | |   (_) |
//             | /  \/ ___   __| | ___| |    _| |_ ___
//             | |    / _ \ / _  |/ _ \ |   | | __/ _ )
//             | \__/\ (_) | (_| |  __/ |___| | ||  __/
//              \____/\___/ \__,_|\___\_____/_|\__\___|
//
//                                                  F i l e
//
//    This program is free software; you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation; either version 2 of the License, or
//    (at your option) any later version.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#ifndef LEXER_CONFIGURATION_H
#define LEXER_CONFIGURATION_H

#include "wx/string.h"
#include "wx/filename.h"
#include "attribute_style.h"
#include "wx/xml/xml.h"
#include <wx/font.h>
#include "codelite_exports.h"
#include <wx/stc/stc.h>
#include <wx/sharedptr.h>
#include <smart_ptr.h>

class WXDLLIMPEXP_SDK LexerConf
{
    StyleProperty::List_t m_properties;
    int m_lexerId;
    wxString m_name;
    wxString m_extension;
    wxString m_keyWords[10];
    bool m_styleWithinPreProcessor;
    wxString m_themeName;
    bool m_isActive;
    bool m_useCustomTextSelectionFgColour;

public:
    typedef SmartPtr<LexerConf> Ptr_t;

public:
    struct FindByNameAndTheme
    {
        wxString m_name;
        wxString m_theme;
        FindByNameAndTheme(const wxString& name, const wxString& theme)
            : m_name(name)
            , m_theme(theme)
        {
        }

        bool operator()(LexerConf::Ptr_t lexer) const
        {
            return lexer->GetName() == m_name && lexer->GetThemeName() == m_theme;
        }
    };

public:
    // Return an xml representation from this object
    wxXmlNode* ToXml() const;

    // Parse lexer object from xml node
    void FromXml(wxXmlNode* node);

public:
    LexerConf();
    virtual ~LexerConf();

    void SetUseCustomTextSelectionFgColour(bool useCustomTextSelectionFgColour)
    {
        this->m_useCustomTextSelectionFgColour = useCustomTextSelectionFgColour;
    }
    bool IsUseCustomTextSelectionFgColour() const { return m_useCustomTextSelectionFgColour; }
    void SetIsActive(bool isActive) { this->m_isActive = isActive; }
    void SetThemeName(const wxString& themeName) { this->m_themeName = themeName; }
    bool IsActive() const { return m_isActive; }
    const wxString& GetThemeName() const { return m_themeName; }
    /**
     * @brief apply the current lexer configuration on an input
     * wxStyledTextCtrl
     */
    void Apply(wxStyledTextCtrl* ctrl, bool applyKeywords = false);

    /**
     * Get the lexer ID, which should be in sync with values of Scintilla
     * \return
     */
    int GetLexerId() const { return m_lexerId; }

    void SetStyleWithinPreProcessor(bool styleWithinPreProcessor)
    {
        this->m_styleWithinPreProcessor = styleWithinPreProcessor;
    }

    bool GetStyleWithinPreProcessor() const { return m_styleWithinPreProcessor; }

    /**
     * Set the lexer ID
     * \param id
     */
    void SetLexerId(int id) { m_lexerId = id; }

    /**
     * Return the lexer description as described in the XML file
     */
    const wxString& GetName() const { return m_name; }
    /**
     * Return the lexer keywords
     * \return
     */
    const wxString& GetKeyWords(int set) const { return m_keyWords[set]; }

    void SetKeyWords(const wxString& keywords, int set) { m_keyWords[set] = keywords; }

    /**
     * File patterns that this lexer should apply to
     */
    const wxString& GetFileSpec() const { return m_extension; }
    /**
     * Return a list of the lexer properties
     * \return
     */
    const StyleProperty::List_t& GetLexerProperties() const { return m_properties; }

    /**
     * Return a list of the lexer properties
     * \return
     */
    StyleProperty::List_t& GetLexerProperties() { return m_properties; }

    /**
     * @brief return property. Check for IsNull() to make sure we got a valid property
     * @param propertyId
     * @return
     */
    StyleProperty& GetProperty(int propertyId);

    /**
     * Set the lexer properties
     * \param &properties
     */
    void SetProperties(StyleProperty::List_t& properties) { m_properties = properties; }
    /**
     * Set file spec for the lexer
     * \param &spec
     */
    void SetFileSpec(const wxString& spec) { m_extension = spec; }

    /**
     * @brief return the font for a given style id
     * @return return wxNullFont if error occured or could locate the style
     */
    wxFont GetFontForSyle(int styleId) const;
};

#endif // LEXER_CONFIGURATION_H