• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Kate

  • kde-4.14
  • applications
  • kate
  • part
  • document
katebuffer.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (c) 2000 Waldo Bastian <bastian@kde.org>
3  Copyright (C) 2002-2004 Christoph Cullmann <cullmann@kde.org>
4  Copyright (C) 2007 Mirko Stocker <me@misto.ch>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License version 2 as published by the Free Software Foundation.
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 
21 #include "katebuffer.h"
22 #include "katebuffer.moc"
23 
24 #include <sys/types.h>
25 #include <sys/stat.h>
26 #include <unistd.h>
27 #include <stdlib.h>
28 
29 #include "katedocument.h"
30 #include "katehighlight.h"
31 #include "kateconfig.h"
32 #include "kateglobal.h"
33 #include "kateautoindent.h"
34 
35 #include <kdebug.h>
36 #include <kglobal.h>
37 #include <kcharsets.h>
38 #include <kde_file.h>
39 
40 // on the fly compression
41 #include <kfilterdev.h>
42 #include <kmimetype.h>
43 #include <kde_file.h>
44 
45 #include <QtCore/QFile>
46 #include <QtCore/QTextStream>
47 #include <QtCore/QTimer>
48 #include <QtCore/QTextCodec>
49 #include <QtCore/QDate>
50 
51 #include <limits.h>
52 
56 static const int KATE_MAX_DYNAMIC_CONTEXTS = 512;
57 
61 KateBuffer::KateBuffer(KateDocument *doc)
62  : Kate::TextBuffer (doc),
63  m_doc (doc),
64  m_brokenEncoding (false),
65  m_tooLongLinesWrapped (false),
66  m_highlight (0),
67  m_tabWidth (8),
68  m_lineHighlighted (0),
69  m_maxDynamicContexts (KATE_MAX_DYNAMIC_CONTEXTS)
70 {
71  // we need kate global to stay alive
72  KateGlobal::incRef ();
73 }
74 
78 KateBuffer::~KateBuffer()
79 {
80  // release HL
81  if (m_highlight)
82  m_highlight->release();
83 
84  // release kate global
85  KateGlobal::decRef ();
86 }
87 
88 void KateBuffer::editStart ()
89 {
90  if (!startEditing ())
91  return;
92 }
93 
94 void KateBuffer::editEnd ()
95 {
99  if (!finishEditing())
100  return;
101 
105  if (!editingChangedBuffer ())
106  return;
107 
111  Q_ASSERT (editingMinimalLineChanged () != -1);
112  Q_ASSERT (editingMaximalLineChanged () != -1);
113  Q_ASSERT (editingMinimalLineChanged () <= editingMaximalLineChanged ());
114 
118  if (!m_highlight)
119  return;
120 
124  if (editingMinimalLineChanged() > m_lineHighlighted)
125  return;
126 
130  int editTagLineEnd = editingMaximalLineChanged () + 1;
131  int editTagLineStart = editingMinimalLineChanged ();
132 
136  if (editTagLineStart > 0)
137  --editTagLineStart;
138 
142  doHighlight (
143  editTagLineStart,
144  editTagLineEnd,
145  true);
146 }
147 
148 void KateBuffer::clear()
149 {
150  // call original clear function
151  Kate::TextBuffer::clear ();
152 
153  // reset the state
154  m_brokenEncoding = false;
155  m_tooLongLinesWrapped = false;
156 
157  // back to line 0 with hl
158  m_lineHighlighted = 0;
159 }
160 
161 bool KateBuffer::openFile (const QString &m_file, bool enforceTextCodec)
162 {
163  // first: setup fallback and normal encoding
164  setEncodingProberType (KateGlobalConfig::global()->proberType ());
165  setFallbackTextCodec (KateGlobalConfig::global()->fallbackCodec ());
166  setTextCodec (m_doc->config()->codec ());
167 
168  // setup eol
169  setEndOfLineMode ((EndOfLineMode) m_doc->config()->eol());
170 
171  // NOTE: we do not remove trailing spaces on load. This was discussed
172  // over the years again and again. bugs: 306926, 239077, ...
173 
174  // line length limit
175  setLineLengthLimit (m_doc->config()->lineLengthLimit());
176 
177  // then, try to load the file
178  m_brokenEncoding = false;
179  m_tooLongLinesWrapped = false;
180 
187  if (m_doc->url().isLocalFile() && !QFile::exists (m_file)) {
188  clear ();
189  KTextEditor::Message* message = new KTextEditor::Message(i18nc("short translation, user created new file", "New file"),
190  KTextEditor::Message::Warning);
191  message->setPosition(KTextEditor::Message::TopInView);
192  message->setAutoHide(1000);
193  m_doc->postMessage(message);
194 
195  // remember error
196  m_doc->setOpeningError(true);
197  m_doc->setOpeningErrorMessage(i18n ("The file %1 does not exist.", m_doc->url().pathOrUrl()));
198  return true;
199  }
200 
205  KDE_struct_stat sbuf;
206  if (KDE::stat(m_file, &sbuf) != 0 || !S_ISREG(sbuf.st_mode)) {
207  clear ();
208  return false;
209  }
210 
214  if (!load (m_file, m_brokenEncoding, m_tooLongLinesWrapped, enforceTextCodec))
215  return false;
216 
217  // save back encoding
218  m_doc->config()->setEncoding (textCodec()->name());
219 
220  // set eol mode, if a eol char was found
221  if (m_doc->config()->allowEolDetection())
222  m_doc->config()->setEol (endOfLineMode ());
223 
224  // generate a bom?
225  if (generateByteOrderMark())
226  m_doc->config()->setBom (true);
227 
228  // okay, loading did work
229  return true;
230 }
231 
232 bool KateBuffer::canEncode ()
233 {
234  QTextCodec *codec = m_doc->config()->codec();
235 
236  kDebug(13020) << "ENC NAME: " << codec->name();
237 
238  // hardcode some unicode encodings which can encode all chars
239  if ((QString(codec->name()) == "UTF-8") || (QString(codec->name()) == "ISO-10646-UCS-2"))
240  return true;
241 
242  for (int i=0; i < lines(); i++)
243  {
244  if (!codec->canEncode (line(i)->string()))
245  {
246  kDebug(13020) << "STRING LINE: " << line(i)->string();
247  kDebug(13020) << "ENC WORKING: FALSE";
248 
249  return false;
250  }
251  }
252 
253  return true;
254 }
255 
256 bool KateBuffer::saveFile (const QString &m_file)
257 {
258  // first: setup fallback and normal encoding
259  setEncodingProberType (KateGlobalConfig::global()->proberType ());
260  setFallbackTextCodec (KateGlobalConfig::global()->fallbackCodec ());
261  setTextCodec (m_doc->config()->codec ());
262 
263  // setup eol
264  setEndOfLineMode ((EndOfLineMode) m_doc->config()->eol());
265 
266  // generate bom?
267  setGenerateByteOrderMark (m_doc->config()->bom());
268 
269  // append a newline character at the end of the file (eof) ?
270  setNewLineAtEof (m_doc->config()->newLineAtEof());
271 
272  // try to save
273  if (!save (m_file))
274  return false;
275 
276  // no longer broken encoding, or we don't care
277  m_brokenEncoding = false;
278  m_tooLongLinesWrapped = false;
279 
280  // okay
281  return true;
282 }
283 
284 void KateBuffer::ensureHighlighted (int line, int lookAhead)
285 {
286  // valid line at all?
287  if (line < 0 || line >= lines ())
288  return;
289 
290  // already hl up-to-date for this line?
291  if (line < m_lineHighlighted)
292  return;
293 
294  // update hl until this line + max lookAhead
295  int end = qMin(line + lookAhead, lines ()-1);
296 
297  // ensure we have enough highlighted
298  doHighlight ( m_lineHighlighted, end, false );
299 }
300 
301 void KateBuffer::wrapLine (const KTextEditor::Cursor &position)
302 {
303  // call original
304  Kate::TextBuffer::wrapLine (position);
305 
306  if (m_lineHighlighted > position.line()+1)
307  m_lineHighlighted++;
308 }
309 
310 void KateBuffer::unwrapLines (int from, int to)
311 {
312  // catch out of range access, should never happen
313  Q_ASSERT(from >= 0);
314  Q_ASSERT(to + 1 <= lines());
315 
316  for (int line = to; line >= from; --line) {
317  if (line + 1 < lines()) {
318  Kate::TextBuffer::unwrapLine (line + 1);
319 
320  if (m_lineHighlighted > (line + 1))
321  --m_lineHighlighted;
322  }
323 
324  // Line "0" can't be unwraped
325  // This call is used to unwrap the last line (if last line != 0)
326  // This call was used in the previous version too and it looks like the last
327  // line can't be unwraped without it
328  else if (line) {
329  Kate::TextBuffer::unwrapLine (line);
330 
331  if (m_lineHighlighted > line)
332  --m_lineHighlighted;
333  }
334  }
335 }
336 
337 void KateBuffer::unwrapLine (int line)
338 {
339  // reimplemented, so first call original
340  Kate::TextBuffer::unwrapLine (line);
341 
342  if (m_lineHighlighted > line)
343  --m_lineHighlighted;
344 }
345 
346 void KateBuffer::setTabWidth (int w)
347 {
348  if ((m_tabWidth != w) && (m_tabWidth > 0))
349  {
350  m_tabWidth = w;
351 
352  if (m_highlight && m_highlight->foldingIndentationSensitive())
353  invalidateHighlighting();
354  }
355 }
356 
357 void KateBuffer::setHighlight(int hlMode)
358 {
359  KateHighlighting *h = KateHlManager::self()->getHl(hlMode);
360 
361  // aha, hl will change
362  if (h != m_highlight)
363  {
364  bool invalidate = !h->noHighlighting();
365 
366  if (m_highlight)
367  {
368  m_highlight->release();
369  invalidate = true;
370  }
371 
372  h->use();
373 
374  m_highlight = h;
375 
376  if (invalidate)
377  invalidateHighlighting();
378 
379  // inform the document that the hl was really changed
380  // needed to update attributes and more ;)
381  m_doc->bufferHlChanged ();
382 
383  // try to set indentation
384  if (!h->indentation().isEmpty())
385  m_doc->config()->setIndentationMode (h->indentation());
386  }
387 }
388 
389 void KateBuffer::invalidateHighlighting()
390 {
391  m_lineHighlighted = 0;
392 }
393 
394 void KateBuffer::doHighlight (int startLine, int endLine, bool invalidate)
395 {
396  // no hl around, no stuff to do
397  if (!m_highlight || m_highlight->noHighlighting())
398  return;
399 
400 #ifdef BUFFER_DEBUGGING
401  QTime t;
402  t.start();
403  kDebug (13020) << "HIGHLIGHTED START --- NEED HL, LINESTART: " << startLine << " LINEEND: " << endLine;
404  kDebug (13020) << "HL UNTIL LINE: " << m_lineHighlighted;
405  kDebug (13020) << "HL DYN COUNT: " << KateHlManager::self()->countDynamicCtxs() << " MAX: " << m_maxDynamicContexts;
406 #endif
407 
408  // see if there are too many dynamic contexts; if yes, invalidate HL of all documents
409  if (KateHlManager::self()->countDynamicCtxs() >= m_maxDynamicContexts)
410  {
411  {
412  if (KateHlManager::self()->resetDynamicCtxs())
413  {
414 #ifdef BUFFER_DEBUGGING
415  kDebug (13020) << "HL invalidated - too many dynamic contexts ( >= " << m_maxDynamicContexts << ")";
416 #endif
417 
418  // avoid recursive invalidation
419  KateHlManager::self()->setForceNoDCReset(true);
420 
421  foreach(KateDocument* doc, KateGlobal::self()->kateDocuments())
422  doc->makeAttribs();
423 
424  // doHighlight *shall* do his work. After invalidation, some highlight has
425  // been recalculated, but *maybe not* until endLine ! So we shall force it manually...
426  doHighlight ( m_lineHighlighted, endLine, false );
427  m_lineHighlighted = endLine;
428 
429  KateHlManager::self()->setForceNoDCReset(false);
430  return;
431  }
432  else
433  {
434  m_maxDynamicContexts *= 2;
435 
436 #ifdef BUFFER_DEBUGGING
437  kDebug (13020) << "New dynamic contexts limit: " << m_maxDynamicContexts;
438 #endif
439  }
440  }
441  }
442 
443  // if possible get previous line, otherwise create 0 line.
444  Kate::TextLine prevLine = (startLine >= 1) ? plainLine (startLine - 1) : Kate::TextLine ();
445 
446  // here we are atm, start at start line in the block
447  int current_line = startLine;
448  int start_spellchecking = -1;
449  int last_line_spellchecking = -1;
450  bool ctxChanged = false;
451  Kate::TextLine textLine = plainLine (current_line);
452  Kate::TextLine nextLine;
453  // loop over the lines of the block, from startline to endline or end of block
454  // if stillcontinue forces us to do so
455  for (; current_line < qMin (endLine+1, lines()); ++current_line)
456  {
457  // get next line, if any
458  if ((current_line + 1) < lines())
459  nextLine = plainLine (current_line+1);
460  else
461  nextLine = Kate::TextLine (new Kate::TextLineData ());
462 
463  ctxChanged = false;
464  m_highlight->doHighlight (prevLine.data(), textLine.data(), nextLine.data(), ctxChanged, tabWidth());
465 
466 #ifdef BUFFER_DEBUGGING
467  // debug stuff
468  kDebug( 13020 ) << "current line to hl: " << current_line;
469  kDebug( 13020 ) << "text length: " << textLine->length() << " attribute list size: " << textLine->attributesList().size();
470 
471  const QVector<int> &ml (textLine->attributesList());
472  for (int i=2; i < ml.size(); i+=3)
473  {
474  kDebug( 13020 ) << "start: " << ml.at(i-2) << " len: " << ml.at(i-1) << " at: " << ml.at(i) << " ";
475  }
476  kDebug( 13020 );
477 #endif
478 
479  // need we to continue ?
480  bool stillcontinue = ctxChanged;
481  if (stillcontinue && start_spellchecking < 0) {
482  start_spellchecking=current_line;
483  }
484  else if (!stillcontinue && start_spellchecking >= 0) {
485  last_line_spellchecking=current_line;
486  }
487 
488  // move around the lines
489  prevLine = textLine;
490  textLine = nextLine;
491  }
492 
496  int oldHighlighted = m_lineHighlighted;
497  if (ctxChanged || current_line > m_lineHighlighted)
498  m_lineHighlighted = current_line;
499 
500  // tag the changed lines !
501  if (invalidate) {
502 #ifdef BUFFER_DEBUGGING
503  kDebug (13020) << "HIGHLIGHTED TAG LINES: " << startLine << current_line;
504 #endif
505 
506  emit tagLines (startLine, qMax (current_line, oldHighlighted));
507 
508  if(start_spellchecking >= 0 && lines() > 0) {
509  emit respellCheckBlock(start_spellchecking,
510  qMin(lines()-1, (last_line_spellchecking==-1)?qMax (current_line, oldHighlighted):last_line_spellchecking));
511  }
512  }
513 
514 #ifdef BUFFER_DEBUGGING
515  kDebug (13020) << "HIGHLIGHTED END --- NEED HL, LINESTART: " << startLine << " LINEEND: " << endLine;
516  kDebug (13020) << "HL UNTIL LINE: " << m_lineHighlighted;
517  kDebug (13020) << "HL DYN COUNT: " << KateHlManager::self()->countDynamicCtxs() << " MAX: " << m_maxDynamicContexts;
518  kDebug (13020) << "TIME TAKEN: " << t.elapsed();
519 #endif
520 }
521 
522 KTextEditor::Range KateBuffer::computeFoldingRangeForStartLine (int startLine)
523 {
527  Q_ASSERT (startLine >= 0);
528  Q_ASSERT (startLine < lines());
529 
533  if (!m_highlight || m_highlight->noHighlighting())
534  return KTextEditor::Range::invalid();
535 
539  ensureHighlighted (startLine);
540  Kate::TextLine startTextLine = plainLine (startLine);
541 
545  if (!startTextLine->markedAsFoldingStart ())
546  return KTextEditor::Range::invalid();
547 
551  if (startTextLine->markedAsFoldingStartIndentation ()) {
555  const int startIndentation = startTextLine->indentDepth (tabWidth());
556 
560  int lastLine = startLine + 1;
561  for (; lastLine < lines(); ++lastLine) {
565  Kate::TextLine textLine = plainLine (lastLine);
566 
570  if (startIndentation < textLine->indentDepth (tabWidth()))
571  continue;
572 
576  if (m_highlight->isEmptyLine (textLine.data()))
577  continue;
578 
582  break;
583  }
584 
588  --lastLine;
589 
593  while (lastLine > startLine) {
594  if (m_highlight->isEmptyLine (plainLine (lastLine).data()))
595  --lastLine;
596  else
597  break;
598  }
599 
603  if (lastLine == startLine)
604  return KTextEditor::Range::invalid();
605 
609  return KTextEditor::Range (KTextEditor::Cursor (startLine, 0), KTextEditor::Cursor (lastLine, plainLine (lastLine)->length()));
610  }
611 
619  short openedRegionType = 0;
620  int openedRegionOffset = -1;
621  {
625  QHash<short, QPair<int, int> > foldingStartToOffsetAndCount;
626 
630  const QVector<Kate::TextLineData::Attribute> &startLineAttributes = startTextLine->attributesList();
631  for ( int i = 0; i < startLineAttributes.size(); ++i ) {
635  if (startLineAttributes[i].foldingValue < 0) {
639  QHash<short, QPair<int, int> >::iterator end = foldingStartToOffsetAndCount.find (-startLineAttributes[i].foldingValue);
640  if (end != foldingStartToOffsetAndCount.end()) {
641  if (end.value().second > 1)
642  --(end.value().second);
643  else
644  foldingStartToOffsetAndCount.erase (end);
645  }
646  }
647 
651  if (startLineAttributes[i].foldingValue > 0) {
655  QHash<short, QPair<int, int> >::iterator start = foldingStartToOffsetAndCount.find (startLineAttributes[i].foldingValue);
656  if (start != foldingStartToOffsetAndCount.end())
657  ++(start.value().second);
658  else
659  foldingStartToOffsetAndCount.insert (startLineAttributes[i].foldingValue, qMakePair (startLineAttributes[i].offset, 1));
660  }
661  }
662 
666  QHashIterator<short, QPair<int, int> > hashIt (foldingStartToOffsetAndCount);
667  while (hashIt.hasNext()) {
668  hashIt.next();
669  if (openedRegionOffset == -1 || hashIt.value().first < openedRegionOffset) {
670  openedRegionType = hashIt.key();
671  openedRegionOffset = hashIt.value().first;
672  }
673  }
674  }
675 
679  if (openedRegionType == 0)
680  return KTextEditor::Range::invalid();
681 
685  int countOfOpenRegions = 1;
686  for (int line = startLine + 1; line < lines(); ++line) {
690  ensureHighlighted (line);
691  Kate::TextLine textLine = plainLine (line);
692 
696  const QVector<Kate::TextLineData::Attribute> &lineAttributes = textLine->attributesList();
697  for (int i = 0; i < lineAttributes.size(); ++i) {
701  if (lineAttributes[i].foldingValue == -openedRegionType) {
702  --countOfOpenRegions;
703 
708  if (countOfOpenRegions == 0) {
714  KTextEditor::Cursor endCursor (line, lineAttributes[i].offset);
715  if (endCursor.column() == 0 && endCursor.line() > 0)
716  endCursor = KTextEditor::Cursor (endCursor.line()-1, plainLine (lines()-1)->length());
717 
721  return KTextEditor::Range (KTextEditor::Cursor (startLine, openedRegionOffset), endCursor);
722  }
723  }
724 
728  if (lineAttributes[i].foldingValue == openedRegionType)
729  ++countOfOpenRegions;
730  }
731  }
732 
736  return KTextEditor::Range (KTextEditor::Cursor (startLine, openedRegionOffset), KTextEditor::Cursor (lines()-1, plainLine (lines()-1)->length()));
737 }
738 
739 // kate: space-indent on; indent-width 2; replace-tabs on;
Kate::TextBuffer::line
TextLine line(int line) const
Retrieve a text line.
Definition: katetextbuffer.cpp:150
KateDocument::config
KateDocumentConfig * config()
Configuration.
Definition: katedocument.h:1009
Kate::TextBuffer::setGenerateByteOrderMark
void setGenerateByteOrderMark(bool generateByteOrderMark)
Generate byte order mark on save.
Definition: katetextbuffer.h:130
Kate::TextBuffer::editingChangedBuffer
bool editingChangedBuffer() const
Query information from the last editing transaction: was the content of the buffer changed...
Definition: katetextbuffer.h:250
Kate::TextBuffer::endOfLineMode
EndOfLineMode endOfLineMode() const
Get end of line mode.
Definition: katetextbuffer.h:149
KATE_MAX_DYNAMIC_CONTEXTS
static const int KATE_MAX_DYNAMIC_CONTEXTS
Initial value for m_maxDynamicContexts.
Definition: katebuffer.cpp:56
Kate::TextBuffer::textCodec
QTextCodec * textCodec() const
Get codec for this buffer.
Definition: katetextbuffer.h:123
katehighlight.h
Kate::Script::i18n
QScriptValue i18n(QScriptContext *context, QScriptEngine *engine)
i18n("text", arguments [optional])
Definition: katescripthelpers.cpp:186
KateBuffer::plainLine
Kate::TextLine plainLine(int lineno)
Return line lineno.
Definition: katebuffer.h:138
QHash::insert
iterator insert(const Key &key, const T &value)
KateDocumentConfig::setIndentationMode
void setIndentationMode(const QString &identationMode)
Definition: kateconfig.cpp:500
QTextCodec::name
virtual QByteArray name() const =0
KateDocument::bufferHlChanged
void bufferHlChanged()
Definition: katedocument.cpp:1519
KateBuffer::ensureHighlighted
void ensureHighlighted(int line, int lookAhead=64)
Update highlighting of given line line, if needed.
Definition: katebuffer.cpp:284
QHashIterator::key
const Key & key() const
KateBuffer::computeFoldingRangeForStartLine
KTextEditor::Range computeFoldingRangeForStartLine(int startLine)
For a given line, compute the folding range that starts there to be used to fold e.g.
Definition: katebuffer.cpp:522
Kate::Script::i18nc
QScriptValue i18nc(QScriptContext *context, QScriptEngine *engine)
i18nc("context", "text", arguments [optional])
Definition: katescripthelpers.cpp:210
KateGlobal::decRef
static void decRef()
decrement reference counter
Definition: kateglobal.h:223
QHashIterator::hasNext
bool hasNext() const
kateautoindent.h
Kate::TextBuffer::finishEditing
virtual bool finishEditing()
Finish an editing transaction.
Definition: katetextbuffer.cpp:193
KateHighlighting::use
void use()
Increase the usage count, and trigger initialization if needed.
Definition: katehighlight.cpp:748
KateBuffer::wrapLine
void wrapLine(const KTextEditor::Cursor &position)
Wrap line at given cursor position.
Definition: katebuffer.cpp:301
Kate::TextBuffer::setFallbackTextCodec
void setFallbackTextCodec(QTextCodec *codec)
Set fallback codec for this buffer to use for load.
Definition: katetextbuffer.h:103
katedocument.h
KateBuffer::respellCheckBlock
void respellCheckBlock(int start, int end)
KateBuffer::clear
void clear()
Clear the buffer.
Definition: katebuffer.cpp:148
KateGlobal::self
static KateGlobal * self()
Kate Part Internal stuff ;)
Definition: kateglobal.cpp:465
KateHighlighting::isEmptyLine
bool isEmptyLine(const Kate::TextLineData *textline) const
Definition: katehighlight.cpp:2209
KateBuffer::saveFile
bool saveFile(const QString &m_file)
Save the buffer to a file, use the given filename + codec + end of line chars (internal use of qtexts...
Definition: katebuffer.cpp:256
QFile::exists
bool exists() const
Kate::TextBuffer::EndOfLineMode
EndOfLineMode
End of line mode.
Definition: katetextbuffer.h:59
Kate::TextBuffer::wrapLine
virtual void wrapLine(const KTextEditor::Cursor &position)
Wrap line at given cursor position.
Definition: katetextbuffer.cpp:218
Kate::TextBuffer::load
virtual bool load(const QString &filename, bool &encodingErrors, bool &tooLongLinesWrapped, bool enforceTextCodec)
Load the given file.
Definition: katetextbuffer.cpp:513
QTime
QSharedPointer::data
T * data() const
Kate::TextLineData
Class representing a single text line.
Definition: katetextline.h:37
KateDocumentConfig::codec
QTextCodec * codec() const
Definition: kateconfig.cpp:837
KateBuffer::setHighlight
void setHighlight(int hlMode)
Use highlight for highlighting.
Definition: katebuffer.cpp:357
KateHighlighting::foldingIndentationSensitive
bool foldingIndentationSensitive()
Definition: katehighlight.h:407
Kate::TextBuffer::startEditing
virtual bool startEditing()
Start an editing transaction, the wrapLine/unwrapLine/insertText and removeText functions are only to...
Definition: katetextbuffer.cpp:171
katebuffer.h
Kate::TextBuffer::editingMaximalLineChanged
int editingMaximalLineChanged() const
Get maximal line number changed by last editing transaction.
Definition: katetextbuffer.h:269
KateHighlighting::noHighlighting
bool noHighlighting() const
Definition: katehighlight.h:255
QObject::name
const char * name() const
KateGlobal::incRef
static void incRef()
increment reference counter
Definition: kateglobal.h:218
QTime::elapsed
int elapsed() const
Kate::TextBuffer::setNewLineAtEof
void setNewLineAtEof(bool newlineAtEof)
Set whether to insert a newline character on save at the end of the file.
Definition: katetextbuffer.h:155
KateDocument::makeAttribs
void makeAttribs(bool needInvalidate=true)
Definition: katedocument.cpp:2503
KateBuffer::openFile
bool openFile(const QString &m_file, bool enforceTextCodec)
Open a file, use the given filename.
Definition: katebuffer.cpp:161
KateBuffer::tabWidth
int tabWidth() const
Definition: katebuffer.h:181
QSharedPointer
QHash
KateHlManager::setForceNoDCReset
void setForceNoDCReset(bool b)
Definition: katesyntaxmanager.h:87
Kate::TextBuffer::setTextCodec
void setTextCodec(QTextCodec *codec)
Set codec for this buffer to use for load/save.
Definition: katetextbuffer.cpp:702
kateglobal.h
QHashIterator
QString::isEmpty
bool isEmpty() const
KateDocumentConfig::eol
int eol() const
Definition: kateconfig.cpp:883
QString
QTextCodec
KateDocumentConfig::allowEolDetection
bool allowEolDetection() const
Definition: kateconfig.cpp:937
KateGlobalConfig::global
static KateGlobalConfig * global()
Definition: kateconfig.h:109
QHash::erase
iterator erase(iterator pos)
KateBuffer::unwrapLine
void unwrapLine(int line)
Unwrap given line.
Definition: katebuffer.cpp:337
KateBuffer::setTabWidth
void setTabWidth(int w)
Definition: katebuffer.cpp:346
KateBuffer::editStart
void editStart()
start some editing action
Definition: katebuffer.cpp:88
QHash::value
const T value(const Key &key) const
QHash::find
iterator find(const Key &key)
KateDocument
Definition: katedocument.h:74
QHashIterator::next
Item next()
Kate::TextBuffer::setEncodingProberType
void setEncodingProberType(KEncodingProber::ProberType proberType)
Set encoding prober type for this buffer to use for load.
Definition: katetextbuffer.h:91
KateBuffer::KateBuffer
KateBuffer(KateDocument *doc)
Create an empty buffer.
Definition: katebuffer.cpp:61
Kate::TextBuffer::save
virtual bool save(const QString &filename)
Save the current buffer content to the given file.
Definition: katetextbuffer.cpp:714
QVector::at
const T & at(int i) const
Kate::TextBuffer::unwrapLine
virtual void unwrapLine(int line)
Unwrap given line.
Definition: katetextbuffer.cpp:257
KateHlManager::countDynamicCtxs
int countDynamicCtxs()
Definition: katesyntaxmanager.h:86
Kate::TextBuffer::lines
int lines() const
Lines currently stored in this buffer.
Definition: katetextbuffer.h:189
KateDocumentConfig::setEol
void setEol(int mode)
Definition: kateconfig.cpp:903
Kate::TextBuffer::setEndOfLineMode
void setEndOfLineMode(EndOfLineMode endOfLineMode)
Set end of line mode for this buffer, not allowed to be set to unknown.
Definition: katetextbuffer.h:143
QVector< int >
KateHlManager::getHl
KateHighlighting * getHl(int n)
Definition: katesyntaxmanager.cpp:108
KateBuffer::unwrapLines
void unwrapLines(int from, int to)
Unwrap given lines.
Definition: katebuffer.cpp:310
KateBuffer::editEnd
void editEnd()
finish some editing action
Definition: katebuffer.cpp:94
KateHighlighting
Definition: katehighlight.h:119
Kate::TextLine
QSharedPointer< TextLineData > TextLine
The normal world only accesses the text lines with shared pointers.
Definition: katetextline.h:443
KateBuffer::canEncode
bool canEncode()
Can the current codec handle all chars.
Definition: katebuffer.cpp:232
Kate::TextBuffer::setLineLengthLimit
void setLineLengthLimit(int lineLengthLimit)
Set line length limit.
Definition: katetextbuffer.h:161
Kate::TextBuffer::generateByteOrderMark
bool generateByteOrderMark() const
Generate byte order mark on save?
Definition: katetextbuffer.h:136
QTextCodec::canEncode
bool canEncode(QChar ch) const
Kate::TextBuffer::editingMinimalLineChanged
int editingMinimalLineChanged() const
Get minimal line number changed by last editing transaction.
Definition: katetextbuffer.h:263
QTime::start
void start()
KateBuffer::invalidateHighlighting
void invalidateHighlighting()
Invalidate highlighting of whole buffer.
Definition: katebuffer.cpp:389
KateDocument::postMessage
virtual bool postMessage(KTextEditor::Message *message)
Definition: katedocument.cpp:5533
KateBuffer::~KateBuffer
~KateBuffer()
Goodbye buffer.
Definition: katebuffer.cpp:78
KateDocumentConfig::lineLengthLimit
int lineLengthLimit() const
Definition: kateconfig.cpp:1113
QHash::end
iterator end()
QHashIterator::value
const T & value() const
KateBuffer::tagLines
void tagLines(int start, int end)
Emitted when the highlighting of a certain range has changed.
KateHighlighting::release
void release()
Decrease the usage count, and trigger cleanup if needed.
Definition: katehighlight.cpp:759
KateDocumentConfig::setBom
void setBom(bool bom)
Definition: kateconfig.cpp:916
QVector::size
int size() const
Kate::Warning
Definition: katedefaultcolors.h:61
kateconfig.h
KateHighlighting::doHighlight
void doHighlight(const Kate::TextLineData *prevLine, Kate::TextLineData *textLine, const Kate::TextLineData *nextLine, bool &ctxChanged, int tabWidth=0, QVector< ContextChange > *contextChanges=0)
Parse the text and fill in the context array and folding list array.
Definition: katehighlight.cpp:279
KateHlManager::self
static KateHlManager * self()
Definition: katesyntaxmanager.cpp:103
Kate::TextBuffer::clear
virtual void clear()
Clears the buffer, reverts to initial empty state.
Definition: katetextbuffer.cpp:108
KateDocumentConfig::setEncoding
bool setEncoding(const QString &encoding)
Definition: kateconfig.cpp:852
KateDocumentConfig::bom
bool bom() const
Definition: kateconfig.cpp:929
KateDocumentConfig::newLineAtEof
bool newLineAtEof() const
Definition: kateconfig.cpp:779
KateHighlighting::indentation
QString indentation()
Definition: katehighlight.h:260
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:57 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Kate

Skip menu "Kate"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal