KTextEditor

katebuffer.h
1 /*
2  SPDX-FileCopyrightText: 2000 Waldo Bastian <[email protected]>
3  SPDX-FileCopyrightText: 2002-2004 Christoph Cullmann <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef KATE_BUFFER_H
9 #define KATE_BUFFER_H
10 
11 #include "katetextbuffer.h"
12 
13 #include <ktexteditor_export.h>
14 
15 #include <QObject>
16 
17 class KateLineInfo;
18 namespace KTextEditor
19 {
20 class DocumentPrivate;
21 }
22 class KateHighlighting;
23 
30 class KTEXTEDITOR_EXPORT KateBuffer : public Kate::TextBuffer
31 {
32  Q_OBJECT
33 
34 public:
39  explicit KateBuffer(KTextEditor::DocumentPrivate *doc);
40 
44  ~KateBuffer() override;
45 
46 public:
50  void editStart();
51 
55  void editEnd();
56 
61  void updateHighlighting();
62 
68  inline bool editChanged() const
69  {
70  return editingChangedBuffer();
71  }
72 
77  inline int editTagStart() const
78  {
79  return editingMinimalLineChanged();
80  }
81 
86  inline int editTagEnd() const
87  {
88  return editingMaximalLineChanged();
89  }
90 
95  inline bool editTagFrom() const
96  {
97  return editingChangedNumberOfLines() != 0;
98  }
99 
100 public:
104  void clear() override;
105 
112  bool openFile(const QString &m_file, bool enforceTextCodec);
113 
118  bool brokenEncoding() const
119  {
120  return m_brokenEncoding;
121  }
122 
127  bool tooLongLinesWrapped() const
128  {
129  return m_tooLongLinesWrapped;
130  }
131 
132  int longestLineLoaded() const
133  {
134  return m_longestLineLoaded;
135  }
136 
141  bool canEncode();
142 
148  bool saveFile(const QString &m_file);
149 
150 public:
158  inline Kate::TextLine plainLine(int lineno)
159  {
160  if (lineno < 0 || lineno >= lines()) {
161  return Kate::TextLine();
162  }
163 
164  return line(lineno);
165  }
166 
174  void ensureHighlighted(int line, int lookAhead = 64);
175 
179  inline int count() const
180  {
181  return lines();
182  }
183 
188  void unwrapLine(int line) override;
189 
194  void wrapLine(const KTextEditor::Cursor &position) override;
195 
196 public:
197  inline int tabWidth() const
198  {
199  return m_tabWidth;
200  }
201 
202 public:
203  void setTabWidth(int w);
204 
211  void setHighlight(int hlMode);
212 
213  KateHighlighting *highlight()
214  {
215  return m_highlight;
216  }
217 
221  void invalidateHighlighting();
222 
230  KTextEditor::Range computeFoldingRangeForStartLine(int startLine);
231 
232 private:
240  void doHighlight(int from, int to, bool invalidate);
241 
242 Q_SIGNALS:
247  void tagLines(KTextEditor::LineRange lineRange);
248  void respellCheckBlock(int start, int end);
249 
250 private:
254  KTextEditor::DocumentPrivate *const m_doc;
255 
259  bool m_brokenEncoding;
260 
264  bool m_tooLongLinesWrapped;
265 
269  int m_longestLineLoaded;
270 
274  KateHighlighting *m_highlight;
275 
276  // for the scrapty indent sensitive langs
277  int m_tabWidth;
278 
282  int m_lineHighlighted;
283 
287  int m_maxDynamicContexts;
288 };
289 
290 #endif
Kate::TextLine plainLine(int lineno)
Return line lineno.
Definition: katebuffer.h:158
bool editTagFrom() const
line inserted/removed?
Definition: katebuffer.h:95
bool editChanged() const
were there changes in the current running editing session?
Definition: katebuffer.h:68
The Cursor represents a position in a Document.
Definition: cursor.h:71
bool editStart()
Enclose editor actions with editStart() and editEnd() to group them.
int count() const
Return the total number of lines in the buffer.
Definition: katebuffer.h:179
An object representing lines from a start line to an end line.
Definition: linerange.h:37
int editTagStart() const
dirty lines start
Definition: katebuffer.h:77
bool brokenEncoding() const
Did encoding errors occur on load?
Definition: katebuffer.h:118
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
Definition: katetextblock.h:21
int editTagEnd() const
dirty lines end
Definition: katebuffer.h:86
An object representing a section of text, from one Cursor to another.
bool openFile() override
open the file obtained by the kparts framework the framework abstracts the loading of remote files ...
bool editEnd()
End a editor operation.
bool saveFile() override
save the file obtained by the kparts framework the framework abstracts the uploading of remote files ...
Class representing a text buffer.
bool tooLongLinesWrapped() const
Too long lines wrapped on load?
Definition: katebuffer.h:127
The KateBuffer class maintains a collections of lines.
Definition: katebuffer.h:30
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Jan 19 2021 23:00:12 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.