~ubuntu-branches/ubuntu/vivid/kate/vivid-updates

« back to all changes in this revision

Viewing changes to part/script/kateindentscript.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2014-12-04 16:49:41 UTC
  • mfrom: (1.6.6)
  • Revision ID: package-import@ubuntu.com-20141204164941-l3qbvsly83hhlw2v
Tags: 4:14.11.97-0ubuntu1
* New upstream release
* Update build-deps and use pkg-kde v3 for Qt 5 build
* kate-data now kate5-data for co-installability

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// This file is part of the KDE libraries
2
 
// Copyright (C) 2008 Paul Giannaros <paul@giannaros.org>
3
 
// Copyright (C) 2009 Dominik Haumann <dhaumann kde org>
4
 
//
5
 
// This library is free software; you can redistribute it and/or
6
 
// modify it under the terms of the GNU Library General Public
7
 
// License as published by the Free Software Foundation; either
8
 
// version 2 of the License, or (at your option) version 3.
9
 
//
10
 
// This library is distributed in the hope that it will be useful,
11
 
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 
// Library General Public License for more details.
14
 
//
15
 
// You should have received a copy of the GNU Library General Public License
16
 
// along with this library; see the file COPYING.LIB.  If not, write to
17
 
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
 
// Boston, MA 02110-1301, USA.
19
 
 
20
 
#ifndef KATE_INDENT_SCRIPT_H
21
 
#define KATE_INDENT_SCRIPT_H
22
 
 
23
 
#include "katescript.h"
24
 
#include "kateview.h"
25
 
 
26
 
#include <QtCore/QPair>
27
 
 
28
 
class KateScriptDocument;
29
 
 
30
 
class KateIndentScriptHeader
31
 
{
32
 
  public:
33
 
    KateIndentScriptHeader() : m_priority(0)
34
 
    {}
35
 
 
36
 
    inline void setName(const QString& name)
37
 
    { m_name = name; }
38
 
    inline const QString& name() const
39
 
    { return m_name; }
40
 
 
41
 
    inline void setRequiredStyle(const QString& requiredStyle)
42
 
    { m_requiredStyle = requiredStyle; }
43
 
    inline const QString& requiredStyle() const
44
 
    { return m_requiredStyle; }
45
 
 
46
 
    inline void setIndentLanguages(const QStringList& indentLanguages)
47
 
    { m_indentLanguages = indentLanguages; }
48
 
    inline const QStringList& indentLanguages() const
49
 
    { return m_indentLanguages; }
50
 
 
51
 
    inline void setPriority(int priority)
52
 
    { m_priority = priority; }
53
 
    inline int priority() const
54
 
    { return m_priority; }
55
 
 
56
 
    inline void setBaseName(const QString& baseName)
57
 
    { m_baseName = baseName; }
58
 
    inline const QString& baseName() const
59
 
    { return m_baseName; }
60
 
 
61
 
  private:
62
 
    QString m_name; ///< indenter name, e.g. Python
63
 
 
64
 
   /**
65
 
    * If this is an indenter, then this specifies the required syntax
66
 
    * highlighting style that must be used for this indenter to work properly.
67
 
    * If this property is empty, the indenter doesn't require a specific style.
68
 
    */
69
 
    QString m_requiredStyle;
70
 
    /**
71
 
    * If this script is an indenter, then the indentLanguages member specifies
72
 
    * which languages this is an indenter for. The values must correspond with
73
 
    * the name of a programming language given in a highlighting file (e.g "TI Basic")
74
 
    */
75
 
    QStringList m_indentLanguages;
76
 
    /**
77
 
    * If this script is an indenter, this value controls the priority it will take
78
 
    * when an indenter for one of the supported languages is requested and multiple
79
 
    * indenters are found
80
 
    */
81
 
    int m_priority;
82
 
 
83
 
    /**
84
 
     * basename of script
85
 
     */
86
 
    QString m_baseName;
87
 
};
88
 
 
89
 
 
90
 
/**
91
 
 * A specialized class for scripts that are of type
92
 
 * KateScriptInformation::IndentationScript
93
 
 */
94
 
class KateIndentScript : public KateScript
95
 
{
96
 
  public:
97
 
    KateIndentScript(const QString &url, const KateIndentScriptHeader &header);
98
 
 
99
 
    const QString &triggerCharacters();
100
 
 
101
 
    const KateIndentScriptHeader& indentHeader() const;
102
 
 
103
 
    /**
104
 
     * Returns a pair where the first value is the indent amount, and the second
105
 
     * value is the alignment.
106
 
     */
107
 
    QPair<int, int> indent(KateView* view, const KTextEditor::Cursor& position,
108
 
                           QChar typedCharacter, int indentWidth);
109
 
 
110
 
  private:
111
 
    QString m_triggerCharacters;
112
 
    bool m_triggerCharactersSet;
113
 
    KateIndentScriptHeader m_indentHeader;
114
 
};
115
 
 
116
 
 
117
 
#endif
118
 
 
119
 
// kate: space-indent on; indent-width 2; replace-tabs on;