• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kate
 

kate

  • kate
  • part
katebuffer.h
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 
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 version 2 as published by the Free Software Foundation.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef __KATE_BUFFER_H__
21 #define __KATE_BUFFER_H__
22 
23 #include "katetextline.h"
24 #include "katecodefoldinghelpers.h"
25 
26 #include <kvmallocator.h>
27 
28 #include <tqptrlist.h>
29 #include <tqobject.h>
30 #include <tqtimer.h>
31 #include <tqvaluevector.h>
32 
33 class KateLineInfo;
34 class KateDocument;
35 class KateHighlighting;
36 class KateBufBlockList;
37 class KateBuffer;
38 class KateFileLoader;
39 
40 class TQTextCodec;
41 
49 class KateBufBlock
50 {
51  friend class KateBufBlockList;
52 
53  public:
61  KateBufBlock ( KateBuffer *parent, KateBufBlock *prev = 0, KateBufBlock *next = 0,
62  KateFileLoader *stream = 0 );
63 
67  ~KateBufBlock ();
68 
69  private:
74  void fillBlock (KateFileLoader *stream);
75 
76  public:
80  enum State
81  {
82  stateSwapped = 0,
83  stateClean = 1,
84  stateDirty = 2
85  };
86 
91  State state () const { return m_state; }
92 
93  public:
101  KateTextLine::Ptr line(uint i);
102 
109  void insertLine(uint i, KateTextLine::Ptr line);
110 
116  void removeLine(uint i);
117 
122  void markDirty ();
123 
124  public:
129  inline uint startLine () const { return m_startLine; };
130 
135  inline void setStartLine (uint line) { m_startLine = line; }
136 
141  inline uint endLine () const { return m_startLine + m_lines; }
142 
147  inline uint lines () const { return m_lines; }
148 
153  inline KateBufBlock *prev () { return m_prev; }
154 
159  inline KateBufBlock *next () { return m_next; }
160 
164  private:
168  void swapIn ();
169 
173  void swapOut ();
174 
175  private:
180  KateBufBlock::State m_state;
181 
185  uint m_startLine;
186 
190  uint m_lines;
191 
195  KVMAllocator::Block *m_vmblock;
196 
200  uint m_vmblockSize;
201 
205  TQValueVector<KateTextLine::Ptr> m_stringList;
206 
210  KateBuffer* m_parent;
211 
215  KateBufBlock *m_prev;
216 
220  KateBufBlock *m_next;
221 
222  private:
227  KateBufBlockList *list;
228 
232  KateBufBlock *listPrev;
233 
237  KateBufBlock *listNext;
238 };
239 
248 class KateBufBlockList
249 {
250  public:
254  KateBufBlockList ();
255 
256  public:
261  inline uint count() const { return m_count; }
262 
267  inline KateBufBlock *first () { return m_first; };
268 
273  inline KateBufBlock *last () { return m_last; };
274 
280  inline bool isFirst (KateBufBlock *buf) { return m_first == buf; };
281 
287  inline bool isLast (KateBufBlock *buf) { return m_last == buf; };
288 
294  void append (KateBufBlock *buf);
295 
300  inline static void remove (KateBufBlock *buf)
301  {
302  if (buf->list)
303  buf->list->removeInternal (buf);
304  }
305 
306  private:
311  void removeInternal (KateBufBlock *buf);
312 
313  private:
317  uint m_count;
318 
322  KateBufBlock *m_first;
323 
327  KateBufBlock *m_last;
328 };
329 
341 class KateBuffer : public TQObject
342 {
343  TQ_OBJECT
344 
345  friend class KateBufBlock;
346 
347  public:
352  inline static uint maxLoadedBlocks () { return m_maxLoadedBlocks; }
353 
358  static void setMaxLoadedBlocks (uint count);
359 
360  private:
364  static uint m_maxLoadedBlocks;
365 
366  public:
371  KateBuffer (KateDocument *doc);
372 
376  ~KateBuffer ();
377 
378  public:
382  void editStart ();
383 
387  void editEnd ();
388 
394  inline bool editChanged () const { return editChangesDone; }
395 
400  inline uint editTagStart () const { return editTagLineStart; }
401 
406  inline uint editTagEnd () const { return editTagLineEnd; }
407 
412  inline bool editTagFrom () const { return editTagLineFrom; }
413 
414  private:
418  uint editSessionNumber;
419 
423  bool editIsRunning;
424 
428  uint editTagLineStart;
429 
433  uint editTagLineEnd;
434 
438  bool editTagLineFrom;
439 
443  bool editChangesDone;
444 
445  public:
449  void clear();
450 
456  bool openFile (const TQString &m_file);
457 
463  bool loadingBorked () const { return m_loadingBorked; }
464 
469  bool binary () const { return m_binary; }
470 
475  bool canEncode ();
476 
482  bool saveFile (const TQString &m_file);
483 
484  public:
488  inline KateTextLine::Ptr line(uint i)
489  {
490  KateBufBlock *buf = findBlock(i);
491  if (!buf)
492  return 0;
493 
494  if (i < m_lineHighlighted)
495  return buf->line (i - buf->startLine());
496 
497  return line_internal (buf, i);
498  }
499 
500  private:
504  KateTextLine::Ptr line_internal (KateBufBlock *buf, uint i);
505 
506  inline void addIndentBasedFoldingInformation(TQMemArray<uint> &foldingList,bool addindent,uint deindent);
507  inline void updatePreviousNotEmptyLine(KateBufBlock *blk,uint current_line,bool addindent,uint deindent);
508  public:
512  inline KateTextLine::Ptr plainLine(uint i)
513  {
514  KateBufBlock *buf = findBlock(i);
515  if (!buf)
516  return 0;
517 
518  return buf->line(i - buf->startLine());
519  }
520 
524  inline uint count() const { return m_lines; }
525 
526  private:
532  KateBufBlock *findBlock (uint i, uint *index = 0)
533  {
534  // out of range !
535  if (i >= m_lines)
536  return 0;
537 
538  if ((m_blocks[m_lastFoundBlock]->startLine() <= i) && (m_blocks[m_lastFoundBlock]->endLine() > i))
539  {
540  if (index)
541  (*index) = m_lastFoundBlock;
542 
543  return m_blocks[m_lastFoundBlock];
544  }
545 
546  return findBlock_internal (i, index);
547  }
548 
549  KateBufBlock *findBlock_internal (uint i, uint *index = 0);
550 
551  public:
555  void changeLine(uint i);
556 
560  void insertLine(uint i, KateTextLine::Ptr line);
561 
565  void removeLine(uint i);
566 
567  public:
568  inline uint countVisible () { return m_lines - m_regionTree.getHiddenLinesCount(m_lines); }
569 
570  inline uint lineNumber (uint visibleLine) { return m_regionTree.getRealLine (visibleLine); }
571 
572  inline uint lineVisibleNumber (uint line) { return m_regionTree.getVirtualLine (line); }
573 
574  inline void lineInfo (KateLineInfo *info, unsigned int line) { m_regionTree.getLineInfo(info,line); }
575 
576  inline uint tabWidth () const { return m_tabWidth; }
577 
578  public:
579  void setTabWidth (uint w);
580 
587  void setHighlight (uint hlMode);
588 
589  KateHighlighting *highlight () { return m_highlight; };
590 
594  void invalidateHighlighting();
595 
596  KateCodeFoldingTree *foldingTree () { return &m_regionTree; };
597 
598  public slots:
599  void codeFoldingColumnUpdate(unsigned int lineNr);
600 
601  private:
614  bool doHighlight (KateBufBlock *buf, uint from, uint to, bool invalidate);
615 
616  signals:
620  void codeFoldingUpdated();
621 
626  void tagLines(int start, int end);
627 
628  private:
632  KateDocument *m_doc;
633 
637  uint m_lines;
638 
643  TQValueVector<KateBufBlock*> m_blocks;
644 
648  uint m_lastInSyncBlock;
649 
653  uint m_lastFoundBlock;
654 
659  bool m_cacheReadError;
660  bool m_cacheWriteError;
661 
665  bool m_loadingBorked;
666 
670  bool m_binary;
671 
675  private:
679  KateHighlighting *m_highlight;
680 
684  KateCodeFoldingTree m_regionTree;
685 
686  // for the scrapty indent sensitive langs
687  uint m_tabWidth;
688 
689  uint m_lineHighlightedMax;
690  uint m_lineHighlighted;
691 
695  uint m_maxDynamicContexts;
696 
700  private:
704  KateBufBlockList m_loadedBlocks;
705 };
706 
707 #endif
KateBufBlockList
list which allows O(1) inserts/removes will not delete the elements on remove will use the next/prevN...
Definition: katebuffer.h:249
KateBufBlockList::last
KateBufBlock * last()
last block in this list or 0
Definition: katebuffer.h:273
KateBufBlockList::KateBufBlockList
KateBufBlockList()
Default Constructor.
Definition: katebuffer.cpp:1582
KateBufBlockList::first
KateBufBlock * first()
first block in this list or 0
Definition: katebuffer.h:267
KateBufBlockList::isLast
bool isLast(KateBufBlock *buf)
is buf the last block?
Definition: katebuffer.h:287
KateBufBlockList::count
uint count() const
count of blocks in this list
Definition: katebuffer.h:261
KateBufBlockList::isFirst
bool isFirst(KateBufBlock *buf)
is buf the last block?
Definition: katebuffer.h:280
KateBufBlockList::append
void append(KateBufBlock *buf)
append a block to this list ! will remove it from the list it belonged before !
Definition: katebuffer.cpp:1589
KateBufBlockList::remove
static void remove(KateBufBlock *buf)
remove the block from the list it belongs to !
Definition: katebuffer.h:300
KateBufBlock
The KateBufBlock class contains an amount of data representing a certain number of lines.
Definition: katebuffer.h:50
KateBufBlock::~KateBufBlock
~KateBufBlock()
destroy this block and take care of freeing all mem
Definition: katebuffer.cpp:1321
KateBufBlock::State
State
state flags
Definition: katebuffer.h:81
KateBufBlock::setStartLine
void setStartLine(uint line)
update the first line, needed to keep it up to date
Definition: katebuffer.h:135
KateBufBlock::prev
KateBufBlock * prev()
prev block
Definition: katebuffer.h:153
KateBufBlock::markDirty
void markDirty()
mark this block as dirty, will invalidate the swap data insert/removeLine will mark the block dirty i...
Definition: katebuffer.cpp:1476
KateBufBlock::line
KateTextLine::Ptr line(uint i)
return line i The first line of this block is line 0.
Definition: katebuffer.cpp:1439
KateBufBlock::removeLine
void removeLine(uint i)
remove line i marks the block dirty
Definition: katebuffer.cpp:1464
KateBufBlock::state
State state() const
returns the current state of this block
Definition: katebuffer.h:91
KateBufBlock::endLine
uint endLine() const
first line behind this block
Definition: katebuffer.h:141
KateBufBlock::insertLine
void insertLine(uint i, KateTextLine::Ptr line)
insert line in front of line i marks the block dirty
Definition: katebuffer.cpp:1452
KateBufBlock::next
KateBufBlock * next()
next block
Definition: katebuffer.h:159
KateBufBlock::lines
uint lines() const
lines in this block
Definition: katebuffer.h:147
KateBufBlock::startLine
uint startLine() const
startLine
Definition: katebuffer.h:129
KateBufBlock::KateBufBlock
KateBufBlock(KateBuffer *parent, KateBufBlock *prev=0, KateBufBlock *next=0, KateFileLoader *stream=0)
Create an empty block.
Definition: katebuffer.cpp:1273
KateBuffer
The KateBuffer class maintains a collections of lines.
Definition: katebuffer.h:342
KateBuffer::openFile
bool openFile(const TQString &m_file)
Open a file, use the given filename.
Definition: katebuffer.cpp:458
KateBuffer::~KateBuffer
~KateBuffer()
Goodbye buffer.
Definition: katebuffer.cpp:352
KateBuffer::tagLines
void tagLines(int start, int end)
Emitted when the highlighting of a certain range has changed.
KateBuffer::editChanged
bool editChanged() const
were there changes in the current running editing session?
Definition: katebuffer.h:394
KateBuffer::removeLine
void removeLine(uint i)
Remove line i.
Definition: katebuffer.cpp:772
KateBuffer::editTagEnd
uint editTagEnd() const
dirty lines end
Definition: katebuffer.h:406
KateBuffer::loadingBorked
bool loadingBorked() const
was the last loading broken because of not enough tmp disk space ? (will be reseted on successful sav...
Definition: katebuffer.h:463
KateBuffer::count
uint count() const
Return the total number of lines in the buffer.
Definition: katebuffer.h:524
KateBuffer::binary
bool binary() const
is this file a binary?
Definition: katebuffer.h:469
KateBuffer::clear
void clear()
Clear the buffer.
Definition: katebuffer.cpp:431
KateBuffer::canEncode
bool canEncode()
Can the current codec handle all chars.
Definition: katebuffer.cpp:540
KateBuffer::editTagFrom
bool editTagFrom() const
line inserted/removed?
Definition: katebuffer.h:412
KateBuffer::changeLine
void changeLine(uint i)
Mark line i as changed !
Definition: katebuffer.cpp:702
KateBuffer::insertLine
void insertLine(uint i, KateTextLine::Ptr line)
Insert line in front of line i.
Definition: katebuffer.cpp:723
KateBuffer::setHighlight
void setHighlight(uint hlMode)
Use highlight for highlighting.
Definition: katebuffer.cpp:856
KateBuffer::KateBuffer
KateBuffer(KateDocument *doc)
Create an empty buffer.
Definition: katebuffer.cpp:323
KateBuffer::editEnd
void editEnd()
finish some editing action
Definition: katebuffer.cpp:379
KateBuffer::editTagStart
uint editTagStart() const
dirty lines start
Definition: katebuffer.h:400
KateBuffer::saveFile
bool saveFile(const TQString &m_file)
Save the buffer to a file, use the given filename + codec + end of line chars (internal use of qtexts...
Definition: katebuffer.cpp:564
KateBuffer::line
KateTextLine::Ptr line(uint i)
Return line i.
Definition: katebuffer.h:488
KateBuffer::plainLine
KateTextLine::Ptr plainLine(uint i)
Return line i without triggering highlighting.
Definition: katebuffer.h:512
KateBuffer::codeFoldingUpdated
void codeFoldingUpdated()
Emittend if codefolding returned with a changed list.
KateBuffer::setMaxLoadedBlocks
static void setMaxLoadedBlocks(uint count)
modifier for max loaded blocks limit
Definition: katebuffer.cpp:79
KateBuffer::invalidateHighlighting
void invalidateHighlighting()
Invalidate highlighting of whole buffer.
Definition: katebuffer.cpp:892
KateBuffer::editStart
void editStart()
start some editing action
Definition: katebuffer.cpp:363
KateBuffer::maxLoadedBlocks
static uint maxLoadedBlocks()
maximal loaded block count
Definition: katebuffer.h:352
TDESharedPtr

kate

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

kate

Skip menu "kate"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for kate by doxygen 1.9.1
This website is maintained by Timothy Pearson.