KTextEditor

attribute.h
1 /*
2  SPDX-FileCopyrightText: 2003-2005 Hamish Rodda <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #ifndef KTEXTEDITOR_ATTRIBUTE_H
8 #define KTEXTEDITOR_ATTRIBUTE_H
9 
10 #include <QTextFormat>
11 
12 #include <QExplicitlySharedDataPointer>
13 #include <QSharedData>
14 
15 #include <ktexteditor_export.h>
16 
17 class QAction;
18 
19 namespace KTextEditor
20 {
27  //
28  // normal text
29  //
31  dsNormal = 0,
50 
51  //
52  // Strings & Characters
53  //
66 
67  //
68  // Number, Types & Constants
69  //
80 
81  //
82  // Comments & Documentation
83  //
100 
101  //
102  // Misc
103  //
108 
109  //
110  // WARNING: Whenever you add a default style to this list,
111  // make sure to adapt KateHlManager::defaultStyleCount()
112  //
113 };
114 
142 class KTEXTEDITOR_EXPORT Attribute : public QTextCharFormat, public QSharedData
143 {
144 public:
149 
154  Attribute();
155 
161  Attribute(const QString &name, DefaultStyle style);
162 
166  Attribute(const Attribute &a);
167 
171  virtual ~Attribute();
172 
173  // BEGIN custom properties
174 
188  QString name() const;
189 
195  void setName(const QString &name);
196 
202  DefaultStyle defaultStyle() const;
203 
209  void setDefaultStyle(DefaultStyle style);
210 
216  bool skipSpellChecking() const;
217 
223  void setSkipSpellChecking(bool skipspellchecking);
224 
232  bool fontBold() const;
233 
241  void setFontBold(bool bold = true);
242 
248  QBrush outline() const;
249 
257  void setOutline(const QBrush &brush);
258 
264  QBrush selectedForeground() const;
265 
273  void setSelectedForeground(const QBrush &foreground);
274 
280  QBrush selectedBackground() const;
281 
289  void setSelectedBackground(const QBrush &brush);
290 
296  bool backgroundFillWhitespace() const;
297 
305  void setBackgroundFillWhitespace(bool fillWhitespace);
306 
310  void clear();
311 
317  bool hasAnyProperty() const;
318 
319  // END
320 
321  // BEGIN Dynamic highlighting
322 
338  ActivateMouseIn = 0,
340  ActivateCaretIn
341  };
342 
350  Attribute::Ptr dynamicAttribute(ActivationType type) const;
351 
360  void setDynamicAttribute(ActivationType type, Attribute::Ptr attribute);
361 
363 
364  // END
365 
373  Attribute &operator+=(const Attribute &a);
374 
380  Attribute &operator=(const Attribute &a);
381 
382 private:
386  class AttributePrivate *const d;
387 };
388 
399 {
400 public:
404  AttributeBlock(int _start, int _length, const Attribute::Ptr &_attribute)
405  : start(_start)
406  , length(_length)
407  , attribute(_attribute)
408  {
409  }
410 
414  int start;
415 
419  int length;
420 
425 };
426 
427 }
428 
429 Q_DECLARE_TYPEINFO(KTextEditor::AttributeBlock, Q_MOVABLE_TYPE);
430 
431 #endif
DefaultStyle
The following lists all valid default styles that are used for the syntax highlighting files in the i...
Definition: attribute.h:26
Used for numbers with base other than 10.
Definition: attribute.h:75
Used for language keywords.
Definition: attribute.h:33
Used for preprocessor statements.
Definition: attribute.h:47
Used for variables, if applicable.
Definition: attribute.h:37
A class which provides customized text decorations.
Definition: attribute.h:142
AttributeBlock(int _start, int _length, const Attribute::Ptr &_attribute)
Constructor of AttributeBlock.
Definition: attribute.h:404
Used for attributes that do not match any of the other default styles.
Definition: attribute.h:105
Used for information, e.g.
Definition: attribute.h:95
int start
The column this attribute starts at.
Definition: attribute.h:414
Used for region markers, typically defined by BEGIN/END.
Definition: attribute.h:93
Used for warnings, e.g.
Definition: attribute.h:97
Used for normal comments.
Definition: attribute.h:85
Used for operators such as +, -, *, / and :: etc.
Definition: attribute.h:41
Used for extensions, such as Qt or boost.
Definition: attribute.h:45
Used to refer to variables in a comment, e.g.
Definition: attribute.h:91
Default for normal text and source code.
Definition: attribute.h:31
Used for language constants.
Definition: attribute.h:79
Attributes of a part of a line.
Definition: attribute.h:398
QExplicitlySharedDataPointer< Attribute > Ptr
Shared data pointer for Attribute.
Definition: attribute.h:148
Used for comments that reflect API documentation.
Definition: attribute.h:87
int length
The number of columns this attribute spans.
Definition: attribute.h:419
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
Definition: katetextblock.h:21
Used for control flow highlighting, e.g., if, then, else, return, continue.
Definition: attribute.h:39
Used for function definitions and function calls.
Definition: attribute.h:35
Used for decimal values.
Definition: attribute.h:73
Used for strings.
Definition: attribute.h:59
Used for data types such as int, char, float etc.
Definition: attribute.h:71
Used for a single character.
Definition: attribute.h:55
Used for comment specials TODO and WARNING in comments.
Definition: attribute.h:99
Used for special strings such as regular expressions or LaTeX math mode.
Definition: attribute.h:63
ActivationType
Several automatic activation mechanisms exist for associated attributes.
Definition: attribute.h:336
Used for an escaped character.
Definition: attribute.h:57
Used for verbatim strings such as HERE docs.
Definition: attribute.h:61
Used to indicate wrong syntax.
Definition: attribute.h:107
Used for includes, imports and modules.
Definition: attribute.h:65
Used for annotations in comments, e.g.
Definition: attribute.h:89
Used for attributes of a function, e.g.
Definition: attribute.h:49
Used for built-in language classes and functions.
Definition: attribute.h:43
Attribute::Ptr attribute
The attribute for the current range.
Definition: attribute.h:424
Used for floating point numbers.
Definition: attribute.h:77
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Jan 23 2021 03:31:31 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.