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 
62  inline bool editChanged() const
63  {
64  return editingChangedBuffer();
65  }
66 
71  inline int editTagStart() const
72  {
73  return editingMinimalLineChanged();
74  }
75 
80  inline int editTagEnd() const
81  {
82  return editingMaximalLineChanged();
83  }
84 
89  inline bool editTagFrom() const
90  {
91  return editingChangedNumberOfLines() != 0;
92  }
93 
94 public:
98  void clear() override;
99 
106  bool openFile(const QString &m_file, bool enforceTextCodec);
107 
112  bool brokenEncoding() const
113  {
114  return m_brokenEncoding;
115  }
116 
121  bool tooLongLinesWrapped() const
122  {
123  return m_tooLongLinesWrapped;
124  }
125 
126  int longestLineLoaded() const
127  {
128  return m_longestLineLoaded;
129  }
130 
135  bool canEncode();
136 
142  bool saveFile(const QString &m_file);
143 
144 public:
152  inline Kate::TextLine plainLine(int lineno)
153  {
154  if (lineno < 0 || lineno >= lines()) {
155  return Kate::TextLine();
156  }
157 
158  return line(lineno);
159  }
160 
168  void ensureHighlighted(int line, int lookAhead = 64);
169 
173  inline int count() const
174  {
175  return lines();
176  }
177 
182  void unwrapLine(int line) override;
183 
188  void wrapLine(const KTextEditor::Cursor &position) override;
189 
190 public:
191  inline int tabWidth() const
192  {
193  return m_tabWidth;
194  }
195 
196 public:
197  void setTabWidth(int w);
198 
205  void setHighlight(int hlMode);
206 
207  KateHighlighting *highlight()
208  {
209  return m_highlight;
210  }
211 
215  void invalidateHighlighting();
216 
224  KTextEditor::Range computeFoldingRangeForStartLine(int startLine);
225 
226 private:
234  void doHighlight(int from, int to, bool invalidate);
235 
236 Q_SIGNALS:
241  void tagLines(int start, int end);
242  void respellCheckBlock(int start, int end);
243 
244 private:
248  KTextEditor::DocumentPrivate *const m_doc;
249 
253  bool m_brokenEncoding;
254 
258  bool m_tooLongLinesWrapped;
259 
263  int m_longestLineLoaded;
264 
268  KateHighlighting *m_highlight;
269 
270  // for the scrapty indent sensitive langs
271  int m_tabWidth;
272 
276  int m_lineHighlighted;
277 
281  int m_maxDynamicContexts;
282 };
283 
284 #endif
Kate::TextLine plainLine(int lineno)
Return line lineno.
Definition: katebuffer.h:152
bool editTagFrom() const
line inserted/removed?
Definition: katebuffer.h:89
bool editChanged() const
were there changes in the current running editing session?
Definition: katebuffer.h:62
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:173
int editTagStart() const
dirty lines start
Definition: katebuffer.h:71
bool brokenEncoding() const
Did encoding errors occur on load?
Definition: katebuffer.h:112
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
int editTagEnd() const
dirty lines end
Definition: katebuffer.h:80
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:121
The KateBuffer class maintains a collections of lines.
Definition: katebuffer.h:30
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Aug 12 2020 22:57:32 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.